Have PlayerAnimator ignore renderers for which no layers/models are stored, fixes #518
This will stop the crashing but might well mean broken animations - for now there's not much I can do about that
This commit is contained in:
@@ -133,9 +133,21 @@ public class PlayerAnimator {
|
||||
|
||||
private static void updateModels(EntityPlayer player, Render<?> renderer, float partialTicks, boolean firstPerson){
|
||||
|
||||
// TODO: This will stop the crashing but it might break animations for any mod that replaces the player renderer
|
||||
// There may be a way to make it compatible but we'll have to look into that at a later date
|
||||
List<ModelBiped> models = playerLayerModels.get(renderer);
|
||||
|
||||
// If no models were registered for the given renderer, don't do anything
|
||||
if(models != null){
|
||||
|
||||
List<LayerRenderer<? extends EntityLivingBase>> layers = playerLayers.get(renderer);
|
||||
|
||||
// If no layers were registered for the given renderer there's no point trying to lazy-load anything!
|
||||
if(layers != null){
|
||||
|
||||
// Biped armour is special because of Forge's armour item render hook
|
||||
// This needs to be lazy-loaded because we need access to an actual item
|
||||
for(LayerRenderer<? extends EntityLivingBase> layer : playerLayers.get(renderer)){
|
||||
for(LayerRenderer<? extends EntityLivingBase> layer : layers){
|
||||
if(layer instanceof LayerBipedArmor){
|
||||
for(EntityEquipmentSlot slot : InventoryUtils.ARMOUR_SLOTS){
|
||||
|
||||
@@ -144,8 +156,6 @@ public class PlayerAnimator {
|
||||
// optimise it further, we *have* to retrieve the model every time (shouldn't be too bad though)
|
||||
ModelBiped model = ForgeHooksClient.getArmorModel(player, armour, slot, ((LayerBipedArmor)layer).getModelFromSlot(slot));
|
||||
|
||||
List<ModelBiped> models = playerLayerModels.get(renderer);
|
||||
|
||||
if(!models.contains(model)){ // Ignore already-wrapped models
|
||||
models.add(model);
|
||||
ModelRendererExtended.wrap(model);
|
||||
@@ -153,6 +163,7 @@ public class PlayerAnimator {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(Animation animation : animations){
|
||||
|
||||
@@ -160,7 +171,7 @@ public class PlayerAnimator {
|
||||
|
||||
boolean autoRotateSecondLayer = animation.autoRotateSecondLayer(player, firstPerson);
|
||||
|
||||
for(ModelBiped model : playerLayerModels.get(renderer)){
|
||||
for(ModelBiped model : models){
|
||||
|
||||
animation.setRotationAngles(player, model, partialTicks, firstPerson);
|
||||
|
||||
@@ -170,6 +181,7 @@ public class PlayerAnimator {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user