aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0139-Option-to-remove-corrupt-tile-entities.patch
blob: 3fa8477aa1dba61f648450a5617ba670e72c1a75 (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
From 6a37f4af427998aa81105d6a80cca73b74427ee7 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 6e28410c37..7e847af00b 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -340,4 +340,9 @@ public class PaperWorldConfig {
     private void maxAutoSaveChunksPerTick() {
         maxAutoSaveChunksPerTick = getInt("max-auto-save-chunks-per-tick", 24);
     }
+
+    public boolean removeCorruptTEs = false;
+    private void removeCorruptTEs() {
+        removeCorruptTEs = getBoolean("remove-corrupt-tile-entities", false);
+    }
 }
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 0bf614ce57..a6cacd7da9 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -844,6 +844,12 @@ public class Chunk implements IChunkAccess {
                             "Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16));
             e.printStackTrace();
             ServerInternalException.reportInternalException(e);
+
+            if (this.world.paperConfig.removeCorruptTEs) {
+                this.removeTileEntity(tileentity.getPosition());
+                this.markDirty();
+                org.bukkit.Bukkit.getLogger().info("Removing corrupt tile entity");
+            }
             // Paper end
             // CraftBukkit end
         }
@@ -853,6 +859,7 @@ public class Chunk implements IChunkAccess {
         this.h.put(new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z")), nbttagcompound);
     }
 
+    public void removeTileEntity(BlockPosition blockposition) { this.d(blockposition); } // Paper - OBFHELPER
     public void d(BlockPosition blockposition) {
         if (this.i) {
             TileEntity tileentity = (TileEntity) this.tileEntities.remove(blockposition);
-- 
2.21.0