From 6a417631f303fc1bc22dc90fa024626e1f5689c3 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:09:47 -0800 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. --- ...stomizable-wither-health-and-healing.patch | 46 ------------------- .../features/0001-Ridables.patch | 6 +-- .../entity/boss/wither/WitherBoss.java.patch | 15 ++++++ .../purpurmc/purpur/PurpurWorldConfig.java | 4 ++ 4 files changed, 22 insertions(+), 49 deletions(-) delete mode 100644 patches/server/0085-Customizable-wither-health-and-healing.patch create mode 100644 purpur-server/minecraft-patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch diff --git a/patches/server/0085-Customizable-wither-health-and-healing.patch b/patches/server/0085-Customizable-wither-health-and-healing.patch deleted file mode 100644 index f4325a5a2..000000000 --- a/patches/server/0085-Customizable-wither-health-and-healing.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jason Penilla <11360596+jpenilla@users.noreply.github.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/net/minecraft/world/entity/boss/wither/WitherBoss.java b/net/minecraft/world/entity/boss/wither/WitherBoss.java -index 57cf253fc69c087cfa0270225166f926ce6829f7..098ef0d6879e88009193c6dcedf1aa285980cbc6 100644 ---- a/net/minecraft/world/entity/boss/wither/WitherBoss.java -+++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -518,8 +518,10 @@ public class WitherBoss extends Monster implements RangedAttackMob { - } - } - -- if (this.tickCount % 20 == 0) { -- this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit -+ // Purpur start - customizable heal rate and amount -+ if (this.tickCount % level().purpurConfig.witherHealthRegenDelay == 0) { -+ this.heal(level().purpurConfig.witherHealthRegenAmount, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit -+ // Purpur end - } - - this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth()); -diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index a28548332baf610521a308a560a858b3fc737b60..e323914f8694043e7b08a2518169695f582bc1a8 100644 ---- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -1876,6 +1876,8 @@ public class PurpurWorldConfig { - public double witherMaxY = 320D; - public double witherMaxHealth = 300.0D; - public double witherScale = 1.0D; -+ public float witherHealthRegenAmount = 1.0f; -+ public int witherHealthRegenDelay = 20; - private void witherSettings() { - witherRidable = getBoolean("mobs.wither.ridable", witherRidable); - witherRidableInWater = getBoolean("mobs.wither.ridable-in-water", witherRidableInWater); -@@ -1892,6 +1894,8 @@ public class PurpurWorldConfig { - } - witherMaxHealth = getDouble("mobs.wither.attributes.max_health", witherMaxHealth); - witherScale = Mth.clamp(getDouble("mobs.wither.attributes.scale", witherScale), 0.0625D, 16.0D); -+ witherHealthRegenAmount = (float) getDouble("mobs.wither.health-regen-amount", witherHealthRegenAmount); -+ witherHealthRegenDelay = getInt("mobs.wither.health-regen-delay", witherHealthRegenDelay); - } - - public boolean witherSkeletonRidable = false; diff --git a/purpur-server/minecraft-patches/features/0001-Ridables.patch b/purpur-server/minecraft-patches/features/0001-Ridables.patch index 9c6f3ed23..779675508 100644 --- a/purpur-server/minecraft-patches/features/0001-Ridables.patch +++ b/purpur-server/minecraft-patches/features/0001-Ridables.patch @@ -75,7 +75,7 @@ index db9860c44faacdf4b24979c2ffa84515e3883299..1fc37692c7ddfc7b7e0961cd9f060233 if ((target instanceof Bucketable && target instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) { target.resendPossiblyDesyncedEntityData(ServerGamePacketListenerImpl.this.player); // Paper - The entire mob gets deleted, so resend it diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index d7ebfa3a9951922780e079b9767ce8854c555dd1..7cea12d1c0e28f5d08963009c9c37f324a52d4fe 100644 +index f7e17ca9f5011503827f7141d62e556c1cc72fcf..25adb04858ad55dc80a2967e49b3dc0dafe44307 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -3136,6 +3136,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -2795,7 +2795,7 @@ index ef3571155ee5757f6eaab67df0fe530408770071..ca9cca5b1eb8549e99d7a594cb969455 this.dragonFight.updateDragon(this); } diff --git a/net/minecraft/world/entity/boss/wither/WitherBoss.java b/net/minecraft/world/entity/boss/wither/WitherBoss.java -index afe43600c4976e01e61d716034a2823d50fb55cb..452fb5473094b713ac456202c3f2f390f8fb7f27 100644 +index 3262531c4164dc4420c4a8dff0502cece1a438a5..a38212ad075623b2fa0c37d991aaaf9e1b2bab75 100644 --- a/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java @@ -69,6 +69,7 @@ public class WitherBoss extends Monster implements RangedAttackMob { @@ -2961,7 +2961,7 @@ index afe43600c4976e01e61d716034a2823d50fb55cb..452fb5473094b713ac456202c3f2f390 if (this.getInvulnerableTicks() > 0) { int i = this.getInvulnerableTicks() - 1; this.bossEvent.setProgress(1.0F - i / 220.0F); -@@ -561,11 +686,11 @@ public class WitherBoss extends Monster implements RangedAttackMob { +@@ -563,11 +688,11 @@ public class WitherBoss extends Monster implements RangedAttackMob { } public int getAlternativeTarget(int head) { diff --git a/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch new file mode 100644 index 000000000..06b6df21f --- /dev/null +++ b/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/entity/boss/wither/WitherBoss.java ++++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java +@@ -376,8 +_,10 @@ + } + } + +- if (this.tickCount % 20 == 0) { +- this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit ++ // Purpur start - Customizable wither health and healing ++ if (this.tickCount % level().purpurConfig.witherHealthRegenDelay == 0) { ++ this.heal(level().purpurConfig.witherHealthRegenAmount, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit ++ // Purpur end - Customizable wither health and healing + } + + this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth()); diff --git a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index 2ca28b56c..e8eab4631 100644 --- a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -1865,6 +1865,8 @@ public class PurpurWorldConfig { public double witherMaxY = 320D; public double witherMaxHealth = 300.0D; public double witherScale = 1.0D; + public float witherHealthRegenAmount = 1.0f; + public int witherHealthRegenDelay = 20; private void witherSettings() { witherRidable = getBoolean("mobs.wither.ridable", witherRidable); witherRidableInWater = getBoolean("mobs.wither.ridable-in-water", witherRidableInWater); @@ -1881,6 +1883,8 @@ public class PurpurWorldConfig { } witherMaxHealth = getDouble("mobs.wither.attributes.max_health", witherMaxHealth); witherScale = Mth.clamp(getDouble("mobs.wither.attributes.scale", witherScale), 0.0625D, 16.0D); + witherHealthRegenAmount = (float) getDouble("mobs.wither.health-regen-amount", witherHealthRegenAmount); + witherHealthRegenDelay = getInt("mobs.wither.health-regen-delay", witherHealthRegenDelay); } public boolean witherSkeletonRidable = false;