I am trying to have an item, when right clicked on an entity, spawn my custom entity.
Problem is, I need to pass the UUID of the player and the type of entity clicked for rendering/AI.
What I tried:
MyEntity entity = new MyEntity();
entity.setType(type)
entity.setOwner(owner)
entity.setPosition(position)
world.addEntity(entity)
Problem is, that entity is replaced with another one server-side which has no data.
Next I tried:
CompoundNBT nbt = new CompoundNBT();
nbt.putInt("type", type.ordinal());
nbt.putUniqueId("owner", player.getGameProfile().getId());
if (tameable != null) nbt.putBoolean("sitting", tameable.isSitting());
ITextComponent name = null;
if (target.getCustomName() != null)
name = target.getCustomName();
PetEntity pet = EntityRegistry.PETENTITY.spawn(target.getEntityWorld(), nbt, null, player, target.getPosition(), SpawnReason.EVENT, false, false);
target.remove();
target.getEntityWorld().addEntity(pet);
Then I read the NBT data by overriding AnimalEntity#readAdditional(NBTCompound), but that is never called.