Hello; I'm having a minor issue with my mod. There's an item in my mod, that when right clicked on a block will turn it into a different block. This works fine; however it also is set to spawn an item there. When it does this, it spawns both the actual item, and a sort of ghost entity of the item. How do I fix this?
Here's all the code used to do this.
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
MovingObjectPosition var4 = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);
if (var4 == null)
{
return par1ItemStack;
}
else
{
if (var4.typeOfHit == EnumMovingObjectType.TILE)
{
int var5 = var4.blockX;
int var6 = var4.blockY;
int var7 = var4.blockZ;
if (!par2World.canMineBlock(par3EntityPlayer, var5, var6, var7))
{
return par1ItemStack;
}
if (!par3EntityPlayer.canPlayerEdit(var5, var6, var7, var4.sideHit, par1ItemStack))
{
return par1ItemStack;
}
if (par2World.getBlockId(var5, var6, var7) == ModAdamant.witherdirt.blockID)
{
par2World.setBlockWithNotify(var5, var6, var7, Block.dirt.blockID);
par1ItemStack.damageItem(1, par3EntityPlayer);
par2World.spawnEntityInWorld(new EntityItem(par2World, var5, var6, var7, new ItemStack(ModAdamant.withershard)));
}
}
return par1ItemStack;
}
}
Thanks for helping me