Hey guys,
How can I prevent an item from falling in a liquid. This is the code I have now but the item just seems to jump around and stuff:
package me.mrkirby153.KCNerfer.playTime;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class IndestructibleItem extends EntityItem {
private final EntityPlayer owner;
public IndestructibleItem(EntityPlayer owner, World world, double x, double y, double z, ItemStack itemStack) {
super(world, x, y, z, itemStack);
this.isImmuneToFire = true;
this.owner = owner;
}
public boolean canPickup(EntityPlayer player) {
return player.getCommandSenderName().equalsIgnoreCase(this.owner.getCommandSenderName());
}
@Override
public boolean isEntityInvulnerable() {
return true;
}
@Override
public boolean canRenderOnFire() {
return false;
}
@Override
public void onUpdate() {
super.onUpdate();
Block currentBlock = worldObj.getBlock((int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ));
if (currentBlock == null)
return;
if (currentBlock instanceof BlockLiquid) {
posY += 1;
// System.out.println("in liquid");
}
}
}