Add a way to hard blacklist Blocks from the Teleposer
The blocks in this list cannot be changed via config file. The two lists are kept (instead just one) so that the config one can be refreshed at any point with ConfigChangedEvent.
This commit is contained in:
parent
ad68a89f15
commit
e5a90c5e7f
|
@ -3,16 +3,23 @@ package WayofTime.bloodmagic.api;
|
|||
import WayofTime.bloodmagic.api.util.helper.LogHelper;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BloodMagicAPI
|
||||
{
|
||||
public static final String ORB = "ItemBloodOrb";
|
||||
public static final String SCRIBE = "ItemInscriptionTool";
|
||||
|
||||
@Getter
|
||||
private static final List<BlockStack> teleposerBlacklist = new ArrayList<BlockStack>();
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private static boolean loggingEnabled;
|
||||
|
@ -23,6 +30,10 @@ public class BloodMagicAPI
|
|||
@Getter
|
||||
private static DamageSource damageSource = new DamageSourceBloodMagic();
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private static Fluid lifeEssence;
|
||||
|
||||
/**
|
||||
* Used to obtain Items from BloodMagic. Use the constants above for common
|
||||
* items in case internal names change.
|
||||
|
@ -37,7 +48,40 @@ public class BloodMagicAPI
|
|||
return GameRegistry.findItem(Constants.Mod.MODID, name);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private static Fluid lifeEssence;
|
||||
/**
|
||||
* Used to add a {@link BlockStack} to the Teleposer blacklist that
|
||||
* cannot be changed via Configuration files.
|
||||
*
|
||||
* @param blockStack
|
||||
* - The BlockStack to blacklist.
|
||||
*/
|
||||
public static void addToTeleposerBlacklist(BlockStack blockStack)
|
||||
{
|
||||
if (!teleposerBlacklist.contains(blockStack))
|
||||
teleposerBlacklist.add(blockStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #addToTeleposerBlacklist(BlockStack)
|
||||
*
|
||||
* @param block
|
||||
* - The block to blacklist
|
||||
* @param meta
|
||||
* - The meta of the block to blacklist
|
||||
*/
|
||||
public static void addToTeleposerBlacklist(Block block, int meta)
|
||||
{
|
||||
addToTeleposerBlacklist(new BlockStack(block, meta));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #addToTeleposerBlacklist(BlockStack)
|
||||
*
|
||||
* @param block
|
||||
* - The block to blacklist
|
||||
*/
|
||||
public static void addToTeleposerBlacklist(Block block)
|
||||
{
|
||||
addToTeleposerBlacklist(block, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package WayofTime.bloodmagic.util.handler;
|
|||
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.event.TeleposeEvent;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
|
@ -89,6 +90,9 @@ public class EventHandler
|
|||
|
||||
if (ConfigHandler.teleposerBlacklist.contains(initialBlock) || ConfigHandler.teleposerBlacklist.contains(finalBlock))
|
||||
event.setCanceled(true);
|
||||
|
||||
if (BloodMagicAPI.getTeleposerBlacklist().contains(initialBlock) || BloodMagicAPI.getTeleposerBlacklist().contains(finalBlock))
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
Loading…
Reference in a new issue