Created
November 18, 2016 00:23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/patches/minecraft/net/minecraft/entity/EntityList.java.patch b/patches/minecraft/net/minecraft/entity/EntityList.java.patch | |
index cb012a6..869bb9f 100644 | |
--- a/patches/minecraft/net/minecraft/entity/EntityList.java.patch | |
+++ b/patches/minecraft/net/minecraft/entity/EntityList.java.patch | |
@@ -1,6 +1,78 @@ | |
--- ../src-base/minecraft/net/minecraft/entity/EntityList.java | |
+++ ../src-work/minecraft/net/minecraft/entity/EntityList.java | |
-@@ -189,7 +189,17 @@ | |
+@@ -105,10 +105,8 @@ | |
+ public static final ResourceLocation field_191307_a = new ResourceLocation("lightning_bolt"); | |
+ private static final ResourceLocation field_191310_e = new ResourceLocation("player"); | |
+ private static final Logger field_151516_b = LogManager.getLogger(); | |
+- public static final RegistryNamespaced < ResourceLocation, Class <? extends Entity >> field_191308_b = new RegistryNamespaced(); | |
+ public static final Map<ResourceLocation, EntityList.EntityEggInfo> field_75627_a = Maps.<ResourceLocation, EntityList.EntityEggInfo>newLinkedHashMap(); | |
+- public static final Set<ResourceLocation> field_191309_d = Sets.<ResourceLocation>newHashSet(); | |
+- private static final List<String> field_191311_g = Lists.<String>newArrayList(); | |
++ private static final Set<ResourceLocation> EXTRA_NAMES = Sets.newHashSet(); | |
+ | |
+ @Nullable | |
+ public static ResourceLocation func_191301_a(Entity p_191301_0_) | |
+@@ -119,30 +117,44 @@ | |
+ @Nullable | |
+ public static ResourceLocation func_191306_a(Class <? extends Entity > p_191306_0_) | |
+ { | |
+- return (ResourceLocation)field_191308_b.func_177774_c(p_191306_0_); | |
++ net.minecraftforge.fml.common.registry.EntityEntry entry = net.minecraftforge.fml.common.registry.EntityRegistry.getEntry(p_191306_0_); | |
++ return entry == null ? null : entry.getRegistryName(); | |
+ } | |
+ | |
+ @Nullable | |
+ public static String func_75621_b(Entity p_75621_0_) | |
+ { | |
+- int i = field_191308_b.func_148757_b(p_75621_0_.getClass()); | |
+- return i == -1 ? null : (String)field_191311_g.get(i); | |
++ net.minecraftforge.fml.common.registry.EntityEntry entry = net.minecraftforge.fml.common.registry.EntityRegistry.getEntry(p_75621_0_.getClass()); | |
++ return entry == null ? null : entry.getName(); | |
+ } | |
+ | |
+ @Nullable | |
+ public static String func_191302_a(@Nullable ResourceLocation p_191302_0_) | |
+ { | |
+- int i = field_191308_b.func_148757_b(field_191308_b.func_82594_a(p_191302_0_)); | |
+- return i == -1 ? null : (String)field_191311_g.get(i); | |
++ net.minecraftforge.fml.common.registry.EntityEntry entry = net.minecraftforge.fml.common.registry.ForgeRegistries.ENTITIES.getValue(p_191302_0_); | |
++ return entry == null ? null : entry.getName(); | |
+ } | |
+ | |
+ @Nullable | |
+ @SideOnly(Side.CLIENT) | |
+ public static Class <? extends Entity > func_90035_a(int p_90035_0_) | |
+ { | |
+- return (Class)field_191308_b.func_148754_a(p_90035_0_); | |
++ net.minecraftforge.fml.common.registry.EntityEntry entry = net.minecraftforge.fml.common.registry.GameData.getEntityRegistry().func_148754_a(p_90035_0_); | |
++ return entry == null ? null : entry.getEntityClass(); | |
+ } | |
+ | |
++ public static int getID(Class<? extends Entity> cls) | |
++ { | |
++ net.minecraftforge.fml.common.registry.EntityEntry entry = net.minecraftforge.fml.common.registry.EntityRegistry.getEntry(cls); | |
++ return entry == null ? -1 : net.minecraftforge.fml.common.registry.GameData.getEntityRegistry().getId(entry); | |
++ } | |
++ | |
++ public static Class<? extends Entity> getClass(ResourceLocation key) | |
++ { | |
++ net.minecraftforge.fml.common.registry.EntityEntry entry = net.minecraftforge.fml.common.registry.ForgeRegistries.ENTITIES.getValue(key); | |
++ return entry == null ? null : entry.getEntityClass(); | |
++ } | |
++ | |
+ @Nullable | |
+ public static Entity func_191304_a(@Nullable Class <? extends Entity > p_191304_0_, World p_191304_1_) | |
+ { | |
+@@ -174,7 +186,7 @@ | |
+ @Nullable | |
+ public static Entity func_188429_b(ResourceLocation p_188429_0_, World p_188429_1_) | |
+ { | |
+- return func_191304_a((Class)field_191308_b.func_82594_a(p_188429_0_), p_188429_1_); | |
++ return func_191304_a(getClass(p_188429_0_), p_188429_1_); | |
+ } | |
+ | |
+ @Nullable | |
+@@ -189,7 +201,17 @@ | |
} | |
else | |
{ | |
@@ -18,3 +90,51 @@ | |
} | |
return entity; | |
+@@ -197,7 +219,7 @@ | |
+ | |
+ public static Set<ResourceLocation> func_180124_b() | |
+ { | |
+- return field_191309_d; | |
++ return Sets.union(net.minecraftforge.fml.common.registry.ForgeRegistries.ENTITIES.getKeys(), EXTRA_NAMES); | |
+ } | |
+ | |
+ public static boolean func_180123_a(Entity p_180123_0_, ResourceLocation p_180123_1_) | |
+@@ -336,7 +358,7 @@ | |
+ func_191305_a("zombie_horse", 3232308, 9945732); | |
+ func_191305_a("zombie_pigman", 15373203, 5009705); | |
+ func_191305_a("zombie_villager", 5651507, 7969893); | |
+- field_191309_d.add(field_191307_a); | |
++ EXTRA_NAMES.add(field_191307_a); | |
+ } | |
+ | |
+ private static void func_191303_a(int p_191303_0_, String p_191303_1_, Class <? extends Entity > p_191303_2_, String p_191303_3_) | |
+@@ -357,22 +379,19 @@ | |
+ else | |
+ { | |
+ ResourceLocation resourcelocation = new ResourceLocation(p_191303_1_); | |
+- field_191308_b.func_177775_a(p_191303_0_, resourcelocation, p_191303_2_); | |
+- field_191309_d.add(resourcelocation); | |
+- | |
+- while (field_191311_g.size() <= p_191303_0_) | |
+- { | |
+- field_191311_g.add((String)null); | |
+- } | |
+- | |
+- field_191311_g.set(p_191303_0_, p_191303_3_); | |
++ net.minecraftforge.fml.common.registry.EntityEntry entry = | |
++ new net.minecraftforge.fml.common.registry.EntityEntry(p_191303_2_, p_191303_3_); | |
++ net.minecraftforge.fml.common.registry.GameData.getEntityRegistry().func_177775_a(p_191303_0_, resourcelocation, entry); | |
+ } | |
+ } | |
+ | |
+ protected static EntityList.EntityEggInfo func_191305_a(String p_191305_0_, int p_191305_1_, int p_191305_2_) | |
+ { | |
+ ResourceLocation resourcelocation = new ResourceLocation(p_191305_0_); | |
+- return (EntityList.EntityEggInfo)field_75627_a.put(resourcelocation, new EntityList.EntityEggInfo(resourcelocation, p_191305_1_, p_191305_2_)); | |
++ EntityList.EntityEggInfo egg = new EntityList.EntityEggInfo(resourcelocation, p_191305_1_, p_191305_2_); | |
++ net.minecraftforge.fml.common.registry.EntityEntry entry = net.minecraftforge.fml.common.registry.ForgeRegistries.ENTITIES.getValue(resourcelocation); | |
++ if (entry != null) entry.setEgg(egg); | |
++ return (EntityList.EntityEggInfo)field_75627_a.put(resourcelocation, egg); | |
+ } | |
+ | |
+ public static class EntityEggInfo | |
diff --git a/src/main/java/net/minecraftforge/common/ForgeModContainer.java b/src/main/java/net/minecraftforge/common/ForgeModContainer.java | |
index ae749ad..ff70583 100644 | |
--- a/src/main/java/net/minecraftforge/common/ForgeModContainer.java | |
+++ b/src/main/java/net/minecraftforge/common/ForgeModContainer.java | |
@@ -420,7 +420,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC | |
{ | |
universalBucket = new UniversalBucket(); | |
universalBucket.setUnlocalizedName("forge.bucketFilled"); | |
- GameRegistry.registerItem(universalBucket, "bucketFilled"); | |
+ GameRegistry.register(universalBucket.setRegistryName("forge", "bucketFilled")); | |
MinecraftForge.EVENT_BUS.register(universalBucket); | |
} | |
} | |
diff --git a/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java b/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java | |
index 2e5bfb0..5684b98 100644 | |
--- a/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java | |
+++ b/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java | |
@@ -28,7 +28,7 @@ import net.minecraft.util.ResourceLocation; | |
import net.minecraft.util.math.BlockPos; | |
import net.minecraft.world.World; | |
import net.minecraftforge.common.DimensionManager; | |
-import net.minecraftforge.fml.common.registry.GameRegistry; | |
+import net.minecraftforge.fml.common.registry.ForgeRegistries; | |
/** | |
* Represents a captured snapshot of a block which will not change | |
@@ -150,7 +150,7 @@ public class BlockSnapshot implements Serializable | |
{ | |
if (this.replacedBlock == null) | |
{ | |
- this.replacedBlock = GameRegistry.findBlock(this.getRegistryName().getResourceDomain(), this.getRegistryName().getResourcePath()).getStateFromMeta(getMeta()); | |
+ this.replacedBlock = ForgeRegistries.BLOCKS.getValue(this.getRegistryName()).getStateFromMeta(getMeta()); | |
} | |
return this.replacedBlock; | |
} | |
@@ -326,4 +326,4 @@ public class BlockSnapshot implements Serializable | |
public void setWorld(World world) { this.world = world; } | |
public ResourceLocation getRegistryName() { return registryName; } | |
public int getMeta() { return meta; } | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/src/main/java/net/minecraftforge/fml/common/registry/EntityRegistry.java b/src/main/java/net/minecraftforge/fml/common/registry/EntityRegistry.java | |
index 14831e4..902d774 100644 | |
--- a/src/main/java/net/minecraftforge/fml/common/registry/EntityRegistry.java | |
+++ b/src/main/java/net/minecraftforge/fml/common/registry/EntityRegistry.java | |
@@ -19,33 +19,28 @@ | |
package net.minecraftforge.fml.common.registry; | |
-import java.util.BitSet; | |
import java.util.Iterator; | |
import java.util.List; | |
-import java.util.Map; | |
+import org.apache.logging.log4j.Level; | |
import net.minecraft.entity.Entity; | |
-import net.minecraft.entity.EntityList; | |
+import net.minecraft.entity.EntityList.EntityEggInfo; | |
import net.minecraft.entity.EntityLiving; | |
import net.minecraft.entity.EntityTracker; | |
import net.minecraft.entity.EnumCreatureType; | |
+import net.minecraft.util.ResourceLocation; | |
import net.minecraft.world.biome.Biome; | |
import net.minecraft.world.biome.Biome.SpawnListEntry; | |
import net.minecraftforge.fml.common.FMLCommonHandler; | |
import net.minecraftforge.fml.common.FMLLog; | |
-import net.minecraftforge.fml.common.Loader; | |
import net.minecraftforge.fml.common.ModContainer; | |
import net.minecraftforge.fml.common.network.internal.FMLMessage.EntitySpawnMessage; | |
-import org.apache.logging.log4j.Level; | |
- | |
import com.google.common.base.Function; | |
import com.google.common.collect.ArrayListMultimap; | |
import com.google.common.collect.BiMap; | |
import com.google.common.collect.HashBiMap; | |
import com.google.common.collect.ListMultimap; | |
-import com.google.common.collect.Maps; | |
-import com.google.common.primitives.UnsignedBytes; | |
public class EntityRegistry | |
{ | |
@@ -53,6 +48,7 @@ public class EntityRegistry | |
{ | |
private Class<? extends Entity> entityClass; | |
private ModContainer container; | |
+ private ResourceLocation regName; | |
private String entityName; | |
private int modId; | |
private int trackingRange; | |
@@ -60,9 +56,10 @@ public class EntityRegistry | |
private boolean sendsVelocityUpdates; | |
private Function<EntitySpawnMessage, Entity> customSpawnCallback; | |
private boolean usesVanillaSpawning; | |
- public EntityRegistration(ModContainer mc, Class<? extends Entity> entityClass, String entityName, int id, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) | |
+ public EntityRegistration(ModContainer mc, ResourceLocation registryName, Class<? extends Entity> entityClass, String entityName, int id, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) | |
{ | |
this.container = mc; | |
+ this.regName = registryName; | |
this.entityClass = entityClass; | |
this.entityName = entityName; | |
this.modId = id; | |
@@ -70,6 +67,10 @@ public class EntityRegistry | |
this.updateFrequency = updateFrequency; | |
this.sendsVelocityUpdates = sendsVelocityUpdates; | |
} | |
+ public ResourceLocation getRegistryName() | |
+ { | |
+ return regName; | |
+ } | |
public Class<? extends Entity> getEntityClass() | |
{ | |
return entityClass; | |
@@ -121,7 +122,6 @@ public class EntityRegistry | |
private static final EntityRegistry INSTANCE = new EntityRegistry(); | |
private ListMultimap<ModContainer, EntityRegistration> entityRegistrations = ArrayListMultimap.create(); | |
- private Map<String,ModContainer> entityNames = Maps.newHashMap(); | |
private BiMap<Class<? extends Entity>, EntityRegistration> entityClassRegistrations = HashBiMap.create(); | |
public static EntityRegistry instance() | |
@@ -144,9 +144,9 @@ public class EntityRegistry | |
* @param updateFrequency The frequency of tracking updates | |
* @param sendsVelocityUpdates Whether to send velocity information packets as well | |
*/ | |
- public static void registerModEntity(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) | |
+ public static void registerModEntity(ResourceLocation registryName, Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) | |
{ | |
- instance().doModEntityRegistration(entityClass, entityName, id, mod, trackingRange, updateFrequency, sendsVelocityUpdates); | |
+ instance().doModEntityRegistration(registryName, entityClass, entityName, id, mod, trackingRange, updateFrequency, sendsVelocityUpdates); | |
} | |
/** | |
@@ -163,15 +163,36 @@ public class EntityRegistry | |
* @param eggPrimary Primary egg color | |
* @param eggSecondary Secondary egg color | |
*/ | |
- public static void registerModEntity(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates, int eggPrimary, int eggSecondary) | |
+ public static void registerModEntity(ResourceLocation registryName, Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates, int eggPrimary, int eggSecondary) | |
{ | |
- instance().doModEntityRegistration(entityClass, entityName, id, mod, trackingRange, updateFrequency, sendsVelocityUpdates); | |
- EntityRegistry.registerEgg(entityClass, eggPrimary, eggSecondary); | |
+ instance().doModEntityRegistration(registryName, entityClass, entityName, id, mod, trackingRange, updateFrequency, sendsVelocityUpdates); | |
+ EntityRegistry.registerEgg(registryName, eggPrimary, eggSecondary); | |
} | |
- private void doModEntityRegistration(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) | |
+ private void doModEntityRegistration(ResourceLocation registryName, Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) | |
{ | |
ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod); | |
+ EntityRegistration er = new EntityRegistration(mc, registryName, entityClass, entityName, id, trackingRange, updateFrequency, sendsVelocityUpdates); | |
+ try | |
+ { | |
+ entityClassRegistrations.put(entityClass, er); | |
+ if (!ForgeRegistries.ENTITIES.containsKey(registryName)) | |
+ { | |
+ EntityEntry entry = new EntityEntry(entityClass, entityName).setRegistryName(registryName); | |
+ ForgeRegistries.ENTITIES.register(entry); | |
+ FMLLog.finer("Automatically registered mod %s entity %s as %s", mc.getModId(), entityName, entry.getRegistryName()); | |
+ } | |
+ else | |
+ { | |
+ FMLLog.fine("Skipping automatic mod %s entity registration for already registered entry %s class %s", mc.getModId(), registryName, entityClass.getName()); | |
+ } | |
+ } | |
+ catch (IllegalArgumentException e) | |
+ { | |
+ FMLLog.log(Level.WARN, e, "The mod %s tried to register the entity (registry,name,class) (%s,%s,%s) one or both of which are already registered", mc.getModId(), registryName, entityName, entityClass.getName()); | |
+ return; | |
+ } | |
+ entityRegistrations.put(mc, er); | |
} | |
/** | |
@@ -189,8 +210,15 @@ public class EntityRegistry | |
* | |
*/ | |
- public static void registerEgg(Class<? extends Entity> entityClass, int primary, int secondary) | |
+ public static void registerEgg(ResourceLocation name, int primary, int secondary) | |
{ | |
+ EntityEntry entry = ForgeRegistries.ENTITIES.getValue(name); | |
+ if (entry == null) | |
+ { | |
+ FMLLog.bigWarning("Attempted to registry a entity egg for entity (%s) that is not in the Entity Registry", name); | |
+ return; | |
+ } | |
+ entry.setEgg(new EntityEggInfo(name, primary, secondary)); | |
} | |
/** | |
@@ -329,4 +357,16 @@ public class EntityRegistry | |
} | |
return false; | |
} | |
+ | |
+ //Helper function | |
+ public static EntityEntry getEntry(Class<? extends Entity> entry) | |
+ { | |
+ //TODO: Slave map for faster lookup? | |
+ for (EntityEntry e : ForgeRegistries.ENTITIES) | |
+ { | |
+ if (e.getEntityClass() == entry) | |
+ return e; | |
+ } | |
+ return null; | |
+ } | |
} | |
diff --git a/src/main/java/net/minecraftforge/fml/common/registry/ForgeRegistries.java b/src/main/java/net/minecraftforge/fml/common/registry/ForgeRegistries.java | |
index 92a8616..8645fbe 100644 | |
--- a/src/main/java/net/minecraftforge/fml/common/registry/ForgeRegistries.java | |
+++ b/src/main/java/net/minecraftforge/fml/common/registry/ForgeRegistries.java | |
@@ -45,6 +45,7 @@ public class ForgeRegistries | |
public static final IForgeRegistry<PotionType> POTION_TYPES = GameRegistry.findRegistry(PotionType.class); | |
public static final IForgeRegistry<Enchantment> ENCHANTMENTS = GameRegistry.findRegistry(Enchantment.class); | |
public static final IForgeRegistry<VillagerProfession> VILLAGER_PROFESSIONS = GameRegistry.findRegistry(VillagerProfession.class); | |
+ public static final IForgeRegistry<EntityEntry> ENTITIES = GameRegistry.findRegistry(EntityEntry.class); | |
/** | |
diff --git a/src/main/java/net/minecraftforge/fml/common/registry/GameData.java b/src/main/java/net/minecraftforge/fml/common/registry/GameData.java | |
index a657d56..d6d9b03 100644 | |
--- a/src/main/java/net/minecraftforge/fml/common/registry/GameData.java | |
+++ b/src/main/java/net/minecraftforge/fml/common/registry/GameData.java | |
@@ -27,6 +27,7 @@ import com.google.common.collect.HashBiMap; | |
import net.minecraft.block.Block; | |
import net.minecraft.block.state.IBlockState; | |
import net.minecraft.enchantment.Enchantment; | |
+import net.minecraft.entity.EntityList; | |
import net.minecraft.item.Item; | |
import net.minecraft.item.ItemBlock; | |
import net.minecraft.potion.Potion; | |
@@ -60,6 +61,8 @@ public class GameData | |
private static final int MAX_POTIONTYPE_ID = Integer.MAX_VALUE >> 5; // Int (SPacketEffect) | |
private static final int MIN_ENCHANTMENT_ID = 0; // Int | |
private static final int MAX_ENCHANTMENT_ID = Short.MAX_VALUE - 1; // Short - serialized as a short in ItemStack NBTs. | |
+ private static final int MIN_ENTITY_ID = 0; | |
+ private static final int MAX_ENTITY_ID = Integer.MAX_VALUE >> 5; // Varint (SPacketSpawnMob) | |
private static final ResourceLocation BLOCK_TO_ITEM = new ResourceLocation("minecraft:blocktoitemmap"); | |
private static final ResourceLocation BLOCKSTATE_TO_ID = new ResourceLocation("minecraft:blockstatetoid"); | |
@@ -78,6 +81,7 @@ public class GameData | |
ResourceLocation WATER = new ResourceLocation("water"); | |
iPotionTypeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONTYPES, PotionType.class, WATER, MIN_POTIONTYPE_ID, MAX_POTIONTYPE_ID, false, null, null, null, null); | |
iEnchantmentRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ENCHANTMENTS, Enchantment.class, null, MIN_ENCHANTMENT_ID, MAX_ENCHANTMENT_ID, false, null, null, null, null); | |
+ iEntityRegistry = (FMLControlledNamespacedRegistry<EntityEntry>)new RegistryBuilder<EntityEntry>().setName(PersistentRegistryManager.ENTITIES).setType(EntityEntry.class).setIDRange(MIN_ENTITY_ID, MAX_ENTITY_ID).addCallback(EntityCallbacks.INSTANCE).create(); | |
try | |
{ | |
@@ -99,6 +103,7 @@ public class GameData | |
private final FMLControlledNamespacedRegistry<SoundEvent> iSoundEventRegistry; | |
private final FMLControlledNamespacedRegistry<PotionType> iPotionTypeRegistry; | |
private final FMLControlledNamespacedRegistry<Enchantment> iEnchantmentRegistry; | |
+ private final FMLControlledNamespacedRegistry<EntityEntry> iEntityRegistry; | |
//TODO: ? These are never used by ID, so they don't need to be full registries/persisted. | |
//Need cpw to decide how we want to go about this as they are generic registries that | |
@@ -145,6 +150,10 @@ public class GameData | |
@Deprecated | |
public static LegacyNamespacedRegistry<Class<? extends TileEntity>> getTileEntityRegistry() { return getMain().iTileEntityRegistry; } | |
+ /** INTERNAL ONLY */ | |
+ @Deprecated | |
+ public static FMLControlledNamespacedRegistry<EntityEntry> getEntityRegistry() { return getMain().iEntityRegistry; } | |
+ | |
@Deprecated | |
static Item findItem(String modId, String name) | |
{ | |
@@ -162,56 +171,6 @@ public class GameData | |
return mainData; | |
} | |
- @Deprecated | |
- int registerItem(Item item, String name) // from GameRegistry | |
- { | |
- return iItemRegistry.add(-1, addPrefix(name), item); | |
- } | |
- | |
- @Deprecated | |
- int registerBlock(Block block, String name) // from GameRegistry | |
- { | |
- return iBlockRegistry.add(-1, addPrefix(name), block); | |
- } | |
- | |
- /** | |
- * Prefix the supplied name with the current mod id. | |
- * <p/> | |
- * If no mod id can be determined, minecraft will be assumed. | |
- * The prefix is separated with a colon. | |
- * <p/> | |
- * If there's already a prefix, it'll be prefixed again if the new prefix | |
- * doesn't match the old prefix, as used by vanilla calls to addObject. | |
- * | |
- * @param name name to prefix. | |
- * @return prefixed name. | |
- */ | |
- private ResourceLocation addPrefix(String name) | |
- { | |
- int index = name.lastIndexOf(':'); | |
- String oldPrefix = index == -1 ? "" : name.substring(0, index); | |
- name = index == -1 ? name : name.substring(index + 1); | |
- String prefix; | |
- ModContainer mc = Loader.instance().activeModContainer(); | |
- | |
- if (mc != null) | |
- { | |
- prefix = mc.getModId().toLowerCase(); | |
- } | |
- else // no mod container, assume minecraft | |
- { | |
- prefix = "minecraft"; | |
- } | |
- | |
- if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0) | |
- { | |
- FMLLog.bigWarning("Dangerous alternative prefix %s for name %s, invalid registry invocation/invalid name?", prefix, name); | |
- prefix = oldPrefix; | |
- } | |
- | |
- return new ResourceLocation(prefix, name); | |
- } | |
- | |
void registerSubstitutionAlias(String name, GameRegistry.Type type, Object toReplace) throws ExistingSubstitutionException | |
{ | |
ResourceLocation nameToSubstitute = new ResourceLocation(name); | |
@@ -476,4 +435,27 @@ public class GameData | |
// no op for the minute? | |
} | |
} | |
+ private static class EntityCallbacks implements IForgeRegistry.AddCallback<EntityEntry>,IForgeRegistry.ClearCallback<EntityEntry>,IForgeRegistry.CreateCallback<EntityEntry> | |
+ { | |
+ static final EntityCallbacks INSTANCE = new EntityCallbacks(); | |
+ | |
+ @Override | |
+ public void onAdd(EntityEntry entry, int id, Map<ResourceLocation, ?> slaves) | |
+ { | |
+ if (entry.getEgg() != null) | |
+ EntityList.ENTITY_EGGS.put(entry.getRegistryName(), entry.getEgg()); | |
+ } | |
+ | |
+ @Override | |
+ public void onClear(IForgeRegistry<EntityEntry> registry, Map<ResourceLocation, ?> slaveset) | |
+ { | |
+ // no op for the minute? | |
+ } | |
+ | |
+ @Override | |
+ public void onCreate(Map<ResourceLocation, ?> slaveset, BiMap<ResourceLocation, ? extends IForgeRegistry<?>> registries) | |
+ { | |
+ // no op for the minute? | |
+ } | |
+ } | |
} | |
diff --git a/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java b/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java | |
index 606c7b6..dc78bfa 100644 | |
--- a/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java | |
+++ b/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java | |
@@ -398,133 +398,4 @@ public class GameRegistry | |
} | |
return is; | |
} | |
- | |
- | |
- | |
- | |
- // ============================= DEPRECATED/INTERNAL MODDERS DO NOT USE ================================= | |
- /** | |
- * Use {@link #register(IForgeRegistryEntry)} instead | |
- */ | |
- @Deprecated public static void registerItem(Item item){ register(item); } | |
- /** | |
- * Use {@link #register(IForgeRegistryEntry)} instead | |
- */ | |
- @Deprecated | |
- public static void registerItem(Item item, String name) | |
- { | |
- if (item.getRegistryName() == null && Strings.isNullOrEmpty(name)) | |
- throw new IllegalArgumentException("Attempted to register a item with no name: " + item); | |
- if (item.getRegistryName() != null && !item.getRegistryName().toString().equals(name)) | |
- throw new IllegalArgumentException("Attempted to register a item with conflicting names. Old: " + item.getRegistryName() + " New: " + name); | |
- register(item.getRegistryName() == null ? item.setRegistryName(name) : item); | |
- } | |
- /** | |
- * Use {@link #register(IForgeRegistryEntry)} instead | |
- */ | |
- @Deprecated | |
- public static Block registerBlock(Block block) | |
- { | |
- register(block); | |
- register(new ItemBlock(block).setRegistryName(block.getRegistryName())); | |
- return block; | |
- } | |
- /** | |
- * Use {@link #register(IForgeRegistryEntry)} instead | |
- */ | |
- @Deprecated | |
- public static Block registerBlock(Block block, String name) | |
- { | |
- if (block.getRegistryName() == null && Strings.isNullOrEmpty(name)) | |
- throw new IllegalArgumentException("Attempted to register a Block with no name: " + block); | |
- if (block.getRegistryName() != null && !block.getRegistryName().toString().equals(name)) | |
- throw new IllegalArgumentException("Attempted to register a Block with conflicting names. Old: " + block.getRegistryName() + " New: " + name); | |
- return registerBlock(block.getRegistryName() != null ? block : block.setRegistryName(name)); | |
- } | |
- /** | |
- * Use {@link #register(IForgeRegistryEntry)} instead | |
- */ | |
- @Deprecated public static Block registerBlock(Block block, Class<? extends ItemBlock> itemclass){ return registerBlock(block, itemclass, block.getRegistryName()); } | |
- /** | |
- * Use {@link #register(IForgeRegistryEntry)} instead | |
- */ | |
- @Deprecated public static Block registerBlock(Block block, Class<? extends ItemBlock> itemclass, String name){ return registerBlock(block, itemclass, name, new Object[] {}); } | |
- /** | |
- * Use {@link #register(IForgeRegistryEntry)} instead | |
- */ | |
- @Deprecated public static Block registerBlock(Block block, Class<? extends ItemBlock> itemclass, Object... itemCtorArgs){ return registerBlock(block, itemclass, block.getRegistryName().toString(), itemCtorArgs); } | |
- /** | |
- * Use {@link #register(IForgeRegistryEntry)} instead | |
- */ | |
- @Deprecated | |
- public static Block registerBlock(Block block, Class<? extends ItemBlock> itemclass, String name, Object... itemCtorArgs) | |
- { | |
- if (Strings.isNullOrEmpty(name)) | |
- { | |
- throw new IllegalArgumentException("Attempted to register a block with no name: " + block); | |
- } | |
- if (Loader.instance().isInState(LoaderState.CONSTRUCTING)) | |
- { | |
- FMLLog.warning("The mod %s is attempting to register a block whilst it it being constructed. This is bad modding practice - please use a proper mod lifecycle event.", Loader.instance().activeModContainer()); | |
- } | |
- try | |
- { | |
- assert block != null : "registerBlock: block cannot be null"; | |
- if (block.getRegistryName() != null && !block.getRegistryName().toString().equals(name)) | |
- throw new IllegalArgumentException("Attempted to register a Block with conflicting names. Old: " + block.getRegistryName() + " New: " + name); | |
- ItemBlock i = null; | |
- if (itemclass != null) | |
- { | |
- Class<?>[] ctorArgClasses = new Class<?>[itemCtorArgs.length + 1]; | |
- ctorArgClasses[0] = Block.class; | |
- for (int idx = 1; idx < ctorArgClasses.length; idx++) | |
- { | |
- ctorArgClasses[idx] = itemCtorArgs[idx - 1].getClass(); | |
- } | |
- Constructor<? extends ItemBlock> itemCtor = itemclass.getConstructor(ctorArgClasses); | |
- i = itemCtor.newInstance(ObjectArrays.concat(block, itemCtorArgs)); | |
- } | |
- // block registration has to happen first | |
- register(block.getRegistryName() == null ? block.setRegistryName(name) : block); | |
- if (i != null) | |
- register(i.setRegistryName(name)); | |
- return block; | |
- } catch (Exception e) | |
- { | |
- FMLLog.log(Level.ERROR, e, "Caught an exception during block registration"); | |
- throw new LoaderException(e); | |
- } | |
- } | |
- | |
- /** | |
- * | |
- * Use Block.REGISTRY.getValue(ResourceLocation) instead! | |
- * | |
- * | |
- * Look up a mod block in the global "named item list" | |
- * | |
- * @param modId The modid owning the block | |
- * @param name The name of the block itself | |
- * @return The block or null if not found | |
- */ | |
- @Deprecated | |
- public static Block findBlock(String modId, String name) | |
- { | |
- return GameData.findBlock(modId, name); | |
- } | |
- | |
- /** | |
- * Use Item.REGISTRY.getValue(ResourceLocation) instead! | |
- * | |
- * Look up a mod item in the global "named item list" | |
- * | |
- * @param modId The modid owning the item | |
- * @param name The name of the item itself | |
- * @return The item or null if not found | |
- */ | |
- @Deprecated | |
- public static Item findItem(String modId, String name) | |
- { | |
- return GameData.findItem(modId, name); | |
- } | |
} | |
diff --git a/src/main/java/net/minecraftforge/fml/common/registry/PersistentRegistryManager.java b/src/main/java/net/minecraftforge/fml/common/registry/PersistentRegistryManager.java | |
index 545dcb2..706f15e 100644 | |
--- a/src/main/java/net/minecraftforge/fml/common/registry/PersistentRegistryManager.java | |
+++ b/src/main/java/net/minecraftforge/fml/common/registry/PersistentRegistryManager.java | |
@@ -189,6 +189,7 @@ public class PersistentRegistryManager | |
public static final ResourceLocation SOUNDEVENTS = new ResourceLocation("minecraft:soundevents"); | |
public static final ResourceLocation POTIONTYPES = new ResourceLocation("minecraft:potiontypes"); | |
public static final ResourceLocation ENCHANTMENTS = new ResourceLocation("minecraft:enchantments"); | |
+ public static final ResourceLocation ENTITIES = new ResourceLocation("minecraft:entities"); | |
static final ResourceLocation SUBSTITUTION_ORIGINALS = new ResourceLocation("fml:suboriginals"); | |
@Deprecated //Use RegistryBuilder TODO: Remove in 1.11 | |
diff --git a/src/test/java/net/minecraftforge/debug/DynBucketTest.java b/src/test/java/net/minecraftforge/debug/DynBucketTest.java | |
index 05fdbbb..40389e7 100644 | |
--- a/src/test/java/net/minecraftforge/debug/DynBucketTest.java | |
+++ b/src/test/java/net/minecraftforge/debug/DynBucketTest.java | |
@@ -1,7 +1,5 @@ | |
package net.minecraftforge.debug; | |
-import java.util.List; | |
- | |
import net.minecraft.block.Block; | |
import net.minecraft.block.BlockContainer; | |
import net.minecraft.block.material.Material; | |
@@ -29,8 +27,6 @@ import net.minecraft.util.text.TextComponentString; | |
import net.minecraft.util.EnumFacing; | |
import net.minecraft.util.EnumHand; | |
import net.minecraft.util.ResourceLocation; | |
-import net.minecraft.util.math.BlockPos; | |
-import net.minecraft.util.text.TextComponentString; | |
import net.minecraft.world.World; | |
import net.minecraftforge.client.model.ModelLoader; | |
import net.minecraftforge.common.ForgeModContainer; | |
@@ -98,6 +94,7 @@ public class DynBucketTest | |
public static class ClientProxy extends CommonProxy | |
{ | |
+ @SuppressWarnings("unused") | |
@Override | |
void setupModels() | |
{ | |
diff --git a/src/test/java/net/minecraftforge/debug/ModelAnimationDebug.java b/src/test/java/net/minecraftforge/debug/ModelAnimationDebug.java | |
index 026ef36..99eb938 100644 | |
--- a/src/test/java/net/minecraftforge/debug/ModelAnimationDebug.java | |
+++ b/src/test/java/net/minecraftforge/debug/ModelAnimationDebug.java | |
@@ -195,7 +195,7 @@ public class ModelAnimationDebug | |
}); | |
String entityName = MODID + ":entity_chest"; | |
//EntityRegistry.registerGlobalEntityID(EntityChest.class, entityName, EntityRegistry.findGlobalUniqueEntityId()); | |
- EntityRegistry.registerModEntity(EntityChest.class, entityName, 0, ModelAnimationDebug.instance, 64, 20, true, 0xFFAAAA00, 0xFFDDDD00); | |
+ EntityRegistry.registerModEntity(new ResourceLocation(entityName), EntityChest.class, entityName, 0, ModelAnimationDebug.instance, 64, 20, true, 0xFFAAAA00, 0xFFDDDD00); | |
RenderingRegistry.registerEntityRenderingHandler(EntityChest.class, new IRenderFactory<EntityChest>() | |
{ | |
@SuppressWarnings("deprecation") | |
diff --git a/src/test/java/net/minecraftforge/test/WRNormalMod.java b/src/test/java/net/minecraftforge/test/WRNormalMod.java | |
index f37825a..72f93bc 100644 | |
--- a/src/test/java/net/minecraftforge/test/WRNormalMod.java | |
+++ b/src/test/java/net/minecraftforge/test/WRNormalMod.java | |
@@ -29,7 +29,7 @@ public class WRNormalMod | |
@EventHandler | |
public void init(FMLPreInitializationEvent event) | |
{ | |
- EntityRegistry.registerModEntity(EntityScaleTest.class, "scale_test", 0, instance, 60, 3, true); | |
+ EntityRegistry.registerModEntity(new ResourceLocation("wrnormal", "scale_test"), EntityScaleTest.class, "scale_test", 0, instance, 60, 3, true); | |
proxy.registerRenders(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment