From 36fb3e07d7d49252738f7c7cd817fa7db784716f Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Sun, 12 Jan 2025 14:06:18 -0800 Subject: [PATCH] Mob head visibility percent --- .../0220-Mob-head-visibility-percent.patch | 101 ------------------ .../world/entity/LivingEntity.java.patch | 35 ++++-- .../purpurmc/purpur/PurpurWorldConfig.java | 8 ++ 3 files changed, 37 insertions(+), 107 deletions(-) delete mode 100644 patches/server/0220-Mob-head-visibility-percent.patch diff --git a/patches/server/0220-Mob-head-visibility-percent.patch b/patches/server/0220-Mob-head-visibility-percent.patch deleted file mode 100644 index 68598f2e9..000000000 --- a/patches/server/0220-Mob-head-visibility-percent.patch +++ /dev/null @@ -1,101 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: BillyGalbreath -Date: Fri, 31 Dec 2021 06:40:19 -0600 -Subject: [PATCH] Mob head visibility percent - - -diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index c7e2330e7f30081dbf5d79f08c8adb1d7d84fa03..480617d9e59bfbb21cccf2555616ad3985b7f7be 100644 ---- a/net/minecraft/world/entity/LivingEntity.java -+++ b/net/minecraft/world/entity/LivingEntity.java -@@ -1069,9 +1069,20 @@ public abstract class LivingEntity extends Entity implements Attackable { - ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); - EntityType entitytypes = entity.getType(); - -- if (entitytypes == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL) || entitytypes == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD) || entitytypes == EntityType.PIGLIN && itemstack.is(Items.PIGLIN_HEAD) || entitytypes == EntityType.PIGLIN_BRUTE && itemstack.is(Items.PIGLIN_HEAD) || entitytypes == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD)) { -- d0 *= 0.5D; -+ // Purpur start -+ if (entitytypes == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL)) { -+ d0 *= entity.level().purpurConfig.skeletonHeadVisibilityPercent; -+ } -+ else if (entitytypes == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD)) { -+ d0 *= entity.level().purpurConfig.zombieHeadVisibilityPercent; -+ } -+ else if (entitytypes == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD)) { -+ d0 *= entity.level().purpurConfig.creeperHeadVisibilityPercent; - } -+ else if ((entitytypes == EntityType.PIGLIN || entitytypes == EntityType.PIGLIN_BRUTE) && itemstack.is(Items.PIGLIN_HEAD)) { -+ d0 *= entity.level().purpurConfig.piglinHeadVisibilityPercent; -+ } -+ // Purpur end - - // Purpur start - if (entity instanceof LivingEntity entityliving) { -diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index 0d5fb6e2b4d46c6de5222190d2c5535a233c1067..2c1a380a423e4858f7c1c617fb53e169c882247f 100644 ---- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -1401,6 +1401,7 @@ public class PurpurWorldConfig { - public boolean creeperExplodeWhenKilled = false; - public boolean creeperHealthRadius = false; - public boolean creeperAlwaysDropExp = false; -+ public double creeperHeadVisibilityPercent = 0.5D; - private void creeperSettings() { - creeperRidable = getBoolean("mobs.creeper.ridable", creeperRidable); - creeperRidableInWater = getBoolean("mobs.creeper.ridable-in-water", creeperRidableInWater); -@@ -1419,6 +1420,7 @@ public class PurpurWorldConfig { - creeperExplodeWhenKilled = getBoolean("mobs.creeper.explode-when-killed", creeperExplodeWhenKilled); - creeperHealthRadius = getBoolean("mobs.creeper.health-impacts-explosion", creeperHealthRadius); - creeperAlwaysDropExp = getBoolean("mobs.creeper.always-drop-exp", creeperAlwaysDropExp); -+ creeperHeadVisibilityPercent = getDouble("mobs.creeper.head-visibility-percent", creeperHeadVisibilityPercent); - } - - public boolean dolphinRidable = false; -@@ -2246,6 +2248,7 @@ public class PurpurWorldConfig { - public boolean piglinTakeDamageFromWater = false; - public int piglinPortalSpawnModifier = 2000; - public boolean piglinAlwaysDropExp = false; -+ public double piglinHeadVisibilityPercent = 0.5D; - private void piglinSettings() { - piglinRidable = getBoolean("mobs.piglin.ridable", piglinRidable); - piglinRidableInWater = getBoolean("mobs.piglin.ridable-in-water", piglinRidableInWater); -@@ -2261,6 +2264,7 @@ public class PurpurWorldConfig { - piglinTakeDamageFromWater = getBoolean("mobs.piglin.takes-damage-from-water", piglinTakeDamageFromWater); - piglinPortalSpawnModifier = getInt("mobs.piglin.portal-spawn-modifier", piglinPortalSpawnModifier); - piglinAlwaysDropExp = getBoolean("mobs.piglin.always-drop-exp", piglinAlwaysDropExp); -+ piglinHeadVisibilityPercent = getDouble("mobs.piglin.head-visibility-percent", piglinHeadVisibilityPercent); - } - - public boolean piglinBruteRidable = false; -@@ -2545,6 +2549,7 @@ public class PurpurWorldConfig { - public double skeletonScale = 1.0D; - public boolean skeletonTakeDamageFromWater = false; - public boolean skeletonAlwaysDropExp = false; -+ public double skeletonHeadVisibilityPercent = 0.5D; - private void skeletonSettings() { - skeletonRidable = getBoolean("mobs.skeleton.ridable", skeletonRidable); - skeletonRidableInWater = getBoolean("mobs.skeleton.ridable-in-water", skeletonRidableInWater); -@@ -2558,6 +2563,7 @@ public class PurpurWorldConfig { - skeletonScale = Mth.clamp(getDouble("mobs.skeleton.attributes.scale", skeletonScale), 0.0625D, 16.0D); - skeletonTakeDamageFromWater = getBoolean("mobs.skeleton.takes-damage-from-water", skeletonTakeDamageFromWater); - skeletonAlwaysDropExp = getBoolean("mobs.skeleton.always-drop-exp", skeletonAlwaysDropExp); -+ skeletonHeadVisibilityPercent = getDouble("mobs.skeleton.head-visibility-percent", skeletonHeadVisibilityPercent); - } - - public boolean skeletonHorseRidable = false; -@@ -3131,6 +3137,7 @@ public class PurpurWorldConfig { - public boolean zombieBypassMobGriefing = false; - public boolean zombieTakeDamageFromWater = false; - public boolean zombieAlwaysDropExp = false; -+ public double zombieHeadVisibilityPercent = 0.5D; - private void zombieSettings() { - zombieRidable = getBoolean("mobs.zombie.ridable", zombieRidable); - zombieRidableInWater = getBoolean("mobs.zombie.ridable-in-water", zombieRidableInWater); -@@ -3150,6 +3157,7 @@ public class PurpurWorldConfig { - zombieBypassMobGriefing = getBoolean("mobs.zombie.bypass-mob-griefing", zombieBypassMobGriefing); - zombieTakeDamageFromWater = getBoolean("mobs.zombie.takes-damage-from-water", zombieTakeDamageFromWater); - zombieAlwaysDropExp = getBoolean("mobs.zombie.always-drop-exp", zombieAlwaysDropExp); -+ zombieHeadVisibilityPercent = getDouble("mobs.zombie.head-visibility-percent", zombieHeadVisibilityPercent); - } - - public boolean zombieHorseRidable = false; diff --git a/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index 20a13e925..e75dba848 100644 --- a/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/purpur-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -31,10 +31,34 @@ } } else if (this.getAirSupply() < this.getMaxAirSupply()) { this.setAirSupply(this.increaseAirSupply(this.getAirSupply())); -@@ -1018,6 +_,17 @@ - } - } - +@@ -1009,14 +_,32 @@ + if (lookingEntity != null) { + ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.HEAD); + EntityType type = lookingEntity.getType(); +- if (type == EntityType.SKELETON && itemBySlot.is(Items.SKELETON_SKULL) +- || type == EntityType.ZOMBIE && itemBySlot.is(Items.ZOMBIE_HEAD) +- || type == EntityType.PIGLIN && itemBySlot.is(Items.PIGLIN_HEAD) +- || type == EntityType.PIGLIN_BRUTE && itemBySlot.is(Items.PIGLIN_HEAD) +- || type == EntityType.CREEPER && itemBySlot.is(Items.CREEPER_HEAD)) { +- d *= 0.5; +- } +- } ++ // Purpur start - Mob head visibility percent ++ if (type == EntityType.SKELETON && itemBySlot.is(Items.SKELETON_SKULL)) { ++ d *= lookingEntity.level().purpurConfig.skeletonHeadVisibilityPercent; ++ } ++ else if (type == EntityType.ZOMBIE && itemBySlot.is(Items.ZOMBIE_HEAD)) { ++ d *= lookingEntity.level().purpurConfig.zombieHeadVisibilityPercent; ++ } ++ else if ((type == EntityType.PIGLIN || type == EntityType.PIGLIN_BRUTE) && itemBySlot.is(Items.PIGLIN_HEAD)) { ++ d *= lookingEntity.level().purpurConfig.piglinHeadVisibilityPercent; ++ } ++ else if (type == EntityType.CREEPER && itemBySlot.is(Items.CREEPER_HEAD)) { ++ d *= lookingEntity.level().purpurConfig.creeperHeadVisibilityPercent; ++ } ++ // Purpur end - Mob head visibility percent ++ } ++ + // Purpur start - Configurable mob blindness + if (lookingEntity instanceof LivingEntity entityliving) { + if (entityliving.hasEffect(MobEffects.BLINDNESS)) { @@ -45,10 +69,9 @@ + } + } + // Purpur end - Configurable mob blindness -+ + return d; } - @@ -1372,6 +_,24 @@ this.stopSleeping(); } 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 e5be55afb..34d55e8c2 100644 --- a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -1400,6 +1400,7 @@ public class PurpurWorldConfig { public boolean creeperExplodeWhenKilled = false; public boolean creeperHealthRadius = false; public boolean creeperAlwaysDropExp = false; + public double creeperHeadVisibilityPercent = 0.5D; private void creeperSettings() { creeperRidable = getBoolean("mobs.creeper.ridable", creeperRidable); creeperRidableInWater = getBoolean("mobs.creeper.ridable-in-water", creeperRidableInWater); @@ -1418,6 +1419,7 @@ public class PurpurWorldConfig { creeperExplodeWhenKilled = getBoolean("mobs.creeper.explode-when-killed", creeperExplodeWhenKilled); creeperHealthRadius = getBoolean("mobs.creeper.health-impacts-explosion", creeperHealthRadius); creeperAlwaysDropExp = getBoolean("mobs.creeper.always-drop-exp", creeperAlwaysDropExp); + creeperHeadVisibilityPercent = getDouble("mobs.creeper.head-visibility-percent", creeperHeadVisibilityPercent); } public boolean dolphinRidable = false; @@ -2245,6 +2247,7 @@ public class PurpurWorldConfig { public boolean piglinTakeDamageFromWater = false; public int piglinPortalSpawnModifier = 2000; public boolean piglinAlwaysDropExp = false; + public double piglinHeadVisibilityPercent = 0.5D; private void piglinSettings() { piglinRidable = getBoolean("mobs.piglin.ridable", piglinRidable); piglinRidableInWater = getBoolean("mobs.piglin.ridable-in-water", piglinRidableInWater); @@ -2260,6 +2263,7 @@ public class PurpurWorldConfig { piglinTakeDamageFromWater = getBoolean("mobs.piglin.takes-damage-from-water", piglinTakeDamageFromWater); piglinPortalSpawnModifier = getInt("mobs.piglin.portal-spawn-modifier", piglinPortalSpawnModifier); piglinAlwaysDropExp = getBoolean("mobs.piglin.always-drop-exp", piglinAlwaysDropExp); + piglinHeadVisibilityPercent = getDouble("mobs.piglin.head-visibility-percent", piglinHeadVisibilityPercent); } public boolean piglinBruteRidable = false; @@ -2544,6 +2548,7 @@ public class PurpurWorldConfig { public double skeletonScale = 1.0D; public boolean skeletonTakeDamageFromWater = false; public boolean skeletonAlwaysDropExp = false; + public double skeletonHeadVisibilityPercent = 0.5D; private void skeletonSettings() { skeletonRidable = getBoolean("mobs.skeleton.ridable", skeletonRidable); skeletonRidableInWater = getBoolean("mobs.skeleton.ridable-in-water", skeletonRidableInWater); @@ -2557,6 +2562,7 @@ public class PurpurWorldConfig { skeletonScale = Mth.clamp(getDouble("mobs.skeleton.attributes.scale", skeletonScale), 0.0625D, 16.0D); skeletonTakeDamageFromWater = getBoolean("mobs.skeleton.takes-damage-from-water", skeletonTakeDamageFromWater); skeletonAlwaysDropExp = getBoolean("mobs.skeleton.always-drop-exp", skeletonAlwaysDropExp); + skeletonHeadVisibilityPercent = getDouble("mobs.skeleton.head-visibility-percent", skeletonHeadVisibilityPercent); } public boolean skeletonHorseRidable = false; @@ -3130,6 +3136,7 @@ public class PurpurWorldConfig { public boolean zombieBypassMobGriefing = false; public boolean zombieTakeDamageFromWater = false; public boolean zombieAlwaysDropExp = false; + public double zombieHeadVisibilityPercent = 0.5D; private void zombieSettings() { zombieRidable = getBoolean("mobs.zombie.ridable", zombieRidable); zombieRidableInWater = getBoolean("mobs.zombie.ridable-in-water", zombieRidableInWater); @@ -3149,6 +3156,7 @@ public class PurpurWorldConfig { zombieBypassMobGriefing = getBoolean("mobs.zombie.bypass-mob-griefing", zombieBypassMobGriefing); zombieTakeDamageFromWater = getBoolean("mobs.zombie.takes-damage-from-water", zombieTakeDamageFromWater); zombieAlwaysDropExp = getBoolean("mobs.zombie.always-drop-exp", zombieAlwaysDropExp); + zombieHeadVisibilityPercent = getDouble("mobs.zombie.head-visibility-percent", zombieHeadVisibilityPercent); } public boolean zombieHorseRidable = false;