Merge pull request #464 from TehNut/master

Various fixes and improvements (Details in description)
This commit is contained in:
WayofTime 2015-10-07 18:55:51 -04:00
commit 9fb1f61a6a
11 changed files with 258 additions and 58 deletions

View file

@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import WayofTime.alchemicalWizardry.api.BlockStack;
import WayofTime.alchemicalWizardry.common.achievements.ModAchievements;
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
import net.minecraft.block.Block;
@ -68,6 +69,7 @@ public class AlchemicalWizardryEventHooks
public static Map<Integer, List<CoordAndRange>> respawnMap = new HashMap();
public static Map<Integer, List<CoordAndRange>> forceSpawnMap = new HashMap();
public static ArrayList<BlockStack> teleposerBlacklist = new ArrayList<BlockStack>();
public static Random rand = new Random();
@ -771,41 +773,62 @@ public class AlchemicalWizardryEventHooks
}
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onTelepose(TeleposeEvent event) {
for (int i = 0; i < BloodMagicConfiguration.teleposerBlacklist.length; i++) {
String[] blockData = BloodMagicConfiguration.teleposerBlacklist[i].split(":");
// @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;
// }
// }
// }
// }
// }
// If the block follows full syntax: modid:blockname:meta
if (blockData.length == 3) {
@SubscribeEvent
public void onTelepose(TeleposeEvent event) {
BlockStack initialBlock = new BlockStack(event.initialBlock, event.initialMetadata);
BlockStack finalBlock = new BlockStack(event.finalBlock, event.finalMetadata);
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 (blockData[2].matches("-?\\d+"))
meta = Integer.parseInt(blockData[2]);
else if (blockData[2].equals("*"))
meta = OreDictionary.WILDCARD_VALUE;
else
meta = 0;
if (block != null)
if (( block == event.initialBlock || block == event.finalBlock) && (meta == event.initialMetadata || meta == event.finalMetadata || meta == OreDictionary.WILDCARD_VALUE))
event.setCanceled(true);
// 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 || block == event.finalBlock) && (meta == event.initialMetadata || meta == event.finalMetadata || meta == OreDictionary.WILDCARD_VALUE))
event.setCanceled(true);
}
}
}
if (teleposerBlacklist.contains(initialBlock) || teleposerBlacklist.contains(finalBlock))
event.setCanceled(true);
}
@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event)

View file

@ -5,6 +5,7 @@ import WayofTime.alchemicalWizardry.ModItems;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.block.Block;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
@ -15,12 +16,13 @@ public class LifeBucketHandler
@SubscribeEvent
public void onBucketFill(FillBucketEvent event)
{
if (event.current.getItem() != Items.bucket)
return;
ItemStack result = fillCustomBucket(event.world, event.target);
if (result == null)
{
return;
}
event.result = result;
event.setResult(Result.ALLOW);

View file

@ -44,7 +44,7 @@ public class ImperfectRitualStone extends Block
{
Block block = world.getBlock(x, y + 1, z);
if (block == Blocks.water)
if (block == Blocks.water && !AlchemicalWizardry.ritualWeakDisabledThunderstorm)
{
if (!player.capabilities.isCreativeMode && !world.isRemote)
{
@ -67,8 +67,7 @@ public class ImperfectRitualStone extends Block
world.getWorldInfo().setThunderTime(0);
world.getWorldInfo().setThundering(true);
return true;
} else if (block == Blocks.coal_block)
{
} else if (block == Blocks.coal_block && !AlchemicalWizardry.ritualWeakDisabledZombie) {
if (!player.capabilities.isCreativeMode && !world.isRemote)
{
EnergyItems.drainPlayerNetwork(player, 5000);
@ -87,7 +86,7 @@ public class ImperfectRitualStone extends Block
}
return true;
} else if (block == Blocks.lapis_block)
} else if (block == Blocks.lapis_block && !AlchemicalWizardry.ritualWeakDisabledNight)
{
if (!player.capabilities.isCreativeMode && !world.isRemote)
{
@ -99,7 +98,7 @@ public class ImperfectRitualStone extends Block
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 2, z));
world.setWorldTime((world.getWorldTime() / 24000) * 24000 + 13800);
}
} else if (block == Blocks.bedrock)
} else if (block == Blocks.bedrock && !AlchemicalWizardry.ritualWeakDisabledResistance)
{
if (!player.capabilities.isCreativeMode && !world.isRemote)
{

View file

@ -0,0 +1,26 @@
package WayofTime.alchemicalWizardry.common.bloodAltarUpgrade;
import WayofTime.alchemicalWizardry.api.BlockStack;
import com.cricketcraft.chisel.api.carving.CarvingUtils;
import com.cricketcraft.chisel.api.carving.ICarvingGroup;
import com.google.common.base.Strings;
public class CompatChecks {
public static boolean checkChiselBlock(BlockStack blockStack, String groupName) {
if (blockStack.getBlock() == null)
return false;
ICarvingGroup group = CarvingUtils.getChiselRegistry().getGroup(blockStack.getBlock(), blockStack.getMeta());
if (group != null) {
String check = CarvingUtils.getChiselRegistry().getGroup(blockStack.getBlock(), blockStack.getMeta()).getName();
if (Strings.isNullOrEmpty(check))
return false;
return check.equals(groupName);
}
return false;
}
}

View file

@ -3,7 +3,10 @@ package WayofTime.alchemicalWizardry.common.bloodAltarUpgrade;
import java.util.ArrayList;
import java.util.List;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.BlockStack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBeacon;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.ModBlocks;
@ -45,10 +48,12 @@ public class UpgradedAltars
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))
{
return false;
if (!checkRuneSpecials(ac, new BlockStack(testBlock, testMeta)))
return false;
}
} else
{
@ -57,7 +62,8 @@ public class UpgradedAltars
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
return false;
if (!checkSpecials(ac, new BlockStack(block, metadata)))
return false;
}
}
}
@ -70,10 +76,12 @@ public class UpgradedAltars
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))
{
return false;
if (!checkRuneSpecials(ac, new BlockStack(testBlock, testMeta)))
return false;
}
} else
{
@ -82,7 +90,8 @@ public class UpgradedAltars
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
return false;
if (!checkSpecials(ac, new BlockStack(block, metadata)))
return false;
}
}
}
@ -95,10 +104,12 @@ public class UpgradedAltars
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))
{
return false;
if (!checkRuneSpecials(ac, new BlockStack(testBlock, testMeta)))
return false;
}
} else
{
@ -107,7 +118,8 @@ public class UpgradedAltars
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
return false;
if (!checkSpecials(ac, new BlockStack(block, metadata)))
return false;
}
}
}
@ -120,19 +132,21 @@ public class UpgradedAltars
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))
{
return false;
if (!checkRuneSpecials(ac, new BlockStack(testBlock, testMeta)))
return false;
}
} else
{
} 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())))
{
return false;
if (!checkSpecials(ac, new BlockStack(block, metadata)))
return false;
}
}
}
@ -145,10 +159,12 @@ public class UpgradedAltars
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))
{
return false;
if (!checkRuneSpecials(ac, new BlockStack(testBlock, testMeta)))
return false;
}
} else
{
@ -157,7 +173,8 @@ public class UpgradedAltars
if (((ac.getBlock() != block) || (ac.getMetadata() != metadata)) && !(ac.getBlock() == Blocks.stonebrick && !world.isAirBlock(x + ac.getX(), y + ac.getY(), z + ac.getZ())))
{
return false;
if (!checkSpecials(ac, new BlockStack(block, metadata)))
return false;
}
}
}
@ -338,6 +355,31 @@ public class UpgradedAltars
}
}
private static boolean checkRuneSpecials(AltarComponent altarComponent, BlockStack blockStack) {
if (AlchemicalWizardry.isChiselLoaded) {
if (altarComponent.getBlock() == ModBlocks.bloodRune && CompatChecks.checkChiselBlock(blockStack, "bloodRune"))
return true;
}
return false;
}
private static boolean checkSpecials(AltarComponent altarComponent, BlockStack blockStack) {
if (AlchemicalWizardry.isChiselLoaded) {
if (altarComponent.getBlock() == Blocks.glowstone && CompatChecks.checkChiselBlock(blockStack, "glowstone"))
return true;
if (altarComponent.getBlock() == ModBlocks.largeBloodStoneBrick && CompatChecks.checkChiselBlock(blockStack, "bloodBrick"))
return true;
}
if (altarComponent.getBlock() == Blocks.beacon && blockStack.getBlock() instanceof BlockBeacon)
return true;
return false;
}
public static List<AltarComponent> getAltarUpgradeListForTier(int tier)
{
switch (tier)

View file

@ -36,11 +36,14 @@ public class TEAltarRenderer extends TileEntitySpecialRenderer
@Override
public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f)
{
modelBloodAltar.renderBloodAltar((TEAltar) tileEntity, d0, d1, d2);
modelBloodAltar.renderBloodLevel((TEAltar) tileEntity, d0, d1, d2);
if (tileEntity instanceof TEAltar)
{
modelBloodAltar.renderBloodAltar((TEAltar) tileEntity, d0, d1, d2);
if (((TEAltar)tileEntity).getCurrentBlood() > 0)
modelBloodAltar.renderBloodLevel((TEAltar) tileEntity, d0, d1, d2);
TEAltar tileAltar = (TEAltar) tileEntity;
GL11.glPushMatrix();