Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 36fb3e0

Browse files
BillyGalbreathgranny
authored andcommitted
Mob head visibility percent
1 parent f133c42 commit 36fb3e0

3 files changed

Lines changed: 37 additions & 107 deletions

File tree

patches/server/0220-Mob-head-visibility-percent.patch

Lines changed: 0 additions & 101 deletions
This file was deleted.

purpur-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,34 @@
3131
}
3232
} else if (this.getAirSupply() < this.getMaxAirSupply()) {
3333
this.setAirSupply(this.increaseAirSupply(this.getAirSupply()));
34-
@@ -1018,6 +_,17 @@
35-
}
36-
}
37-
34+
@@ -1009,14 +_,32 @@
35+
if (lookingEntity != null) {
36+
ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.HEAD);
37+
EntityType<?> type = lookingEntity.getType();
38+
- if (type == EntityType.SKELETON && itemBySlot.is(Items.SKELETON_SKULL)
39+
- || type == EntityType.ZOMBIE && itemBySlot.is(Items.ZOMBIE_HEAD)
40+
- || type == EntityType.PIGLIN && itemBySlot.is(Items.PIGLIN_HEAD)
41+
- || type == EntityType.PIGLIN_BRUTE && itemBySlot.is(Items.PIGLIN_HEAD)
42+
- || type == EntityType.CREEPER && itemBySlot.is(Items.CREEPER_HEAD)) {
43+
- d *= 0.5;
44+
- }
45+
- }
46+
+ // Purpur start - Mob head visibility percent
47+
+ if (type == EntityType.SKELETON && itemBySlot.is(Items.SKELETON_SKULL)) {
48+
+ d *= lookingEntity.level().purpurConfig.skeletonHeadVisibilityPercent;
49+
+ }
50+
+ else if (type == EntityType.ZOMBIE && itemBySlot.is(Items.ZOMBIE_HEAD)) {
51+
+ d *= lookingEntity.level().purpurConfig.zombieHeadVisibilityPercent;
52+
+ }
53+
+ else if ((type == EntityType.PIGLIN || type == EntityType.PIGLIN_BRUTE) && itemBySlot.is(Items.PIGLIN_HEAD)) {
54+
+ d *= lookingEntity.level().purpurConfig.piglinHeadVisibilityPercent;
55+
+ }
56+
+ else if (type == EntityType.CREEPER && itemBySlot.is(Items.CREEPER_HEAD)) {
57+
+ d *= lookingEntity.level().purpurConfig.creeperHeadVisibilityPercent;
58+
+ }
59+
+ // Purpur end - Mob head visibility percent
60+
+ }
61+
+
3862
+ // Purpur start - Configurable mob blindness
3963
+ if (lookingEntity instanceof LivingEntity entityliving) {
4064
+ if (entityliving.hasEffect(MobEffects.BLINDNESS)) {
@@ -45,10 +69,9 @@
4569
+ }
4670
+ }
4771
+ // Purpur end - Configurable mob blindness
48-
+
72+
4973
return d;
5074
}
51-
5275
@@ -1372,6 +_,24 @@
5376
this.stopSleeping();
5477
}

purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,7 @@ private void creakingSettings() {
14001400
public boolean creeperExplodeWhenKilled = false;
14011401
public boolean creeperHealthRadius = false;
14021402
public boolean creeperAlwaysDropExp = false;
1403+
public double creeperHeadVisibilityPercent = 0.5D;
14031404
private void creeperSettings() {
14041405
creeperRidable = getBoolean("mobs.creeper.ridable", creeperRidable);
14051406
creeperRidableInWater = getBoolean("mobs.creeper.ridable-in-water", creeperRidableInWater);
@@ -1418,6 +1419,7 @@ private void creeperSettings() {
14181419
creeperExplodeWhenKilled = getBoolean("mobs.creeper.explode-when-killed", creeperExplodeWhenKilled);
14191420
creeperHealthRadius = getBoolean("mobs.creeper.health-impacts-explosion", creeperHealthRadius);
14201421
creeperAlwaysDropExp = getBoolean("mobs.creeper.always-drop-exp", creeperAlwaysDropExp);
1422+
creeperHeadVisibilityPercent = getDouble("mobs.creeper.head-visibility-percent", creeperHeadVisibilityPercent);
14211423
}
14221424

14231425
public boolean dolphinRidable = false;
@@ -2245,6 +2247,7 @@ private void pigSettings() {
22452247
public boolean piglinTakeDamageFromWater = false;
22462248
public int piglinPortalSpawnModifier = 2000;
22472249
public boolean piglinAlwaysDropExp = false;
2250+
public double piglinHeadVisibilityPercent = 0.5D;
22482251
private void piglinSettings() {
22492252
piglinRidable = getBoolean("mobs.piglin.ridable", piglinRidable);
22502253
piglinRidableInWater = getBoolean("mobs.piglin.ridable-in-water", piglinRidableInWater);
@@ -2260,6 +2263,7 @@ private void piglinSettings() {
22602263
piglinTakeDamageFromWater = getBoolean("mobs.piglin.takes-damage-from-water", piglinTakeDamageFromWater);
22612264
piglinPortalSpawnModifier = getInt("mobs.piglin.portal-spawn-modifier", piglinPortalSpawnModifier);
22622265
piglinAlwaysDropExp = getBoolean("mobs.piglin.always-drop-exp", piglinAlwaysDropExp);
2266+
piglinHeadVisibilityPercent = getDouble("mobs.piglin.head-visibility-percent", piglinHeadVisibilityPercent);
22632267
}
22642268

22652269
public boolean piglinBruteRidable = false;
@@ -2544,6 +2548,7 @@ private void silverfishSettings() {
25442548
public double skeletonScale = 1.0D;
25452549
public boolean skeletonTakeDamageFromWater = false;
25462550
public boolean skeletonAlwaysDropExp = false;
2551+
public double skeletonHeadVisibilityPercent = 0.5D;
25472552
private void skeletonSettings() {
25482553
skeletonRidable = getBoolean("mobs.skeleton.ridable", skeletonRidable);
25492554
skeletonRidableInWater = getBoolean("mobs.skeleton.ridable-in-water", skeletonRidableInWater);
@@ -2557,6 +2562,7 @@ private void skeletonSettings() {
25572562
skeletonScale = Mth.clamp(getDouble("mobs.skeleton.attributes.scale", skeletonScale), 0.0625D, 16.0D);
25582563
skeletonTakeDamageFromWater = getBoolean("mobs.skeleton.takes-damage-from-water", skeletonTakeDamageFromWater);
25592564
skeletonAlwaysDropExp = getBoolean("mobs.skeleton.always-drop-exp", skeletonAlwaysDropExp);
2565+
skeletonHeadVisibilityPercent = getDouble("mobs.skeleton.head-visibility-percent", skeletonHeadVisibilityPercent);
25602566
}
25612567

25622568
public boolean skeletonHorseRidable = false;
@@ -3130,6 +3136,7 @@ private void zoglinSettings() {
31303136
public boolean zombieBypassMobGriefing = false;
31313137
public boolean zombieTakeDamageFromWater = false;
31323138
public boolean zombieAlwaysDropExp = false;
3139+
public double zombieHeadVisibilityPercent = 0.5D;
31333140
private void zombieSettings() {
31343141
zombieRidable = getBoolean("mobs.zombie.ridable", zombieRidable);
31353142
zombieRidableInWater = getBoolean("mobs.zombie.ridable-in-water", zombieRidableInWater);
@@ -3149,6 +3156,7 @@ private void zombieSettings() {
31493156
zombieBypassMobGriefing = getBoolean("mobs.zombie.bypass-mob-griefing", zombieBypassMobGriefing);
31503157
zombieTakeDamageFromWater = getBoolean("mobs.zombie.takes-damage-from-water", zombieTakeDamageFromWater);
31513158
zombieAlwaysDropExp = getBoolean("mobs.zombie.always-drop-exp", zombieAlwaysDropExp);
3159+
zombieHeadVisibilityPercent = getDouble("mobs.zombie.head-visibility-percent", zombieHeadVisibilityPercent);
31523160
}
31533161

31543162
public boolean zombieHorseRidable = false;

0 commit comments

Comments
 (0)