I have a custom entity that opens a gui when the player right clicks on it. This works all fine but if you try to right click it again after the player died, you can't click the entity anymore. If you reopen the world, it works again. I'm I doing something wrong?
int entityId = EntityRegistry.findGlobalUniqueEntityId();
EntityRegistry.registerGlobalEntityID(EntityCorpse.class, "Corpse", entityId, 2342, 3246);
EntityRegistry.registerModEntity(EntityCorpse.class, "Corpse", entityId, PXYMain.instance, 64, 1, true);
public class EntityCorpse extends EntityLivingBase
{
public InventoryCorpse inventory = new InventoryCorpse();
public EntityCorpse(World world)
{
super(world);
setHealth(getMaxHealth());
this.setSize(0.9F, 2F);
}
@Override
public void readEntityFromNBT(NBTTagCompound nbt)
{
super.readEntityFromNBT(nbt);
inventory.readFromNBT(nbt);
}
@Override
public ItemStack getHeldItem()
{
return null;
}
@Override
public ItemStack getEquipmentInSlot(int p_71124_1_)
{
return null;
}
@Override
public void setCurrentItemOrArmor(int p_70062_1_, ItemStack p_70062_2_)
{
}
@Override
public ItemStack[] getLastActiveItems()
{
return new ItemStack[0];
}
@Override
public void writeEntityToNBT(NBTTagCompound nbt)
{
super.writeEntityToNBT(nbt);
inventory.writeToNBT(nbt);
}
@Override
public boolean interactFirst(EntityPlayer player)
{
if (!player.worldObj.isRemote)
{
new PacketOpenCorpseGuiServer.Handler().handleMessage(new PacketOpenCorpseGuiServer(this), (EntityPlayerMP) player);
}
return true;
}
}