Merge remote branch 'upstream/master'

This commit is contained in:
durron597
2011-01-05 04:54:39 -05:00
8 changed files with 519 additions and 19 deletions

View File

@@ -0,0 +1,155 @@
package net.minecraft.server;
import java.util.Random;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.LeavesDecayEvent;
public class BlockLeaves extends BlockLeavesBase {
private int c;
int b[];
protected BlockLeaves(int i, int j) {
super(i, j, Material.h, false);
c = j;
a(true);
}
public void b(World world, int i, int j, int k) {
int l = 1;
int i1 = l + 1;
if (world.a(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) {
for (int j1 = -l; j1 <= l; j1++) {
for (int k1 = -l; k1 <= l; k1++) {
for (int l1 = -l; l1 <= l; l1++) {
int i2 = world.a(i + j1, j + k1, k + l1);
if (i2 == Block.K.bh) {
world.c(i + j1, j + k1, k + l1, 7);
}
}
}
}
}
}
public void a(World world, int i, int j, int k, Random random) {
if (world.z) {
return;
}
if (world.b(i, j, k) == 7) {
byte byte0 = 4;
int l = byte0 + 1;
byte byte1 = 32;
int i1 = byte1 * byte1;
int j1 = byte1 / 2;
if (b == null) {
b = new int[byte1 * byte1 * byte1];
}
if (world.a(i - l, j - l, k - l, i + l, j + l, k + l)) {
for (int k1 = -byte0; k1 <= byte0; k1++) {
for (int j2 = -byte0; j2 <= byte0; j2++) {
for (int l2 = -byte0; l2 <= byte0; l2++) {
int j3 = world.a(i + k1, j + j2, k + l2);
if (j3 == Block.J.bh) {
b[(k1 + j1) * i1 + (j2 + j1) * byte1 + (l2 + j1)] = 0;
continue;
}
if (j3 == Block.K.bh) {
b[(k1 + j1) * i1 + (j2 + j1) * byte1 + (l2 + j1)] = -2;
} else {
b[(k1 + j1) * i1 + (j2 + j1) * byte1 + (l2 + j1)] = -1;
}
}
}
}
for (int l1 = 1; l1 <= 4; l1++) {
for (int k2 = -byte0; k2 <= byte0; k2++) {
for (int i3 = -byte0; i3 <= byte0; i3++) {
for (int k3 = -byte0; k3 <= byte0; k3++) {
if (b[(k2 + j1) * i1 + (i3 + j1) * byte1 + (k3 + j1)] != l1 - 1) {
continue;
}
if (b[((k2 + j1) - 1) * i1 + (i3 + j1) * byte1 + (k3 + j1)] == -2) {
b[((k2 + j1) - 1) * i1 + (i3 + j1) * byte1 + (k3 + j1)] = l1;
}
if (b[(k2 + j1 + 1) * i1 + (i3 + j1) * byte1 + (k3 + j1)] == -2) {
b[(k2 + j1 + 1) * i1 + (i3 + j1) * byte1 + (k3 + j1)] = l1;
}
if (b[(k2 + j1) * i1 + ((i3 + j1) - 1) * byte1 + (k3 + j1)] == -2) {
b[(k2 + j1) * i1 + ((i3 + j1) - 1) * byte1 + (k3 + j1)] = l1;
}
if (b[(k2 + j1) * i1 + (i3 + j1 + 1) * byte1 + (k3 + j1)] == -2) {
b[(k2 + j1) * i1 + (i3 + j1 + 1) * byte1 + (k3 + j1)] = l1;
}
if (b[(k2 + j1) * i1 + (i3 + j1) * byte1 + ((k3 + j1) - 1)] == -2) {
b[(k2 + j1) * i1 + (i3 + j1) * byte1 + ((k3 + j1) - 1)] = l1;
}
if (b[(k2 + j1) * i1 + (i3 + j1) * byte1 + (k3 + j1 + 1)] == -2) {
b[(k2 + j1) * i1 + (i3 + j1) * byte1 + (k3 + j1 + 1)] = l1;
}
}
}
}
}
}
int i2 = b[j1 * i1 + j1 * byte1 + j1];
if (i2 >= 0) {
world.b(i, j, k, 0);
} else {
g(world, i, j, k);
}
}
}
private void g(World world, int i, int j, int k) {
// Craftbukkit start
CraftServer server = ((WorldServer)world).getServer();
CraftWorld cworld = ((WorldServer)world).getWorld();
LeavesDecayEvent event = new LeavesDecayEvent(Type.LEAVES_DECAY, cworld.getBlockAt(i, j, k));
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
// Craftbukkit end
a_(world, i, j, k, world.b(i, j, k));
world.d(i, j, k, 0);
}
public int a(Random random) {
return random.nextInt(16) != 0 ? 0 : 1;
}
public int a(int i, Random random) {
return Block.y.bh;
}
public boolean a() {
return !a;
}
public void b(World world, int i, int j, int k, Entity entity) {
super.b(world, i, j, k, entity);
}
}

View File

@@ -0,0 +1,226 @@
package net.minecraft.server;
import java.io.IOException;
import java.util.*;
import org.bukkit.craftbukkit.CraftChunk;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.Event.Type;
import org.bukkit.event.world.ChunkLoadedEvent;
public class ChunkProviderServer
implements IChunkProvider {
private Set a;
private Chunk b;
private IChunkProvider c;
private IChunkLoader d;
private Map e;
private List f;
private WorldServer g;
public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) {
a = new HashSet();
e = new HashMap();
f = new ArrayList();
b = new Chunk(worldserver, new byte[32768], 0, 0);
b.q = true;
b.p = true;
g = worldserver;
d = ichunkloader;
c = ichunkprovider;
}
public boolean a(int i, int j) {
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j);
return e.containsKey(chunkcoordinates);
}
public void c(int i, int j) {
int k = (i * 16 + 8) - g.m;
int l = (j * 16 + 8) - g.o;
char c1 = '\200';
if (k < -c1 || k > c1 || l < -c1 || l > c1) {
a.add(new ChunkCoordinates(i, j));
}
}
public Chunk d(int i, int j) {
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j);
a.remove(new ChunkCoordinates(i, j));
Chunk chunk = (Chunk) e.get(chunkcoordinates);
if (chunk == null) {
chunk = e(i, j);
if (chunk == null) {
if (c == null) {
chunk = b;
} else {
chunk = c.b(i, j);
}
}
e.put(chunkcoordinates, chunk);
f.add(chunk);
chunk.c();
if (chunk != null) {
chunk.d();
}
// Craftbukkit start
CraftServer server = g.getServer();
if (server != null) {
/*
* If it's a new world, the first few chunks are generated inside
* the World constructor. We can't reliably alter that, so we have
* no way of creating a CraftWorld/CraftServer at that point.
*/
CraftWorld world = g.getWorld();
CraftChunk cchunk = world.updateChunk(i, j);
server.getPluginManager().callEvent(new ChunkLoadedEvent(Type.CHUNK_LOADED, cchunk));
}
// Craftbukkit end
if (!chunk.n && a(i + 1, j + 1) && a(i, j + 1) && a(i + 1, j)) {
a(this, i, j);
}
if (a(i - 1, j) && !b(i - 1, j).n && a(i - 1, j + 1) && a(i, j + 1) && a(i - 1, j)) {
a(this, i - 1, j);
}
if (a(i, j - 1) && !b(i, j - 1).n && a(i + 1, j - 1) && a(i, j - 1) && a(i + 1, j)) {
a(this, i, j - 1);
}
if (a(i - 1, j - 1) && !b(i - 1, j - 1).n && a(i - 1, j - 1) && a(i, j - 1) && a(i - 1, j)) {
a(this, i - 1, j - 1);
}
}
return chunk;
}
public Chunk b(int i, int j) {
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j);
Chunk chunk = (Chunk) e.get(chunkcoordinates);
if (chunk == null) {
if (g.x) {
return d(i, j);
} else {
return b;
}
} else {
return chunk;
}
}
private Chunk e(int i, int j) {
if (d == null) {
return null;
}
try {
Chunk chunk = d.a(g, i, j);
if (chunk != null) {
chunk.s = g.e;
}
return chunk;
} catch (Exception exception) {
exception.printStackTrace();
}
return null;
}
private void a(Chunk chunk) {
if (d == null) {
return;
}
try {
d.b(g, chunk);
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void b(Chunk chunk) {
if (d == null) {
return;
}
try {
chunk.s = g.e;
d.a(g, chunk);
} catch (Throwable ioexception) { // Craftbukkit: Cast down to compile
ioexception.printStackTrace();
}
}
public void a(IChunkProvider ichunkprovider, int i, int j) {
Chunk chunk = b(i, j);
if (!chunk.n) {
chunk.n = true;
if (c != null) {
c.a(ichunkprovider, i, j);
chunk.f();
}
}
}
public boolean a(boolean flag, IProgressUpdate iprogressupdate) {
int i = 0;
for (int j = 0; j < f.size(); j++) {
Chunk chunk = (Chunk) f.get(j);
if (flag && !chunk.p) {
a(chunk);
}
if (!chunk.a(flag)) {
continue;
}
b(chunk);
chunk.o = false;
if (++i == 24 && !flag) {
return false;
}
}
if (flag) {
if (d == null) {
return true;
}
d.b();
}
return true;
}
public boolean a() {
if (!g.C) {
for (int i = 0; i < 100; i++) {
if (!a.isEmpty()) {
ChunkCoordinates chunkcoordinates = (ChunkCoordinates) a.iterator().next();
Chunk chunk = b(chunkcoordinates.a, chunkcoordinates.b);
chunk.e();
b(chunk);
a(chunk);
a.remove(chunkcoordinates);
e.remove(chunkcoordinates);
f.remove(chunk);
}
}
if (d != null) {
d.a();
}
}
return c.a();
}
public boolean b() {
return !g.C;
}
}

View File

@@ -113,6 +113,12 @@ public class EntityMinecart extends Entity
// CraftBukkit end
}
// CraftBukkit start
public ItemStack[] getContents() {
return this.ak;
}
// CraftBukkit end
public AxisAlignedBB d(Entity entity) {
return entity.z;
}

