2010-12-29 00:52:29 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2011-01-01 09:12:39 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-30 22:53:57 +01:00
|
|
|
import org.bukkit.BlockChangeDelegate;
|
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;
|
2011-04-26 01:47:25 +02:00
|
|
|
import org.bukkit.event.weather.LightningStrikeEvent;
|
2010-12-29 00:52:29 +01:00
|
|
|
|
2011-01-30 22:53:57 +01:00
|
|
|
public class WorldServer extends World implements BlockChangeDelegate {
|
|
|
|
// CraftBukkit end
|
2010-12-29 00:52:29 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public ChunkProviderServer chunkProviderServer;
|
|
|
|
public boolean weirdIsOpCache = false;
|
2011-04-20 22:47:26 +02:00
|
|
|
public boolean y;
|
2011-04-20 19:05:14 +02:00
|
|
|
public final MinecraftServer server; // CraftBukkit - private -> public final
|
2011-04-20 22:47:26 +02:00
|
|
|
private EntityList A = new EntityList();
|
2010-12-29 00:52:29 +01:00
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, long j) {
|
|
|
|
super(idatamanager, s, j, WorldProvider.a(i));
|
2011-04-20 19:05:14 +02:00
|
|
|
this.server = minecraftserver;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
// CraftBukkit start
|
2011-04-20 19:05:14 +02:00
|
|
|
this.cserver = minecraftserver.server;
|
2011-02-08 13:48:29 +01:00
|
|
|
this.world = new CraftWorld(this);
|
2011-02-07 10:43:50 +01:00
|
|
|
this.manager = new PlayerManager(minecraftserver, this);
|
2011-04-30 00:34:37 +02:00
|
|
|
this.pvpMode = minecraftserver.pvpMode;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public PlayerManager manager;
|
2011-01-29 22:50:29 +01:00
|
|
|
private final CraftWorld world;
|
2011-04-20 19:05:14 +02:00
|
|
|
private final CraftServer cserver;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
public CraftWorld getWorld() {
|
|
|
|
return world;
|
|
|
|
}
|
|
|
|
|
|
|
|
public CraftServer getServer() {
|
2011-04-20 19:05:14 +02:00
|
|
|
return cserver;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void entityJoinedWorld(Entity entity, boolean flag) {
|
2011-02-23 03:37:56 +01:00
|
|
|
// CraftBukkit start -- We prevent spawning in general, so this butchering is not needed
|
2011-04-20 19:05:14 +02:00
|
|
|
//if (!this.server.spawnAnimals && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) {
|
|
|
|
// entity.die();
|
2011-02-13 01:21:50 +01:00
|
|
|
//}
|
|
|
|
// CraftBukkit end
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (entity.passenger == null || !(entity.passenger instanceof EntityHuman)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
super.entityJoinedWorld(entity, flag);
|
2011-01-11 09:25:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void vehicleEnteredWorld(Entity entity, boolean flag) {
|
|
|
|
super.entityJoinedWorld(entity, flag);
|
2011-01-11 09:25:13 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
protected IChunkProvider b() {
|
2011-04-20 22:47:26 +02:00
|
|
|
IChunkLoader ichunkloader = this.r.a(this.worldProvider);
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.chunkProviderServer = new ChunkProviderServer(this, ichunkloader, this.worldProvider.c());
|
|
|
|
return this.chunkProviderServer;
|
2011-01-11 09:25:13 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public List getTileEntities(int i, int j, int k, int l, int i1, int j1) {
|
2011-01-11 09:25:13 +01:00
|
|
|
ArrayList arraylist = new ArrayList();
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
for (int k1 = 0; k1 < this.c.size(); ++k1) {
|
|
|
|
TileEntity tileentity = (TileEntity) this.c.get(k1);
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (tileentity.e >= i && tileentity.f >= j && tileentity.g >= k && tileentity.e < l && tileentity.f < i1 && tileentity.g < j1) {
|
2011-01-29 22:50:29 +01:00
|
|
|
arraylist.add(tileentity);
|
2011-01-11 09:25:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
return arraylist;
|
2011-01-11 09:25:13 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public boolean a(EntityHuman entityhuman, int i, int j, int k) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int l = (int) MathHelper.abs((float) (i - this.worldData.c()));
|
|
|
|
int i1 = (int) MathHelper.abs((float) (k - this.worldData.e()));
|
2011-01-11 09:25:13 +01:00
|
|
|
|
|
|
|
if (l > i1) {
|
|
|
|
i1 = l;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit -- Configurable spawn protection
|
2011-04-20 19:05:14 +02:00
|
|
|
return i1 > this.server.spawnProtection || this.server.serverConfigurationManager.isOp(entityhuman.name);
|
2011-01-11 09:25:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void c(Entity entity) {
|
|
|
|
super.c(entity);
|
2011-04-20 22:47:26 +02:00
|
|
|
this.A.a(entity.id, entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void d(Entity entity) {
|
|
|
|
super.d(entity);
|
|
|
|
this.A.d(entity.id);
|
2011-01-11 09:25:13 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public Entity getEntity(int i) {
|
2011-04-20 22:47:26 +02:00
|
|
|
return (Entity) this.A.a(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(Entity entity) {
|
|
|
|
if (super.a(entity)) {
|
2011-04-26 01:47:25 +02:00
|
|
|
CraftServer server = cserver;
|
|
|
|
|
|
|
|
LightningStrikeEvent lightning = new LightningStrikeEvent((org.bukkit.World) world, entity.getBukkitEntity());
|
|
|
|
server.getPluginManager().callEvent(lightning);
|
|
|
|
if (!lightning.isCancelled()) {
|
|
|
|
this.server.serverConfigurationManager.a(entity.locX, entity.locY, entity.locZ, 512.0D, new Packet71Weather(entity));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2011-04-20 22:47:26 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Entity entity, byte b0) {
|
|
|
|
Packet38EntityStatus packet38entitystatus = new Packet38EntityStatus(entity.id, b0);
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.server.tracker.b(entity, packet38entitystatus);
|
2011-01-11 09:25:13 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag) {
|
|
|
|
Explosion explosion = super.createExplosion(entity, d0, d1, d2, f, flag);
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
if (explosion.wasCanceled) {
|
2011-02-07 19:37:08 +01:00
|
|
|
return explosion;
|
|
|
|
}
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2011-02-07 19:37:08 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.server.serverConfigurationManager.a(d0, d1, d2, 64.0D, new Packet60Explosion(d0, d1, d2, f, explosion.g));
|
2011-01-11 09:25:13 +01:00
|
|
|
return explosion;
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void d(int i, int j, int k, int l, int i1) {
|
|
|
|
super.d(i, j, k, l, i1);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.server.serverConfigurationManager.a((double) i, (double) j, (double) k, 64.0D, new Packet54PlayNoteBlock(i, j, k, l, i1));
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void saveLevel() {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.r.e();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void i() {
|
|
|
|
boolean flag = this.v();
|
|
|
|
|
|
|
|
super.i();
|
|
|
|
if (flag != this.v()) {
|
|
|
|
if (flag) {
|
|
|
|
this.server.serverConfigurationManager.sendAll(new Packet70Bed(2));
|
|
|
|
} else {
|
|
|
|
this.server.serverConfigurationManager.sendAll(new Packet70Bed(1));
|
|
|
|
}
|
|
|
|
}
|
2011-01-14 22:22:14 +01:00
|
|
|
}
|
2010-12-29 00:52:29 +01:00
|
|
|
}
|