From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Fri, 7 Feb 2020 14:36:56 -0600 Subject: [PATCH] Add option to nerf pigmen from nether portals diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java index 7fbd501d70dccf869a4454e2789a5d68f2e15754..9e4591ddc4b755f4ff5a6f1078b51cb13db80480 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -594,4 +594,9 @@ public class PaperWorldConfig { disableHopperMoveEvents = getBoolean("hopper.disable-move-event", disableHopperMoveEvents); log("Hopper Move Item Events: " + (disableHopperMoveEvents ? "disabled" : "enabled")); } + + public boolean nerfNetherPortalPigmen = false; + private void nerfNetherPortalPigmen() { + nerfNetherPortalPigmen = getBoolean("game-mechanics.nerf-pigmen-from-nether-portals", nerfNetherPortalPigmen); + } } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 82e025776b0b6a01c35940df63f334b1d1fbdeb1..c89c56a6d116526e11f4ba9ad3333d8cceafc3e8 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -274,6 +274,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne public long activatedTick = Integer.MIN_VALUE; public boolean isTemporarilyActive = false; // Paper public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one + public boolean fromNetherPortal; // Paper protected int numCollisions = 0; // Paper public void inactiveTick() { } // Spigot end @@ -1689,6 +1690,9 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne if (spawnedViaMobSpawner) { nbttagcompound.setBoolean("Paper.FromMobSpawner", true); } + if (fromNetherPortal) { + nbttagcompound.setBoolean("Paper.FromNetherPortal", true); + } // Paper end return nbttagcompound; } catch (Throwable throwable) { @@ -1819,6 +1823,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne } spawnedViaMobSpawner = nbttagcompound.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status + fromNetherPortal = nbttagcompound.getBoolean("Paper.FromNetherPortal"); if (nbttagcompound.hasKey("Paper.SpawnReason")) { String spawnReasonName = nbttagcompound.getString("Paper.SpawnReason"); try { diff --git a/src/main/java/net/minecraft/world/level/block/BlockPortal.java b/src/main/java/net/minecraft/world/level/block/BlockPortal.java index e115ff86987c69f5e3571af5d7f034f24a3f6bba..4cfa3108996eb879d39337a7b23307a6dbcb97a7 100644 --- a/src/main/java/net/minecraft/world/level/block/BlockPortal.java +++ b/src/main/java/net/minecraft/world/level/block/BlockPortal.java @@ -62,6 +62,8 @@ public class BlockPortal extends Block { if (entity != null) { entity.resetPortalCooldown(); + entity.fromNetherPortal = true; // Paper + if (worldserver.paperConfig.nerfNetherPortalPigmen) ((EntityInsentient) entity).aware = false; // Paper } } }