3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 11:00:06 +01:00
Paper/CraftBukkit-Patches/0009-Add-OldChunkLoader-from-mc-dev-for-diff-visibility.patch

141 Zeilen
5.3 KiB
Diff

From ad4a3b8942231a2542ef3672d0c398d46023d8da Mon Sep 17 00:00:00 2001
From: Agaricus <agaricusb@yahoo.com>
Date: Sun, 13 Jan 2013 03:41:38 -0800
Subject: [PATCH] Add OldChunkLoader from mc-dev for diff visibility
---
.../java/net/minecraft/server/OldChunkLoader.java | 120 +++++++++++++++++++++
1 file changed, 120 insertions(+)
create mode 100644 src/main/java/net/minecraft/server/OldChunkLoader.java
diff --git a/src/main/java/net/minecraft/server/OldChunkLoader.java b/src/main/java/net/minecraft/server/OldChunkLoader.java
new file mode 100644
index 0000000..65b0b70
--- /dev/null
+++ b/src/main/java/net/minecraft/server/OldChunkLoader.java
@@ -0,0 +1,120 @@
+package net.minecraft.server;
+
+public class OldChunkLoader {
+
+ public static OldChunk a(NBTTagCompound nbttagcompound) {
+ int i = nbttagcompound.getInt("xPos");
+ int j = nbttagcompound.getInt("zPos");
+ OldChunk oldchunk = new OldChunk(i, j);
+
+ oldchunk.g = nbttagcompound.getByteArray("Blocks");
+ oldchunk.f = new OldNibbleArray(nbttagcompound.getByteArray("Data"), 7);
+ oldchunk.e = new OldNibbleArray(nbttagcompound.getByteArray("SkyLight"), 7);
+ oldchunk.d = new OldNibbleArray(nbttagcompound.getByteArray("BlockLight"), 7);
+ oldchunk.c = nbttagcompound.getByteArray("HeightMap");
+ oldchunk.b = nbttagcompound.getBoolean("TerrainPopulated");
+ oldchunk.h = nbttagcompound.getList("Entities");
+ oldchunk.i = nbttagcompound.getList("TileEntities");
+ oldchunk.j = nbttagcompound.getList("TileTicks");
+
+ try {
+ oldchunk.a = nbttagcompound.getLong("LastUpdate");
+ } catch (ClassCastException classcastexception) {
+ oldchunk.a = (long) nbttagcompound.getInt("LastUpdate");
+ }
+
+ return oldchunk;
+ }
+
+ public static void a(OldChunk oldchunk, NBTTagCompound nbttagcompound, WorldChunkManager worldchunkmanager) {
+ nbttagcompound.setInt("xPos", oldchunk.k);
+ nbttagcompound.setInt("zPos", oldchunk.l);
+ nbttagcompound.setLong("LastUpdate", oldchunk.a);
+ int[] aint = new int[oldchunk.c.length];
+
+ for (int i = 0; i < oldchunk.c.length; ++i) {
+ aint[i] = oldchunk.c[i];
+ }
+
+ nbttagcompound.setIntArray("HeightMap", aint);
+ nbttagcompound.setBoolean("TerrainPopulated", oldchunk.b);
+ NBTTagList nbttaglist = new NBTTagList("Sections");
+
+ int j;
+
+ for (int k = 0; k < 8; ++k) {
+ boolean flag = true;
+
+ for (j = 0; j < 16 && flag; ++j) {
+ int l = 0;
+
+ while (l < 16 && flag) {
+ int i1 = 0;
+
+ while (true) {
+ if (i1 < 16) {
+ int j1 = j << 11 | i1 << 7 | l + (k << 4);
+ byte b0 = oldchunk.g[j1];
+
+ if (b0 == 0) {
+ ++i1;
+ continue;
+ }
+
+ flag = false;
+ }
+
+ ++l;
+ break;
+ }
+ }
+ }
+
+ if (!flag) {
+ byte[] abyte = new byte[4096];
+ NibbleArray nibblearray = new NibbleArray(abyte.length, 4);
+ NibbleArray nibblearray1 = new NibbleArray(abyte.length, 4);
+ NibbleArray nibblearray2 = new NibbleArray(abyte.length, 4);
+
+ for (int k1 = 0; k1 < 16; ++k1) {
+ for (int l1 = 0; l1 < 16; ++l1) {
+ for (int i2 = 0; i2 < 16; ++i2) {
+ int j2 = k1 << 11 | i2 << 7 | l1 + (k << 4);
+ byte b1 = oldchunk.g[j2];
+
+ abyte[l1 << 8 | i2 << 4 | k1] = (byte) (b1 & 255);
+ nibblearray.a(k1, l1, i2, oldchunk.f.a(k1, l1 + (k << 4), i2));
+ nibblearray1.a(k1, l1, i2, oldchunk.e.a(k1, l1 + (k << 4), i2));
+ nibblearray2.a(k1, l1, i2, oldchunk.d.a(k1, l1 + (k << 4), i2));
+ }
+ }
+ }
+
+ NBTTagCompound nbttagcompound1 = new NBTTagCompound();
+
+ nbttagcompound1.setByte("Y", (byte) (k & 255));
+ nbttagcompound1.setByteArray("Blocks", abyte);
+ nbttagcompound1.setByteArray("Data", nibblearray.a);
+ nbttagcompound1.setByteArray("SkyLight", nibblearray1.a);
+ nbttagcompound1.setByteArray("BlockLight", nibblearray2.a);
+ nbttaglist.add(nbttagcompound1);
+ }
+ }
+
+ nbttagcompound.set("Sections", nbttaglist);
+ byte[] abyte1 = new byte[256];
+
+ for (int k2 = 0; k2 < 16; ++k2) {
+ for (j = 0; j < 16; ++j) {
+ abyte1[j << 4 | k2] = (byte) (worldchunkmanager.getBiome(oldchunk.k << 4 | k2, oldchunk.l << 4 | j).id & 255);
+ }
+ }
+
+ nbttagcompound.setByteArray("Biomes", abyte1);
+ nbttagcompound.set("Entities", oldchunk.h);
+ nbttagcompound.set("TileEntities", oldchunk.i);
+ if (oldchunk.j != null) {
+ nbttagcompound.set("TileTicks", oldchunk.j);
+ }
+ }
+}
\ No newline at end of file
--
1.8.1-rc2