Skip to content

Commit

Permalink
Compatibility - add compatibility with mchorse Metamorph mod. Fix mic…
Browse files Browse the repository at this point in the history
  • Loading branch information
radfast committed Sep 16, 2019
1 parent ba67bb6 commit a7244cd
Showing 1 changed file with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private void addGCLayers()
int skullLayerIndex = -1;
for (int i = 0; i < this.layerRenderers.size(); i++)
{
LayerRenderer layer = this.layerRenderers.get(i);
LayerRenderer layer = this.layerRenderers.get(i);
if (layer instanceof LayerHeldItem)
{
itemLayerIndex = i;
Expand All @@ -91,7 +91,7 @@ else if (layer instanceof LayerArmorBase)
{
try {
f1.set(layer, this);
} catch (Exception ignore) {}
} catch (Exception ignore) { }
}
}
else if (layer instanceof LayerCustomHead)
Expand Down Expand Up @@ -138,11 +138,28 @@ public RenderPlayerGC(RenderPlayer old, boolean smallArms)
this.mainModel = new ModelPlayerGC(0.0F, smallArms);

//Preserve any layers added by other mods, for example WearableBackpacks
try
Class clazz = old.getClass().getSuperclass();
Field f = null;
do {
try
{
f = clazz.getDeclaredField(GCCoreUtil.isDeobfuscated() ? "layerRenderers" : "field_177097_h");
f.setAccessible(true);
} catch (Exception ignore) { }
clazz = clazz.getSuperclass();
} while (f == null && clazz != null);
if (f != null) try
{
Field f = old.getClass().getSuperclass().getDeclaredField(GCCoreUtil.isDeobfuscated() ? "layerRenderers" : "field_177097_h");
f.setAccessible(true);
List<LayerRenderer<?>> layers = (List<LayerRenderer<?>>) f.get(old);
if(layers.size() == 0)
{
//Specifically fix for compatibility with MetaMorph's non-standard "RenderSubPlayer" class
try {
Field g = old.getClass().getDeclaredField("original");
old = (RenderPlayer) g.get(old);
layers = (List<LayerRenderer<?>>) f.get(old);
} catch (Exception ignore) { }
}
if (layers.size() > 0)
{
for (LayerRenderer<?> oldLayer : layers)
Expand Down

0 comments on commit a7244cd

Please sign in to comment.