I think i do becose i am summoning item but it is just ghost item.
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float what, float these, float are) {
if (cooldown > 0) {
return false;
}
TileEntityInfuser tileEntity = (TileEntityInfuser)world.getTileEntity(x, y, z);
if (tileEntity == null) {
return false;
}
ItemStack heldItem = player.inventory.getCurrentItem();
if (heldItem == null) {
if (player.isSneaking()) {
ChatUtils.newChatMessage(player, "Stored NatureFlux: " + String.valueOf(storedNF));
} else if (!player.isSneaking() && tileEntity.getStackInSlot(0) != (ItemStack)null) {
ItemStack item = tileEntity.getStackInSlot(0);
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world,
x + rx, y + ry, z + rz,
new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
if (item.hasTagCompound()) {
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
tileEntity.setInventorySlotContents(0, (ItemStack)null);
}
} else {
if (player.isSneaking() && heldItem.getItem().getUnlocalizedName() == NFItems.transmutator.getUnlocalizedName()) {
//Playrutils.removeItem(player, heldItem);
tileEntity.setInventorySlotContents(0, heldItem);
player.inventory.decrStackSize(player.inventory.currentItem, 64);
//player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
} else if (!player.isSneaking() && tileEntity.getStackInSlot(0) != (ItemStack)null) {
ItemStack item = tileEntity.getStackInSlot(0);
System.out.println(item.getItem().getUnlocalizedName(item));
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world,
x + rx, y + ry, z + rz,
new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
if (item.hasTagCompound()) {
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
//tileEntity.setInventorySlotContents(0, (ItemStack)null);
}
}
cooldown = 10;
return true;
}