Creaking inflicts Shattered II

This commit is contained in:
patience 2026-02-11 22:01:39 +00:00
parent 28a8d19511
commit f9279ce127
No known key found for this signature in database

View file

@ -1,24 +1,43 @@
package xyz.nearmisses.patience.mc_rebalance.mixin;
import com.blackgear.vanillabackport.common.level.entities.creaking.Creaking;
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.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.monster.Monster;
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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import xyz.nearmisses.patience.mc_rebalance.ModEffects;
@Mixin(Creaking.class)
public class CreakingRework {
public class CreakingRework extends Monster {
protected CreakingRework(EntityType<? extends Monster> entityType, Level level) {
super(entityType, level);
}
@Inject(method="createAttributes", at=@At("RETURN"), cancellable=true)
private static void createAttributes(CallbackInfoReturnable<AttributeSupplier.Builder> cir) {
cir.setReturnValue( Monster.createMonsterAttributes()
.add(Attributes.MAX_HEALTH, 1.0)
.add(Attributes.MOVEMENT_SPEED, 0.4)
.add(Attributes.MOVEMENT_SPEED, 0.6)
.add(Attributes.ATTACK_DAMAGE, 15.0)
.add(Attributes.FOLLOW_RANGE, 38.0)
.add(Attributes.STEP_HEIGHT, 2.1) // Step over big fences
);
}
@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, 2, false, true, true));
}
cir.setReturnValue(ret);
}
}