Guard as best we can against shenanigans. Should fix rendering errors, or at least replace them with a clearer message that something or someone is misbehaving

This commit is contained in:
Sollace 2018-08-14 19:05:54 +02:00
parent 73ff4bdec1
commit bf8025bdaf

View file

@ -870,6 +870,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
public ModelRenderer getRandomModelBox(Random rand) {
// grab one at random, but cycle through the list until you find one that's filled.
// Return if you find one, or if you get back to where you started in which case there isn't any.
int randomI = rand.nextInt(boxList.size());
int index = randomI;
@ -881,6 +882,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
index = (index + 1) % boxList.size();
} while (index != randomI);
if (result.cubeList.isEmpty()) {
result.addBox(0, 0, 0, 0, 0, 0);
}
if (result.cubeList.isEmpty()) {
throw new IllegalStateException("This model contains absolutely no boxes and a box could not be added!");
}
return result;
}
}