Warden applies effect after damage
This commit is contained in:
parent
573d12a564
commit
cc562556a9
|
|
@ -2,8 +2,11 @@ package xyz.nearmisses.patience.mc_rebalance.mixin;
|
|||
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.monster.Monster;
|
||||
import net.minecraft.world.entity.monster.warden.Warden;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
|
@ -12,11 +15,17 @@ import xyz.nearmisses.patience.mc_rebalance.ModEffects;
|
|||
|
||||
// Wardens - something you shouldn't fight - armour is broken on hit
|
||||
@Mixin(Warden.class)
|
||||
public class WardenRework {
|
||||
@Inject(method = "doHurtTarget", at = @At("HEAD"))
|
||||
public class WardenRework extends Monster {
|
||||
protected WardenRework(EntityType<? extends Monster> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
}
|
||||
|
||||
@Inject(method = "doHurtTarget", at = @At("RETURN"), cancellable = true)
|
||||
private void doHurtTarget(Entity entity, CallbackInfoReturnable<Boolean> cir){
|
||||
boolean ret = super.doHurtTarget(entity); // Only apply effect after hit, so the player gets advance warning
|
||||
if(entity instanceof LivingEntity){
|
||||
((LivingEntity) entity).addEffect(new MobEffectInstance(ModEffects.Effect_Shattered, 400, 4, false, true, true));
|
||||
}
|
||||
cir.setReturnValue(ret);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue