Fix out of bounds on invalid enum items

This commit is contained in:
Nicholas Ignoffo 2018-03-23 17:12:32 -07:00
parent 58d9678c40
commit 8dce592787

View file

@ -42,7 +42,7 @@ public class ItemEnum<T extends Enum<T> & ISubItem> extends Item {
} }
public T getItemType(ItemStack stack) { public T getItemType(ItemStack stack) {
return types[MathHelper.clamp(stack.getItemDamage(), 0, types.length)]; return types[MathHelper.clamp(stack.getItemDamage(), 0, types.length - 1)];
} }
public static class Variant<T extends Enum<T> & ISubItem> extends ItemEnum<T> implements IVariantProvider { public static class Variant<T extends Enum<T> & ISubItem> extends ItemEnum<T> implements IVariantProvider {