From f0b5353742f2ae1081728801ff2dfb868e4a8106 Mon Sep 17 00:00:00 2001 From: Arcaratus Date: Sun, 22 Mar 2015 11:49:28 -0400 Subject: [PATCH 1/2] Update it to fill IBloodAltar --- .../common/items/CreativeDagger.java | 55 +++++++++++++++---- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/CreativeDagger.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/CreativeDagger.java index 2b00c32a..62a0cbad 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/CreativeDagger.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/CreativeDagger.java @@ -23,6 +23,25 @@ public class CreativeDagger extends Item public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(par3EntityPlayer, true, true, 2); + if(MinecraftForge.EVENT_BUS.post(evt)) + { + return par1ItemStack; + } + + if(evt.shouldDrainHealth) + { + par3EntityPlayer.setHealth(par3EntityPlayer.getHealth() - 2); + } + + if(!evt.shouldFillAltar) + { + return par1ItemStack; + } + } + if (par3EntityPlayer instanceof FakePlayer) { return par1ItemStack; @@ -46,7 +65,20 @@ public class CreativeDagger extends Item { return par1ItemStack; } - findAndFillAltar(par2World, par3EntityPlayer, Integer.MAX_VALUE); + + if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionSoulFray)) + { + findAndFillAltar(par2World, par3EntityPlayer, Integer.MAX_VALUE); + } else + { + findAndFillAltar(par2World, par3EntityPlayer, Integer.MAX_VALUE); + } + + if (par3EntityPlayer.getHealth() <= 0.001f) + { + par3EntityPlayer.onDeath(DamageSource.generic); + } + return par1ItemStack; } @@ -55,7 +87,7 @@ public class CreativeDagger extends Item int posX = (int) Math.round(player.posX - 0.5f); int posY = (int) player.posY; int posZ = (int) Math.round(player.posZ - 0.5f); - TEAltar altarEntity = getAltar(world, posX, posY, posZ); + IBloodAltar altarEntity = getAltar(world, posX, posY, posZ); if (altarEntity == null) { @@ -66,7 +98,7 @@ public class CreativeDagger extends Item altarEntity.startCycle(); } - public TEAltar getAltar(World world, int x, int y, int z) + public IBloodAltar getAltar(World world, int x, int y, int z) { TileEntity tileEntity = null; @@ -78,29 +110,28 @@ public class CreativeDagger extends Item { tileEntity = world.getTileEntity(i + x, k + y, j + z); - if ((tileEntity instanceof TEAltar)) + if ((tileEntity instanceof IBloodAltar)) { - return (TEAltar) tileEntity; + return (IBloodAltar) tileEntity; } } - if ((tileEntity instanceof TEAltar)) + if ((tileEntity instanceof IBloodAltar)) { - return (TEAltar) tileEntity; + return (IBloodAltar) tileEntity; } } - if ((tileEntity instanceof TEAltar)) + if ((tileEntity instanceof IBloodAltar)) { - return (TEAltar) tileEntity; + return (IBloodAltar) tileEntity; } } - if ((tileEntity instanceof TEAltar)) + if ((tileEntity instanceof IBloodAltar)) { - return (TEAltar) tileEntity; + return (IBloodAltar) tileEntity; } return null; } -} From 0b7d4442ee354377d70bdcfc78c57bf9118bd9de Mon Sep 17 00:00:00 2001 From: Arcaratus Date: Mon, 23 Mar 2015 17:48:41 -0400 Subject: [PATCH 2/2] Update CreativeDagger.java --- .../common/items/CreativeDagger.java | 40 ++----------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/CreativeDagger.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/CreativeDagger.java index 62a0cbad..efafc60c 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/CreativeDagger.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/CreativeDagger.java @@ -8,7 +8,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; import WayofTime.alchemicalWizardry.AlchemicalWizardry; import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; -import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar; +import WayofTime.alchemicalWizardry.api.tile.IBloodAltar; public class CreativeDagger extends Item { @@ -23,25 +23,6 @@ public class CreativeDagger extends Item public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (!par3EntityPlayer.capabilities.isCreativeMode) - { - SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(par3EntityPlayer, true, true, 2); - if(MinecraftForge.EVENT_BUS.post(evt)) - { - return par1ItemStack; - } - - if(evt.shouldDrainHealth) - { - par3EntityPlayer.setHealth(par3EntityPlayer.getHealth() - 2); - } - - if(!evt.shouldFillAltar) - { - return par1ItemStack; - } - } - if (par3EntityPlayer instanceof FakePlayer) { return par1ItemStack; @@ -65,20 +46,7 @@ public class CreativeDagger extends Item { return par1ItemStack; } - - if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionSoulFray)) - { - findAndFillAltar(par2World, par3EntityPlayer, Integer.MAX_VALUE); - } else - { - findAndFillAltar(par2World, par3EntityPlayer, Integer.MAX_VALUE); - } - - if (par3EntityPlayer.getHealth() <= 0.001f) - { - par3EntityPlayer.onDeath(DamageSource.generic); - } - + findAndFillAltar(par2World, par3EntityPlayer, Integer.MAX_VALUE); return par1ItemStack; } @@ -87,7 +55,7 @@ public class CreativeDagger extends Item int posX = (int) Math.round(player.posX - 0.5f); int posY = (int) player.posY; int posZ = (int) Math.round(player.posZ - 0.5f); - IBloodAltar altarEntity = getAltar(world, posX, posY, posZ); + TEAltar altarEntity = getAltar(world, posX, posY, posZ); if (altarEntity == null) { @@ -98,7 +66,7 @@ public class CreativeDagger extends Item altarEntity.startCycle(); } - public IBloodAltar getAltar(World world, int x, int y, int z) + public TEAltar getAltar(World world, int x, int y, int z) { TileEntity tileEntity = null;