Fixed RenderingRegistry not working. Closes #2312.

This commit is contained in:
RainWarrior 2016-01-01 02:01:03 +03:00
parent 6e90348dc5
commit cf2bbd1353
5 changed files with 19 additions and 28 deletions

View file

@ -1,8 +1,10 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderManager.java --- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderManager.java
+++ ../src-work/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("default", this.field_178637_m);
this.field_178636_l.put("slim", new RenderPlayer(this, true)); this.field_178636_l.put("slim", new RenderPlayer(this, true));
+ net.minecraftforge.fml.client.registry.RenderingRegistry.loadEntityRenderers(this, this.field_78729_o);
} }
+ +
+ public Map<String, RenderPlayer> getSkinMap() { + public Map<String, RenderPlayer> getSkinMap() {
@ -11,7 +13,7 @@
public void func_178628_a(double p_178628_1_, double p_178628_3_, double p_178628_5_) 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_)); IBlockState iblockstate = p_180597_1_.func_180495_p(new BlockPos(p_180597_3_));
Block block = iblockstate.func_177230_c(); Block block = iblockstate.func_177230_c();

View file

@ -321,7 +321,6 @@ public class FMLClientHandler implements IFMLSidedHandler
// Reload resources // Reload resources
client.refreshResources(); client.refreshResources();
RenderingRegistry.loadEntityRenderers(Minecraft.getMinecraft().getRenderManager().entityRenderMap);
guiFactories = HashBiMap.create(); guiFactories = HashBiMap.create();
for (ModContainer mc : Loader.instance().getActiveModList()) for (ModContainer mc : Loader.instance().getActiveModList())
{ {

View file

@ -31,13 +31,13 @@ public class ClientRegistry
* @param id * @param id
* @param specialRenderer * @param specialRenderer
*/ */
public static <T extends TileEntity> void registerTileEntity(Class<T> tileEntityClass, String id, TileEntitySpecialRenderer<T> specialRenderer) public static <T extends TileEntity> void registerTileEntity(Class<T> tileEntityClass, String id, TileEntitySpecialRenderer<? super T> specialRenderer)
{ {
GameRegistry.registerTileEntity(tileEntityClass, id); GameRegistry.registerTileEntity(tileEntityClass, id);
bindTileEntitySpecialRenderer(tileEntityClass, specialRenderer); bindTileEntitySpecialRenderer(tileEntityClass, specialRenderer);
} }
public static <T extends TileEntity> void bindTileEntitySpecialRenderer(Class<T> tileEntityClass, TileEntitySpecialRenderer<T> specialRenderer) public static <T extends TileEntity> void bindTileEntitySpecialRenderer(Class<T> tileEntityClass, TileEntitySpecialRenderer<? super T> specialRenderer)
{ {
TileEntityRendererDispatcher.instance.mapSpecialRenderers.put(tileEntityClass, specialRenderer); TileEntityRendererDispatcher.instance.mapSpecialRenderers.put(tileEntityClass, specialRenderer);
specialRenderer.setRendererDispatcher(TileEntityRendererDispatcher.instance); specialRenderer.setRendererDispatcher(TileEntityRendererDispatcher.instance);

View file

@ -11,52 +11,44 @@
*/ */
package net.minecraftforge.fml.client.registry; package net.minecraftforge.fml.client.registry;
import java.util.List;
import java.util.Map; import java.util.Map;
import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import com.google.common.collect.Lists; import com.google.common.collect.Maps;
/**
* @author cpw
*
*/
public class RenderingRegistry public class RenderingRegistry
{ {
private static final RenderingRegistry INSTANCE = new RenderingRegistry(); private static final RenderingRegistry INSTANCE = new RenderingRegistry();
private List<EntityRendererInfo> entityRenderers = Lists.newArrayList(); private Map<Class<? extends Entity>, IRenderFactory<? extends Entity>> entityRenderers = Maps.newHashMap();
/** /**
* Register an entity rendering handler. This will, after mod initialization, be inserted into the main * 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 entityClass
* @param renderer * @param renderer
*/ */
public static void registerEntityRenderingHandler(Class<? extends Entity> entityClass, Render<? extends Entity> renderer) public static <T extends Entity> void registerEntityRenderingHandler(Class<T> entityClass, IRenderFactory<? super T> renderFactory)
{ {
INSTANCE.entityRenderers.add(new EntityRendererInfo(entityClass, renderer)); INSTANCE.entityRenderers.put(entityClass, renderFactory);
} }
private static class EntityRendererInfo public static void loadEntityRenderers(RenderManager manager, Map<Class<? extends Entity> , Render<? extends Entity>> renderMap)
{ {
public EntityRendererInfo(Class<? extends Entity> target, Render<? extends Entity> renderer) for (Map.Entry<Class<? extends Entity>, IRenderFactory<? extends Entity>> entry : INSTANCE.entityRenderers.entrySet())
{ {
this.target = target; register(manager, renderMap, entry.getKey(), entry.getValue());
this.renderer = renderer;
} }
private Class<? extends Entity> target;
private Render<? extends Entity> renderer;
} }
public static void loadEntityRenderers(Map<Class<? extends Entity>, Render<? extends Entity>> entityRenderMap) @SuppressWarnings("unchecked")
private static <T extends Entity> void register(RenderManager manager, Map<Class<? extends Entity> , Render<? extends Entity>> renderMap, Class<T> entityClass, IRenderFactory<?> renderFactory)
{ {
for (EntityRendererInfo info : INSTANCE.entityRenderers) renderMap.put(entityClass, ((IRenderFactory<T>)renderFactory).createRenderFor(manager));
{
entityRenderMap.put(info.target, info.renderer);
}
} }
} }

View file

@ -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_75625_b #nameToClassMap
public net.minecraft.entity.EntityList field_75626_c #classToNameMap public net.minecraft.entity.EntityList field_75626_c #classToNameMap
public net.minecraft.entity.EntityList field_75623_d #idToClassMap public net.minecraft.entity.EntityList field_75623_d #idToClassMap
## RenderManager
public net.minecraft.client.renderer.entity.RenderManager field_78729_o #renderers
## TileEntityRendererDispatcher ## TileEntityRendererDispatcher
public net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher field_147559_m public net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher field_147559_m
## WeightedRandomItem ## WeightedRandomItem