Toggle for Zombified Piglin death always counting as player kill when angry

In Vanilla (as of 1.16.4), when Zombified Piglins die while angry, it will count as a player kill regardless of whether a player has ever hit them,
meaning they will drop XP. This is abused in Zombified Piglin farms where the player kills the entities through cramming, but they still drop XP due to the Piglin being angry, even though the player never hit them.

This patch adds a toggle to disable this behavior.
This commit is contained in:
Jason Penilla
2025-01-09 22:37:30 -08:00
committed by granny
parent b93c23e223
commit ce45f0538f
3 changed files with 22 additions and 55 deletions

View File

@@ -0,0 +1,20 @@
--- a/net/minecraft/world/entity/monster/ZombifiedPiglin.java
+++ b/net/minecraft/world/entity/monster/ZombifiedPiglin.java
@@ -112,7 +_,7 @@
this.maybeAlertOthers();
}
- if (this.isAngry()) {
+ if (this.isAngry() && this.level().purpurConfig.zombifiedPiglinCountAsPlayerKillWhenAngry) { // Purpur - Toggle for Zombified Piglin death always counting as player kill when angry
this.lastHurtByPlayerTime = this.tickCount;
}
@@ -163,7 +_,7 @@
this.ticksUntilNextAlert = ALERT_INTERVAL.sample(this.random);
}
- if (livingEntity instanceof Player) {
+ if (livingEntity instanceof Player && this.level().purpurConfig.zombifiedPiglinCountAsPlayerKillWhenAngry) { // Purpur - Toggle for Zombified Piglin death always counting as player kill when angry
this.setLastHurtByPlayer((Player)livingEntity);
}

View File

@@ -2180,6 +2180,7 @@ public class PurpurWorldConfig {
public boolean zombifiedPiglinJockeyOnlyBaby = true;
public double zombifiedPiglinJockeyChance = 0.05D;
public boolean zombifiedPiglinJockeyTryExistingChickens = true;
public boolean zombifiedPiglinCountAsPlayerKillWhenAngry = true;
private void zombifiedPiglinSettings() {
zombifiedPiglinRidable = getBoolean("mobs.zombified_piglin.ridable", zombifiedPiglinRidable);
zombifiedPiglinRidableInWater = getBoolean("mobs.zombified_piglin.ridable-in-water", zombifiedPiglinRidableInWater);
@@ -2195,5 +2196,6 @@ public class PurpurWorldConfig {
zombifiedPiglinJockeyOnlyBaby = getBoolean("mobs.zombified_piglin.jockey.only-babies", zombifiedPiglinJockeyOnlyBaby);
zombifiedPiglinJockeyChance = getDouble("mobs.zombified_piglin.jockey.chance", zombifiedPiglinJockeyChance);
zombifiedPiglinJockeyTryExistingChickens = getBoolean("mobs.zombified_piglin.jockey.try-existing-chickens", zombifiedPiglinJockeyTryExistingChickens);
zombifiedPiglinCountAsPlayerKillWhenAngry = getBoolean("mobs.zombified_piglin.count-as-player-kill-when-angry", zombifiedPiglinCountAsPlayerKillWhenAngry);
}
}