2010-12-29 00:52:29 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.io.File;
|
2011-01-11 09:25:13 +01:00
|
|
|
import java.util.*;
|
2011-01-01 09:12:39 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2010-12-30 23:07:54 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
2010-12-29 00:52:29 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftWorld;
|
2010-12-31 13:52:40 +01:00
|
|
|
import org.bukkit.event.Event;
|
2011-01-01 07:20:44 +01:00
|
|
|
import org.bukkit.event.Event.Type;
|
|
|
|
import org.bukkit.event.block.BlockCanBuildEvent;
|
2010-12-30 23:07:54 +01:00
|
|
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2010-12-29 00:52:29 +01:00
|
|
|
|
|
|
|
public class WorldServer extends World {
|
|
|
|
|
|
|
|
public ChunkProviderServer A;
|
|
|
|
public boolean B;
|
|
|
|
public boolean C;
|
|
|
|
private MinecraftServer D;
|
|
|
|
private MCHashTable E;
|
|
|
|
|
|
|
|
public WorldServer(MinecraftServer minecraftserver, File file, String s, int i) {
|
|
|
|
super(file, s, (new Random()).nextLong(), WorldProvider.a(i));
|
|
|
|
B = false;
|
|
|
|
E = new MCHashTable();
|
|
|
|
D = minecraftserver;
|
2010-12-30 05:37:32 +01:00
|
|
|
world = new CraftWorld(this); // CraftBukkit
|
2010-12-30 23:07:54 +01:00
|
|
|
server = minecraftserver.server; // CraftBukkit
|
2010-12-29 00:52:29 +01:00
|
|
|
}
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
public void f() {
|
|
|
|
super.f();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Entity entity, boolean flag) {
|
2011-01-14 14:31:10 +01:00
|
|
|
if (!D.m && ((entity instanceof EntityAnimals) || (entity instanceof EntityWaterMob))) {
|
|
|
|
entity.q();
|
2011-01-11 09:25:13 +01:00
|
|
|
}
|
|
|
|
if (entity.j == null || !(entity.j instanceof EntityPlayer)) {
|
|
|
|
super.a(entity, flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(Entity entity, boolean flag) {
|
|
|
|
super.a(entity, flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected IChunkProvider a(File file) {
|
|
|
|
A = new ChunkProviderServer(this, q.a(file), q.c());
|
|
|
|
return ((IChunkProvider) (A));
|
|
|
|
}
|
|
|
|
|
|
|
|
public List d(int i, int j, int k, int l, int i1, int j1) {
|
|
|
|
ArrayList arraylist = new ArrayList();
|
|
|
|
|
|
|
|
for (int k1 = 0; k1 < c.size(); k1++) {
|
|
|
|
TileEntity tileentity = (TileEntity) c.get(k1);
|
|
|
|
|
|
|
|
if (tileentity.b >= i && tileentity.c >= j && tileentity.d >= k && tileentity.b < l && tileentity.c < i1 && tileentity.d < j1) {
|
|
|
|
((List) (arraylist)).add(((tileentity)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ((List) (arraylist));
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(EntityPlayer entityplayer, int i, int j, int k) {
|
|
|
|
int l = (int) MathHelper.e(i - m);
|
|
|
|
int i1 = (int) MathHelper.e(k - o);
|
|
|
|
|
|
|
|
if (l > i1) {
|
|
|
|
i1 = l;
|
|
|
|
}
|
|
|
|
return i1 > 16 || D.f.g(entityplayer.aw);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void b(Entity entity) {
|
|
|
|
super.b(entity);
|
|
|
|
E.a(entity.g, ((entity)));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void c(Entity entity) {
|
|
|
|
super.c(entity);
|
|
|
|
E.d(entity.g);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Entity a(int i) {
|
|
|
|
return (Entity) E.a(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Entity entity, byte byte0) {
|
|
|
|
Packet38 packet38 = new Packet38(entity.g, byte0);
|
|
|
|
|
|
|
|
D.k.b(entity, ((Packet) (packet38)));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Explosion a(Entity entity, double d1, double d2, double d3, float f1, boolean flag) {
|
|
|
|
Explosion explosion = super.a(entity, d1, d2, d3, f1, flag);
|
|
|
|
|
|
|
|
D.f.a(d1, d2, d3, 64D, ((Packet) (new Packet60(d1, d2, d3, f1, explosion.g))));
|
|
|
|
return explosion;
|
|
|
|
}
|
|
|
|
|
2011-01-14 22:22:14 +01:00
|
|
|
public void c(int i, int j, int k, int l, int i1) {
|
|
|
|
super.c(i, j, k, l, i1);
|
|
|
|
D.f.a(i, j, k, 64D, ((Packet) (new Packet54(i, j, k, l, i1))));
|
|
|
|
}
|
|
|
|
|
2010-12-29 00:52:29 +01:00
|
|
|
// CraftBukkit start
|
2011-01-11 09:25:13 +01:00
|
|
|
private final CraftWorld world;
|
|
|
|
private final CraftServer server;
|
|
|
|
|
2010-12-29 00:52:29 +01:00
|
|
|
@Override
|
2011-01-14 14:31:10 +01:00
|
|
|
public boolean d(int i1, int j1, int k1, int l1) {
|
|
|
|
boolean result = super.d(i1, j1, k1, l1);
|
2011-01-08 03:03:41 +01:00
|
|
|
if ((result) && (world != null)) world.updateBlock(i1, j1, k1);
|
2010-12-29 00:52:29 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-01-14 14:31:10 +01:00
|
|
|
public boolean b(int i1, int j1, int k1, int l1) {
|
|
|
|
boolean result = super.b(i1, j1, k1, l1);
|
2011-01-08 03:03:41 +01:00
|
|
|
if ((result) && (world != null)) world.updateBlock(i1, j1, k1);
|
2010-12-29 00:52:29 +01:00
|
|
|
return result;
|
|
|
|
}
|
2010-12-30 05:37:32 +01:00
|
|
|
|
2011-01-20 01:16:57 +01:00
|
|
|
@Override
|
|
|
|
public boolean a(int i1, int j1, int k1, int l1, int i2) {
|
|
|
|
boolean result = super.a(i1, j1, k1, l1, i2);
|
|
|
|
if ((result) && (world != null)) world.updateBlock(i1, j1, k1);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-01-08 03:03:41 +01:00
|
|
|
@Override
|
|
|
|
public void a(int i1, int j1, int k1, TileEntity tileentity) {
|
|
|
|
super.a(i1, j1, k1, tileentity);
|
|
|
|
if (world != null) world.updateBlock(i1, j1, k1);
|
|
|
|
}
|
|
|
|
|
2010-12-30 05:37:32 +01:00
|
|
|
public CraftWorld getWorld() {
|
|
|
|
return world;
|
|
|
|
}
|
2011-01-01 14:06:04 +01:00
|
|
|
|
2011-01-01 04:59:30 +01:00
|
|
|
public CraftServer getServer() {
|
2011-01-01 14:06:04 +01:00
|
|
|
return server;
|
2010-12-31 22:58:18 +01:00
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2010-12-29 00:52:29 +01:00
|
|
|
|
2011-01-02 00:36:24 +01:00
|
|
|
// XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED!
|
2011-01-11 09:25:13 +01:00
|
|
|
// XXX: done because it calls private k()
|
2010-12-30 23:07:54 +01:00
|
|
|
@Override
|
2011-01-14 14:31:10 +01:00
|
|
|
public void h(int i1, int j1, int k1, int l1) {
|
|
|
|
l(i1 - 1, j1, k1, l1);
|
|
|
|
l(i1 + 1, j1, k1, l1);
|
|
|
|
l(i1, j1 - 1, k1, l1);
|
|
|
|
l(i1, j1 + 1, k1, l1);
|
|
|
|
l(i1, j1, k1 - 1, l1);
|
|
|
|
l(i1, j1, k1 + 1, l1);
|
2010-12-30 23:07:54 +01:00
|
|
|
}
|
|
|
|
|
2011-01-02 00:36:24 +01:00
|
|
|
// XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED!
|
2011-01-14 14:31:10 +01:00
|
|
|
private void l(int i1, int j1, int k1, int l1) {
|
2010-12-30 23:07:54 +01:00
|
|
|
if (i || z) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Block block = Block.m[a(i1, j1, k1)];
|
|
|
|
|
|
|
|
if (block != null) {
|
|
|
|
// CraftBukkit start
|
2011-01-04 22:13:59 +01:00
|
|
|
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;
|
|
|
|
}
|
2010-12-30 23:07:54 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit stop
|
|
|
|
|
|
|
|
block.b(this, i1, j1, k1, l1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-02 00:36:24 +01:00
|
|
|
// XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED!
|
2011-01-11 09:25:13 +01:00
|
|
|
@Override
|
2011-01-01 07:39:28 +01:00
|
|
|
public boolean a(int i1, int j1, int k1, int l1, boolean flag) {
|
2011-01-02 00:48:58 +01:00
|
|
|
int i2 = a(j1, k1, l1);
|
|
|
|
Block block = Block.m[i2];
|
|
|
|
Block block1 = Block.m[i1];
|
|
|
|
AxisAlignedBB axisalignedbb = block1.d(this, j1, k1, l1);
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
axisalignedbb = null;
|
|
|
|
}
|
|
|
|
if (axisalignedbb != null && !a(axisalignedbb)) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
// Craftbukkit start - We dont want to allow the user to override the bounding box check
|
2011-01-02 00:48:58 +01:00
|
|
|
boolean defaultReturn;
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-01-02 00:48:58 +01:00
|
|
|
if (block == Block.A || block == Block.B || block == Block.C || block == Block.D || block == Block.ar || block == Block.aS) {
|
|
|
|
defaultReturn = true;
|
|
|
|
} else {
|
2011-01-04 17:17:05 +01:00
|
|
|
defaultReturn = (i1 > 0) && (block == null) && (block1.a(this, j1, k1, l1));
|
2011-01-02 00:48:58 +01:00
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-01-02 00:48:58 +01:00
|
|
|
// Craftbukkit - If flag is true, it's natural, not user placement. Don't hook.
|
2011-01-01 14:06:04 +01:00
|
|
|
if (!flag) {
|
2011-01-02 00:48:58 +01:00
|
|
|
BlockCanBuildEvent event = new BlockCanBuildEvent(Type.BLOCK_CANBUILD, getWorld().getBlockAt(j1, k1, l1), i1, defaultReturn);
|
2011-01-01 14:06:04 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
return event.isBuildable();
|
|
|
|
} else {
|
2011-01-02 00:48:58 +01:00
|
|
|
return defaultReturn;
|
2011-01-01 14:06:04 +01:00
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2010-12-29 00:52:29 +01:00
|
|
|
}
|
|
|
|
}
|