Fixed eath types bonemeal consuming

This commit is contained in:
GotoLink 2014-03-22 03:17:15 +01:00
commit d98091f850
2 changed files with 33 additions and 7 deletions

View file

@ -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;
}
}

View file

@ -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);
}
}