Aquaculture 2

Aquaculture 2

96M Downloads

Neptunium leggings affect the player in spectator mode & onArmorTick is deprecated

meemkoo opened this issue ยท 0 comments

commented

EDIT: Forget the second point its been a long day and it was only after I made the issue that I decided to check the most recent version for the onArmorTick thing. My bad lol.

I wrote some (Admittedly bad) code in NeptuniumArmor.java demonstrating a solution. I didn't want to make a PR because I was not sure how the branches are set up.

I'm also not sure how the leggings were intended to affect you underwater. In another issue you said that they are supposed to make you not sink, however the old "player.setDeltaMovement(Vec3.ZERO);" affect the players XZ motion as well. If this is intended then no worries. :)

@Override
public void inventoryTick(ItemStack p_41404_, Level p_41405_, Entity p_41406_, int p_41407_, boolean p_41408_) {
    if (p_41406_.getType() != EntityType.PLAYER) return;

    Player player = ((Player) p_41406_);

    if (player.isEyeInFluidType(ForgeMod.WATER_TYPE.get())) {
        if (this.type == Type.HELMET) {
            player.addEffect(new MobEffectInstance(MobEffects.NIGHT_VISION, 20, 0, false, false, false));
        } else if (this.type == Type.CHESTPLATE) {
            player.addEffect(new MobEffectInstance(MobEffects.WATER_BREATHING, 20, 0, false, false, false));
        } else if (this.type == Type.LEGGINGS) {
            player.setNoGravity(!player.isCrouching() && !player.jumping && !player.isSwimming() && !player.isSpectator());
        }
    }
}