Add transposition blacklist to API (#790)
Blacklist the same blocks that are blacklisted from the Teleposer.
This commit is contained in:
parent
cc5f7b88c0
commit
513bb113e1
|
@ -172,7 +172,7 @@ public class ConfigHandler
|
||||||
|
|
||||||
category = "Transposition Sigil Blacklist";
|
category = "Transposition Sigil Blacklist";
|
||||||
config.addCustomCategoryComment(category, "Block blacklisting");
|
config.addCustomCategoryComment(category, "Block blacklisting");
|
||||||
transpositionBlacklisting = config.getStringList("transpositionBlacklist", category, new String[] { "minecraft:bedrock" }, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta");
|
transpositionBlacklisting = config.getStringList("transpositionBlacklist", category, new String[] { "minecraft:bedrock", "minecraft:mob_spawner" }, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta");
|
||||||
buildBlacklist(transpositionBlacklisting, transpositionBlacklist);
|
buildBlacklist(transpositionBlacklisting, transpositionBlacklist);
|
||||||
|
|
||||||
category = "Well of Suffering Blacklist";
|
category = "Well of Suffering Blacklist";
|
||||||
|
|
|
@ -32,6 +32,8 @@ public class BloodMagicAPI
|
||||||
@Getter
|
@Getter
|
||||||
private static final List<BlockStack> teleposerBlacklist = new ArrayList<BlockStack>();
|
private static final List<BlockStack> teleposerBlacklist = new ArrayList<BlockStack>();
|
||||||
@Getter
|
@Getter
|
||||||
|
private static final List<BlockStack> transpositionBlacklist = new ArrayList<BlockStack>();
|
||||||
|
@Getter
|
||||||
private static final Map<String, Integer> entitySacrificeValues = new HashMap<String, Integer>();
|
private static final Map<String, Integer> entitySacrificeValues = new HashMap<String, Integer>();
|
||||||
@Getter
|
@Getter
|
||||||
private static final ArrayList<Block> greenGroveBlacklist = new ArrayList<Block>();
|
private static final ArrayList<Block> greenGroveBlacklist = new ArrayList<Block>();
|
||||||
|
@ -148,6 +150,48 @@ public class BloodMagicAPI
|
||||||
addToTeleposerBlacklist(block, 0);
|
addToTeleposerBlacklist(block, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to add a {@link BlockStack} to the Transposition blacklist that cannot
|
||||||
|
* be changed via Configuration files.
|
||||||
|
*
|
||||||
|
* IMC:
|
||||||
|
* {@code FMLInterModComs.sendMessage("BloodMagic", "transpositionBlacklist", ItemStack)}
|
||||||
|
* Example:
|
||||||
|
* {@code FMLInterModComs.sendMessage("BloodMagic", "transpositionBlacklist", new ItemStack(Blocks.bedrock))}
|
||||||
|
*
|
||||||
|
* @param blockStack
|
||||||
|
* - The BlockStack to blacklist.
|
||||||
|
*/
|
||||||
|
public static void addToTranspositionBlacklist(BlockStack blockStack)
|
||||||
|
{
|
||||||
|
if (!transpositionBlacklist.contains(blockStack))
|
||||||
|
transpositionBlacklist.add(blockStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #addToTranspositionBlacklist(BlockStack)
|
||||||
|
*
|
||||||
|
* @param block
|
||||||
|
* - The block to blacklist
|
||||||
|
* @param meta
|
||||||
|
* - The meta of the block to blacklist
|
||||||
|
*/
|
||||||
|
public static void addToTranspositionBlacklist(Block block, int meta)
|
||||||
|
{
|
||||||
|
addToTranspositionBlacklist(new BlockStack(block, meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #addToTranspositionBlacklist(BlockStack)
|
||||||
|
*
|
||||||
|
* @param block
|
||||||
|
* - The block to blacklist
|
||||||
|
*/
|
||||||
|
public static void addToTranspositionBlacklist(Block block)
|
||||||
|
{
|
||||||
|
addToTranspositionBlacklist(block, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to set the sacrifice value of an Entity. The value provided is how
|
* Used to set the sacrifice value of an Entity. The value provided is how
|
||||||
* much LP will be gained when the entity is sacrificed at a Blood Altar.
|
* much LP will be gained when the entity is sacrificed at a Blood Altar.
|
||||||
|
|
|
@ -2,6 +2,8 @@ package WayofTime.bloodmagic.item.sigil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -13,8 +15,10 @@ import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import WayofTime.bloodmagic.ConfigHandler;
|
import WayofTime.bloodmagic.ConfigHandler;
|
||||||
|
@ -54,7 +58,7 @@ public class ItemSigilTransposition extends ItemSigilBase
|
||||||
|
|
||||||
if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META))
|
if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META))
|
||||||
{
|
{
|
||||||
BlockStack blockStack = new BlockStack(Block.getBlockFromName(tag.getString(Constants.NBT.CONTAINED_BLOCK_NAME)), tag.getByte(Constants.NBT.CONTAINED_BLOCK_META));
|
BlockStack blockStack = new BlockStack(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString(Constants.NBT.CONTAINED_BLOCK_NAME))), tag.getByte(Constants.NBT.CONTAINED_BLOCK_META));
|
||||||
return super.getItemStackDisplayName(stack) + " (" + blockStack.getItemStack().getDisplayName() + ")";
|
return super.getItemStackDisplayName(stack) + " (" + blockStack.getItemStack().getDisplayName() + ")";
|
||||||
}
|
}
|
||||||
return super.getItemStackDisplayName(stack);
|
return super.getItemStackDisplayName(stack);
|
||||||
|
@ -69,9 +73,12 @@ public class ItemSigilTransposition extends ItemSigilBase
|
||||||
if (!world.isRemote)
|
if (!world.isRemote)
|
||||||
{
|
{
|
||||||
BlockStack rightClickedBlock = BlockStack.getStackFromPos(world, blockPos);
|
BlockStack rightClickedBlock = BlockStack.getStackFromPos(world, blockPos);
|
||||||
|
if (BloodMagicAPI.getTranspositionBlacklist().contains(rightClickedBlock))
|
||||||
|
return EnumActionResult.FAIL;
|
||||||
|
|
||||||
if (!ConfigHandler.transpositionBlacklist.contains(rightClickedBlock) && player.isSneaking() && (!stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) || !stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META)))
|
if (!ConfigHandler.transpositionBlacklist.contains(rightClickedBlock) && player.isSneaking() && (!stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) || !stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META)))
|
||||||
{
|
{
|
||||||
if (rightClickedBlock.getBlock().getPlayerRelativeBlockHardness(state, player, world, blockPos) >= 0 && rightClickedBlock.getBlock().getBlockHardness(state, world, blockPos) >= 0)
|
if (rightClickedBlock.getState().getPlayerRelativeBlockHardness(player, world, blockPos) >= 0 && rightClickedBlock.getState().getBlockHardness(world, blockPos) >= 0)
|
||||||
{
|
{
|
||||||
int cost = getLpUsed();
|
int cost = getLpUsed();
|
||||||
|
|
||||||
|
|
|
@ -144,9 +144,13 @@ public class ModBlocks
|
||||||
// testSpellBlock = registerBlock(new BlockTestSpellBlock());
|
// testSpellBlock = registerBlock(new BlockTestSpellBlock());
|
||||||
|
|
||||||
BloodMagicAPI.addToTeleposerBlacklist(inputRoutingNode);
|
BloodMagicAPI.addToTeleposerBlacklist(inputRoutingNode);
|
||||||
|
BloodMagicAPI.addToTranspositionBlacklist(inputRoutingNode);
|
||||||
BloodMagicAPI.addToTeleposerBlacklist(outputRoutingNode);
|
BloodMagicAPI.addToTeleposerBlacklist(outputRoutingNode);
|
||||||
|
BloodMagicAPI.addToTranspositionBlacklist(outputRoutingNode);
|
||||||
BloodMagicAPI.addToTeleposerBlacklist(itemRoutingNode);
|
BloodMagicAPI.addToTeleposerBlacklist(itemRoutingNode);
|
||||||
|
BloodMagicAPI.addToTranspositionBlacklist(itemRoutingNode);
|
||||||
BloodMagicAPI.addToTeleposerBlacklist(demonCrystal);
|
BloodMagicAPI.addToTeleposerBlacklist(demonCrystal);
|
||||||
|
BloodMagicAPI.addToTranspositionBlacklist(demonCrystal);
|
||||||
|
|
||||||
initTiles();
|
initTiles();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,15 @@ public class IMCHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (message.key.equals("transpositionBlacklist") && message.isItemStackMessage())
|
||||||
|
{
|
||||||
|
ItemStack stack = message.getItemStackValue();
|
||||||
|
if (stack.getItem() instanceof ItemBlock) {
|
||||||
|
Block block = Block.getBlockFromItem(stack.getItem());
|
||||||
|
BloodMagicAPI.addToTranspositionBlacklist(block, stack.getItemDamage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (message.key.equals("sacrificeValue") && message.isStringMessage())
|
if (message.key.equals("sacrificeValue") && message.isStringMessage())
|
||||||
{
|
{
|
||||||
String[] splitInfo = message.getStringValue().split(";");
|
String[] splitInfo = message.getStringValue().split(";");
|
||||||
|
|
Loading…
Reference in a new issue