aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0108-Option-to-remove-corrupt-tile-entities.patch
blob: 7a9b695de20995833221f6e2922ee86577ab08c9 (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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Wed, 5 Oct 2016 16:27:36 -0500
Subject: [PATCH] Option to remove corrupt tile entities


diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index d7734fbc6b684b14bc32c94e65947fb41aae126a..80345730b8ccc11d3d0833485d25b03f614aeee2 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -347,4 +347,9 @@ public class PaperWorldConfig {
         preventTntFromMovingInWater = getBoolean("prevent-tnt-from-moving-in-water", false);
         log("Prevent TNT from moving in water: " + preventTntFromMovingInWater);
     }
+
+    public boolean removeCorruptTEs = false;
+    private void removeCorruptTEs() {
+        removeCorruptTEs = getBoolean("remove-corrupt-tile-entities", false);
+    }
 }
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index a9a14062a94b18b553a10b30de0cda7354ae4b7d..a009122a8ea9dc2b04a178248f20ef01886e832b 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -259,7 +259,7 @@ public class LevelChunk extends ChunkAccess {
         }
 
         this.setLightCorrect(protoChunk.isLightCorrect());
-        this.unsaved = true;
+        this.setUnsaved(true);
         this.needsDecoration = true; // CraftBukkit
         // CraftBukkit start
         this.persistentDataContainer = protoChunk.persistentDataContainer; // SPIGOT-6814: copy PDC to account for 1.17 to 1.18 chunk upgrading.
@@ -582,6 +582,12 @@ public class LevelChunk extends ChunkAccess {
                     "Chunk coordinates: " + (this.chunkPos.x * 16) + "," + (this.chunkPos.z * 16));
             e.printStackTrace();
             ServerInternalException.reportInternalException(e);
+
+            if (this.level.paperConfig.removeCorruptTEs) {
+                this.removeBlockEntity(blockEntity.getBlockPos());
+                this.setUnsaved(true);
+                org.bukkit.Bukkit.getLogger().info("Removing corrupt tile entity");
+            }
             // Paper end
             // CraftBukkit end
         }