Server starts

This commit is contained in:
cpw authored and LexManos committed 2018-09-05 13:13:53 -07:00
1 parent 330db1a54d
commit b50b768852
44 files changed
+449 -475

No files matched your search

@@ -56,7 +56,7 @@ import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRegistryInternal<V>, IForgeRegistryModifiable<V>
public class ForgeRegistry<V extends ForgeRegistryEntry<V>> implements IForgeRegistryInternal<V>, IForgeRegistryModifiable<V>
{
public static Marker REGISTRIES = MarkerManager.getMarker("REGISTRIES");
private static Logger LOGGER = LogManager.getLogger();
@@ -100,7 +100,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
this.clear = clear;
this.validate = validate;
this.missing = missing;
this.isDelegated = IForgeRegistryEntry.Impl.class.isAssignableFrom(superType); //TODO: Make this IDelegatedRegistryEntry?
this.isDelegated = ForgeRegistryEntry.class.isAssignableFrom(superType); //TODO: Make this IDelegatedRegistryEntry?
this.allowOverrides = allowOverrides;
this.isModifiable = isModifiable;
this.dummyFactory = dummyFactory;
@@ -392,7 +392,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
private RegistryDelegate<V> getDelegate(V thing)
{
if (isDelegated)
return (RegistryDelegate<V>)((IForgeRegistryEntry.Impl<V>)thing).delegate;
return (RegistryDelegate<V>)((ForgeRegistryEntry<V>)thing).delegate;
else
throw new IllegalStateException("Tried to get existing delegate from registry that is not delegated.");
}
@@ -0,0 +1,68 @@
/*
* Minecraft Forge
* Copyright (c) 2016.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.registries;
import com.google.common.reflect.TypeToken;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.ModThreadContext;
import org.apache.logging.log4j.LogManager;
import javax.annotation.Nullable;
@SuppressWarnings("unchecked")
public abstract class ForgeRegistryEntry<V extends ForgeRegistryEntry<V>>
{
private final TypeToken<V> token = new TypeToken<V>(getClass()){};
public final IRegistryDelegate<V> delegate = new RegistryDelegate<>((V)this, (Class<V>)token.getRawType());
private ResourceLocation registryName = null;
public final V setRegistryName(String name)
{
if (getRegistryName() != null)
throw new IllegalStateException("Attempted to set registry name with existing registry name! New: " + name + " Old: " + getRegistryName());
int index = name.lastIndexOf(':');
String oldPrefix = index == -1 ? "" : name.substring(0, index).toLowerCase();
name = index == -1 ? name : name.substring(index + 1);
String prefix = ModThreadContext.get().getActiveContainer().getPrefix();
if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0)
{
LogManager.getLogger().info("Potentially Dangerous alternative prefix `{}` for name `{}`, expected `{}`. This could be a intended override, but in most cases indicates a broken mod.", oldPrefix, name, prefix);
prefix = oldPrefix;
}
this.registryName = new ResourceLocation(prefix, name);
return (V)this;
}
//Helper functions
public final V setRegistryName(ResourceLocation name){ return setRegistryName(name.toString()); }
public final V setRegistryName(String modID, String name){ return setRegistryName(modID + ":" + name); }
@Nullable
public final ResourceLocation getRegistryName()
{
if (delegate.name() != null) return delegate.name();
return registryName != null ? registryName : null;
}
public final Class<V> getRegistryType() { return (Class<V>)token.getRawType(); }
}
@@ -26,10 +26,10 @@ import com.google.common.collect.Multimap;
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockObserver;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
@@ -50,9 +50,6 @@ import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.RegistryEvent.MissingMappings;
import net.minecraftforge.fml.common.EnhancedRuntimeException;
import net.minecraftforge.fml.StartupQuery;
import net.minecraftforge.fml.common.ZipperUtil;
import net.minecraftforge.fml.common.registry.EntityEntry;
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
import com.google.common.collect.ArrayListMultimap;
@@ -137,9 +134,9 @@ public class GameData
makeRegistry(SOUNDEVENTS, SoundEvent.class, MAX_SOUND_ID).create();
makeRegistry(POTIONTYPES, PotionType.class, MAX_POTIONTYPE_ID, new ResourceLocation("empty")).create();
makeRegistry(ENCHANTMENTS, Enchantment.class, MAX_ENCHANTMENT_ID).create();
makeRegistry(RECIPES, IRecipe.class, MAX_RECIPE_ID).disableSaving().allowModification().addCallback(RecipeCallbacks.INSTANCE).create();
makeRegistry(PROFESSIONS, VillagerProfession.class, MAX_PROFESSION_ID).create();
entityRegistry = (ForgeRegistry<EntityEntry>)makeRegistry(ENTITIES, EntityEntry.class, MAX_ENTITY_ID).addCallback(EntityCallbacks.INSTANCE).create();
// makeRegistry(RECIPES, IRecipe.class, MAX_RECIPE_ID).disableSaving().allowModification().addCallback(RecipeCallbacks.INSTANCE).create();
// makeRegistry(PROFESSIONS, VillagerProfession.class, MAX_PROFESSION_ID).create();
// entityRegistry = (ForgeRegistry<EntityEntry>)makeRegistry(ENTITIES, EntityEntry.class, MAX_ENTITY_ID).addCallback(EntityCallbacks.INSTANCE).create();
}
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceLocation name, Class<T> type, int min, int max)
@@ -178,13 +175,13 @@ public class GameData
@SuppressWarnings("unchecked")
public static BiMap<Block,Item> getBlockItemMap()
{
return RegistryManager.ACTIVE.getRegistry((Class<K>)Item.class).getSlaveMap(BLOCK_TO_ITEM, BiMap.class);
return RegistryManager.ACTIVE.getRegistry(Item.class).getSlaveMap(BLOCK_TO_ITEM, BiMap.class);
}
@SuppressWarnings("unchecked")
public static ObjectIntIdentityMap<IBlockState> getBlockStateIDMap()
{
return RegistryManager.ACTIVE.getRegistry((Class<K>)Block.class).getSlaveMap(BLOCKSTATE_TO_ID, ObjectIntIdentityMap.class);
return RegistryManager.ACTIVE.getRegistry(Block.class).getSlaveMap(BLOCKSTATE_TO_ID, ObjectIntIdentityMap.class);
}
public static <K extends IForgeRegistryEntry<K>> K register_impl(K value)
@@ -201,7 +198,7 @@ public class GameData
public static void vanillaSnapshot()
{
LOGGER.debug("Creating vanilla freeze snapshot");
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends ForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
{
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(r.getKey());
loadRegistry(r.getKey(), RegistryManager.ACTIVE, RegistryManager.VANILLA, clazz, true);
@@ -232,7 +229,7 @@ public class GameData
});
RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.freeze());
// the id mapping is fanilized, no ids actually changed but this is a good place to tell everyone to 'bake' their stuff.
// the id mapping is finalized, no ids actually changed but this is a good place to tell everyone to 'bake' their stuff.
//Loader.instance().fireRemapEvent(ImmutableMap.of(), true);
LOGGER.debug(GD, "All registries frozen");
@@ -249,7 +246,7 @@ public class GameData
RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.resetDelegates());
LOGGER.debug(GD, "Reverting to frozen data state.");
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends ForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
{
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(r.getKey());
loadRegistry(r.getKey(), RegistryManager.FROZEN, RegistryManager.ACTIVE, clazz, true);
@@ -291,6 +288,7 @@ public class GameData
{
@SuppressWarnings("unchecked")
ClearableObjectIntIdentityMap<IBlockState> blockstateMap = owner.getSlaveMap(BLOCKSTATE_TO_ID, ClearableObjectIntIdentityMap.class);
/*
if ("minecraft:tripwire".equals(block.getRegistryName().toString())) //Tripwire is crap so we have to special case whee!
{
@@ -326,17 +324,19 @@ public class GameData
if (item != null)
blockToItem.forcePut(block, item);
}
*/
}
@Override
public void onClear(IForgeRegistryInternal<Block> owner, RegistryManager stage)
{
owner.getSlaveMap(BLOCKSTATE_TO_ID, ClearableObjectIntIdentityMap.class).clear();
// owner.getSlaveMap(BLOCKSTATE_TO_ID, ClearableObjectIntIdentityMap.class).clear();
}
@Override
public void onCreate(IForgeRegistryInternal<Block> owner, RegistryManager stage)
{
/*
final ClearableObjectIntIdentityMap<IBlockState> idMap = new ClearableObjectIntIdentityMap<IBlockState>()
{
@SuppressWarnings("deprecation")
@@ -352,20 +352,28 @@ public class GameData
}
};
owner.setSlaveMap(BLOCKSTATE_TO_ID, idMap);
*/
owner.setSlaveMap(BLOCK_TO_ITEM, HashBiMap.create());
}
@Override
public Block createDummy(ResourceLocation key)
{
Block ret = new BlockDummyAir().setUnlocalizedName("air");
Block ret = new BlockDummyAir(Block.Builder.func_200945_a(Material.AIR));
GameData.forceRegistryName(ret, key);
return ret;
}
private static class BlockDummyAir extends BlockAir //A named class so DummyBlockReplacementTest can detect if its a dummy
{
private BlockDummyAir()
private BlockDummyAir(Block.Builder builder)
{
super(builder);
}
@Override
public String getTranslationKey()
{
return "block.minecraft.air";
}
}
}
@@ -400,6 +408,7 @@ public class GameData
}
}
/*
private static class RecipeCallbacks implements IForgeRegistry.ValidateCallback<IRecipe>, IForgeRegistry.MissingFactory<IRecipe>
{
static final RecipeCallbacks INSTANCE = new RecipeCallbacks();
@@ -465,6 +474,7 @@ public class GameData
EntityList.ENTITY_EGGS.put(entry.getRegistryName(), entry.getEgg());
}
}
*/
private static <T extends IForgeRegistryEntry<T>> void loadRegistry(final ResourceLocation registryName, final RegistryManager from, final RegistryManager to, final Class<T> regType, boolean freeze)
{
@@ -618,6 +628,7 @@ public class GameData
if (!confirmed)
StartupQuery.abort();
/*
try
{
String skip = System.getProperty("fml.doNotBackup");
@@ -636,6 +647,7 @@ public class GameData
StartupQuery.notify("The world backup couldn't be created.\n\n" + e);
StartupQuery.abort();
}
*/
}
if (!defaulted.isEmpty())
@@ -670,7 +682,7 @@ public class GameData
STAGING.registries.forEach((name, reg) -> reg.validateContent(name));
// Load the STAGING registry into the ACTIVE registry
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
for (Map.Entry<ResourceLocation, IForgeRegistry<? extends ForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
{
final Class<? extends IForgeRegistryEntry> registrySuperType = RegistryManager.ACTIVE.getSuperType(r.getKey());
loadRegistry(r.getKey(), STAGING, RegistryManager.ACTIVE, registrySuperType, true);
@@ -690,7 +702,7 @@ public class GameData
}
//Has to be split because of generics, Yay!
private static <T extends IForgeRegistryEntry<T>> void loadPersistentDataToStagingRegistry(RegistryManager pool, RegistryManager to, Map<ResourceLocation, Integer[]> remaps, Map<ResourceLocation, Integer> missing, ResourceLocation name, ForgeRegistry.Snapshot snap, Class<T> regType)
private static <T extends ForgeRegistryEntry<T>> void loadPersistentDataToStagingRegistry(RegistryManager pool, RegistryManager to, Map<ResourceLocation, Integer[]> remaps, Map<ResourceLocation, Integer> missing, ResourceLocation name, ForgeRegistry.Snapshot snap, Class<T> regType)
{
ForgeRegistry<T> active = pool.getRegistry(name);
if (active == null)
@@ -705,7 +717,7 @@ public class GameData
//Another bouncer for generic reasons
@SuppressWarnings("unchecked")
private static <T extends IForgeRegistryEntry<T>> void processMissing(Class<T> clazz, ResourceLocation name, RegistryManager STAGING, MissingMappings<?> e, Map<ResourceLocation, Integer> missing, Map<ResourceLocation, Integer[]> remaps, Collection<ResourceLocation> defaulted, Collection<ResourceLocation> failed, boolean injectNetworkDummies)
private static <T extends ForgeRegistryEntry<T>> void processMissing(Class<T> clazz, ResourceLocation name, RegistryManager STAGING, MissingMappings<?> e, Map<ResourceLocation, Integer> missing, Map<ResourceLocation, Integer[]> remaps, Collection<ResourceLocation> defaulted, Collection<ResourceLocation> failed, boolean injectNetworkDummies)
{
List<MissingMappings.Mapping<T>> mappings = ((MissingMappings<T>)e).getAllMappings();
ForgeRegistry<T> active = RegistryManager.ACTIVE.getRegistry(name);
@@ -713,7 +725,7 @@ public class GameData
staging.processMissingEvent(name, active, mappings, missing, remaps, defaulted, failed, injectNetworkDummies);
}
private static <T extends IForgeRegistryEntry<T>> void loadFrozenDataToStagingRegistry(RegistryManager STAGING, ResourceLocation name, Map<ResourceLocation, Integer[]> remaps, Class<T> clazz)
private static <T extends ForgeRegistryEntry<T>> void loadFrozenDataToStagingRegistry(RegistryManager STAGING, ResourceLocation name, Map<ResourceLocation, Integer[]> remaps, Class<T> clazz)
{
ForgeRegistry<T> frozen = RegistryManager.FROZEN.getRegistry(name);
ForgeRegistry<T> newRegistry = STAGING.getRegistry(name, RegistryManager.FROZEN);
@@ -34,7 +34,7 @@ import javax.annotation.Nullable;
*
* @param <V> The top level type for the registry
*/
public interface IForgeRegistry<V extends IForgeRegistryEntry<V>> extends Iterable<V>
public interface IForgeRegistry<V extends ForgeRegistryEntry<V>> extends Iterable<V>
{
Class<V> getRegistrySuperType();
@@ -72,7 +72,7 @@ public interface IForgeRegistry<V extends IForgeRegistryEntry<V>> extends Iterab
* Callback fired when objects are added to the registry. This will fire when the registry is rebuilt
* on the client side from a server side synchronization, or when a world is loaded.
*/
interface AddCallback<V extends IForgeRegistryEntry<V>>
interface AddCallback<V extends ForgeRegistryEntry<V>>
{
void onAdd(IForgeRegistryInternal<V> owner, RegistryManager stage, int id, V obj, @Nullable V oldObj);
}
@@ -81,7 +81,7 @@ public interface IForgeRegistry<V extends IForgeRegistryEntry<V>> extends Iterab
* Callback fired when the registry is cleared. This is done before a registry is reloaded from client
* or server.
*/
interface ClearCallback<V extends IForgeRegistryEntry<V>>
interface ClearCallback<V extends ForgeRegistryEntry<V>>
{
void onClear(IForgeRegistryInternal<V> owner, RegistryManager stage);
}
@@ -89,7 +89,7 @@ public interface IForgeRegistry<V extends IForgeRegistryEntry<V>> extends Iterab
/**
* Callback fired when a registry instance is created. Populate slave maps here.
*/
interface CreateCallback<V extends IForgeRegistryEntry<V>>
interface CreateCallback<V extends ForgeRegistryEntry<V>>
{
void onCreate(IForgeRegistryInternal<V> owner, RegistryManager stage);
}
@@ -105,7 +105,7 @@ public interface IForgeRegistry<V extends IForgeRegistryEntry<V>> extends Iterab
/**
* Factory for creating dummy entries, allowing worlds to be loaded and keep the missing block references.
*/
interface DummyFactory<V extends IForgeRegistryEntry<V>>
interface DummyFactory<V extends ForgeRegistryEntry<V>>
{
V createDummy(ResourceLocation key);
}
@@ -113,7 +113,7 @@ public interface IForgeRegistry<V extends IForgeRegistryEntry<V>> extends Iterab
/**
*
*/
interface MissingFactory<V extends IForgeRegistryEntry<V>>
interface MissingFactory<V extends ForgeRegistryEntry<V>>
{
V createMissing(ResourceLocation key, boolean isNetwork);
}
@@ -41,7 +41,7 @@ public interface IForgeRegistryEntry<V>
*
* @param name Unique registry name
* @return This instance
*/
* /
V setRegistryName(ResourceLocation name);
/**
@@ -50,7 +50,7 @@ public interface IForgeRegistryEntry<V>
* If neither are valid null is returned.
*
* @return Unique identifier or null.
*/
* /
@Nullable
ResourceLocation getRegistryName();
@@ -89,4 +89,5 @@ public interface IForgeRegistryEntry<V>
@Override
public final Class<T> getRegistryType() { return (Class<T>) token.getRawType(); };
}
*/
}
@@ -21,7 +21,7 @@ package net.minecraftforge.registries;
import net.minecraft.util.ResourceLocation;
public interface IForgeRegistryInternal<V extends IForgeRegistryEntry<V>> extends IForgeRegistry<V>
public interface IForgeRegistryInternal<V extends ForgeRegistryEntry<V>> extends IForgeRegistry<V>
{
void setSlaveMap(ResourceLocation name, Object obj);
}
@@ -21,7 +21,7 @@ package net.minecraftforge.registries;
import net.minecraft.util.ResourceLocation;
public interface IForgeRegistryModifiable<V extends IForgeRegistryEntry<V>> extends IForgeRegistry<V>
public interface IForgeRegistryModifiable<V extends ForgeRegistryEntry<V>> extends IForgeRegistry<V>
{
void clear();
V remove(ResourceLocation key);
@@ -21,8 +21,6 @@ package net.minecraftforge.registries;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
@@ -30,14 +28,14 @@ import javax.annotation.Nullable;
import org.apache.commons.lang3.Validate;
import com.google.common.collect.Maps;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
import net.minecraftforge.fml.common.FMLLog;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamespacedDefaultedByKey<ResourceLocation, V> implements ILockableRegistry
class NamespacedDefaultedWrapper<V extends ForgeRegistryEntry<V>> extends RegistryNamespacedDefaultedByKey<ResourceLocation, V> implements ILockableRegistry
{
private static final Logger LOGGER = LogManager.getLogger();
private boolean locked = false;
private ForgeRegistry<V> delegate;
@@ -59,7 +57,7 @@ class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends Regis
int realId = this.delegate.add(id, value);
if (realId != id && id != -1)
FMLLog.log.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", key, value.getRegistryType().getName(), id, realId);
LOGGER.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", key, value.getRegistryType().getName(), id, realId);
}
@Override
@@ -132,7 +130,7 @@ class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends Regis
@Override
public void lock(){ this.locked = true; }
public static class Factory<V extends IForgeRegistryEntry<V>> implements IForgeRegistry.CreateCallback<V>
public static class Factory<V extends ForgeRegistryEntry<V>> implements IForgeRegistry.CreateCallback<V>
{
public static final ResourceLocation ID = new ResourceLocation("forge", "registry_defaulted_wrapper");
@Override
@@ -19,11 +19,8 @@
package net.minecraftforge.registries;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
@@ -33,10 +30,12 @@ import org.apache.commons.lang3.Validate;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.RegistryNamespaced;
import net.minecraftforge.fml.common.FMLLog;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
class NamespacedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamespaced<ResourceLocation, V> implements ILockableRegistry
class NamespacedWrapper<V extends ForgeRegistryEntry<V>> extends RegistryNamespaced<ResourceLocation, V> implements ILockableRegistry
{
private static final Logger LOGGER = LogManager.getLogger();
private boolean locked = false;
private ForgeRegistry<V> delegate;
@@ -58,7 +57,7 @@ class NamespacedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamesp
int realId = this.delegate.add(id, value);
if (realId != id && id != -1)
FMLLog.log.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", key, value.getRegistryType().getName(), id, realId);
LOGGER.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", key, value.getRegistryType().getName(), id, realId);
}
@Override
@@ -126,7 +125,7 @@ class NamespacedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamesp
@Override
public void lock(){ this.locked = true; }
public static class Factory<V extends IForgeRegistryEntry<V>> implements IForgeRegistry.CreateCallback<V>
public static class Factory<V extends ForgeRegistryEntry<V>> implements IForgeRegistry.CreateCallback<V>
{
public static final ResourceLocation ID = new ResourceLocation("forge", "registry_defaulted_wrapper");
@Override
@@ -66,7 +66,7 @@ class ObjectHolderRef
}
else
{
this.injectedObject = ((IForgeRegistryEntry)existing).getRegistryName();
this.injectedObject = ((ForgeRegistryEntry)existing).getRegistryName();
}
}
catch (IllegalAccessException e)
@@ -105,9 +105,9 @@ class ObjectHolderRef
{
Class<?> type = typesToExamine.remove();
Collections.addAll(typesToExamine, type.getInterfaces());
if (IForgeRegistryEntry.class.isAssignableFrom(type))
if (ForgeRegistryEntry.class.isAssignableFrom(type))
{
registry = (ForgeRegistry<?>)RegistryManager.ACTIVE.getRegistry((Class<IForgeRegistryEntry>)type);
registry = (ForgeRegistry<?>)RegistryManager.ACTIVE.getRegistry((Class<ForgeRegistryEntry>)type);
final Class<?> parentType = type.getSuperclass();
if (parentType != null)
{
@@ -28,7 +28,7 @@ import net.minecraftforge.registries.IForgeRegistry.*;
import javax.annotation.Nullable;
public class RegistryBuilder<T extends IForgeRegistryEntry<T>>
public class RegistryBuilder<T extends ForgeRegistryEntry<T>>
{
private ResourceLocation registryName;
private Class<T> registryType;
@@ -31,18 +31,20 @@ import com.google.common.collect.Sets;
import com.google.common.collect.Sets.SetView;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.registries.ForgeRegistry.Snapshot;
import net.minecraftforge.registries.IForgeRegistry.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class RegistryManager
{
private static final Logger LOGGER = LogManager.getLogger();
public static final RegistryManager ACTIVE = new RegistryManager("ACTIVE");
public static final RegistryManager VANILLA = new RegistryManager("VANILLA");
public static final RegistryManager FROZEN = new RegistryManager("FROZEN");
BiMap<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> registries = HashBiMap.create();
private BiMap<Class<? extends IForgeRegistryEntry<?>>, ResourceLocation> superTypes = HashBiMap.create();
private BiMap<Class<? extends ForgeRegistryEntry<?>>, ResourceLocation> superTypes = HashBiMap.create();
private Set<ResourceLocation> persisted = Sets.newHashSet();
private final String name;
@@ -103,7 +105,7 @@ public class RegistryManager
if (!overlappedTypes.isEmpty())
{
Class<?> foundType = overlappedTypes.iterator().next();
FMLLog.log.error("Found existing registry of type {} named {}, you cannot create a new registry ({}) with type {}, as {} has a parent of that type", foundType, superTypes.get(foundType), name, type, type);
LOGGER.error("Found existing registry of type {} named {}, you cannot create a new registry ({}) with type {}, as {} has a parent of that type", foundType, superTypes.get(foundType), name, type, type);
throw new IllegalArgumentException("Duplicate registry parent type found - you can only have one registry for a particular super type");
}
ForgeRegistry<V> reg = new ForgeRegistry<V>(type, defaultKey, min, max, create, add, clear, validate, this, allowOverrides, isModifiable, dummyFactory, missing);