mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-23 04:57:58 +01:00
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:
parent
73ff4bdec1
commit
bf8025bdaf
1 changed files with 9 additions and 0 deletions
|
@ -870,6 +870,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
||||||
public ModelRenderer getRandomModelBox(Random rand) {
|
public ModelRenderer getRandomModelBox(Random rand) {
|
||||||
// grab one at random, but cycle through the list until you find one that's filled.
|
// 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.
|
// 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 randomI = rand.nextInt(boxList.size());
|
||||||
int index = randomI;
|
int index = randomI;
|
||||||
|
|
||||||
|
@ -881,6 +882,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
||||||
index = (index + 1) % boxList.size();
|
index = (index + 1) % boxList.size();
|
||||||
} while (index != randomI);
|
} 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;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue