From 1f68025252474e70cf94eeedf274ef605221bc26 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 1 May 2018 12:40:18 +0200 Subject: [PATCH] Cleaned up MixinRenderManager and made KillJoy happy This will be the last commit on master until I can get this PR merged --- .../com/minelittlepony/PonyRenderManager.java | 14 ++++++++------ .../com/minelittlepony/ducks/IRenderManager.java | 12 ------------ .../minelittlepony/mixin/MixinRenderManager.java | 16 ++++------------ .../render/player/RenderPonyPlayer.java | 12 +++--------- 4 files changed, 15 insertions(+), 39 deletions(-) delete mode 100644 src/main/java/com/minelittlepony/ducks/IRenderManager.java diff --git a/src/main/java/com/minelittlepony/PonyRenderManager.java b/src/main/java/com/minelittlepony/PonyRenderManager.java index 95a7a0a0..809e305c 100644 --- a/src/main/java/com/minelittlepony/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/PonyRenderManager.java @@ -3,7 +3,7 @@ package com.minelittlepony; import java.util.Map; import com.google.common.collect.Maps; -import com.minelittlepony.ducks.IRenderManager; +import com.minelittlepony.mixin.MixinRenderManager; import com.minelittlepony.hdskins.gui.EntityPonyModel; import com.minelittlepony.hdskins.gui.RenderPonyModel; import com.minelittlepony.model.player.PlayerModels; @@ -56,13 +56,15 @@ public class PonyRenderManager { registerPlayerSkin(manager, PlayerModels.ALICORN); } - protected void registerPlayerSkin(RenderManager manager, PlayerModels playerModel) { - addPlayerSkin(manager, new RenderPonyPlayer(manager, false, playerModel)); - addPlayerSkin(manager, new RenderPonyPlayer(manager, true, playerModel)); + private void registerPlayerSkin(RenderManager manager, PlayerModels playerModel) { + addPlayerSkin(manager, false, playerModel); + addPlayerSkin(manager, true, playerModel); } - public void addPlayerSkin(RenderManager manager, RenderPonyPlayer renderer) { - ((IRenderManager)manager).addPlayerSkin(renderer.skinId, renderer); + private void addPlayerSkin(RenderManager manager, boolean slimArms, PlayerModels playerModel) { + RenderPonyPlayer renderer = new RenderPonyPlayer(manager, slimArms, playerModel.getModel(slimArms)); + + ((MixinRenderManager)manager).getSkinMap().put(playerModel.getId(slimArms), renderer); } /** diff --git a/src/main/java/com/minelittlepony/ducks/IRenderManager.java b/src/main/java/com/minelittlepony/ducks/IRenderManager.java deleted file mode 100644 index d48b127a..00000000 --- a/src/main/java/com/minelittlepony/ducks/IRenderManager.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.minelittlepony.ducks; - -import net.minecraft.client.renderer.entity.RenderPlayer; - -public interface IRenderManager { - /** - * Registers a new player model to the underlying skinMap object. - * @param key The key to identify it by. - * @param render The renderer to add. - */ - void addPlayerSkin(String key, RenderPlayer render); -} diff --git a/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java b/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java index 8b732680..5f200841 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java +++ b/src/main/java/com/minelittlepony/mixin/MixinRenderManager.java @@ -2,22 +2,14 @@ package com.minelittlepony.mixin; import java.util.Map; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import com.minelittlepony.ducks.IRenderManager; +import org.spongepowered.asm.mixin.gen.Accessor; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderPlayer; @Mixin(RenderManager.class) -public abstract class MixinRenderManager implements IRenderManager { - @Shadow @Final - private Map skinMap; - - @Override - public void addPlayerSkin(String key, RenderPlayer render) { - skinMap.put(key, render); - } +public interface MixinRenderManager { + @Accessor + Map getSkinMap(); } diff --git a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java index 1ef664ac..793cd758 100644 --- a/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/render/player/RenderPonyPlayer.java @@ -2,7 +2,7 @@ package com.minelittlepony.render.player; import com.minelittlepony.MineLittlePony; import com.minelittlepony.ducks.IPonyAnimationHolder; -import com.minelittlepony.model.player.PlayerModels; +import com.minelittlepony.model.ModelWrapper; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.GlStateManager; @@ -10,14 +10,8 @@ import net.minecraft.client.renderer.entity.RenderManager; public class RenderPonyPlayer extends RenderPonyBase { - /** - * The id used to find this renderer in the player skin map. - */ - public final String skinId; - - public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, PlayerModels model) { - super(renderManager, useSmallArms, model.getModel(useSmallArms)); - skinId = model.getId(useSmallArms); + public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, ModelWrapper model) { + super(renderManager, useSmallArms, model); } @Override