Jump to content

[Solved] Trying to store and release mobs via custom item causes addEntityUuid to throw a warning.


Lucie

Recommended Posts

I'm trying to store mobs inside an item using compounds. To write the mob into compound I use:

mob.addAdditionalSaveData(compound);

When all data is stored in the item I use this to discard it.

mob.discard()

The compound also stores the mobs resource location and I use this to spawn and set the data:

// Resource location stored in entity tag.
EntityType<?> type = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(stack.getOrCreateTag().getString("entity")));

// I use this to get the entity. I'm using 'MobSpawnType.BUCKET' which may not be correct, if so please inform me what else to use.
Entity entity = type.spawn(level, stack, null, pos, MobSpawnType.BUCKET, true, false);

// Adding data.
((LivingEntity)entity).readAdditionalSaveData(stack.getOrCreateTag().getCompound("data"));

// Spawning
level.addFreshEntity(entity);

When spawning the logger outputs for example: 

UUID of added entity already exists: Horse['Horse'/128, l='ServerLevel[Test World]', x=-93.50, y=72.00, z=52.50]

And the UUID always increments with 2 so if I summon it again it would say 'Horse'/130, 'Horse'/132, 'Horse'/134 etc.

How can I prevent this?

Edited by Lucie
Cleanup
Link to comment
Share on other sites

  • Lucie changed the title to [Solved] Trying to store and release mobs via custom item causes addEntityUuid to throw a warning.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.