View File

@@ -36,14 +36,14 @@ public class WorldServer extends World {
@Override
public boolean c(int i1, int j1, int k1, int l1) {
boolean result = super.c(i1, j1, k1, l1);
world.updateBlock(i1, j1, k1);
if (world != null) world.updateBlock(i1, j1, k1);
return result;
}
@Override
public boolean d(int i1, int j1, int k1, int l1) {
boolean result = super.d(i1, j1, k1, l1);
world.updateBlock(i1, j1, k1);
if (world != null) world.updateBlock(i1, j1, k1);
return result;
}
@@ -75,10 +75,12 @@ public class WorldServer extends World {
if (block != null) {
// CraftBukkit start
BlockPhysicsEvent event = new BlockPhysicsEvent(Event.Type.BLOCK_PHYSICS, world.getBlockAt(i1, j1, k1), l1);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
if (world != null) {
BlockPhysicsEvent event = new BlockPhysicsEvent(Event.Type.BLOCK_PHYSICS, world.getBlockAt(i1, j1, k1), l1);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
}
// CraftBukkit stop
@@ -101,17 +103,13 @@ public class WorldServer extends World {
if (axisalignedbb != null && !a(axisalignedbb)) {
return false;
}
// Craftbukkit - check this first as we dont want to allow the user to override this either
// Notch checks it after the check to see if block is water, lava, fire, portal
if (!(i1 > 0 && block == null)) return false;
boolean defaultReturn;
if (block == Block.A || block == Block.B || block == Block.C || block == Block.D || block == Block.ar || block == Block.aS) {
defaultReturn = true;
} else {
defaultReturn = block1.a(this, j1, k1, l1);
defaultReturn = (i1 > 0) && (block == null) && (block1.a(this, j1, k1, l1));
}
// Craftbukkit - If flag is true, it's natural, not user placement. Don't hook.