2012-03-09 06:49:05 +01:00
|
|
|
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;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-03-09 06:57:26 +01:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
this.f = new NibbleArray(this.d.length, 4);
|
|
|
|
this.h = new NibbleArray(this.d.length, 4);
|
|
|
|
this.g = new NibbleArray(this.d.length, 4);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.e();
|
2012-03-09 06:57:26 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-03-09 06:49:05 +01:00
|
|
|
public int a(int i, int j, int k) {
|
|
|
|
int l = this.d[j << 8 | k << 4 | i] & 255;
|
|
|
|
|
|
|
|
return this.e != null ? this.e.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;
|
|
|
|
|
|
|
|
if (this.e != null) {
|
|
|
|
i1 |= this.e.a(i, j, k) << 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i1 == 0 && l != 0) {
|
|
|
|
++this.b;
|
2012-07-29 09:33:13 +02:00
|
|
|
if (Block.byId[l] != null && Block.byId[l].r()) {
|
2012-03-09 06:49:05 +01:00
|
|
|
++this.c;
|
|
|
|
}
|
|
|
|
} else if (i1 != 0 && l == 0) {
|
|
|
|
--this.b;
|
2012-07-29 09:33:13 +02:00
|
|
|
if (Block.byId[i1] != null && Block.byId[i1].r()) {
|
2012-03-09 06:49:05 +01:00
|
|
|
--this.c;
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
} else if (Block.byId[i1] != null && Block.byId[i1].r() && (Block.byId[l] == null || !Block.byId[l].r())) {
|
2012-03-09 06:49:05 +01:00
|
|
|
--this.c;
|
2012-07-29 09:33:13 +02:00
|
|
|
} else if ((Block.byId[i1] == null || !Block.byId[i1].r()) && Block.byId[l] != null && Block.byId[l].r()) {
|
2012-03-09 06:49:05 +01:00
|
|
|
++this.c;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.d[j << 8 | k << 4 | i] = (byte) (l & 255);
|
|
|
|
if (l > 255) {
|
|
|
|
if (this.e == null) {
|
|
|
|
this.e = new NibbleArray(this.d.length, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.e.a(i, j, k, (l & 3840) >> 8);
|
|
|
|
} else if (this.e != null) {
|
|
|
|
this.e.a(i, j, k, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int b(int i, int j, int k) {
|
|
|
|
return this.f.a(i, j, k);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(int i, int j, int k, int l) {
|
|
|
|
this.f.a(i, j, k, l);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
|
|
|
return this.b == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean b() {
|
|
|
|
return this.c > 0;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public int d() {
|
2012-03-09 06:49:05 +01:00
|
|
|
return this.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void c(int i, int j, int k, int l) {
|
|
|
|
this.h.a(i, j, k, l);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int c(int i, int j, int k) {
|
|
|
|
return this.h.a(i, j, k);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void d(int i, int j, int k, int l) {
|
|
|
|
this.g.a(i, j, k, l);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int d(int i, int j, int k) {
|
|
|
|
return this.g.a(i, j, k);
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void e() {
|
2012-08-09 08:10:12 +02:00
|
|
|
// 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;
|
|
|
|
if (l > 0) {
|
|
|
|
if (Block.byId[l] == null) {
|
|
|
|
dd[off] = 0;
|
|
|
|
} else {
|
|
|
|
++cntb;
|
|
|
|
if (Block.byId[l].r()) {
|
|
|
|
++cntc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
byte[] ext = this.e.a;
|
|
|
|
for (int off = 0, off2 = 0; off < dd.length;) {
|
|
|
|
byte extid = ext[off2];
|
|
|
|
int l = (dd[off] & 0xFF) | ((extid & 0xF) << 8); // Even data
|
|
|
|
if (l > 0) {
|
|
|
|
if (Block.byId[l] == null) {
|
|
|
|
dd[off] = 0;
|
|
|
|
ext[off2] &= 0xF0;
|
|
|
|
} else {
|
|
|
|
++cntb;
|
|
|
|
if (Block.byId[l].r()) {
|
|
|
|
++cntc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
off++;
|
|
|
|
l = (dd[off] & 0xFF) | ((extid & 0xF0) << 4); // Odd data
|
|
|
|
if (l > 0) {
|
|
|
|
if (Block.byId[l] == null) {
|
|
|
|
dd[off] = 0;
|
|
|
|
ext[off2] &= 0x0F;
|
|
|
|
} else {
|
|
|
|
++cntb;
|
|
|
|
if (Block.byId[l].r()) {
|
|
|
|
++cntc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
off++;
|
|
|
|
off2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.b = cntb;
|
|
|
|
this.c = cntc;
|
|
|
|
}
|
2012-09-14 07:03:47 +02:00
|
|
|
|
2012-08-09 08:10:12 +02:00
|
|
|
private void old_e() {
|
|
|
|
// CraftBukkit end
|
2012-03-09 06:49:05 +01:00
|
|
|
this.b = 0;
|
|
|
|
this.c = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < 16; ++i) {
|
|
|
|
for (int j = 0; j < 16; ++j) {
|
|
|
|
for (int k = 0; k < 16; ++k) {
|
|
|
|
int l = this.a(i, j, k);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
++this.b;
|
2012-07-29 09:33:13 +02:00
|
|
|
if (Block.byId[l].r()) {
|
2012-03-09 06:49:05 +01:00
|
|
|
++this.c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public byte[] g() {
|
|
|
|
return this.d;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public NibbleArray i() {
|
2012-03-09 06:49:05 +01:00
|
|
|
return this.e;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public NibbleArray j() {
|
2012-03-09 06:49:05 +01:00
|
|
|
return this.f;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public NibbleArray k() {
|
2012-03-09 06:49:05 +01:00
|
|
|
return this.g;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public NibbleArray l() {
|
2012-03-09 06:49:05 +01:00
|
|
|
return this.h;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(byte[] abyte) {
|
|
|
|
this.d = abyte;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NibbleArray nibblearray) {
|
|
|
|
this.e = nibblearray;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NibbleArray nibblearray) {
|
|
|
|
this.f = nibblearray;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void c(NibbleArray nibblearray) {
|
|
|
|
this.g = nibblearray;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void d(NibbleArray nibblearray) {
|
|
|
|
this.h = nibblearray;
|
|
|
|
}
|
|
|
|
}
|