Fix IllegalStateException: Duplicate key
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
package exopandora.worldhandler.helper;
|
package exopandora.worldhandler.helper;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.fml.common.registry.EntityEntry;
|
||||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
@@ -15,8 +16,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class EntityHelper
|
public class EntityHelper
|
||||||
{
|
{
|
||||||
private static final Map<ResourceLocation, String> RESOURCELOCATION_TO_NAME;
|
private static final Map<ResourceLocation, String> RESOURCELOCATION_TO_NAME = new HashMap<ResourceLocation, String>();
|
||||||
private static final Map<Class<? extends Entity>, ResourceLocation> CLASS_TO_RESOURCELOCATION;
|
private static final Map<Class<? extends Entity>, ResourceLocation> CLASS_TO_RESOURCELOCATION = new HashMap<Class<? extends Entity>, ResourceLocation>();
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
@@ -25,8 +26,11 @@ public class EntityHelper
|
|||||||
throw new RuntimeException("Accessed Entities before register!");
|
throw new RuntimeException("Accessed Entities before register!");
|
||||||
}
|
}
|
||||||
|
|
||||||
RESOURCELOCATION_TO_NAME = ForgeRegistries.ENTITIES.getEntries().stream().collect(Collectors.toMap(Entry::getKey, entry -> entry.getValue().getName()));
|
for(Entry<ResourceLocation, EntityEntry> entity : ForgeRegistries.ENTITIES.getEntries())
|
||||||
CLASS_TO_RESOURCELOCATION = ForgeRegistries.ENTITIES.getEntries().stream().collect(Collectors.toMap(entry -> entry.getValue().getEntityClass(), Entry::getKey));
|
{
|
||||||
|
RESOURCELOCATION_TO_NAME.put(entity.getKey(), entity.getValue().getName());
|
||||||
|
CLASS_TO_RESOURCELOCATION.put(entity.getValue().getEntityClass(), entity.getKey());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
Reference in New Issue
Block a user