Fixed apples being able to have an invalid metadata (may fix rendering issues with Pam's Harvest)

This commit is contained in:
Sollace 2019-01-27 17:34:12 +02:00
parent 23499cc011
commit 5063c6e766

View file

@ -76,7 +76,7 @@ public class ItemApple extends ItemFood {
}
public ItemApple setSubTypes(String... types) {
setHasSubtypes(true);
setHasSubtypes(types.length > 0);
setMaxDamage(0);
subTypes = types;
@ -110,12 +110,28 @@ public class ItemApple extends ItemFood {
}
}
@Override
public int getDamage(ItemStack stack) {
return super.getDamage(stack);// % subTypes.length;
}
@Override
public int getMetadata(ItemStack stack) {
if (getHasSubtypes()) {
return super.getMetadata(stack) % subTypes.length;
}
return super.getMetadata(stack);
}
@Override
public String getTranslationKey(ItemStack stack) {
if (subTypes.length > 0) {
if (getHasSubtypes()) {
int meta = Math.max(0, stack.getMetadata() % subTypes.length);
return super.getTranslationKey(stack) + (meta > 0 ? "." + subTypes[meta] : "");
if (meta > 0) {
return super.getTranslationKey(stack) + "." + subTypes[meta];
}
}
return super.getTranslationKey(stack);