Touch up wither health patch

This commit is contained in:
William Blake Galbreath
2020-08-20 21:34:11 -05:00
parent e0c5a02e03
commit c26df78337

View File

@@ -6,22 +6,27 @@ Subject: [PATCH] Customizable WitherBoss Health and Healing
Adds the ability to customize the health of the Wither Boss, as well as the amount that it heals, and how often in the PurpurWorldConfig.
diff --git a/src/main/java/net/minecraft/server/EntityWither.java b/src/main/java/net/minecraft/server/EntityWither.java
index 1511212cbf..78a5449d1c 100644
index 1511212cbf..81b3b9fbc5 100644
--- a/src/main/java/net/minecraft/server/EntityWither.java
+++ b/src/main/java/net/minecraft/server/EntityWither.java
@@ -36,6 +36,11 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
public EntityWither(EntityTypes<? extends EntityWither> entitytypes, World world) {
super(entitytypes, world);
this.bossBattle = (BossBattleServer) (new BossBattleServer(this.getScoreboardDisplayName(), BossBattle.BarColor.PURPLE, BossBattle.BarStyle.PROGRESS)).setDarkenSky(true);
+ // Purpur start
+ if (world != null) {
+ this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(world.purpurConfig.witherBossMaxHealth);
+ }
+ // Purpur end
this.setHealth(this.getMaxHealth());
this.getNavigation().d(true);
@@ -41,6 +41,16 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
this.f = 50;
@@ -230,7 +235,7 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
}
+ // Purpur start
+ @Override
+ public void initAttributes(World world) {
+ if (world != null) {
+ this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(world.purpurConfig.witherMaxHealth);
+ setHealth(getMaxHealth());
+ }
+ }
+ // Purpur end
+
@Override
protected void initPathfinder() {
this.goalSelector.a(0, new EntityWither.a());
@@ -230,7 +240,7 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
this.setInvul(i);
if (this.ticksLived % 10 == 0) {
@@ -30,37 +35,37 @@ index 1511212cbf..78a5449d1c 100644
}
} else {
@@ -339,9 +344,11 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
@@ -339,9 +349,11 @@ 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.witherBossHealthRegenDelay == 0) {
+ this.heal(world.purpurConfig.witherBossHealthRegenAmount, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
+ 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());
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index d19c6d13cf..aaf1735e66 100644
index d19c6d13cf..2b05ae68bc 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -887,6 +887,15 @@ public class PurpurWorldConfig {
witherSkeletonTakesWitherDamage = getBoolean("mobs.wither_skeleton.takes-wither-damage", witherSkeletonTakesWitherDamage);
@@ -878,6 +878,15 @@ public class PurpurWorldConfig {
witchRidableInWater = getBoolean("mobs.witch.ridable-in-water", witchRidableInWater);
}
+ public double witherBossMaxHealth = 300.0D;
+ public float witherBossHealthRegenAmount = 1.0f;
+ public int witherBossHealthRegenDelay = 20;
+ public double witherMaxHealth = 300.0D;
+ public float witherHealthRegenAmount = 1.0f;
+ public int witherHealthRegenDelay = 20;
+ private void witherSettings() {
+ witherBossMaxHealth = getDouble("mobs.wither_boss.max-health", witherBossMaxHealth);
+ witherBossHealthRegenAmount = (float) getDouble("mobs.wither_boss.health-regen-amount", witherBossHealthRegenAmount);
+ witherBossHealthRegenDelay = getInt("mobs.wither_boss.health-regen-delay", witherBossHealthRegenDelay);
+ witherMaxHealth = getDouble("mobs.wither.max-health", witherMaxHealth);
+ witherHealthRegenAmount = (float) getDouble("mobs.wither.health-regen-amount", witherHealthRegenAmount);
+ witherHealthRegenDelay = getInt("mobs.wither.health-regen-delay", witherHealthRegenDelay);
+ }
+
public boolean wolfRidable = false;
public boolean wolfRidableInWater = false;
private void wolfSettings() {
public boolean witherSkeletonRidable = false;
public boolean witherSkeletonRidableInWater = false;
public boolean witherSkeletonTakesWitherDamage = false;