Optimised wither collapse calc

This commit is contained in:
patience 2026-02-08 15:03:09 +00:00
parent a12936a827
commit b86e581fc5
No known key found for this signature in database

View file

@ -39,12 +39,10 @@ public abstract class WitherSkeletonRework extends AbstractSkeleton {
} }
} else { // If on hoe, collapse wither effect } else { // If on hoe, collapse wither effect
int duration = effectsMap.get(MobEffects.WITHER).getDuration(); int duration = effectsMap.get(MobEffects.WITHER).getDuration();
int dmgCount = 0; int dmgCount;
int durationToDmg = 40 >> amp; 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){dmgCount=duration;}
if(durationToDmg == 0 || duration % durationToDmg == 0) {dmgCount++;} else{dmgCount = duration / durationToDmg;}
duration--;
}
instance.removeEffect(MobEffects.WITHER); instance.removeEffect(MobEffects.WITHER);
instance.hurt(instance.damageSources().wither(), dmgCount); instance.hurt(instance.damageSources().wither(), dmgCount);
this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.STONE_SWORD)); this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.STONE_SWORD));