diff --git a/src/main/java/com/minelittlepony/unicopia/item/UItems.java b/src/main/java/com/minelittlepony/unicopia/item/UItems.java index 22db6390..e4191ff9 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/item/UItems.java @@ -6,8 +6,6 @@ import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.entity.UEntities; import com.minelittlepony.unicopia.magic.spell.ScorchSpell; -import com.minelittlepony.unicopia.toxin.DynamicToxicBlockItem; -import com.minelittlepony.unicopia.toxin.DynamicToxicItem; import com.minelittlepony.unicopia.toxin.ToxicBlockItem; import com.minelittlepony.unicopia.toxin.ToxicItem; import com.minelittlepony.unicopia.toxin.Toxicity; @@ -138,16 +136,16 @@ public interface UItems { Item APPLE_SEEDS = register(new BlockItem(UBlocks.APPLE_SAPLING, new Item.Settings().group(ItemGroup.DECORATIONS)), "apple_seeds"); Item APPLE_LEAVES = register(new BlockItem(UBlocks.APPLE_LEAVES, new Item.Settings().group(ItemGroup.DECORATIONS)), "apple_leaves"); - Item DAFFODIL_DAISY_SANDWICH = register(new DynamicToxicItem(new Item.Settings(), 3, 2, UseAction.EAT, Toxicity::fromStack), "daffodil_daisy_sandwich"); - Item HAY_BURGER = register(new DynamicToxicItem(new Item.Settings(), 3, 4, UseAction.EAT, Toxicity::fromStack), "hay_burger"); - Item HAY_FRIES = register(new ToxicItem(new Item.Settings(), 1, 5, UseAction.EAT, Toxicity.SAFE), "hay_fries"); - Item SALAD = register(new DynamicToxicItem(new Item.Settings().recipeRemainder(Items.BOWL), 4, 2, UseAction.EAT, Toxicity::fromStack), "salad"); + Item DAFFODIL_DAISY_SANDWICH = register(new ToxicItem(new Item.Settings(), 3, 2, UseAction.EAT, Toxicity::fromStack, Toxin.FOOD), "daffodil_daisy_sandwich"); + Item HAY_BURGER = register(new ToxicItem(new Item.Settings(), 3, 4, UseAction.EAT, Toxicity::fromStack, Toxin.FOOD), "hay_burger"); + Item HAY_FRIES = register(new ToxicItem(new Item.Settings(), 1, 5, UseAction.EAT, Toxicity.SAFE, Toxin.FOOD), "hay_fries"); + Item SALAD = register(new ToxicItem(new Item.Settings().recipeRemainder(Items.BOWL), 4, 2, UseAction.EAT, Toxicity::fromStack, Toxin.FOOD), "salad"); - Item WHEAT_WORMS = register(new ToxicItem(new Item.Settings(), 1, 0, UseAction.EAT, Toxicity.SEVERE), "wheat_worms"); + Item WHEAT_WORMS = register(new ToxicItem(new Item.Settings(), 1, 0, UseAction.EAT, Toxicity.SEVERE, Toxin.FOOD), "wheat_worms"); Item MUG = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "mug"); - Item CIDER = register(new ToxicItem(new Item.Settings().recipeRemainder(MUG), 4, 2, UseAction.DRINK, Toxicity.MILD), "apple_cider"); - Item JUICE = register(new ToxicItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE), 2, 2, UseAction.DRINK, Toxicity.SAFE), "juice"); - Item BURNED_JUICE = register(new ToxicItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE), 3, 1, UseAction.DRINK, Toxicity.FAIR), "burned_juice"); + Item CIDER = register(new ToxicItem(new Item.Settings().recipeRemainder(MUG), 4, 2, UseAction.DRINK, Toxicity.MILD, Toxin.FOOD), "apple_cider"); + Item JUICE = register(new ToxicItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE), 2, 2, UseAction.DRINK, Toxicity.SAFE, Toxin.FOOD), "juice"); + Item BURNED_JUICE = register(new ToxicItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE), 3, 1, UseAction.DRINK, Toxicity.FAIR, Toxin.FOOD), "burned_juice"); Item CLOUD_SPAWN_EGG = register(new SpawnEggItem(UEntities.CLOUD, 0x4169e1, 0x7fff00, new Item.Settings().group(ItemGroup.MISC)), "cloud_spawn_egg"); Item BUTTERFLY_SPAWN_EGG = register(new SpawnEggItem(UEntities.BUTTERFLY, 0x222200, 0xaaeeff, new Item.Settings().group(ItemGroup.MISC)), "butterfly_spawn_egg"); @@ -176,26 +174,26 @@ public interface UItems { AppleItem APPLE = register(new AppleItem(FoodComponents.APPLE), Items.APPLE); - Item GRASS = register(new DynamicToxicBlockItem(Blocks.GRASS, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.NAUSEA), Items.GRASS); - Item FERN = register(new DynamicToxicBlockItem(Blocks.FERN, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.STRENGTH), Items.FERN); - Item DEAD_BUSH = register(new DynamicToxicBlockItem(Blocks.DEAD_BUSH, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.NAUSEA), Items.DEAD_BUSH); + Item GRASS = register(new ToxicBlockItem(Blocks.GRASS, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.FOOD.and(Toxin.NAUSEA)), Items.GRASS); + Item FERN = register(new ToxicBlockItem(Blocks.FERN, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.FOOD.and(Toxin.STRENGTH)), Items.FERN); + Item DEAD_BUSH = register(new ToxicBlockItem(Blocks.DEAD_BUSH, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.FOOD.and(Toxin.NAUSEA)), Items.DEAD_BUSH); - Item DANDELION = register(new ToxicBlockItem(Blocks.DANDELION, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.DANDELION); - Item POPPY = register(new ToxicBlockItem(Blocks.POPPY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE), Items.POPPY); - Item BLUE_ORCHID = register(new ToxicBlockItem(Blocks.BLUE_ORCHID, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.BLUE_ORCHID); - Item ALLIUM = register(new ToxicBlockItem(Blocks.ALLIUM, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.FAIR), Items.ALLIUM); - Item AZUER_BLUET = register(new DynamicToxicBlockItem(Blocks.AZURE_BLUET, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.RADIOACTIVITY), Items.AZURE_BLUET); - Item RED_TULIP = register(new ToxicBlockItem(Blocks.RED_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.RED_TULIP); - Item ORANGE_TULIP = register(new ToxicBlockItem(Blocks.ORANGE_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.ORANGE_TULIP); - Item WHITE_TULIP = register(new ToxicBlockItem(Blocks.WHITE_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.FAIR), Items.WHITE_TULIP); - Item PINK_TULIP = register(new ToxicBlockItem(Blocks.PINK_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.PINK_TULIP); - Item OXEYE_DAISY = register(new DynamicToxicBlockItem(Blocks.OXEYE_DAISY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.BLINDNESS), Items.OXEYE_DAISY); - Item CORNFLOWER = register(new ToxicBlockItem(Blocks.CORNFLOWER, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.CORNFLOWER); + Item DANDELION = register(new ToxicBlockItem(Blocks.DANDELION, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.FOOD), Items.DANDELION); + Item POPPY = register(new ToxicBlockItem(Blocks.POPPY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.FOOD), Items.POPPY); + Item BLUE_ORCHID = register(new ToxicBlockItem(Blocks.BLUE_ORCHID, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.FOOD), Items.BLUE_ORCHID); + Item ALLIUM = register(new ToxicBlockItem(Blocks.ALLIUM, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.FAIR, Toxin.FOOD), Items.ALLIUM); + Item AZUER_BLUET = register(new ToxicBlockItem(Blocks.AZURE_BLUET, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.FOOD.and(Toxin.RADIOACTIVITY)), Items.AZURE_BLUET); + Item RED_TULIP = register(new ToxicBlockItem(Blocks.RED_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.FOOD), Items.RED_TULIP); + Item ORANGE_TULIP = register(new ToxicBlockItem(Blocks.ORANGE_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.FOOD), Items.ORANGE_TULIP); + Item WHITE_TULIP = register(new ToxicBlockItem(Blocks.WHITE_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.FAIR, Toxin.FOOD), Items.WHITE_TULIP); + Item PINK_TULIP = register(new ToxicBlockItem(Blocks.PINK_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.FOOD), Items.PINK_TULIP); + Item OXEYE_DAISY = register(new ToxicBlockItem(Blocks.OXEYE_DAISY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.FOOD.and(Toxin.BLINDNESS)), Items.OXEYE_DAISY); + Item CORNFLOWER = register(new ToxicBlockItem(Blocks.CORNFLOWER, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.FOOD), Items.CORNFLOWER); - Item ROSE_BUSH = register(new DynamicToxicBlockItem(Blocks.ROSE_BUSH, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.DAMAGE), Items.ROSE_BUSH); - Item PEONY = register(new ToxicBlockItem(Blocks.PEONY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.PEONY); - Item TALL_GRASS = register(new ToxicBlockItem(Blocks.TALL_GRASS, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.TALL_GRASS); - Item LARGE_FERN = register(new DynamicToxicBlockItem(Blocks.LARGE_FERN, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.DAMAGE), Items.LARGE_FERN); + Item ROSE_BUSH = register(new ToxicBlockItem(Blocks.ROSE_BUSH, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.FOOD.and(Toxin.DAMAGE)), Items.ROSE_BUSH); + Item PEONY = register(new ToxicBlockItem(Blocks.PEONY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.FOOD), Items.PEONY); + Item TALL_GRASS = register(new ToxicBlockItem(Blocks.TALL_GRASS, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.FOOD), Items.TALL_GRASS); + Item LARGE_FERN = register(new ToxicBlockItem(Blocks.LARGE_FERN, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.FOOD.and(Toxin.DAMAGE)), Items.LARGE_FERN); static T register(T newItem, Item oldItem) { return Registry.ITEM.set(Registry.ITEM.getRawId(oldItem), Registry.ITEM.getId(oldItem), newItem); diff --git a/src/main/java/com/minelittlepony/unicopia/toxin/DynamicToxicBlockItem.java b/src/main/java/com/minelittlepony/unicopia/toxin/DynamicToxicBlockItem.java deleted file mode 100644 index a41f6778..00000000 --- a/src/main/java/com/minelittlepony/unicopia/toxin/DynamicToxicBlockItem.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.minelittlepony.unicopia.toxin; - -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.UseAction; - -public class DynamicToxicBlockItem extends ToxicBlockItem { - - private final Toxin toxin; - - public DynamicToxicBlockItem(Block block, Item.Settings settings, int hunger, float saturation, UseAction action, Toxicity toxicity, @Nonnull Toxin toxin) { - super(block, settings, hunger, saturation, action, toxicity); - - this.toxin = toxin; - } - - @Override - public void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack) { - super.addSecondaryEffects(player, toxicity, stack); - toxin.addSecondaryEffects(player, toxicity, stack); - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/toxin/DynamicToxicItem.java b/src/main/java/com/minelittlepony/unicopia/toxin/DynamicToxicItem.java deleted file mode 100644 index 35bad2c5..00000000 --- a/src/main/java/com/minelittlepony/unicopia/toxin/DynamicToxicItem.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.minelittlepony.unicopia.toxin; - -import javax.annotation.Nonnull; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.UseAction; - -public class DynamicToxicItem extends ToxicItem { - - private final Toxic toxic; - - public DynamicToxicItem(Item.Settings settings, int hunger, float saturation, UseAction action, @Nonnull Toxic toxic) { - super(settings, hunger, saturation, action, Toxicity.SAFE); - this.toxic = toxic; - } - - @Override - public void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack) { - super.addSecondaryEffects(player, toxicity, stack); - } - - @Override - public Toxicity getToxicity(ItemStack stack) { - return toxic.getToxicity(stack); - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/toxin/ToxicBlockItem.java b/src/main/java/com/minelittlepony/unicopia/toxin/ToxicBlockItem.java index 0383de27..6867bb22 100644 --- a/src/main/java/com/minelittlepony/unicopia/toxin/ToxicBlockItem.java +++ b/src/main/java/com/minelittlepony/unicopia/toxin/ToxicBlockItem.java @@ -6,13 +6,9 @@ import javax.annotation.Nullable; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.entity.player.Pony; -import com.minelittlepony.unicopia.item.UEffects; - import net.minecraft.block.Block; import net.minecraft.client.item.TooltipContext; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItem; import net.minecraft.item.FoodComponent; @@ -26,12 +22,13 @@ import net.minecraft.util.TypedActionResult; import net.minecraft.util.UseAction; import net.minecraft.world.World; -public class ToxicBlockItem extends BlockItem implements Toxic, Toxin { +public class ToxicBlockItem extends BlockItem { private final UseAction action; private final Toxicity toxicity; + private final Toxin toxin; - public ToxicBlockItem(Block block, Item.Settings settings, int hunger, float saturation, UseAction action, Toxicity toxicity) { + public ToxicBlockItem(Block block, Item.Settings settings, int hunger, float saturation, UseAction action, Toxicity toxicity, Toxin toxin) { super(block, settings .group(ItemGroup.FOOD) .food(new FoodComponent.Builder() @@ -40,11 +37,7 @@ public class ToxicBlockItem extends BlockItem implements Toxic, Toxin { .build())); this.toxicity = toxicity; this.action = action; - } - - @Override - public Toxicity getToxicity(ItemStack stack) { - return toxicity; + this.toxin = toxin; } @Override @@ -54,7 +47,7 @@ public class ToxicBlockItem extends BlockItem implements Toxic, Toxin { @Override public void appendTooltip(ItemStack stack, @Nullable World world, List tooltip, TooltipContext context) { - tooltip.add(getToxicity(stack).getTooltip()); + tooltip.add(toxicity.getTooltip()); } @Override @@ -63,9 +56,9 @@ public class ToxicBlockItem extends BlockItem implements Toxic, Toxin { if (entity instanceof PlayerEntity) { Race race = Pony.of((PlayerEntity)entity).getSpecies(); - Toxicity toxicity = (race.isDefault() || race == Race.CHANGELING) ? Toxicity.LETHAL : getToxicity(stack); + Toxicity toxicity = (race.isDefault() || race == Race.CHANGELING) ? Toxicity.LETHAL : this.toxicity; - addSecondaryEffects((PlayerEntity)entity, toxicity, stack); + toxin.addSecondaryEffects((PlayerEntity)entity, toxicity, stack); } return new ItemStack(getRecipeRemainder()); @@ -81,18 +74,4 @@ public class ToxicBlockItem extends BlockItem implements Toxic, Toxin { return super.use(world, player, hand); } - - @Override - public void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack) { - - if (toxicity.toxicWhenRaw()) { - player.addStatusEffect(toxicity.getPoisonEffect()); - } - - if (toxicity.isLethal()) { - player.addStatusEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 300, 7, false, false)); - } else if (toxicity.toxicWhenCooked()) { - player.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 3, 1, false, false)); - } - } } diff --git a/src/main/java/com/minelittlepony/unicopia/toxin/ToxicItem.java b/src/main/java/com/minelittlepony/unicopia/toxin/ToxicItem.java index 038872f9..ea6e27c6 100644 --- a/src/main/java/com/minelittlepony/unicopia/toxin/ToxicItem.java +++ b/src/main/java/com/minelittlepony/unicopia/toxin/ToxicItem.java @@ -1,17 +1,14 @@ package com.minelittlepony.unicopia.toxin; import java.util.List; +import java.util.function.Function; import javax.annotation.Nullable; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.entity.player.Pony; -import com.minelittlepony.unicopia.item.UEffects; - import net.minecraft.client.item.TooltipContext; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.FoodComponent; import net.minecraft.item.Item; @@ -24,12 +21,17 @@ import net.minecraft.util.TypedActionResult; import net.minecraft.util.UseAction; import net.minecraft.world.World; -public class ToxicItem extends Item implements Toxic, Toxin { +public class ToxicItem extends Item { private final UseAction action; - private final Toxicity toxicity; + private final Function toxicity; + private final Toxin toxin; - public ToxicItem(Item.Settings settings, int hunger, float saturation, UseAction action, Toxicity toxicity) { + public ToxicItem(Item.Settings settings, int hunger, float saturation, UseAction action, Toxicity toxicity, Toxin toxin) { + this(settings, hunger, saturation, action, stack -> toxicity, toxin); + } + + public ToxicItem(Item.Settings settings, int hunger, float saturation, UseAction action, Function toxicity, Toxin toxin) { super(settings .group(ItemGroup.FOOD) .food(new FoodComponent.Builder() @@ -38,11 +40,7 @@ public class ToxicItem extends Item implements Toxic, Toxin { .build())); this.toxicity = toxicity; this.action = action; - } - - @Override - public Toxicity getToxicity(ItemStack stack) { - return toxicity; + this.toxin = toxin; } @Override @@ -52,7 +50,7 @@ public class ToxicItem extends Item implements Toxic, Toxin { @Override public void appendTooltip(ItemStack stack, @Nullable World world, List tooltip, TooltipContext context) { - tooltip.add(getToxicity(stack).getTooltip()); + tooltip.add(toxicity.apply(stack).getTooltip()); } @Override @@ -61,9 +59,9 @@ public class ToxicItem extends Item implements Toxic, Toxin { if (entity instanceof PlayerEntity) { Race race = Pony.of((PlayerEntity)entity).getSpecies(); - Toxicity toxicity = (race.isDefault() || race == Race.CHANGELING) ? Toxicity.LETHAL : getToxicity(stack); + Toxicity toxicity = (race.isDefault() || race == Race.CHANGELING) ? Toxicity.LETHAL : this.toxicity.apply(stack); - addSecondaryEffects((PlayerEntity)entity, toxicity, stack); + toxin.addSecondaryEffects((PlayerEntity)entity, toxicity, stack); } return new ItemStack(getRecipeRemainder()); @@ -79,18 +77,4 @@ public class ToxicItem extends Item implements Toxic, Toxin { return super.use(world, player, hand); } - - @Override - public void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack) { - - if (toxicity.toxicWhenRaw()) { - player.addStatusEffect(toxicity.getPoisonEffect()); - } - - if (toxicity.isLethal()) { - player.addStatusEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 300, 7, false, false)); - } else if (toxicity.toxicWhenCooked()) { - player.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 3, 1, false, false)); - } - } } diff --git a/src/main/java/com/minelittlepony/unicopia/toxin/Toxin.java b/src/main/java/com/minelittlepony/unicopia/toxin/Toxin.java index 29ef8730..c3c07618 100644 --- a/src/main/java/com/minelittlepony/unicopia/toxin/Toxin.java +++ b/src/main/java/com/minelittlepony/unicopia/toxin/Toxin.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.toxin; +import com.minelittlepony.unicopia.item.UEffects; + import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; @@ -26,6 +28,24 @@ public interface Toxin { Toxin BLINDNESS = (player, toxicity, stack) -> { player.addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 30, 1, false, false)); }; + Toxin FOOD = (player, toxicity, stack) -> { + if (toxicity.toxicWhenRaw()) { + player.addStatusEffect(toxicity.getPoisonEffect()); + } + + if (toxicity.isLethal()) { + player.addStatusEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 300, 7, false, false)); + } else if (toxicity.toxicWhenCooked()) { + player.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 3, 1, false, false)); + } + }; void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack); + + default Toxin and(Toxin other) { + return (player, toxicity, stack) -> { + other.addSecondaryEffects(player, toxicity, stack); + this.addSecondaryEffects(player, toxicity, stack); + }; + } }