diff --git a/common/MysticWorld/Items/ItemOrbEarth.java b/common/MysticWorld/Items/ItemOrbEarth.java index c0ac44c..d5f514c 100644 --- a/common/MysticWorld/Items/ItemOrbEarth.java +++ b/common/MysticWorld/Items/ItemOrbEarth.java @@ -1,11 +1,15 @@ package mysticworld.items; +import cpw.mods.fml.common.eventhandler.Event; import mysticworld.MysticWorld; +import net.minecraft.block.Block; +import net.minecraft.block.IGrowable; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemDye; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.BonemealEvent; public class ItemOrbEarth extends ItemOrb { public ItemOrbEarth() { @@ -31,11 +35,34 @@ public class ItemOrbEarth extends ItemOrb { public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) { EntityPlayer player = (EntityPlayer) entity; if (par5) { - MysticWorld.proxy.earthFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); + MysticWorld.proxy.earthFX(world, (player.posX - 0.5D) + itemRand.nextDouble(), player.posY, (player.posZ - 0.5D) + itemRand.nextDouble(), 1.0F); } } - public static boolean applyBonemeal(ItemStack itemStack, World par1World, int par2, int par3, int par4, EntityPlayer player) { - return ItemDye.applyBonemeal(itemStack, par1World, par2, par3, par4, player); + public static boolean applyBonemeal(ItemStack itemStack, World world, int x, int y, int z, EntityPlayer player) { + Block block = world.getBlock(x, y, z); + BonemealEvent event = new BonemealEvent(player, world, block, x, y, z); + if (MinecraftForge.EVENT_BUS.post(event)){ + return false; + } + if (event.getResult() == Event.Result.ALLOW){ + if (!world.isRemote){ + itemStack.damageItem(1, player); + } + return true; + } + if (block instanceof IGrowable){ + IGrowable igrowable = (IGrowable)block; + if (igrowable.func_149851_a(world, x, y, z, world.isRemote)){ + if (!world.isRemote){ + if (igrowable.func_149852_a(world, world.rand, x, y, z)){ + igrowable.func_149853_b(world, world.rand, x, y, z); + } + itemStack.damageItem(1, player); + } + return true; + } + } + return false; } } diff --git a/common/MysticWorld/Items/ItemStaffEarth.java b/common/MysticWorld/Items/ItemStaffEarth.java index 850736c..7de7ef7 100644 --- a/common/MysticWorld/Items/ItemStaffEarth.java +++ b/common/MysticWorld/Items/ItemStaffEarth.java @@ -4,7 +4,6 @@ import mysticworld.MysticWorld; import mysticworld.entity.EntityChargeEarth; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemDye; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; @@ -54,11 +53,11 @@ public class ItemStaffEarth extends ItemStaff { @Override public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) { if (par5) { - MysticWorld.proxy.earthFX(world, (entity.posX - 0.5D) + rand.nextDouble(), entity.posY, (entity.posZ - 0.5D) + rand.nextDouble(), 1.0F); + MysticWorld.proxy.earthFX(world, (entity.posX - 0.5D) + itemRand.nextDouble(), entity.posY, (entity.posZ - 0.5D) + itemRand.nextDouble(), 1.0F); } } public static boolean applyBonemeal(ItemStack itemStack, World par1World, int par2, int par3, int par4, EntityPlayer player) { - return ItemDye.applyBonemeal(itemStack, par1World, par2, par3, par4, player); + return ItemOrbEarth.applyBonemeal(itemStack, par1World, par2, par3, par4, player); } }