Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/src/main/java/net/minecraft/server/Chunk.java

862 Zeilen
24 KiB
Java

2011-02-01 23:49:28 +01:00
package net.minecraft.server;
import java.util.ArrayList;
2011-09-15 02:23:52 +02:00
import java.util.Arrays;
2011-02-01 23:49:28 +01:00
import java.util.HashMap;
2011-06-30 00:02:25 +02:00
import java.util.Iterator;
2011-02-01 23:49:28 +01:00
import java.util.List;
import java.util.Map;
import java.util.Random;
public class Chunk {
public static boolean a;
public byte[] b;
2011-09-15 02:23:52 +02:00
public int[] c;
public boolean[] d;
public boolean e;
public World world;
2011-02-01 23:49:28 +01:00
public NibbleArray g;
2011-09-15 02:23:52 +02:00
public NibbleArray h;
public NibbleArray i;
public byte[] heightMap;
2011-09-15 02:23:52 +02:00
public int k;
public final int x;
public final int z;
public Map tileEntities;
public List[] entitySlices;
public boolean done;
2011-02-01 23:49:28 +01:00
public boolean q;
2011-09-15 02:23:52 +02:00
public boolean r;
public boolean s;
public long t;
boolean u;
2011-02-01 23:49:28 +01:00
public Chunk(World world, int i, int j) {
2011-09-15 02:23:52 +02:00
this.c = new int[256];
this.d = new boolean[256];
this.tileEntities = new HashMap();
this.done = false;
2011-02-01 23:49:28 +01:00
this.q = false;
2011-09-15 02:23:52 +02:00
this.s = false;
this.t = 0L;
this.u = false;
world.getClass();
this.entitySlices = new List[128 / 16];
this.world = world;
this.x = i;
this.z = j;
this.heightMap = new byte[256];
2011-02-01 23:49:28 +01:00
for (int k = 0; k < this.entitySlices.length; ++k) {
this.entitySlices[k] = new ArrayList();
2011-02-01 23:49:28 +01:00
}
2011-09-15 02:23:52 +02:00
Arrays.fill(this.c, -999);
2011-02-01 23:49:28 +01:00
// CraftBukkit start
org.bukkit.craftbukkit.CraftWorld cworld = this.world.getWorld();
this.bukkitChunk = (cworld == null) ? null : cworld.popPreservedChunk(i, j);
if (this.bukkitChunk == null) {
this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
}
2011-02-01 23:49:28 +01:00
}
public org.bukkit.Chunk bukkitChunk;
// CraftBukkit end
public Chunk(World world, byte[] abyte, int i, int j) {
this(world, i, j);
this.b = abyte;
2011-09-15 02:23:52 +02:00
int k = abyte.length;
// Craftbukkit start - FIX THE DECOMPILER!
this.g = new NibbleArray(k, 7);
this.h = new NibbleArray(k, 7);
this.i = new NibbleArray(k, 7);
// Craftbukkit end
2011-02-01 23:49:28 +01:00
}
public boolean a(int i, int j) {
return i == this.x && j == this.z;
2011-02-01 23:49:28 +01:00
}
public int b(int i, int j) {
return this.heightMap[j << 4 | i] & 255;
2011-02-01 23:49:28 +01:00
}
public void a() {}
public void initLighting() {
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
int i = 128 - 1;
2011-02-01 23:49:28 +01:00
int j;
int k;
for (j = 0; j < 16; ++j) {
for (k = 0; k < 16; ++k) {
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
int l = 128 - 1;
2011-02-01 23:49:28 +01:00
2011-09-15 02:23:52 +02:00
int i1 = j << 11;
2011-02-01 23:49:28 +01:00
2011-09-15 02:23:52 +02:00
int j1;
for (j1 = i1 | k << 7; l > 0 && Block.q[this.b[j1 + l - 1] & 255] == 0; --l) {
2011-02-01 23:49:28 +01:00
;
}
this.heightMap[k << 4 | j] = (byte) l;
2011-02-01 23:49:28 +01:00
if (l < i) {
i = l;
}
if (!this.world.worldProvider.e) {
2011-09-15 02:23:52 +02:00
int k1 = 15;
int l1 = 128 - 1;
2011-02-01 23:49:28 +01:00
do {
2011-09-15 02:23:52 +02:00
k1 -= Block.q[this.b[j1 + l1] & 255];
if (k1 > 0) {
this.h.a(j, l1, k, k1);
2011-02-01 23:49:28 +01:00
}
2011-09-15 02:23:52 +02:00
--l1;
} while (l1 > 0 && k1 > 0);
2011-02-01 23:49:28 +01:00
}
}
}
2011-09-15 02:23:52 +02:00
this.k = i;
2011-02-01 23:49:28 +01:00
for (j = 0; j < 16; ++j) {
for (k = 0; k < 16; ++k) {
2011-09-15 02:23:52 +02:00
this.d(j, k);
2011-02-01 23:49:28 +01:00
}
}
2011-09-15 02:23:52 +02:00
this.q = true;
2011-02-01 23:49:28 +01:00
}
public void loadNOP() {}
2011-02-01 23:49:28 +01:00
2011-09-15 02:23:52 +02:00
private void d(int i, int j) {
this.d[i + j * 16] = true;
}
private void i() {
World j0000 = this.world;
int j0001 = this.x * 16 + 8;
if (j0000.areChunksLoaded(j0001, 128 / 2, this.z * 16 + 8, 16)) {
for (int j = 0; j < 16; ++j) {
for (int k = 0; k < 16; ++k) {
if (this.d[j + k * 16]) {
this.d[j + k * 16] = false;
int l = this.b(j, k);
int i1 = this.x * 16 + j;
int j1 = this.z * 16 + k;
int k1 = this.world.getHighestBlockYAt(i1 - 1, j1);
int l1 = this.world.getHighestBlockYAt(i1 + 1, j1);
int i2 = this.world.getHighestBlockYAt(i1, j1 - 1);
int j2 = this.world.getHighestBlockYAt(i1, j1 + 1);
if (l1 < k1) {
k1 = l1;
}
if (i2 < k1) {
k1 = i2;
}
if (j2 < k1) {
k1 = j2;
}
2011-02-01 23:49:28 +01:00
2011-09-15 02:23:52 +02:00
this.u = true;
this.f(i1, j1, k1);
this.u = true;
this.f(i1 - 1, j1, l);
this.f(i1 + 1, j1, l);
this.f(i1, j1 - 1, l);
this.f(i1, j1 + 1, l);
}
}
}
}
2011-02-01 23:49:28 +01:00
}
private void f(int i, int j, int k) {
int l = this.world.getHighestBlockYAt(i, j);
2011-02-01 23:49:28 +01:00
if (l > k) {
2011-09-15 02:23:52 +02:00
this.d(i, j, k, l + 1);
2011-02-01 23:49:28 +01:00
} else if (l < k) {
2011-09-15 02:23:52 +02:00
this.d(i, j, l, k + 1);
}
}
private void d(int i, int j, int k, int l) {
if (l > k) {
World world = this.world;
if (world.areChunksLoaded(i, 128 / 2, j, 16)) {
for (int i1 = k; i1 < l; ++i1) {
this.world.b(EnumSkyBlock.SKY, i, i1, j);
}
this.q = true;
}
2011-02-01 23:49:28 +01:00
}
}
private void g(int i, int j, int k) {
int l = this.heightMap[k << 4 | i] & 255;
2011-02-01 23:49:28 +01:00
int i1 = l;
if (j > l) {
i1 = j;
}
2011-09-15 05:13:14 +02:00
//
2011-09-15 02:23:52 +02:00
this.world.getClass();
int j1 = i << 11;
for (int k1 = j1 | k << 7; i1 > 0 && Block.q[this.b[k1 + i1 - 1] & 255] == 0; --i1) {
2011-02-01 23:49:28 +01:00
;
}
if (i1 != l) {
this.world.g(i, k, i1, l);
this.heightMap[k << 4 | i] = (byte) i1;
2011-02-01 23:49:28 +01:00
int l1;
int i2;
2011-09-15 02:23:52 +02:00
int j2;
2011-02-01 23:49:28 +01:00
2011-09-15 02:23:52 +02:00
if (i1 < this.k) {
this.k = i1;
2011-02-01 23:49:28 +01:00
} else {
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
l1 = 128 - 1;
2011-02-01 23:49:28 +01:00
2011-09-15 02:23:52 +02:00
for (i2 = 0; i2 < 16; ++i2) {
for (j2 = 0; j2 < 16; ++j2) {
if ((this.heightMap[j2 << 4 | i2] & 255) < l1) {
l1 = this.heightMap[j2 << 4 | i2] & 255;
2011-02-01 23:49:28 +01:00
}
}
}
2011-09-15 02:23:52 +02:00
this.k = l1;
2011-02-01 23:49:28 +01:00
}
2011-09-15 02:23:52 +02:00
l1 = this.x * 16 + i;
i2 = this.z * 16 + k;
2011-02-01 23:49:28 +01:00
if (i1 < l) {
2011-09-15 02:23:52 +02:00
for (j2 = i1; j2 < l; ++j2) {
this.h.a(i, j2, k, 15);
2011-02-01 23:49:28 +01:00
}
} else {
2011-09-15 02:23:52 +02:00
for (j2 = l; j2 < i1; ++j2) {
this.h.a(i, j2, k, 0);
2011-02-01 23:49:28 +01:00
}
}
2011-09-15 02:23:52 +02:00
for (j2 = 15; i1 > 0 && j2 > 0; this.h.a(i, i1, k, j2)) {
2011-02-01 23:49:28 +01:00
--i1;
int k2 = Block.q[this.getTypeId(i, i1, k)];
2011-02-01 23:49:28 +01:00
if (k2 == 0) {
k2 = 1;
}
2011-09-15 02:23:52 +02:00
j2 -= k2;
if (j2 < 0) {
j2 = 0;
2011-02-01 23:49:28 +01:00
}
}
2011-09-15 02:23:52 +02:00
byte b0 = this.heightMap[k << 4 | i];
int l2 = l;
int i3 = b0;
2011-02-01 23:49:28 +01:00
2011-09-15 02:23:52 +02:00
if (b0 < l) {
l2 = b0;
i3 = l;
2011-02-01 23:49:28 +01:00
}
2011-09-15 02:23:52 +02:00
this.d(l1 - 1, i2, l2, i3);
this.d(l1 + 1, i2, l2, i3);
this.d(l1, i2 - 1, l2, i3);
this.d(l1, i2 + 1, l2, i3);
this.d(l1, i2, l2, i3);
this.q = true;
2011-02-01 23:49:28 +01:00
}
}
public int getTypeId(int i, int j, int k) {
2011-09-15 02:23:52 +02:00
byte[] abyte = this.b;
int l = i << 11;
return abyte[l | k << 7 | j] & 255;
2011-02-01 23:49:28 +01:00
}
public boolean a(int i, int j, int k, int l, int i1) {
byte b0 = (byte) l;
2011-09-15 02:23:52 +02:00
int j1 = k << 4 | i;
if (j >= this.c[j1] - 1) {
this.c[j1] = -999;
}
int k1 = this.heightMap[k << 4 | i] & 255;
byte[] j2000 = this.b;
int j2001 = i << 11;
2011-02-01 23:49:28 +01:00
2011-09-15 02:23:52 +02:00
int i2 = j2000[j2001 | k << 7 | j] & 255;
if (i2 == l && this.g.a(i, j, k) == i1) {
2011-02-01 23:49:28 +01:00
return false;
} else {
2011-09-15 02:23:52 +02:00
int j2 = this.x * 16 + i;
int k2 = this.z * 16 + k;
j2000 = this.b;
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
j2001 = i << 11;
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
j2000[j2001 | k << 7 | j] = (byte) (b0 & 255);
if (i2 != 0 && !this.world.isStatic) {
Block.byId[i2].remove(this.world, j2, j, k2);
2011-02-01 23:49:28 +01:00
}
2011-09-15 02:23:52 +02:00
this.g.a(i, j, k, i1);
if (!this.world.worldProvider.e) {
2011-03-31 22:40:00 +02:00
if (Block.q[b0 & 255] != 0) {
2011-09-15 02:23:52 +02:00
if (j >= k1) {
2011-02-01 23:49:28 +01:00
this.g(i, j + 1, k);
}
2011-09-15 02:23:52 +02:00
} else if (j == k1 - 1) {
2011-02-01 23:49:28 +01:00
this.g(i, j, k);
}
2011-09-15 02:23:52 +02:00
this.world.a(EnumSkyBlock.SKY, j2, j, k2, j2, j, k2);
2011-02-01 23:49:28 +01:00
}
2011-09-15 02:23:52 +02:00
this.world.a(EnumSkyBlock.BLOCK, j2, j, k2, j2, j, k2);
this.d(i, k);
this.g.a(i, j, k, i1);
TileEntity tileentity;
2011-02-01 23:49:28 +01:00
if (l != 0) {
2011-09-15 02:23:52 +02:00
if (!this.world.isStatic) {
Block.byId[l].a(this.world, j2, j, k2);
}
if (Block.byId[l] instanceof BlockContainer) {
tileentity = this.d(i, j, k);
if (tileentity == null) {
tileentity = ((BlockContainer) Block.byId[l]).a_();
this.world.setTileEntity(i, j, k, tileentity);
}
if (tileentity != null) {
tileentity.g();
}
}
} else if (i2 > 0 && Block.byId[i2] instanceof BlockContainer) {
tileentity = this.d(i, j, k);
if (tileentity != null) {
tileentity.g();
}
2011-02-01 23:49:28 +01:00
}
2011-09-15 02:23:52 +02:00
this.q = true;
2011-02-01 23:49:28 +01:00
return true;
}
}
public boolean a(int i, int j, int k, int l) {
byte b0 = (byte) l;
2011-09-15 02:23:52 +02:00
int i1 = k << 4 | i;
if (j >= this.c[i1] - 1) {
this.c[i1] = -999;
}
int j1 = this.heightMap[i1] & 255;
byte[] j2000 = this.b;
int j2001 = i << 11;
int l1 = j2000[j2001 | k << 7 | j] & 255;
2011-02-01 23:49:28 +01:00
2011-09-15 02:23:52 +02:00
if (l1 == l) {
2011-02-01 23:49:28 +01:00
return false;
} else {
2011-09-15 02:23:52 +02:00
int i2 = this.x * 16 + i;
int j2 = this.z * 16 + k;
j2000 = this.b;
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
j2001 = i << 11;
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
j2000[j2001 | k << 7 | j] = (byte) (b0 & 255);
if (l1 != 0) {
Block.byId[l1].remove(this.world, i2, j, j2);
2011-02-01 23:49:28 +01:00
}
2011-09-15 02:23:52 +02:00
this.g.a(i, j, k, 0);
2011-03-31 22:40:00 +02:00
if (Block.q[b0 & 255] != 0) {
2011-09-15 02:23:52 +02:00
if (j >= j1) {
2011-02-01 23:49:28 +01:00
this.g(i, j + 1, k);
}
2011-09-15 02:23:52 +02:00
} else if (j == j1 - 1) {
2011-02-01 23:49:28 +01:00
this.g(i, j, k);
}
2011-09-15 02:23:52 +02:00
this.world.a(EnumSkyBlock.SKY, i2, j, j2, i2, j, j2);
this.world.a(EnumSkyBlock.BLOCK, i2, j, j2, i2, j, j2);
this.d(i, k);
TileEntity tileentity;
if (l != 0) {
if (!this.world.isStatic) {
Block.byId[l].a(this.world, i2, j, j2);
}
if (l > 0 && Block.byId[l] instanceof BlockContainer) {
tileentity = this.d(i, j, k);
if (tileentity == null) {
tileentity = ((BlockContainer) Block.byId[l]).a_();
this.world.setTileEntity(i, j, k, tileentity);
}
if (tileentity != null) {
tileentity.g();
}
}
} else if (l1 > 0 && Block.byId[l1] instanceof BlockContainer) {
tileentity = this.d(i, j, k);
if (tileentity != null) {
tileentity.g();
}
2011-02-01 23:49:28 +01:00
}
2011-09-15 02:23:52 +02:00
this.q = true;
2011-02-01 23:49:28 +01:00
return true;
}
}
public int getData(int i, int j, int k) {
2011-09-15 02:23:52 +02:00
return this.g.a(i, j, k);
2011-02-01 23:49:28 +01:00
}
public void b(int i, int j, int k, int l) {
2011-09-15 02:23:52 +02:00
this.q = true;
this.g.a(i, j, k, l);
int i1 = this.getTypeId(i, j, k);
if (i1 > 0 && Block.byId[i1] instanceof BlockContainer) {
TileEntity tileentity = this.d(i, j, k);
if (tileentity != null) {
tileentity.g();
tileentity.n = l;
}
}
2011-02-01 23:49:28 +01:00
}
public int a(EnumSkyBlock enumskyblock, int i, int j, int k) {
2011-09-15 02:23:52 +02:00
return enumskyblock == EnumSkyBlock.SKY ? this.h.a(i, j, k) : (enumskyblock == EnumSkyBlock.BLOCK ? this.i.a(i, j, k) : 0);
2011-02-01 23:49:28 +01:00
}
public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l) {
2011-09-15 02:23:52 +02:00
this.q = true;
2011-02-01 23:49:28 +01:00
if (enumskyblock == EnumSkyBlock.SKY) {
2011-09-15 02:23:52 +02:00
this.h.a(i, j, k, l);
2011-02-01 23:49:28 +01:00
} else {
if (enumskyblock != EnumSkyBlock.BLOCK) {
return;
}
2011-09-15 02:23:52 +02:00
this.i.a(i, j, k, l);
2011-02-01 23:49:28 +01:00
}
}
public int c(int i, int j, int k, int l) {
2011-09-15 02:23:52 +02:00
int i1 = this.h.a(i, j, k);
2011-02-01 23:49:28 +01:00
if (i1 > 0) {
a = true;
}
i1 -= l;
2011-09-15 02:23:52 +02:00
int j1 = this.i.a(i, j, k);
2011-02-01 23:49:28 +01:00
if (j1 > i1) {
i1 = j1;
}
return i1;
}
public void a(Entity entity) {
2011-09-15 02:23:52 +02:00
this.s = true;
int i = MathHelper.floor(entity.locX / 16.0D);
int j = MathHelper.floor(entity.locZ / 16.0D);
2011-02-01 23:49:28 +01:00
if (i != this.x || j != this.z) {
2011-02-01 23:49:28 +01:00
System.out.println("Wrong location! " + entity);
2011-06-12 00:02:58 +02:00
// Thread.dumpStack(); // CraftBukkit
2011-02-23 13:56:36 +01:00
// CraftBukkit
System.out.println("" + entity.locX + "," + entity.locZ + "(" + i + "," + j + ") vs " + this.x + "," + this.z);
2011-02-01 23:49:28 +01:00
}
int k = MathHelper.floor(entity.locY / 16.0D);
2011-02-01 23:49:28 +01:00
if (k < 0) {
k = 0;
}
if (k >= this.entitySlices.length) {
k = this.entitySlices.length - 1;
2011-02-01 23:49:28 +01:00
}
2011-09-15 02:23:52 +02:00
entity.bV = true;
entity.bW = this.x;
entity.bX = k;
entity.bY = this.z;
this.entitySlices[k].add(entity);
2011-02-01 23:49:28 +01:00
}
public void b(Entity entity) {
2011-09-15 02:23:52 +02:00
this.a(entity, entity.bX);
2011-02-01 23:49:28 +01:00
}
public void a(Entity entity, int i) {
if (i < 0) {
i = 0;
}
if (i >= this.entitySlices.length) {
i = this.entitySlices.length - 1;
2011-02-01 23:49:28 +01:00
}
this.entitySlices[i].remove(entity);
2011-02-01 23:49:28 +01:00
}
public boolean c(int i, int j, int k) {
return j >= (this.heightMap[k << 4 | i] & 255);
2011-02-01 23:49:28 +01:00
}
public TileEntity d(int i, int j, int k) {
ChunkPosition chunkposition = new ChunkPosition(i, j, k);
TileEntity tileentity = (TileEntity) this.tileEntities.get(chunkposition);
2011-02-01 23:49:28 +01:00
if (tileentity == null) {
int l = this.getTypeId(i, j, k);
2011-02-01 23:49:28 +01:00
if (!Block.isTileEntity[l]) {
2011-02-01 23:49:28 +01:00
return null;
}
2011-09-15 02:23:52 +02:00
if (tileentity == null) {
tileentity = ((BlockContainer) Block.byId[l]).a_();
this.world.setTileEntity(this.x * 16 + i, j, this.z * 16 + k, tileentity);
}
2011-02-01 23:49:28 +01:00
tileentity = (TileEntity) this.tileEntities.get(chunkposition);
2011-02-01 23:49:28 +01:00
}
2011-09-15 02:23:52 +02:00
if (tileentity != null && tileentity.m()) {
2011-06-30 00:02:25 +02:00
this.tileEntities.remove(chunkposition);
return null;
} else {
return tileentity;
}
2011-02-01 23:49:28 +01:00
}
public void a(TileEntity tileentity) {
int i = tileentity.x - this.x * 16;
int j = tileentity.y;
int k = tileentity.z - this.z * 16;
2011-02-01 23:49:28 +01:00
this.a(i, j, k, tileentity);
2011-09-15 02:23:52 +02:00
if (this.e) {
this.world.h.add(tileentity);
2011-06-30 00:02:25 +02:00
}
2011-02-01 23:49:28 +01:00
}
public void a(int i, int j, int k, TileEntity tileentity) {
ChunkPosition chunkposition = new ChunkPosition(i, j, k);
tileentity.world = this.world;
tileentity.x = this.x * 16 + i;
tileentity.y = j;
tileentity.z = this.z * 16 + k;
if (this.getTypeId(i, j, k) != 0 && Block.byId[this.getTypeId(i, j, k)] instanceof BlockContainer) {
2011-09-15 02:23:52 +02:00
tileentity.n();
this.tileEntities.put(chunkposition, tileentity);
2011-02-01 23:49:28 +01:00
} else {
System.out.println("Attempted to place a tile entity where there was no entity tile!");
}
}
public void e(int i, int j, int k) {
ChunkPosition chunkposition = new ChunkPosition(i, j, k);
2011-09-15 02:23:52 +02:00
if (this.e) {
2011-06-30 00:02:25 +02:00
TileEntity tileentity = (TileEntity) this.tileEntities.remove(chunkposition);
if (tileentity != null) {
2011-09-15 02:23:52 +02:00
tileentity.i();
2011-06-30 00:02:25 +02:00
}
2011-02-01 23:49:28 +01:00
}
}
public void addEntities() {
2011-09-15 02:23:52 +02:00
this.e = true;
2011-06-30 00:02:25 +02:00
this.world.a(this.tileEntities.values());
2011-02-01 23:49:28 +01:00
for (int i = 0; i < this.entitySlices.length; ++i) {
this.world.a(this.entitySlices[i]);
2011-02-01 23:49:28 +01:00
}
}
public void removeEntities() {
2011-09-15 02:23:52 +02:00
this.e = false;
2011-06-30 00:02:25 +02:00
Iterator iterator = this.tileEntities.values().iterator();
while (iterator.hasNext()) {
TileEntity tileentity = (TileEntity) iterator.next();
2011-09-15 02:23:52 +02:00
this.world.a(tileentity);
2011-06-30 00:02:25 +02:00
}
for (int i = 0; i < this.entitySlices.length; ++i) {
2011-05-14 16:29:42 +02:00
// CraftBukkit start
java.util.Iterator<Object> iter = this.entitySlices[i].iterator();
while (iter.hasNext()) {
Entity entity = (Entity) iter.next();
int cx = org.bukkit.Location.locToBlock(entity.locX) >> 4;
int cz = org.bukkit.Location.locToBlock(entity.locZ) >> 4;
2011-05-14 16:29:42 +02:00
// Do not pass along players, as doing so can get them stuck outside of time.
// (which for example disables inventory icon updates and prevents block breaking)
if (entity instanceof EntityPlayer && (cx != this.x || cz != this.z)) {
iter.remove();
}
}
2011-05-14 16:29:42 +02:00
// CraftBukkit end
this.world.b(this.entitySlices[i]);
2011-02-01 23:49:28 +01:00
}
}
public void f() {
2011-09-15 02:23:52 +02:00
this.q = true;
2011-02-01 23:49:28 +01:00
}
public void a(Entity entity, AxisAlignedBB axisalignedbb, List list) {
int i = MathHelper.floor((axisalignedbb.b - 2.0D) / 16.0D);
int j = MathHelper.floor((axisalignedbb.e + 2.0D) / 16.0D);
2011-02-01 23:49:28 +01:00
if (i < 0) {
i = 0;
}
if (j >= this.entitySlices.length) {
j = this.entitySlices.length - 1;
2011-02-01 23:49:28 +01:00
}
for (int k = i; k <= j; ++k) {
List list1 = this.entitySlices[k];
2011-02-01 23:49:28 +01:00
for (int l = 0; l < list1.size(); ++l) {
Entity entity1 = (Entity) list1.get(l);
if (entity1 != entity && entity1.boundingBox.a(axisalignedbb)) {
list.add(entity1);
}
}
}
}
public void a(Class oclass, AxisAlignedBB axisalignedbb, List list) {
int i = MathHelper.floor((axisalignedbb.b - 2.0D) / 16.0D);
int j = MathHelper.floor((axisalignedbb.e + 2.0D) / 16.0D);
2011-02-01 23:49:28 +01:00
if (i < 0) {
i = 0;
}
if (j >= this.entitySlices.length) {
j = this.entitySlices.length - 1;
2011-02-01 23:49:28 +01:00
}
for (int k = i; k <= j; ++k) {
List list1 = this.entitySlices[k];
2011-02-01 23:49:28 +01:00
for (int l = 0; l < list1.size(); ++l) {
Entity entity = (Entity) list1.get(l);
if (oclass.isAssignableFrom(entity.getClass()) && entity.boundingBox.a(axisalignedbb)) {
list.add(entity);
}
}
}
}
public boolean a(boolean flag) {
2011-09-15 02:23:52 +02:00
if (this.r) {
2011-02-01 23:49:28 +01:00
return false;
} else {
if (flag) {
2011-09-15 02:23:52 +02:00
if (this.s && this.world.getTime() != this.t) {
2011-02-01 23:49:28 +01:00
return true;
}
2011-09-15 02:23:52 +02:00
} else if (this.s && this.world.getTime() >= this.t + 600L) {
2011-02-01 23:49:28 +01:00
return true;
}
2011-09-15 02:23:52 +02:00
return this.q;
2011-02-01 23:49:28 +01:00
}
}
public int getData(byte[] abyte, int i, int j, int k, int l, int i1, int j1, int k1) {
2011-05-26 14:48:22 +02:00
int l1 = l - i;
int i2 = i1 - j;
int j2 = j1 - k;
if (l1 * i2 * j2 == this.b.length) {
System.arraycopy(this.b, 0, abyte, k1, this.b.length);
k1 += this.b.length;
System.arraycopy(this.g.a, 0, abyte, k1, this.g.a.length);
k1 += this.g.a.length;
2011-09-15 02:23:52 +02:00
System.arraycopy(this.i.a, 0, abyte, k1, this.i.a.length);
k1 += this.i.a.length;
System.arraycopy(this.h.a, 0, abyte, k1, this.h.a.length);
k1 += this.h.a.length;
2011-05-26 14:48:22 +02:00
return k1;
} else {
int k2;
int l2;
int i3;
int j3;
2011-09-15 02:23:52 +02:00
int k3;
2011-05-26 14:48:22 +02:00
for (k2 = i; k2 < l; ++k2) {
2011-09-15 02:23:52 +02:00
for (i3 = k; i3 < j1; ++i3) {
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
l2 = k2 << 11;
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
j3 = l2 | i3 << 7 | j;
k3 = i1 - j;
System.arraycopy(this.b, j3, abyte, k1, k3);
k1 += k3;
2011-05-26 14:48:22 +02:00
}
2011-02-01 23:49:28 +01:00
}
2011-05-26 14:48:22 +02:00
for (k2 = i; k2 < l; ++k2) {
2011-09-15 02:23:52 +02:00
for (i3 = k; i3 < j1; ++i3) {
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
l2 = k2 << 11;
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
j3 = (l2 | i3 << 7 | j) >> 1;
k3 = (i1 - j) / 2;
System.arraycopy(this.g.a, j3, abyte, k1, k3);
k1 += k3;
2011-05-26 14:48:22 +02:00
}
2011-02-01 23:49:28 +01:00
}
2011-05-26 14:48:22 +02:00
for (k2 = i; k2 < l; ++k2) {
2011-09-15 02:23:52 +02:00
for (i3 = k; i3 < j1; ++i3) {
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
l2 = k2 << 11;
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
j3 = (l2 | i3 << 7 | j) >> 1;
k3 = (i1 - j) / 2;
System.arraycopy(this.i.a, j3, abyte, k1, k3);
k1 += k3;
2011-05-26 14:48:22 +02:00
}
2011-02-01 23:49:28 +01:00
}
2011-05-26 14:48:22 +02:00
for (k2 = i; k2 < l; ++k2) {
2011-09-15 02:23:52 +02:00
for (i3 = k; i3 < j1; ++i3) {
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
l2 = k2 << 11;
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
j3 = (l2 | i3 << 7 | j) >> 1;
k3 = (i1 - j) / 2;
System.arraycopy(this.h.a, j3, abyte, k1, k3);
k1 += k3;
2011-05-26 14:48:22 +02:00
}
2011-02-01 23:49:28 +01:00
}
2011-05-26 14:48:22 +02:00
return k1;
}
2011-02-01 23:49:28 +01:00
}
public Random a(long i) {
return new Random(this.world.getSeed() + (long) (this.x * this.x * 4987142) + (long) (this.x * 5947611) + (long) (this.z * this.z) * 4392871L + (long) (this.z * 389711) ^ i);
2011-02-01 23:49:28 +01:00
}
2011-09-15 02:23:52 +02:00
public void g() {
BlockRegister.a(this.b);
}
public void a(IChunkProvider ichunkprovider, IChunkProvider ichunkprovider1, int i, int j) {
if (!this.done && ichunkprovider.isChunkLoaded(i + 1, j + 1) && ichunkprovider.isChunkLoaded(i, j + 1) && ichunkprovider.isChunkLoaded(i + 1, j)) {
ichunkprovider.getChunkAt(ichunkprovider1, i, j);
}
if (ichunkprovider.isChunkLoaded(i - 1, j) && !ichunkprovider.getOrCreateChunk(i - 1, j).done && ichunkprovider.isChunkLoaded(i - 1, j + 1) && ichunkprovider.isChunkLoaded(i, j + 1) && ichunkprovider.isChunkLoaded(i - 1, j + 1)) {
ichunkprovider.getChunkAt(ichunkprovider1, i - 1, j);
}
if (ichunkprovider.isChunkLoaded(i, j - 1) && !ichunkprovider.getOrCreateChunk(i, j - 1).done && ichunkprovider.isChunkLoaded(i + 1, j - 1) && ichunkprovider.isChunkLoaded(i + 1, j - 1) && ichunkprovider.isChunkLoaded(i + 1, j)) {
ichunkprovider.getChunkAt(ichunkprovider1, i, j - 1);
}
if (ichunkprovider.isChunkLoaded(i - 1, j - 1) && !ichunkprovider.getOrCreateChunk(i - 1, j - 1).done && ichunkprovider.isChunkLoaded(i, j - 1) && ichunkprovider.isChunkLoaded(i - 1, j)) {
ichunkprovider.getChunkAt(ichunkprovider1, i - 1, j - 1);
}
}
public int c(int i, int j) {
int k = i | j << 4;
int l = this.c[k];
if (l == -999) {
2011-09-15 05:13:14 +02:00
2011-09-15 02:23:52 +02:00
int i1 = 128 - 1;
l = -1;
while (i1 > 0 && l == -1) {
int j1 = this.getTypeId(i, i1, j);
Material material = j1 == 0 ? Material.AIR : Block.byId[j1].material;
if (!material.isSolid() && !material.isLiquid()) {
--i1;
} else {
l = i1 + 1;
}
}
this.c[k] = l;
}
return l;
2011-02-01 23:49:28 +01:00
}
2011-03-31 22:40:00 +02:00
public void h() {
2011-09-15 02:23:52 +02:00
this.i();
2011-03-31 22:40:00 +02:00
}
2011-02-01 23:49:28 +01:00
}