summaryrefslogtreecommitdiffstats
path: root/nms-patches/DataPaletteBlock.patch
blob: d761b41d68f6c32a43cb2767fd4154001605ada8 (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
--- a/net/minecraft/server/DataPaletteBlock.java
+++ b/net/minecraft/server/DataPaletteBlock.java
@@ -109,7 +109,21 @@
             int i1 = nibblearray1 == null ? 0 : nibblearray1.a(j, k, l);
             int j1 = i1 << 12 | (abyte[i] & 255) << 4 | nibblearray.a(j, k, l);
 
-            this.setBlockIndex(i, (IBlockData) Block.REGISTRY_ID.fromId(j1));
+            // CraftBukkit start - fix blocks with random data values (caused by plugins)
+            IBlockData data = Block.REGISTRY_ID.fromId(j1);
+            if (data == null) {
+                Block block = Block.getById(j1 >> 4);
+                if (block != null) {
+                    try {
+                        data = block.fromLegacyData(j1 & 0xF);
+                    } catch (Exception ignored) {
+                        data = block.getBlockData();
+                    }
+                }
+            }
+            this.setBlockIndex(i, data);
+            // this.setBlockIndex(i, (IBlockData) Block.REGISTRY_ID.fromId(j1));
+            // CraftBukkit end
         }
 
     }