Skip to content

Commit

Permalink
Move potion effect to onItemUseFinish()
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan19 committed Dec 2, 2019
1 parent c00fcfd commit f5ff304
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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);
}
}

0 comments on commit f5ff304

Please sign in to comment.