调整载具免疫buff机制

This commit is contained in:
17146 2025-06-06 22:15:18 +08:00 committed by Light_Quanta
parent 6b568fb006
commit 0198540927
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959

View file

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