aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0027-Configurable-top-of-nether-void-damage.patch
blob: cf16b0e54f9850dae6a34bcca57662c84478e3a7 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 1 Mar 2016 23:58:50 -0600
Subject: [PATCH] Configurable top of nether void damage


diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index d59b82b7bb1f6d1b231f4e394e0a67a3d154d7be..f7a0a33e49cadf9b2bd43f118c106937760da762 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -129,4 +129,19 @@ public class PaperWorldConfig {
         if (fallingBlockHeightNerf != 0) log("Falling Block Height Limit set to Y: " + fallingBlockHeightNerf);
         if (entityTNTHeightNerf != 0) log("TNT Entity Height Limit set to Y: " + entityTNTHeightNerf);
     }
+
+    public int netherVoidTopDamageHeight;
+    public boolean doNetherTopVoidDamage() { return netherVoidTopDamageHeight > 0; }
+    private void netherVoidTopDamageHeight() {
+        netherVoidTopDamageHeight = getInt("nether-ceiling-void-damage-height", 0);
+        log("Top of the nether void damage height: " + netherVoidTopDamageHeight);
+
+        if (PaperConfig.version < 18) {
+            boolean legacy = getBoolean("nether-ceiling-void-damage", false);
+            if (legacy) {
+                netherVoidTopDamageHeight = 128;
+                set("nether-ceiling-void-damage-height", netherVoidTopDamageHeight);
+            }
+        }
+    }
 }
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index bfe36be070677d215eadd3ad38f93c6bddab0b75..9e132052e1a9b997300e3f5d88473fc5f9ebdd73 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -420,9 +420,16 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
             this.fallDistance *= 0.5F;
         }
 
+        // Paper start - Configurable nether ceiling damage
+
+        // Extracted to own function
+        /*
         if (this.locY() < -64.0D) {
             this.ai();
         }
+        */
+        this.performVoidDamage();
+        // Paper end
 
         if (!this.world.isClientSide) {
             this.setFlag(0, this.fireTicks > 0);
@@ -432,6 +439,17 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
         this.world.getMethodProfiler().exit();
     }
 
+    // Paper start
+    protected void performVoidDamage() {
+        if (this.locY() < -64.0D || (this.world.getWorld().getEnvironment() == org.bukkit.World.Environment.NETHER
+            && world.paperConfig.doNetherTopVoidDamage()
+            && this.locY() >= world.paperConfig.netherVoidTopDamageHeight)) {
+
+            this.doVoidDamage();
+        }
+    }
+    // Paper end
+
     protected void E() {
         if (this.portalCooldown > 0) {
             --this.portalCooldown;
@@ -507,6 +525,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
         this.setFireTicks(0);
     }
 
+    protected final void doVoidDamage() { this.ai(); } // Paper - OBFHELPER
     protected void ai() {
         this.die();
     }
diff --git a/src/main/java/net/minecraft/server/EntityMinecartAbstract.java b/src/main/java/net/minecraft/server/EntityMinecartAbstract.java
index cb25cf3bb7be041d9b135165b6f66b5c232a2553..9124d00521463157df6348b84260f91a47e1f076 100644
--- a/src/main/java/net/minecraft/server/EntityMinecartAbstract.java
+++ b/src/main/java/net/minecraft/server/EntityMinecartAbstract.java
@@ -285,9 +285,15 @@ public abstract class EntityMinecartAbstract extends Entity {
             this.setDamage(this.getDamage() - 1.0F);
         }
 
+        // Paper start - Configurable nether ceiling damage
+        // Extracted to own function
+        /*
         if (this.locY() < -64.0D) {
             this.ai();
         }
+        */
+        this.performVoidDamage();
+        // Paper end
 
         // this.doPortalTick(); // CraftBukkit - handled in postTick
         if (this.world.isClientSide) {