aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0323-Add-option-to-nerf-pigmen-from-nether-portals.patch
blob: 515c72656240365325c4728d38c8f04d01d73eb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
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/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 5bb379251c5af88d4350bd2715147e6442d695fd..f75457a5297fc041de5f2d7eabcc072201a42a09 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -399,6 +399,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
     public void inactiveTick() { }
     // Spigot end
     protected int numCollisions = 0; // Paper - Cap entity collisions
+    public boolean fromNetherPortal; // Paper - Add option to nerf pigmen from nether portals
     public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one
     // Paper start - Entity origin API
     @javax.annotation.Nullable
@@ -2214,6 +2215,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
             if (spawnedViaMobSpawner) {
                 nbttagcompound.putBoolean("Paper.FromMobSpawner", true);
             }
+            if (fromNetherPortal) {
+                nbttagcompound.putBoolean("Paper.FromNetherPortal", true);
+            }
             // Paper end
             return nbttagcompound;
         } catch (Throwable throwable) {
@@ -2356,6 +2360,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
             }
 
             spawnedViaMobSpawner = nbt.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status
+            fromNetherPortal = nbt.getBoolean("Paper.FromNetherPortal");
             if (nbt.contains("Paper.SpawnReason")) {
                 String spawnReasonName = nbt.getString("Paper.SpawnReason");
                 try {
diff --git a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java b/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
index f0d4c16fffe7af7e913f4bb300c72f7bdf91e0e8..d3f2c0e3107a781b462a2b67c10cd1e5f05feefb 100644
--- a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
@@ -71,6 +71,8 @@ public class NetherPortalBlock extends Block {
 
                 if (entity != null) {
                     entity.setPortalCooldown();
+                    entity.fromNetherPortal = true; // Paper - Add option to nerf pigmen from nether portals
+                    if (world.paperConfig().entities.behavior.nerfPigmenFromNetherPortals) ((net.minecraft.world.entity.Mob) entity).aware = false; // Paper - Add option to nerf pigmen from nether portals
                 }
             }
         }