ForgePatch/patches_old_unknown/EntityList.java.patch

184 lines
8.6 KiB
Diff
Raw Normal View History

--- ../src-base/minecraft/net/minecraft/entity/EntityList.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityList.java
@@ -107,10 +107,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 < ResourceLocation, Class <? extends Entity >> ();
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_)
@@ -121,38 +119,54 @@
@Nullable
public static ResourceLocation func_191306_a(Class <? extends Entity > p_191306_0_)
{
- return 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.registries.GameData.getEntityRegistry().getValue(p_90035_0_);
+ return entry == null ? null : entry.getEntityClass();
}
@Nullable
@SideOnly(Side.CLIENT)
public static Class <? extends Entity > func_192839_a(String p_192839_0_)
{
- return (Class)field_191308_b.func_82594_a(new ResourceLocation(p_192839_0_));
+ net.minecraftforge.fml.common.registry.EntityEntry entry = net.minecraftforge.fml.common.registry.ForgeRegistries.ENTITIES.getValue(new ResourceLocation(p_192839_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.registries.GameData.getEntityRegistry().getID(entry);
+ }
+
@Nullable
+ 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_)
{
if (p_191304_0_ == null)
@@ -163,6 +177,8 @@
{
try
{
+ net.minecraftforge.fml.common.registry.EntityEntry entry = net.minecraftforge.fml.common.registry.EntityRegistry.getEntry(p_191304_0_);
+ if (entry != null) return entry.newInstance(p_191304_1_);
return p_191304_0_.getConstructor(World.class).newInstance(p_191304_1_);
}
catch (Exception exception)
@@ -177,13 +193,15 @@
@SideOnly(Side.CLIENT)
public static Entity func_75616_a(int p_75616_0_, World p_75616_1_)
{
- return func_191304_a(func_90035_a(p_75616_0_), p_75616_1_);
+ net.minecraftforge.fml.common.registry.EntityEntry entry = net.minecraftforge.registries.GameData.getEntityRegistry().getValue(p_75616_0_);
+ return entry == null ? null : entry.newInstance(p_75616_1_);
}
@Nullable
public static Entity func_188429_b(ResourceLocation p_188429_0_, World p_188429_1_)
{
- return func_191304_a(field_191308_b.func_82594_a(p_188429_0_), p_188429_1_);
+ net.minecraftforge.fml.common.registry.EntityEntry entry = net.minecraftforge.fml.common.registry.ForgeRegistries.ENTITIES.getValue(p_188429_0_);
+ return entry == null ? null : entry.newInstance(p_188429_1_);
}
@Nullable
@@ -198,7 +216,16 @@
}
else
{
+ try
+ {
entity.func_70020_e(p_75615_0_);
+ }
+ catch (Exception e)
+ {
+ net.minecraftforge.fml.common.FMLLog.log.error("An Entity {}({}) has thrown an exception during loading, its state cannot be restored. Report this to the mod author",
+ p_75615_0_.func_74779_i("id"), entity.func_70005_c_(), e);
+ entity = null;
+ }
}
return entity;
@@ -206,7 +233,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_)
@@ -373,7 +400,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_)
@@ -394,22 +421,17 @@
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(null);
- }
-
- field_191311_g.set(p_191303_0_, p_191303_3_);
+ net.minecraftforge.registries.GameData.registerEntity(p_191303_0_, resourcelocation, p_191303_2_, p_191303_3_);
}
}
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 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
@@ -428,5 +450,16 @@
this.field_151512_d = StatList.func_151182_a(this);
this.field_151513_e = StatList.func_151176_b(this);
}
+
+ // Forge start
+ public EntityEggInfo(ResourceLocation id, int primaryColor, int secondaryColor, StatBase killEntityStatistic, StatBase entityKilledByStatistic)
+ {
+ this.field_75613_a = id;
+ this.field_75611_b = primaryColor;
+ this.field_75612_c = secondaryColor;
+ this.field_151512_d = killEntityStatistic;
+ this.field_151513_e = entityKilledByStatistic;
+ }
+ // Forge end
}
}