mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 22:27:32 +00:00
Fixed NPC part type searching in the mixin
This commit is contained in:
1 parent
4e5a12690e
commit
477cf03f1b
1 file changed
+19
-20
@@ -48,6 +48,22 @@ public abstract class MixinModelRenderer {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(float p_78785_1_)
|
||||
{
|
||||
if (ClientEventHandler.partNames.isEmpty()) {
|
||||
String[] headNames = new String[]{"field_78116_c","bipedHead","bipedHeadwear","head","Head","bipedHeadAll",
|
||||
"bipedHeadg","bipedHeadt","bipedHeadgh","bipedHeadv","bipedHeadb","bipedHeadt2"};
|
||||
String[] bodyNames = new String[]{"field_78115_e","bipedBody","B1","body","UpperBody","Body1","BodyBase"};
|
||||
String[] larmNames = new String[]{"field_78113_g","bipedLeftArm","LA","leftarm","ArmL","Arm1L","ArmL1"};
|
||||
String[] rarmNames = new String[]{"field_78112_f","bipedRightArm","RA","rightarm","ArmR","Arm1R","ArmR1"};
|
||||
String[] llegNames = new String[]{"field_78124_i","bipedLeftLeg","LL","leftleg","LegL","Leg1L","LegL1"};
|
||||
String[] rlegNames = new String[]{"field_78123_h","bipedRightLeg","RL","rightleg","LegR","Leg1R","LegR1"};
|
||||
|
||||
ClientEventHandler.partNames.put(EnumAnimationPart.HEAD, headNames);
|
||||
ClientEventHandler.partNames.put(EnumAnimationPart.BODY, bodyNames);
|
||||
ClientEventHandler.partNames.put(EnumAnimationPart.LEFT_ARM, larmNames);
|
||||
ClientEventHandler.partNames.put(EnumAnimationPart.RIGHT_ARM, rarmNames);
|
||||
ClientEventHandler.partNames.put(EnumAnimationPart.LEFT_LEG, llegNames);
|
||||
ClientEventHandler.partNames.put(EnumAnimationPart.RIGHT_LEG, rlegNames);
|
||||
}
|
||||
if (!this.isHidden)
|
||||
{
|
||||
if (this.showModel)
|
||||
@@ -296,20 +312,8 @@ public abstract class MixinModelRenderer {
|
||||
public EnumAnimationPart getPartType(ModelRenderer renderer, HashMap<EnumAnimationPart,String[]> partNames) {
|
||||
Class<?> RenderClass = renderer.baseModel.getClass();
|
||||
Object model = renderer.baseModel;
|
||||
EnumAnimationPart type = null;
|
||||
|
||||
while (type == null) {
|
||||
for (Field f : RenderClass.getDeclaredFields()) {
|
||||
f.setAccessible(true);
|
||||
try {
|
||||
if (renderer == f.get(model)) {
|
||||
int i = 0;
|
||||
break;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
while (RenderClass != Object.class) {
|
||||
for (Map.Entry<EnumAnimationPart, String[]> entry : partNames.entrySet()) {
|
||||
String[] names = entry.getValue();
|
||||
for (String partName : names) {
|
||||
@@ -317,20 +321,15 @@ public abstract class MixinModelRenderer {
|
||||
Field field = RenderClass.getDeclaredField(partName);
|
||||
field.setAccessible(true);
|
||||
if (renderer == field.get(model)) {
|
||||
type = entry.getKey();
|
||||
break;
|
||||
return entry.getKey();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (RenderClass == ModelBase.class || RenderClass.getSuperclass() == null) {
|
||||
break;
|
||||
}
|
||||
RenderClass = RenderClass.getSuperclass();
|
||||
}
|
||||
|
||||
return type;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user