Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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

  • Author

Ah, I should known "EntityType#spawn" actually spawns the entity. It's all fixed now, thanks for the help.

  • 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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.