Update for 1.4_00_01 -- if you bypassed Bukkit, you will most likely break.

This commit is contained in:
Erik Broes
2011-04-20 19:05:14 +02:00
parent ac9f297445
commit 483a878b8b
116 changed files with 3155 additions and 3207 deletions

View File

@@ -34,9 +34,9 @@ public class CraftWorld implements World {
public CraftWorld(WorldServer world) {
this.world = world;
this.server = world.getServer();
this.provider = world.u;
this.provider = world.chunkProviderServer;
if (world.m instanceof WorldProviderHell) {
if (world.worldProvider instanceof WorldProviderHell) {
environment = Environment.NETHER;
} else {
environment = Environment.NORMAL;
@@ -63,18 +63,18 @@ public class CraftWorld implements World {
}
public int getHighestBlockYAt(int x, int z) {
return world.d(x, z);
return world.getHighestBlockYAt(x, z);
}
public Location getSpawnLocation() {
ChunkCoordinates spawn = world.m();
return new Location(this, spawn.a, spawn.b, spawn.c);
ChunkCoordinates spawn = world.getSpawn();
return new Location(this, spawn.x, spawn.y, spawn.z);
}
public boolean setSpawnLocation(int x, int y, int z) {
try {
Location previousLocation = getSpawnLocation();
world.q.a(x, y, z);
world.worldData.setSpawn(x, y, z);
// Notify anyone who's listening.
SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
@@ -85,9 +85,9 @@ public class CraftWorld implements World {
return false;
}
}
public Chunk getChunkAt(int x, int z) {
return this.provider.c(x, z).bukkitChunk;
return this.provider.getChunkAt(x,z).bukkitChunk;
}
public Chunk getChunkAt(Block block) {
@@ -95,11 +95,11 @@ public class CraftWorld implements World {
}
public boolean isChunkLoaded(int x, int z) {
return provider.a( x, z );
return provider.isChunkLoaded( x, z );
}
public Chunk[] getLoadedChunks() {
Object[] chunks = provider.e.values().toArray();
Object[] chunks = provider.chunks.values().toArray();
org.bukkit.Chunk[] craftChunks = new CraftChunk[chunks.length];
for (int i = 0; i < chunks.length; i++) {
@@ -131,7 +131,7 @@ public class CraftWorld implements World {
return false;
}
provider.d(x, z);
provider.queueUnload(x, z);
return true;
}
@@ -140,34 +140,34 @@ public class CraftWorld implements World {
if (safe && isChunkInUse(x, z)) {
return false;
}
net.minecraft.server.Chunk chunk = provider.b(x, z);
net.minecraft.server.Chunk chunk = provider.getOrCreateChunk(x, z);
if (save) {
chunk.e();
provider.b(chunk);
provider.a(chunk);
chunk.removeEntities();
provider.saveChunk(chunk);
provider.saveChunkNOP(chunk);
}
preserveChunk((CraftChunk)chunk.bukkitChunk);
provider.a.remove(x, z);
provider.e.remove(x, z);
provider.f.remove(chunk);
preserveChunk((CraftChunk) chunk.bukkitChunk);
provider.unloadQueue.remove(x, z);
provider.chunks.remove(x, z);
provider.chunkList.remove(chunk);
return true;
}
public boolean regenerateChunk(int x, int z) {
unloadChunk(x, z, false, false);
provider.a.remove(x, z);
provider.unloadQueue.remove(x, z);
net.minecraft.server.Chunk chunk = null;
if (provider.c == null) {
chunk = provider.b;
if (provider.chunkProvider == null) {
chunk = provider.emptyChunk;
} else {
chunk = provider.c.b(x, z);
chunk = provider.chunkProvider.getOrCreateChunk(x, z);
}
chunkLoadPostProcess(chunk, x, z);
@@ -191,9 +191,9 @@ public class CraftWorld implements World {
// The server will compress the chunk and send it to all clients
for(int xx = px; xx < (px + 16); xx++) {
world.g(xx, 0, pz);
world.notify(xx, 0, pz);
}
world.g(px, 127, pz+15);
world.notify(px, 127, pz+15);
return true;
}
@@ -201,10 +201,10 @@ public class CraftWorld implements World {
public boolean isChunkInUse(int x, int z) {
Player[] players = server.getOnlinePlayers();
for (Player player : players) {
Location loc = player.getLocation();
if (loc.getWorld() != provider.g.getWorld()) {
if (loc.getWorld() != provider.world.getWorld()) {
continue;
}
@@ -221,14 +221,14 @@ public class CraftWorld implements World {
public boolean loadChunk(int x, int z, boolean generate) {
if (generate) {
// Use the default variant of loadChunk when generate == true.
return provider.c(x, z) != null;
return provider.getChunkAt(x, z) != null;
}
provider.a.remove(x, z);
net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) provider.e.get(x, z);
provider.unloadQueue.remove(x, z);
net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) provider.chunks.get(x, z);
if (chunk == null) {
chunk = provider.e(x, z);
chunk = provider.loadChunk(x, z);
chunkLoadPostProcess(chunk, x, z);
}
@@ -237,26 +237,26 @@ public class CraftWorld implements World {
private void chunkLoadPostProcess(net.minecraft.server.Chunk chunk, int x, int z) {
if (chunk != null) {
provider.e.put(x, z, chunk);
provider.f.add(chunk);
provider.chunks.put(x, z, chunk);
provider.chunkList.add(chunk);
chunk.c();
chunk.d();
chunk.loadNOP();
chunk.addEntities();
if (!chunk.n && provider.a(x + 1, z + 1) && provider.a(x, z + 1) && provider.a(x + 1, z)) {
provider.a(provider, x, z);
if (!chunk.done && provider.isChunkLoaded(x + 1, z + 1) && provider.isChunkLoaded(x, z + 1) && provider.isChunkLoaded(x + 1, z)) {
provider.getChunkAt(provider, x, z);
}
if (provider.a(x - 1, z) && !provider.b(x - 1, z).n && provider.a(x - 1, z + 1) && provider.a(x, z + 1) && provider.a(x - 1, z)) {
provider.a(provider, x - 1, z);
if (provider.isChunkLoaded(x - 1, z) && !provider.getOrCreateChunk(x - 1, z).done && provider.isChunkLoaded(x - 1, z + 1) && provider.isChunkLoaded(x, z + 1) && provider.isChunkLoaded(x - 1, z)) {
provider.getChunkAt(provider, x - 1, z);
}
if (provider.a(x, z - 1) && !provider.b(x, z - 1).n && provider.a(x + 1, z - 1) && provider.a(x, z - 1) && provider.a(x + 1, z)) {
provider.a(provider, x, z - 1);
if (provider.isChunkLoaded(x, z - 1) && !provider.getOrCreateChunk(x, z - 1).done && provider.isChunkLoaded(x + 1, z - 1) && provider.isChunkLoaded(x, z - 1) && provider.isChunkLoaded(x + 1, z)) {
provider.getChunkAt(provider, x, z - 1);
}
if (provider.a(x - 1, z - 1) && !provider.b(x - 1, z - 1).n && provider.a(x - 1, z - 1) && provider.a(x, z - 1) && provider.a(x - 1, z)) {
provider.a(provider, x - 1, z - 1);
if (provider.isChunkLoaded(x - 1, z - 1) && !provider.getOrCreateChunk(x - 1, z - 1).done && provider.isChunkLoaded(x - 1, z - 1) && provider.isChunkLoaded(x, z - 1) && provider.isChunkLoaded(x - 1, z)) {
provider.getChunkAt(provider, x - 1, z - 1);
}
}
}
@@ -281,17 +281,17 @@ public class CraftWorld implements World {
item.getDurability()
);
EntityItem entity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), stack);
entity.c = 10;
world.a(entity);
entity.pickupDelay = 10;
world.addEntity(entity);
//TODO this is inconsistent with how Entity.getBukkitEntity() works.
// However, this entity is not at the moment backed by a server entity class so it may be left.
return new CraftItem(world.getServer(), entity);
}
public org.bukkit.entity.Item dropItemNaturally(Location loc, ItemStack item) {
double xs = world.k.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
double ys = world.k.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
double zs = world.k.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
double xs = world.random.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
double ys = world.random.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
double zs = world.random.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
loc = loc.clone();
loc.setX(loc.getX() + xs);
loc.setY(loc.getY() + ys);
@@ -301,8 +301,8 @@ public class CraftWorld implements World {
public Arrow spawnArrow(Location loc, Vector velocity, float speed, float spread) {
EntityArrow arrow = new EntityArrow(world);
arrow.c(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
world.a(arrow);
arrow.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
world.addEntity(arrow);
arrow.a(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread);
return (Arrow) arrow.getBukkitEntity();
}
@@ -315,7 +315,7 @@ public class CraftWorld implements World {
loc.getZ(),
CraftMinecart.Type.Minecart.getId()
);
world.a(minecart);
world.addEntity(minecart);
return (Minecart) minecart.getBukkitEntity();
}
@@ -327,7 +327,7 @@ public class CraftWorld implements World {
loc.getZ(),
CraftMinecart.Type.StorageMinecart.getId()
);
world.a(minecart);
world.addEntity(minecart);
return (StorageMinecart) minecart.getBukkitEntity();
}
@@ -339,13 +339,13 @@ public class CraftWorld implements World {
loc.getZ(),
CraftMinecart.Type.PoweredMinecart.getId()
);
world.a(minecart);
world.addEntity(minecart);
return (PoweredMinecart) minecart.getBukkitEntity();
}
public Boat spawnBoat(Location loc) {
EntityBoat boat = new EntityBoat(world, loc.getX(), loc.getY(), loc.getZ());
world.a(boat);
world.addEntity(boat);
return (Boat) boat.getBukkitEntity();
}
@@ -353,9 +353,9 @@ public class CraftWorld implements World {
LivingEntity creature;
try {
EntityLiving entityCreature = (EntityLiving) EntityTypes.a(creatureType.getName(), world);
entityCreature.a(loc.getX(), loc.getY(), loc.getZ());
entityCreature.setPosition(loc.getX(), loc.getY(), loc.getZ());
creature = (LivingEntity) CraftEntity.getEntity(server, entityCreature);
world.a(entityCreature);
world.addEntity(entityCreature);
} catch (Exception e) {
// if we fail, for any reason, return null.
creature = null;
@@ -388,11 +388,11 @@ public class CraftWorld implements World {
}
public String getName() {
return world.q.j;
return world.worldData.name;
}
public long getId() {
return world.q.b();
return world.worldData.b();
}
@Override
@@ -413,16 +413,16 @@ public class CraftWorld implements World {
}
public long getFullTime() {
return world.l();
return world.getTime();
}
public void setFullTime(long time) {
world.a(time);
world.setTime(time);
//Forces the client to update to the new time immediately
for (Player p: getPlayers()) {
CraftPlayer cp = (CraftPlayer) p;
cp.getHandle().a.b(new Packet4UpdateTime(time));
cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(time));
}
}
@@ -485,7 +485,7 @@ public class CraftWorld implements World {
public List<Entity> getEntities() {
List<Entity> list = new ArrayList<Entity>();
for (Object o: world.b) {
for (Object o: world.entityList) {
if (o instanceof net.minecraft.server.Entity) {
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o;
Entity bukkitEntity = mcEnt.getBukkitEntity();
@@ -503,7 +503,7 @@ public class CraftWorld implements World {
public List<LivingEntity> getLivingEntities() {
List<LivingEntity> list = new ArrayList<LivingEntity>();
for (Object o: world.b) {
for (Object o: world.entityList) {
if (o instanceof net.minecraft.server.Entity) {
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o;
Entity bukkitEntity = mcEnt.getBukkitEntity();
@@ -521,11 +521,11 @@ public class CraftWorld implements World {
public List<Player> getPlayers() {
List<Player> list = new ArrayList<Player>();
for (Object o : world.b) {
for (Object o : world.entityList) {
if (o instanceof net.minecraft.server.Entity) {
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o;
Entity bukkitEntity = mcEnt.getBukkitEntity();
if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) {
list.add((Player)bukkitEntity);
}
@@ -537,9 +537,9 @@ public class CraftWorld implements World {
public void save() {
// Writes level.dat
world.t();
world.saveLevel();
// Saves all chunks/regions
world.o.a(true, null);
world.chunkProvider.saveChunks(true, null);
}
}