use of WayofTime.alchemicalWizardry.api.BlockStack in project BloodMagic by WayofTime.
the class BloodMagicConfiguration method buildTeleposerBlacklist.
private static void buildTeleposerBlacklist() {
// Make sure it's empty before setting the blacklist.
// Otherwise, reloading the config while in-game will duplicate the list.
AlchemicalWizardryEventHooks.teleposerBlacklist.clear();
for (String blockSet : BloodMagicConfiguration.teleposerBlacklist) {
String[] blockData = blockSet.split(":");
Block block = GameRegistry.findBlock(blockData[0], blockData[1]);
int meta = 0;
// If the block follows full syntax: modid:blockname:meta
if (blockData.length == 3) {
// Check if it's an int, if so, parse it. If not, set meta to 0 to avoid crashing.
if (isInteger(blockData[2]))
meta = Integer.parseInt(blockData[2]);
else if (blockData[2].equals("*"))
meta = OreDictionary.WILDCARD_VALUE;
else
meta = 0;
}
AlchemicalWizardryEventHooks.teleposerBlacklist.add(new BlockStack(block, meta));
}
}
use of WayofTime.alchemicalWizardry.api.BlockStack in project BloodMagic by WayofTime.
the class UpgradedAltars method checkAltarIsValid.
public static boolean checkAltarIsValid(World world, int x, int y, int z, int altarTier) {
switch(altarTier) {
case 1:
return true;
case 2:
for (AltarComponent ac : secondTierAltar) {
if (ac.isBloodRune()) {
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int testMeta = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune)) {
if (!checkRuneSpecials(ac, new BlockStack(testBlock, testMeta)))
return false;
}
} else {
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ()))) {
if (!checkSpecials(ac, new BlockStack(block, metadata)))
return false;
}
}
}
return true;
case 3:
for (AltarComponent ac : thirdTierAltar) {
if (ac.isBloodRune()) {
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int testMeta = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune)) {
if (!checkRuneSpecials(ac, new BlockStack(testBlock, testMeta)))
return false;
}
} else {
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ()))) {
if (!checkSpecials(ac, new BlockStack(block, metadata)))
return false;
}
}
}
return true;
case 4:
for (AltarComponent ac : fourthTierAltar) {
if (ac.isBloodRune()) {
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int testMeta = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune)) {
if (!checkRuneSpecials(ac, new BlockStack(testBlock, testMeta)))
return false;
}
} else {
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ()))) {
if (!checkSpecials(ac, new BlockStack(block, metadata)))
return false;
}
}
}
return true;
case 5:
for (AltarComponent ac : fifthTierAltar) {
if (ac.isBloodRune()) {
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int testMeta = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune)) {
if (!checkRuneSpecials(ac, new BlockStack(testBlock, testMeta)))
return false;
}
} else {
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ()))) {
if (!checkSpecials(ac, new BlockStack(block, metadata)))
return false;
}
}
}
return true;
case 6:
for (AltarComponent ac : sixthTierAltar) {
if (ac.isBloodRune()) {
Block testBlock = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int testMeta = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (!(testBlock instanceof BloodRune)) {
if (!checkRuneSpecials(ac, new BlockStack(testBlock, testMeta)))
return false;
}
} else {
Block block = world.getBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ());
int metadata = world.getBlockMetadata(x + ac.getX(), y + ac.getY(), z + ac.getZ());
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ()))) {
if (!checkSpecials(ac, new BlockStack(block, metadata)))
return false;
}
}
}
return true;
default:
return false;
}
}
use of WayofTime.alchemicalWizardry.api.BlockStack in project BloodMagic by WayofTime.
the class AlchemicalWizardryEventHooks method onTelepose.
// @SubscribeEvent(priority = EventPriority.LOWEST)
// public void onTelepose(TeleposeEvent event) {
//
// AlchemicalWizardry.logger.info(event.initialBlock + ":" + event.initialMetadata);
// AlchemicalWizardry.logger.info(event.finalBlock + ":" + event.finalMetadata);
//
// for (int i = 0; i < BloodMagicConfiguration.teleposerBlacklist.length; i++) {
// String[] blockData = BloodMagicConfiguration.teleposerBlacklist[i].split(":");
//
// // If the block follows full syntax: modid:blockname:meta
// if (blockData.length == 3) {
//
// Block block = GameRegistry.findBlock(blockData[0], blockData[1]);
// int meta;
//
// // Check if it's an int, if so, parse it. If not, set meta to 0 to avoid crashing.
// if (isInteger(blockData[2]))
// meta = Integer.parseInt(blockData[2]);
// else if (blockData[2].equals("*"))
// meta = OreDictionary.WILDCARD_VALUE;
// else
// meta = 0;
//
// AlchemicalWizardry.logger.info(block + ":" + meta);
//
// if (block != null) {
// if ((block == event.initialBlock || block == event.finalBlock) && (meta == event.initialMetadata || meta == event.finalMetadata || meta == OreDictionary.WILDCARD_VALUE)) {
// event.setCanceled(true);
// return;
// }
// }
//
// // If the block uses shorthand syntax: modid:blockname
// } else if (blockData.length == 2) {
//
// Block block = GameRegistry.findBlock(blockData[0], blockData[1]);
// int meta = 0;
//
// if (block != null) {
// if ((block == event.initialBlock && (meta == event.initialMetadata || meta == OreDictionary.WILDCARD_VALUE)) || (block == event.finalBlock && (meta == event.finalMetadata || meta == OreDictionary.WILDCARD_VALUE))) {
// event.setCanceled(true);
// return;
// }
// }
// }
// }
// }
@SubscribeEvent
public void onTelepose(TeleposeEvent event) {
BlockStack initialBlock = new BlockStack(event.initialBlock, event.initialMetadata);
BlockStack finalBlock = new BlockStack(event.finalBlock, event.finalMetadata);
if (teleposerBlacklist.contains(initialBlock) || teleposerBlacklist.contains(finalBlock))
event.setCanceled(true);
}
Aggregations