From 5063c6e7669cac10a70d91014e6f01c2aec67917 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 27 Jan 2019 17:34:12 +0200 Subject: [PATCH] Fixed apples being able to have an invalid metadata (may fix rendering issues with Pam's Harvest) --- .../unicopia/item/ItemApple.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/item/ItemApple.java b/src/main/java/com/minelittlepony/unicopia/item/ItemApple.java index 3f668bd1..dbc8d7a8 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ItemApple.java +++ b/src/main/java/com/minelittlepony/unicopia/item/ItemApple.java @@ -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);