From ad327c683148b6479ddadde17d9882c7a350599b Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 31 Jan 2019 15:58:24 +0200 Subject: [PATCH] Added toxicity indicators to more food items --- .../unicopia/edibles/UItemFoodDelegate.java | 9 +++++++++ .../unicopia/item/ItemApple.java | 20 +++++++++++++++---- .../unicopia/item/ItemZapApple.java | 7 +++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/edibles/UItemFoodDelegate.java b/src/main/java/com/minelittlepony/unicopia/edibles/UItemFoodDelegate.java index 5797042a..6b3d3914 100644 --- a/src/main/java/com/minelittlepony/unicopia/edibles/UItemFoodDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/edibles/UItemFoodDelegate.java @@ -1,8 +1,12 @@ package com.minelittlepony.unicopia.edibles; +import java.util.List; + import javax.annotation.Nonnull; +import javax.annotation.Nullable; import net.minecraft.block.Block; +import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; @@ -27,6 +31,11 @@ public class UItemFoodDelegate extends ItemMultiTexture implements IEdible { return this; } + @Override + public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { + foodItem.addInformation(stack, worldIn, tooltip, flagIn); + } + @Override public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) { return foodItem.onItemUseFinish(stack, worldIn, entityLiving); diff --git a/src/main/java/com/minelittlepony/unicopia/item/ItemApple.java b/src/main/java/com/minelittlepony/unicopia/item/ItemApple.java index e5f95015..0f5e102a 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ItemApple.java +++ b/src/main/java/com/minelittlepony/unicopia/item/ItemApple.java @@ -1,17 +1,24 @@ package com.minelittlepony.unicopia.item; +import java.util.List; import java.util.Random; +import javax.annotation.Nullable; + import com.minelittlepony.unicopia.UItems; +import com.minelittlepony.unicopia.edibles.IEdible; +import com.minelittlepony.unicopia.edibles.Toxicity; import com.minelittlepony.unicopia.forgebullshit.IMultiItem; import net.minecraft.block.BlockPlanks; +import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; +import net.minecraft.world.World; -public class ItemApple extends ItemFood implements IMultiItem { +public class ItemApple extends ItemFood implements IMultiItem, IEdible { private int[] typeRarities = new int[0]; @@ -115,9 +122,9 @@ public class ItemApple extends ItemFood implements IMultiItem { } } - @Override - public int getDamage(ItemStack stack) { - return super.getDamage(stack);// % subTypes.length; + @Override + public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { + tooltip.add(getToxicityLevel(stack).getTooltip()); } @Override @@ -141,4 +148,9 @@ public class ItemApple extends ItemFood implements IMultiItem { return super.getTranslationKey(stack); } + + @Override + public Toxicity getToxicityLevel(ItemStack stack) { + return Toxicity.SAFE; + } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/ItemZapApple.java b/src/main/java/com/minelittlepony/unicopia/item/ItemZapApple.java index 15645c2e..c6f6fe65 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ItemZapApple.java +++ b/src/main/java/com/minelittlepony/unicopia/item/ItemZapApple.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.item; + +import com.minelittlepony.unicopia.edibles.Toxicity; import com.minelittlepony.util.MagicalDamageSource; import com.minelittlepony.util.vector.VecHelper; @@ -73,6 +75,11 @@ public class ItemZapApple extends ItemApple { } } + @Override + public Toxicity getToxicityLevel(ItemStack stack) { + return stack.getMetadata() == 0 ? Toxicity.SEVERE : Toxicity.SAFE; + } + @Override public EnumRarity getRarity(ItemStack stack) { int meta = stack.getMetadata();