From f5ff30445c524fa62bea5db830ae950a9d9d6f28 Mon Sep 17 00:00:00 2001 From: Alan19 Date: Sun, 1 Dec 2019 21:54:52 -0500 Subject: [PATCH] Move potion effect to onItemUseFinish() --- .../com/alan199921/astral/effects/AstralEffects.java | 4 +++- .../alan199921/astral/items/TravellingMedicine.java | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/alan199921/astral/effects/AstralEffects.java b/src/main/java/com/alan199921/astral/effects/AstralEffects.java index 64e41230..3629e44b 100644 --- a/src/main/java/com/alan199921/astral/effects/AstralEffects.java +++ b/src/main/java/com/alan199921/astral/effects/AstralEffects.java @@ -7,6 +7,8 @@ import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.ObjectHolder; +import static com.alan199921.astral.util.InjectionUtil.Null; + @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public class AstralEffects { @@ -15,7 +17,7 @@ public class AstralEffects { on Travelling Medicine would be null */ @ObjectHolder("astral:astral_travel") - public static final Effect astralTravelEffect = new AstralTravelEffect(); + public static final Effect astralTravelEffect = Null(); @SubscribeEvent diff --git a/src/main/java/com/alan199921/astral/items/TravellingMedicine.java b/src/main/java/com/alan199921/astral/items/TravellingMedicine.java index e1d019e0..013ed834 100644 --- a/src/main/java/com/alan199921/astral/items/TravellingMedicine.java +++ b/src/main/java/com/alan199921/astral/items/TravellingMedicine.java @@ -3,9 +3,12 @@ import com.alan199921.astral.Astral; import com.alan199921.astral.configs.AstralConfig; import com.alan199921.astral.effects.AstralEffects; +import net.minecraft.entity.LivingEntity; import net.minecraft.item.Food; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.potion.EffectInstance; +import net.minecraft.world.World; public class TravellingMedicine extends Item { @@ -20,7 +23,12 @@ public TravellingMedicine() { .setAlwaysEdible() .saturation(-2F) .hunger(1) - .effect(new EffectInstance(AstralEffects.astralTravelEffect, AstralConfig.getHerbEffectDurations().getTravellingMedicineDuration(), 1), 1) .build())); } + + @Override + public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) { + entityLiving.addPotionEffect(new EffectInstance(AstralEffects.astralTravelEffect, AstralConfig.getHerbEffectDurations().getTravellingMedicineDuration(), 1)); + return super.onItemUseFinish(stack, worldIn, entityLiving); + } }