调整载具免疫buff机制
This commit is contained in:
parent
6b568fb006
commit
0198540927
1 changed files with 8 additions and 1 deletions
|
@ -31,6 +31,7 @@ import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.damagesource.DamageType;
|
import net.minecraft.world.damagesource.DamageType;
|
||||||
import net.minecraft.world.damagesource.DamageTypes;
|
import net.minecraft.world.damagesource.DamageTypes;
|
||||||
|
import net.minecraft.world.effect.MobEffectCategory;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
@ -645,7 +646,13 @@ public class LivingEventHandler {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onEffectApply(MobEffectEvent.Applicable event) {
|
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);
|
event.setResult(MobEffectEvent.Applicable.Result.DO_NOT_APPLY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue