diff --git a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java index 00ac9d3e9..dc21eefae 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java @@ -31,6 +31,7 @@ import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageType; import net.minecraft.world.damagesource.DamageTypes; +import net.minecraft.world.effect.MobEffectCategory; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; @@ -645,7 +646,13 @@ public class LivingEventHandler { @SubscribeEvent public static void onEffectApply(MobEffectEvent.Applicable event) { - if (event.getEntity().getVehicle() instanceof ArmedVehicleEntity vehicle && vehicle.hidePassenger(event.getEntity())) { + var effectInstance = event.getEffectInstance(); + if (effectInstance == null) return; + + if (effectInstance.getEffect().value().getCategory() == MobEffectCategory.HARMFUL + && event.getEntity().getVehicle() instanceof ArmedVehicleEntity vehicle + && vehicle.hidePassenger(event.getEntity()) + ) { event.setResult(MobEffectEvent.Applicable.Result.DO_NOT_APPLY); } }