Wither skeletons got hands

This commit is contained in:
patience 2026-02-08 14:39:33 +00:00
parent 05df5ca4b2
commit b26b44625c
No known key found for this signature in database
2 changed files with 59 additions and 1 deletions

View file

@ -0,0 +1,57 @@
package xyz.nearmisses.patience.mc_rebalance.mixin;
import net.minecraft.core.Holder;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.AbstractSkeleton;
import net.minecraft.world.entity.monster.WitherSkeleton;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
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.Redirect;
import java.util.Map;
@Mixin(WitherSkeleton.class)
public abstract class WitherSkeletonRework extends AbstractSkeleton {
protected WitherSkeletonRework(EntityType<? extends AbstractSkeleton> entityType, Level level) {
super(entityType, level);
}
@Redirect(method = "doHurtTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;addEffect(Lnet/minecraft/world/effect/MobEffectInstance;Lnet/minecraft/world/entity/Entity;)Z"))
public boolean doHurtTarget(LivingEntity instance, MobEffectInstance mobEffectInstance, Entity entity) {
Map<Holder<MobEffect>, MobEffectInstance> effectsMap = instance.getActiveEffectsMap();
if (effectsMap.containsKey(MobEffects.WITHER)) {
int amp = effectsMap.get(MobEffects.WITHER).getAmplifier();
if (this.getMainHandItem().is(Items.STONE_SWORD)) {
instance.addEffect(new MobEffectInstance(MobEffects.WITHER, 180, amp+1), this);
if(amp+1>2){
this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.STONE_HOE));
}
} else { // If on hoe, collapse wither effect
int duration = effectsMap.get(MobEffects.WITHER).getDuration();
int dmgCount = 0;
int durationToDmg = 40 >> amp;
while(duration>0){ // There is definitely a better way to do this, I'll come back to it later
if(durationToDmg == 0 || duration % durationToDmg == 0) {dmgCount++;}
duration--;
}
instance.removeEffect(MobEffects.WITHER);
instance.hurt(instance.damageSources().wither(), dmgCount);
this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.STONE_SWORD));
}
} else { // If enemy doesn't have wither, apply it
instance.addEffect(new MobEffectInstance(MobEffects.WITHER, 180), this);
}
return true;
}
}

View file

@ -3,7 +3,8 @@
"package": "xyz.nearmisses.patience.mc_rebalance.mixin", "package": "xyz.nearmisses.patience.mc_rebalance.mixin",
"compatibilityLevel": "JAVA_21", "compatibilityLevel": "JAVA_21",
"mixins": [ "mixins": [
"ExperienceOrbRework" "ExperienceOrbRework",
"WitherSkeletonRework"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1