diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-10-24 22:53:23 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-10-27 22:19:03 -0400 |
commit | 60819c6693daf19dde68b04af38a4fee8c7da988 (patch) | |
tree | e7bd96a07f0e9d9f1f6b2721ddd1bb5dd71eaf48 /src/main/java/net/minecraft/server/ChunkSection.java | |
parent | b9a72531b6e2ccc84bd021bca421255a957d96f7 (diff) | |
download | craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.gz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.lz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.xz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.zip |
Update CraftBukkit to Minecraft 1.4(.2).
Diffstat (limited to 'src/main/java/net/minecraft/server/ChunkSection.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ChunkSection.java | 192 |
1 files changed, 96 insertions, 96 deletions
diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java index 1b0c8e00..60d2a73c 100644 --- a/src/main/java/net/minecraft/server/ChunkSection.java +++ b/src/main/java/net/minecraft/server/ChunkSection.java @@ -2,159 +2,159 @@ package net.minecraft.server; public class ChunkSection { - private int a; - private int b; - private int c; - private byte[] d; - private NibbleArray e; - private NibbleArray f; - private NibbleArray g; - private NibbleArray h; + private int yPos; + private int nonEmptyBlockCount; + private int tickingBlockCount; + private byte[] blockIds; + private NibbleArray extBlockIds; + private NibbleArray blockData; + private NibbleArray blockLight; + private NibbleArray skyLight; public ChunkSection(int i) { - this.a = i; - this.d = new byte[4096]; - this.f = new NibbleArray(this.d.length, 4); - this.h = new NibbleArray(this.d.length, 4); - this.g = new NibbleArray(this.d.length, 4); + this.yPos = i; + this.blockIds = new byte[4096]; + this.blockData = new NibbleArray(this.blockIds.length, 4); + this.skyLight = new NibbleArray(this.blockIds.length, 4); + this.blockLight = new NibbleArray(this.blockIds.length, 4); } // CraftBukkit start - public ChunkSection(int y, byte[] blkData, byte[] extBlkData) { - this.a = y; - this.d = blkData; - if (extBlkData != null) { - this.e = new NibbleArray(extBlkData, 4); + public ChunkSection(int y, byte[] blkIds, byte[] extBlkIds) { + this.yPos = y; + this.blockIds = blkIds; + if (extBlkIds != null) { + this.extBlockIds = new NibbleArray(extBlkIds, 4); } - this.f = new NibbleArray(this.d.length, 4); - this.h = new NibbleArray(this.d.length, 4); - this.g = new NibbleArray(this.d.length, 4); - this.e(); + this.blockData = new NibbleArray(this.blockIds.length, 4); + this.blockLight = new NibbleArray(this.blockIds.length, 4); + this.skyLight = new NibbleArray(this.blockIds.length, 4); + this.recalcBlockCounts(); } // CraftBukkit end public int a(int i, int j, int k) { - int l = this.d[j << 8 | k << 4 | i] & 255; + int l = this.blockIds[j << 8 | k << 4 | i] & 255; - return this.e != null ? this.e.a(i, j, k) << 8 | l : l; + return this.extBlockIds != null ? this.extBlockIds.a(i, j, k) << 8 | l : l; } public void a(int i, int j, int k, int l) { - int i1 = this.d[j << 8 | k << 4 | i] & 255; + int i1 = this.blockIds[j << 8 | k << 4 | i] & 255; - if (this.e != null) { - i1 |= this.e.a(i, j, k) << 8; + if (this.extBlockIds != null) { + i1 |= this.extBlockIds.a(i, j, k) << 8; } if (i1 == 0 && l != 0) { - ++this.b; - if (Block.byId[l] != null && Block.byId[l].r()) { - ++this.c; + ++this.nonEmptyBlockCount; + if (Block.byId[l] != null && Block.byId[l].isTicking()) { + ++this.tickingBlockCount; } } else if (i1 != 0 && l == 0) { - --this.b; - if (Block.byId[i1] != null && Block.byId[i1].r()) { - --this.c; + --this.nonEmptyBlockCount; + if (Block.byId[i1] != null && Block.byId[i1].isTicking()) { + --this.tickingBlockCount; } - } else if (Block.byId[i1] != null && Block.byId[i1].r() && (Block.byId[l] == null || !Block.byId[l].r())) { - --this.c; - } else if ((Block.byId[i1] == null || !Block.byId[i1].r()) && Block.byId[l] != null && Block.byId[l].r()) { - ++this.c; + } else if (Block.byId[i1] != null && Block.byId[i1].isTicking() && (Block.byId[l] == null || !Block.byId[l].isTicking())) { + --this.tickingBlockCount; + } else if ((Block.byId[i1] == null || !Block.byId[i1].isTicking()) && Block.byId[l] != null && Block.byId[l].isTicking()) { + ++this.tickingBlockCount; } - this.d[j << 8 | k << 4 | i] = (byte) (l & 255); + this.blockIds[j << 8 | k << 4 | i] = (byte) (l & 255); if (l > 255) { - if (this.e == null) { - this.e = new NibbleArray(this.d.length, 4); + if (this.extBlockIds == null) { + this.extBlockIds = new NibbleArray(this.blockIds.length, 4); } - this.e.a(i, j, k, (l & 3840) >> 8); - } else if (this.e != null) { - this.e.a(i, j, k, 0); + this.extBlockIds.a(i, j, k, (l & 3840) >> 8); + } else if (this.extBlockIds != null) { + this.extBlockIds.a(i, j, k, 0); } } public int b(int i, int j, int k) { - return this.f.a(i, j, k); + return this.blockData.a(i, j, k); } public void b(int i, int j, int k, int l) { - this.f.a(i, j, k, l); + this.blockData.a(i, j, k, l); } public boolean a() { - return this.b == 0; + return this.nonEmptyBlockCount == 0; } public boolean b() { - return this.c > 0; + return this.tickingBlockCount > 0; } public int d() { - return this.a; + return this.yPos; } public void c(int i, int j, int k, int l) { - this.h.a(i, j, k, l); + this.skyLight.a(i, j, k, l); } public int c(int i, int j, int k) { - return this.h.a(i, j, k); + return this.skyLight.a(i, j, k); } public void d(int i, int j, int k, int l) { - this.g.a(i, j, k, l); + this.blockLight.a(i, j, k, l); } public int d(int i, int j, int k) { - return this.g.a(i, j, k); + return this.blockLight.a(i, j, k); } - public void e() { + public void recalcBlockCounts() { // CraftBukkit start - optimize for speed - byte[] dd = this.d; - int cntb = 0; - int cntc = 0; - if (this.e == null) { // No extended block IDs? Don't waste time messing with them - for (int off = 0; off < dd.length; off++) { - int l = dd[off] & 0xFF; + byte[] blkIds = this.blockIds; + int cntNonEmpty = 0; + int cntTicking = 0; + if (this.extBlockIds == null) { // No extended block IDs? Don't waste time messing with them + for (int off = 0; off < blkIds.length; off++) { + int l = blkIds[off] & 0xFF; if (l > 0) { if (Block.byId[l] == null) { - dd[off] = 0; + blkIds[off] = 0; } else { - ++cntb; - if (Block.byId[l].r()) { - ++cntc; + ++cntNonEmpty; + if (Block.byId[l].isTicking()) { + ++cntTicking; } } } } } else { - byte[] ext = this.e.a; - for (int off = 0, off2 = 0; off < dd.length;) { + byte[] ext = this.extBlockIds.a; + for (int off = 0, off2 = 0; off < blkIds.length;) { byte extid = ext[off2]; - int l = (dd[off] & 0xFF) | ((extid & 0xF) << 8); // Even data + int l = (blkIds[off] & 0xFF) | ((extid & 0xF) << 8); // Even data if (l > 0) { if (Block.byId[l] == null) { - dd[off] = 0; + blkIds[off] = 0; ext[off2] &= 0xF0; } else { - ++cntb; - if (Block.byId[l].r()) { - ++cntc; + ++cntNonEmpty; + if (Block.byId[l].isTicking()) { + ++cntTicking; } } } off++; - l = (dd[off] & 0xFF) | ((extid & 0xF0) << 4); // Odd data + l = (blkIds[off] & 0xFF) | ((extid & 0xF0) << 4); // Odd data if (l > 0) { if (Block.byId[l] == null) { - dd[off] = 0; + blkIds[off] = 0; ext[off2] &= 0x0F; } else { - ++cntb; - if (Block.byId[l].r()) { - ++cntc; + ++cntNonEmpty; + if (Block.byId[l].isTicking()) { + ++cntTicking; } } } @@ -162,14 +162,14 @@ public class ChunkSection { off2++; } } - this.b = cntb; - this.c = cntc; + this.nonEmptyBlockCount = cntNonEmpty; + this.tickingBlockCount = cntTicking; } - private void old_e() { + public void old_recalcBlockCounts() { // CraftBukkit end - this.b = 0; - this.c = 0; + this.nonEmptyBlockCount = 0; + this.tickingBlockCount = 0; for (int i = 0; i < 16; ++i) { for (int j = 0; j < 16; ++j) { @@ -178,14 +178,14 @@ public class ChunkSection { if (l > 0) { if (Block.byId[l] == null) { - this.d[j << 8 | k << 4 | i] = 0; - if (this.e != null) { - this.e.a(i, j, k, 0); + this.blockIds[j << 8 | k << 4 | i] = 0; + if (this.extBlockIds != null) { + this.extBlockIds.a(i, j, k, 0); } } else { - ++this.b; - if (Block.byId[l].r()) { - ++this.c; + ++this.nonEmptyBlockCount; + if (Block.byId[l].isTicking()) { + ++this.tickingBlockCount; } } } @@ -195,42 +195,42 @@ public class ChunkSection { } public byte[] g() { - return this.d; + return this.blockIds; } public NibbleArray i() { - return this.e; + return this.extBlockIds; } public NibbleArray j() { - return this.f; + return this.blockData; } public NibbleArray k() { - return this.g; + return this.blockLight; } public NibbleArray l() { - return this.h; + return this.skyLight; } public void a(byte[] abyte) { - this.d = abyte; + this.blockIds = abyte; } public void a(NibbleArray nibblearray) { - this.e = nibblearray; + this.extBlockIds = nibblearray; } public void b(NibbleArray nibblearray) { - this.f = nibblearray; + this.blockData = nibblearray; } public void c(NibbleArray nibblearray) { - this.g = nibblearray; + this.blockLight = nibblearray; } public void d(NibbleArray nibblearray) { - this.h = nibblearray; + this.skyLight = nibblearray; } } |