DEUF - Duplicate Entity UUID Fix

Mods
9,482 Downloads Last Updated: Jun 26, 2018 Game Version: 1.12.2

"Keeping entity minecraft:xxxx that already exists with UUID xxxx"

Now that message can occure quite often in case you use an old world. And there is no fix for it currently even though the bug is listed in the bug tracker for some time now. The logs (and server console, in case you have one - like me) also get spammed quite a lot so I thought I would make a mod which fixes those duplicate UUIDs and thus removes the spam.

Simply drag and drop the file into your mods folder. Clients do not need to install the mod to join your server (in case you use it for a server - like I do).

When installed, simply explore your world. Initially the spam will be more than before, since there should be an additional message which tells you that the UUID has been changed. But when reloading the world or restarting the server, that will not occure anymore for that exact entity, which now has a non-duplicate UUID.

 

I have not tested it a lot. But all short tests I have done were positive and bug free. Still: BACK UP YOUR WORLD BEFORE USING.

 

Example:

Without Mod:

[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID bd4f648f-ca0d-4680-9ed5-d28c68356379
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 1bfcaf96-e93d-4dd8-a402-dc000794acae
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 2a01ea3a-1ac2-48fa-9731-1399c3f5d256
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID c77765cb-f3fa-42d8-9326-52fa7e176dad
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID bd4f648f-ca0d-4680-9ed5-d28c68356379
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 1bfcaf96-e93d-4dd8-a402-dc000794acae
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 2a01ea3a-1ac2-48fa-9731-1399c3f5d256
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID c77765cb-f3fa-42d8-9326-52fa7e176dad
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID bd4f648f-ca0d-4680-9ed5-d28c68356379
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 1bfcaf96-e93d-4dd8-a402-dc000794acae
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 2a01ea3a-1ac2-48fa-9731-1399c3f5d256
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID c77765cb-f3fa-42d8-9326-52fa7e176dad
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID bd4f648f-ca0d-4680-9ed5-d28c68356379
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 1bfcaf96-e93d-4dd8-a402-dc000794acae
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 2a01ea3a-1ac2-48fa-9731-1399c3f5d256
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID c77765cb-f3fa-42d8-9326-52fa7e176dad
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID bd4f648f-ca0d-4680-9ed5-d28c68356379
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 1bfcaf96-e93d-4dd8-a402-dc000794acae
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 2a01ea3a-1ac2-48fa-9731-1399c3f5d256
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID c77765cb-f3fa-42d8-9326-52fa7e176dad

 

 With Mod (first load):

[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID bd4f648f-ca0d-4680-9ed5-d28c68356379
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 1bfcaf96-e93d-4dd8-a402-dc000794acae
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 2a01ea3a-1ac2-48fa-9731-1399c3f5d256
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID c77765cb-f3fa-42d8-9326-52fa7e176dad
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID bd4f648f-ca0d-4680-9ed5-d28c68356379
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 1bfcaf96-e93d-4dd8-a402-dc000794acae
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 2a01ea3a-1ac2-48fa-9731-1399c3f5d256
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID c77765cb-f3fa-42d8-9326-52fa7e176dad
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID bd4f648f-ca0d-4680-9ed5-d28c68356379
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 1bfcaf96-e93d-4dd8-a402-dc000794acae
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 2a01ea3a-1ac2-48fa-9731-1399c3f5d256
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID c77765cb-f3fa-42d8-9326-52fa7e176dad
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID bd4f648f-ca0d-4680-9ed5-d28c68356379
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 1bfcaf96-e93d-4dd8-a402-dc000794acae
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 2a01ea3a-1ac2-48fa-9731-1399c3f5d256
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID c77765cb-f3fa-42d8-9326-52fa7e176dad
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID bd4f648f-ca0d-4680-9ed5-d28c68356379
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 1bfcaf96-e93d-4dd8-a402-dc000794acae
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID 2a01ea3a-1ac2-48fa-9731-1399c3f5d256
[17:41:21] [Server thread/WARN] [net.minecraft.world.WorldServer]: Keeping entity minecraft:painting that already exists with UUID c77765cb-f3fa-42d8-9326-52fa7e176dad
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from bd4f648f-ca0d-4680-9ed5-d28c68356379 to ae673ae3-2d57-4cf0-b192-87e4dee826d5
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from 1bfcaf96-e93d-4dd8-a402-dc000794acae to b727c571-7fd0-4e98-8bf2-fd63c935dbc5
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from 2a01ea3a-1ac2-48fa-9731-1399c3f5d256 to 6a6019d7-7c7f-4e90-8c38-9b7de5799efe
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from c77765cb-f3fa-42d8-9326-52fa7e176dad to dd1dc13a-7014-43a2-8dcd-9a242319db28
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from bd4f648f-ca0d-4680-9ed5-d28c68356379 to 1cd933f4-0fe9-4adc-ba88-49e45362922f
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from 1bfcaf96-e93d-4dd8-a402-dc000794acae to 1d2939bd-aa00-488d-9f51-64da4d684b43
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from 2a01ea3a-1ac2-48fa-9731-1399c3f5d256 to 4fa92741-e4de-4878-8de5-3b04ed68aef2
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from c77765cb-f3fa-42d8-9326-52fa7e176dad to 19595751-d5b1-416e-b885-11c0ada925ff
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from bd4f648f-ca0d-4680-9ed5-d28c68356379 to e7fa7ce7-55b4-411f-b6c9-8740dae0d812
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from 1bfcaf96-e93d-4dd8-a402-dc000794acae to 5240568b-3d40-4837-8ca5-cd3b48519d8a
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from 2a01ea3a-1ac2-48fa-9731-1399c3f5d256 to f28fb4ba-b509-40ad-9a97-b9cee67406e1
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from c77765cb-f3fa-42d8-9326-52fa7e176dad to 42999a16-8e11-42ed-b83e-bc3cdee031b8
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from bd4f648f-ca0d-4680-9ed5-d28c68356379 to 0aa6193b-0662-4c11-be18-22031040fb37
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from 1bfcaf96-e93d-4dd8-a402-dc000794acae to d40910d1-213f-4e10-8a54-25c0694b4124
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from 2a01ea3a-1ac2-48fa-9731-1399c3f5d256 to 85099341-acc6-44eb-a8b0-af86ca08446b
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from c77765cb-f3fa-42d8-9326-52fa7e176dad to a4ed61fa-098d-4fab-be2c-d1eee9c06b62
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from bd4f648f-ca0d-4680-9ed5-d28c68356379 to 6bd662c4-6555-438d-a202-a6b962cd56a1
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from 1bfcaf96-e93d-4dd8-a402-dc000794acae to 04a9acdd-6bb4-4c28-9ad7-39fdbc395bad
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from 2a01ea3a-1ac2-48fa-9731-1399c3f5d256 to ed93b32a-58f1-436e-80ac-012e52cedf81
[17:41:21] [Server thread/INFO] [uuidfix]: Changing UUID of entity minecraft:painting that already existed from c77765cb-f3fa-42d8-9326-52fa7e176dad to e13f6b2d-637d-448e-b371-f10e77be5aff

 

 With Mod (second load and beyond):

 

 

Also Check out my current main project:

 

Or support me:

 

 

And finally the source code:

package de.cas_ual_ty.uuidfix;

import java.util.Collection;
import java.util.Random;
import java.util.UUID;

import org.apache.logging.log4j.Logger;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ClassInheritanceMultiMap;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@Mod(version = UUIDFix.VERSION, name = UUIDFix.NAME, modid = UUIDFix.MOD_ID, acceptableRemoteVersions = "*")
public class UUIDFix
{
	public static final String VERSION = "1.1-1.12.2";
	public static final String MOD_ID = "deuf";
	public static final String NAME = "Duplicate Entity UUID Fix (DEUF)";
	public static Logger logger;
	
	@EventHandler
	public void preInit(FMLPreInitializationEvent event)
	{
		UUIDFix.logger = event.getModLog();
	}
	
	@EventHandler
	public void init(FMLInitializationEvent event)
	{
		MinecraftForge.EVENT_BUS.register(new EntityHandler());
	}
	
	public static class EntityHandler
	{
		@SubscribeEvent
		public void fix(ChunkEvent.Load event)
		{
			Chunk chunk = event.getChunk();
			
			if(!chunk.getWorld().isRemote && chunk.getWorld() instanceof WorldServer)
			{
				WorldServer world = (WorldServer) chunk.getWorld();
				
				ClassInheritanceMultiMap<Entity>[] entities = chunk.getEntityLists();
				UUID uuid;
				UUID uuidNew;
				Collection<Entity> entityCollection;
				
				for (ClassInheritanceMultiMap<Entity> classinheritancemultimap : entities)
				{
					entityCollection = com.google.common.collect.ImmutableList.copyOf(classinheritancemultimap);
					
					for(Entity entity : entityCollection)
					{
						if(!(entity instanceof EntityPlayer))
						{
							uuid = entity.getUniqueID();
							if(world.getEntityFromUuid(uuid) != null && world.getEntityFromUuid(uuid) != entity)
							{
								uuidNew = MathHelper.getRandomUUID(new Random());
								while(world.getEntityFromUuid(uuidNew) != null)
								{
									uuidNew = MathHelper.getRandomUUID(new Random());
								}
								entity.setUniqueId(uuidNew);
								UUIDFix.logger.info("Changing UUID of entity {} that already existed from {} to {}", EntityList.getKey(entity), uuid.toString(), uuidNew.toString());
							}
						}
					}
				}
			}
		}
	}
}
 

Comments

Posts Quoted: