Files
Purpur/patches/server/0112-Customizable-wither-health-and-healing.patch
BillyGalbreath 4c7ab7083d Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
1c8b6065e Skip distance map update when spawning is disabled
091e6700f Added PlayerStonecutterRecipeSelectEvent
fc885f966 Add toggle for always placing the dragon egg
b3a6da3a7 Updated Upstream (Bukkit/CraftBukkit)
18ccc062d [Auto] Updated Upstream (Spigot)
e9a87b72b fix BaseTag constructor (#5095)
2021-01-24 05:36:26 -06:00

72 lines
3.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: jmp <jasonpenilla2@me.com>
Date: Thu, 20 Aug 2020 17:38:12 -0700
Subject: [PATCH] Customizable wither health and healing
Adds the ability to customize the health of the wither, as well as the amount that it heals, and how often.
diff --git a/src/main/java/net/minecraft/server/EntityWither.java b/src/main/java/net/minecraft/server/EntityWither.java
index 0442b722e5dc7ccc6e607fb3fa7766496b3398d5..9d67ce93573f85d64e8f0a8bd9434c130fc75b17 100644
--- a/src/main/java/net/minecraft/server/EntityWither.java
+++ b/src/main/java/net/minecraft/server/EntityWither.java
@@ -150,6 +150,11 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
skull.setPositionRaw(headX, headY, headZ);
world.addEntity(skull);
}
+
+ @Override
+ public void initAttributes() {
+ this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(world.purpurConfig.witherMaxHealth);
+ }
// Purpur end
@Override
@@ -353,7 +358,7 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
this.setInvul(i);
if (this.ticksLived % 10 == 0) {
- this.heal(10.0F, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit
+ this.heal(this.getMaxHealth() / 33, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit // Purpur - use max health for healing instead of a constant
}
} else {
@@ -462,8 +467,10 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
}
}
- if (this.ticksLived % 20 == 0) {
- this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
+ // Purpur start - customizable heal rate and amount
+ if (this.ticksLived % world.purpurConfig.witherHealthRegenDelay == 0) {
+ this.heal(world.purpurConfig.witherHealthRegenAmount, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
+ // Purpur end
}
//this.bossBattle.setProgress(this.getHealth() / this.getMaxHealth()); // Paper - Moved down
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 50aa19fc54dab84e587bae45dee00ec984853666..7e237f24f8e5b8777ea035c57f91ff80c688a974 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -907,10 +907,21 @@ public class PurpurWorldConfig {
public boolean witherRidable = false;
public boolean witherRidableInWater = false;
public double witherMaxY = 256D;
+ public float witherHealthRegenAmount = 1.0f;
+ public int witherHealthRegenDelay = 20;
+ public double witherMaxHealth = 300.0D;
private void witherSettings() {
witherRidable = getBoolean("mobs.wither.ridable", witherRidable);
witherRidableInWater = getBoolean("mobs.wither.ridable-in-water", witherRidableInWater);
witherMaxY = getDouble("mobs.wither.ridable-max-y", witherMaxY);
+ witherHealthRegenAmount = (float) getDouble("mobs.wither.health-regen-amount", witherHealthRegenAmount);
+ witherHealthRegenDelay = getInt("mobs.wither.health-regen-delay", witherHealthRegenDelay);
+ if (PurpurConfig.version < 8) {
+ double oldValue = getDouble("mobs.wither.max-health", witherMaxHealth);
+ set("mobs.wither.attributes.max-health", oldValue);
+ set("mobs.wither.max-health", null);
+ }
+ witherMaxHealth = getDouble("mobs.wither.attributes.max-health", witherMaxHealth);
}
public boolean witherSkeletonRidable = false;