From cf2bbd1353df3b87e004bbd8a86324eb82f278e3 Mon Sep 17 00:00:00 2001 From: RainWarrior Date: Fri, 1 Jan 2016 02:01:03 +0300 Subject: [PATCH] Fixed RenderingRegistry not working. Closes #2312. --- .../renderer/entity/RenderManager.java.patch | 6 ++-- .../fml/client/FMLClientHandler.java | 1 - .../fml/client/registry/ClientRegistry.java | 4 +-- .../client/registry/RenderingRegistry.java | 34 +++++++------------ src/main/resources/forge_at.cfg | 2 -- 5 files changed, 19 insertions(+), 28 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RenderManager.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RenderManager.java.patch index 7b9014d93..267976b53 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/RenderManager.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RenderManager.java.patch @@ -1,8 +1,10 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderManager.java +++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RenderManager.java -@@ -193,6 +193,10 @@ +@@ -192,7 +192,12 @@ + this.field_178637_m = new RenderPlayer(this); this.field_178636_l.put("default", this.field_178637_m); this.field_178636_l.put("slim", new RenderPlayer(this, true)); ++ net.minecraftforge.fml.client.registry.RenderingRegistry.loadEntityRenderers(this, this.field_78729_o); } + + public Map getSkinMap() { @@ -11,7 +13,7 @@ public void func_178628_a(double p_178628_1_, double p_178628_3_, double p_178628_5_) { -@@ -241,9 +245,9 @@ +@@ -241,9 +246,9 @@ IBlockState iblockstate = p_180597_1_.func_180495_p(new BlockPos(p_180597_3_)); Block block = iblockstate.func_177230_c(); diff --git a/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java b/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java index 993ded08c..d652c3ff7 100644 --- a/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java +++ b/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java @@ -321,7 +321,6 @@ public class FMLClientHandler implements IFMLSidedHandler // Reload resources client.refreshResources(); - RenderingRegistry.loadEntityRenderers(Minecraft.getMinecraft().getRenderManager().entityRenderMap); guiFactories = HashBiMap.create(); for (ModContainer mc : Loader.instance().getActiveModList()) { diff --git a/src/main/java/net/minecraftforge/fml/client/registry/ClientRegistry.java b/src/main/java/net/minecraftforge/fml/client/registry/ClientRegistry.java index 853b321be..205837e34 100644 --- a/src/main/java/net/minecraftforge/fml/client/registry/ClientRegistry.java +++ b/src/main/java/net/minecraftforge/fml/client/registry/ClientRegistry.java @@ -31,13 +31,13 @@ public class ClientRegistry * @param id * @param specialRenderer */ - public static void registerTileEntity(Class tileEntityClass, String id, TileEntitySpecialRenderer specialRenderer) + public static void registerTileEntity(Class tileEntityClass, String id, TileEntitySpecialRenderer specialRenderer) { GameRegistry.registerTileEntity(tileEntityClass, id); bindTileEntitySpecialRenderer(tileEntityClass, specialRenderer); } - public static void bindTileEntitySpecialRenderer(Class tileEntityClass, TileEntitySpecialRenderer specialRenderer) + public static void bindTileEntitySpecialRenderer(Class tileEntityClass, TileEntitySpecialRenderer specialRenderer) { TileEntityRendererDispatcher.instance.mapSpecialRenderers.put(tileEntityClass, specialRenderer); specialRenderer.setRendererDispatcher(TileEntityRendererDispatcher.instance); diff --git a/src/main/java/net/minecraftforge/fml/client/registry/RenderingRegistry.java b/src/main/java/net/minecraftforge/fml/client/registry/RenderingRegistry.java index d8c3071e2..fd45582bc 100644 --- a/src/main/java/net/minecraftforge/fml/client/registry/RenderingRegistry.java +++ b/src/main/java/net/minecraftforge/fml/client/registry/RenderingRegistry.java @@ -11,52 +11,44 @@ */ package net.minecraftforge.fml.client.registry; -import java.util.List; import java.util.Map; import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; -import com.google.common.collect.Lists; +import com.google.common.collect.Maps; -/** - * @author cpw - * - */ public class RenderingRegistry { private static final RenderingRegistry INSTANCE = new RenderingRegistry(); - private List entityRenderers = Lists.newArrayList(); + private Map, IRenderFactory> entityRenderers = Maps.newHashMap(); /** * Register an entity rendering handler. This will, after mod initialization, be inserted into the main - * render map for entities + * render map for entities. + * Call this during Preinitialization phase. * * @param entityClass * @param renderer */ - public static void registerEntityRenderingHandler(Class entityClass, Render renderer) + public static void registerEntityRenderingHandler(Class entityClass, IRenderFactory renderFactory) { - INSTANCE.entityRenderers.add(new EntityRendererInfo(entityClass, renderer)); + INSTANCE.entityRenderers.put(entityClass, renderFactory); } - private static class EntityRendererInfo + public static void loadEntityRenderers(RenderManager manager, Map , Render> renderMap) { - public EntityRendererInfo(Class target, Render renderer) + for (Map.Entry, IRenderFactory> entry : INSTANCE.entityRenderers.entrySet()) { - this.target = target; - this.renderer = renderer; + register(manager, renderMap, entry.getKey(), entry.getValue()); } - private Class target; - private Render renderer; } - public static void loadEntityRenderers(Map, Render> entityRenderMap) + @SuppressWarnings("unchecked") + private static void register(RenderManager manager, Map , Render> renderMap, Class entityClass, IRenderFactory renderFactory) { - for (EntityRendererInfo info : INSTANCE.entityRenderers) - { - entityRenderMap.put(info.target, info.renderer); - } + renderMap.put(entityClass, ((IRenderFactory)renderFactory).createRenderFor(manager)); } } diff --git a/src/main/resources/forge_at.cfg b/src/main/resources/forge_at.cfg index 70b634801..31f70fdef 100644 --- a/src/main/resources/forge_at.cfg +++ b/src/main/resources/forge_at.cfg @@ -159,8 +159,6 @@ public net.minecraft.entity.EntityList func_75614_a(Ljava/lang/Class;Ljava/lang/ public net.minecraft.entity.EntityList field_75625_b #nameToClassMap public net.minecraft.entity.EntityList field_75626_c #classToNameMap public net.minecraft.entity.EntityList field_75623_d #idToClassMap -## RenderManager -public net.minecraft.client.renderer.entity.RenderManager field_78729_o #renderers ## TileEntityRendererDispatcher public net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher field_147559_m ## WeightedRandomItem