Generic cleanup

This commit is contained in:
Erik Broes 2011-06-12 00:02:58 +02:00
parent 938db4de2d
commit 96b1b8a10c
37 changed files with 667 additions and 635 deletions

View File

@ -114,10 +114,8 @@ public class BlockDispenser extends BlockContainer {
if (itemstack == null) { if (itemstack == null) {
world.e(1001, i, j, k, 0); world.e(1001, i, j, k, 0);
} else { } else {
double d3;
// CraftBukkit start // CraftBukkit start
d3 = random.nextDouble() * 0.1D + 0.2D; double d3 = random.nextDouble() * 0.1D + 0.2D;
double motX = (double) b0 * d3; double motX = (double) b0 * d3;
double motY = 0.20000000298023224D; double motY = 0.20000000298023224D;
double motZ = (double) b1 * d3; double motZ = (double) b1 * d3;
@ -167,9 +165,9 @@ public class BlockDispenser extends BlockContainer {
world.e(1002, i, j, k, 0); world.e(1002, i, j, k, 0);
} else { } else {
EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack); EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack);
// CraftBukkit start // CraftBukkit start
d3 = random.nextDouble() * 0.1D + 0.2D; // double d3 = random.nextDouble() * 0.1D + 0.2D; // Moved up
entityitem.motX = motX; entityitem.motX = motX;
entityitem.motY = motY; entityitem.motY = motY;
entityitem.motZ = motZ; entityitem.motZ = motZ;

View File

@ -177,8 +177,8 @@ public class BlockDoor extends Block {
int power = block.getBlockPower(); int power = block.getBlockPower();
int powerTop = blockTop.getBlockPower(); int powerTop = blockTop.getBlockPower();
if (powerTop > power) power = powerTop; if (powerTop > power) power = powerTop;
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, (world.getData(i, j, k) & 4) > 0 ? 15 : 0, power);
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, (world.getData(i, j, k) & 4) > 0 ? 15: 0, power);
server.getPluginManager().callEvent(eventRedstone); server.getPluginManager().callEvent(eventRedstone);
flag1 = eventRedstone.getNewCurrent() > 0; flag1 = eventRedstone.getNewCurrent() > 0;

View File

@ -126,8 +126,9 @@ public class BlockFlowing extends BlockFluids {
} }
// CraftBukkit start - all four cardinal directions. Do not change the order! // CraftBukkit start - all four cardinal directions. Do not change the order!
BlockFace[] faces = new BlockFace[]{ BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST }; BlockFace[] faces = new BlockFace[] { BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST };
int index = 0; int index = 0;
for (BlockFace currentFace: faces) { for (BlockFace currentFace: faces) {
if (aboolean[index]) { if (aboolean[index]) {
BlockFromToEvent event = new BlockFromToEvent(source, currentFace); BlockFromToEvent event = new BlockFromToEvent(source, currentFace);

View File

@ -2,10 +2,12 @@ package net.minecraft.server;
import java.util.Random; import java.util.Random;
// CraftBukkit start
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.event.entity.EntityPortalEnterEvent; import org.bukkit.event.entity.EntityPortalEnterEvent;
// CraftBukkit end
public class BlockPortal extends BlockBreakable { public class BlockPortal extends BlockBreakable {
@ -141,9 +143,10 @@ public class BlockPortal extends BlockBreakable {
if (entity.vehicle == null && entity.passenger == null) { if (entity.vehicle == null && entity.passenger == null) {
// CraftBukkit start - Entity in portal // CraftBukkit start - Entity in portal
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(craftWorld,i, j, k)); EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(craftWorld, i, j, k));
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
// CraftBukkit end // CraftBukkit end
entity.O(); entity.O();
} }
} }

View File

@ -108,14 +108,15 @@ public class BlockPressurePlate extends Block {
for (Object object: list) { for (Object object: list) {
if (object != null) { if (object != null) {
Cancellable cancellable; Cancellable cancellable;
if (object instanceof EntityHuman) { if (object instanceof EntityHuman) {
cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, Action.PHYSICAL, i, j, k, -1, null); cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, Action.PHYSICAL, i, j, k, -1, null);
} else if (object instanceof Entity) {
cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), ((WorldServer) world).getWorld().getBlockAt(i, j, k));
((CraftServer) Bukkit.getServer()).getPluginManager().callEvent((EntityInteractEvent) cancellable);
} else {
continue;
} }
else if (object instanceof Entity) {
cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), ((WorldServer)world).getWorld().getBlockAt(i, j, k));
((CraftServer)Bukkit.getServer()).getPluginManager().callEvent((EntityInteractEvent) cancellable);
}
else continue;
if (cancellable.isCancelled()) { if (cancellable.isCancelled()) {
return; return;
} }

View File

@ -61,7 +61,7 @@ public class BlockSoil extends Block {
cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, Action.PHYSICAL, i, j, k, -1, null); cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, Action.PHYSICAL, i, j, k, -1, null);
} else { } else {
cancellable = new EntityInteractEvent(entity.getBukkitEntity(), ((WorldServer) world).getWorld().getBlockAt(i, j, k)); cancellable = new EntityInteractEvent(entity.getBukkitEntity(), ((WorldServer) world).getWorld().getBlockAt(i, j, k));
((CraftServer)Bukkit.getServer()).getPluginManager().callEvent((EntityInteractEvent) cancellable); ((CraftServer) Bukkit.getServer()).getPluginManager().callEvent((EntityInteractEvent) cancellable);
} }
if (cancellable.isCancelled()) { if (cancellable.isCancelled()) {

View File

@ -362,9 +362,9 @@ public class Chunk {
if (i != this.x || j != this.z) { if (i != this.x || j != this.z) {
System.out.println("Wrong location! " + entity); System.out.println("Wrong location! " + entity);
// Thread.dumpStack(); // CraftBukkit
// CraftBukkit // CraftBukkit
System.out.println("" + entity.locX + "," + entity.locZ + "(" + i + "," + j + ") vs " + this.x + "," + this.z); System.out.println("" + entity.locX + "," + entity.locZ + "(" + i + "," + j + ") vs " + this.x + "," + this.z);
// Thread.dumpStack(); // CraftBukkit
} }
int k = MathHelper.floor(entity.locY / 16.0D); int k = MathHelper.floor(entity.locY / 16.0D);

View File

@ -6,10 +6,10 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random;
import java.util.Set; import java.util.Set;
// CraftBukkit start // CraftBukkit start
import java.util.Random;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.craftbukkit.CraftChunk; import org.bukkit.craftbukkit.CraftChunk;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
@ -117,7 +117,7 @@ public class ChunkProviderServer implements IChunkProvider {
chunk = chunk == null ? (!this.world.isLoading && !this.a ? this.emptyChunk : this.getChunkAt(i, j)) : chunk; chunk = chunk == null ? (!this.world.isLoading && !this.a ? this.emptyChunk : this.getChunkAt(i, j)) : chunk;
if (chunk == this.emptyChunk) return chunk; if (chunk == this.emptyChunk) return chunk;
if (i != chunk.x || j != chunk.z) { if (i != chunk.x || j != chunk.z) {
MinecraftServer.log.info("Chunk (" + chunk.x + ", " + chunk.z +") stored at (" + i + ", " + j + ")"); MinecraftServer.log.info("Chunk (" + chunk.x + ", " + chunk.z + ") stored at (" + i + ", " + j + ")");
MinecraftServer.log.info(chunk.getClass().getName()); MinecraftServer.log.info(chunk.getClass().getName());
Throwable ex = new Throwable(); Throwable ex = new Throwable();
ex.fillInStackTrace(); ex.fillInStackTrace();
@ -175,7 +175,7 @@ public class ChunkProviderServer implements IChunkProvider {
if (this.chunkProvider != null) { if (this.chunkProvider != null) {
this.chunkProvider.getChunkAt(ichunkprovider, i, j); this.chunkProvider.getChunkAt(ichunkprovider, i, j);
// Craftbukkit start // CraftBukkit start
BlockSand.a = true; BlockSand.a = true;
Random random = new Random(); Random random = new Random();
random.setSeed(world.getSeed()); random.setSeed(world.getSeed());
@ -186,7 +186,7 @@ public class ChunkProviderServer implements IChunkProvider {
populator.populate(world.getWorld(), random, chunk.bukkitChunk); populator.populate(world.getWorld(), random, chunk.bukkitChunk);
} }
BlockSand.a = false; BlockSand.a = false;
// Craftbukkit end // CraftBukkit end
chunk.f(); chunk.f();
} }

View File

@ -4,12 +4,12 @@ import java.util.Iterator;
import java.util.Set; import java.util.Set;
import java.util.logging.Logger; import java.util.logging.Logger;
// Craftbukkit start // CraftBukkit start
import java.util.List; import java.util.List;
import org.bukkit.craftbukkit.command.ServerCommandListener; import org.bukkit.craftbukkit.command.ServerCommandListener;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
// Craftbukkit end // CraftBukkit end
public class ConsoleCommandHandler { public class ConsoleCommandHandler {
@ -44,7 +44,7 @@ public class ConsoleCommandHandler {
serverconfigurationmanager.savePlayers(); serverconfigurationmanager.savePlayers();
} }
// Craftbukkit start // CraftBukkit start
for (i = 0; i < this.server.worlds.size(); ++i) { for (i = 0; i < this.server.worlds.size(); ++i) {
worldserver = this.server.worlds.get(i); worldserver = this.server.worlds.get(i);
boolean save = worldserver.E; boolean save = worldserver.E;
@ -58,15 +58,15 @@ public class ConsoleCommandHandler {
} else if (s.toLowerCase().startsWith("save-off")) { } else if (s.toLowerCase().startsWith("save-off")) {
this.print(s1, "Disabling level saving.."); this.print(s1, "Disabling level saving..");
for (i = 0; i < this.server.worlds.size(); ++i) { // Craftbukkit start for (i = 0; i < this.server.worlds.size(); ++i) { // CraftBukkit
worldserver = this.server.worlds.get(i); // Craftbukkit start worldserver = this.server.worlds.get(i); // CraftBukkit
worldserver.E = true; worldserver.E = true;
} }
} else if (s.toLowerCase().startsWith("save-on")) { } else if (s.toLowerCase().startsWith("save-on")) {
this.print(s1, "Enabling level saving.."); this.print(s1, "Enabling level saving..");
for (i = 0; i < this.server.worlds.size(); ++i) { // Craftbukkit start for (i = 0; i < this.server.worlds.size(); ++i) { // CraftBukkit
worldserver = this.server.worlds.get(i); // Craftbukkit start worldserver = this.server.worlds.get(i); // CraftBukkit
worldserver.E = false; worldserver.E = false;
} }
} else { } else {
@ -205,15 +205,15 @@ public class ConsoleCommandHandler {
WorldServer worldserver1; WorldServer worldserver1;
if ("add".equalsIgnoreCase(s3)) { if ("add".equalsIgnoreCase(s3)) {
for (k = 0; k < this.server.worlds.size(); ++k) { // Craftbukkit start for (k = 0; k < this.server.worlds.size(); ++k) { // CraftBukkit
worldserver1 = this.server.worlds.get(k); // Craftbukkit start worldserver1 = this.server.worlds.get(k); // CraftBukkit
worldserver1.setTime(worldserver1.getTime() + (long) j); worldserver1.setTime(worldserver1.getTime() + (long) j);
} }
this.print(s1, "Added " + j + " to time"); this.print(s1, "Added " + j + " to time");
} else if ("set".equalsIgnoreCase(s3)) { } else if ("set".equalsIgnoreCase(s3)) {
for (k = 0; k < this.server.worlds.size(); ++k) { // Craftbukkit start for (k = 0; k < this.server.worlds.size(); ++k) { // CraftBukkit
worldserver1 = this.server.worlds.get(k); // Craftbukkit start worldserver1 = this.server.worlds.get(k); // CraftBukkit
worldserver1.setTime((long) j); worldserver1.setTime((long) j);
} }

View File

@ -752,11 +752,12 @@ public abstract class Entity {
public void a(World world) { public void a(World world) {
// CraftBukkit start // CraftBukkit start
if(world == null) { if (world == null) {
this.die(); this.die();
this.world = ((CraftWorld)Bukkit.getServer().getWorlds().get(0)).getHandle(); this.world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
} else {
this.world = world;
} }
else this.world = world;
// CraftBukkit end // CraftBukkit end
} }
@ -909,9 +910,11 @@ public abstract class Entity {
nbttagcompound.a("Fire", (short) this.fireTicks); nbttagcompound.a("Fire", (short) this.fireTicks);
nbttagcompound.a("Air", (short) this.airTicks); nbttagcompound.a("Air", (short) this.airTicks);
nbttagcompound.a("OnGround", this.onGround); nbttagcompound.a("OnGround", this.onGround);
nbttagcompound.setString("World", world.worldData.name); // CraftBukkit // CraftBukkit start
nbttagcompound.a("UUIDLeast", this.uniqueId.getLeastSignificantBits()); // CraftBukkit nbttagcompound.setString("World", world.worldData.name);
nbttagcompound.a("UUIDMost", this.uniqueId.getMostSignificantBits()); // CraftBukkit nbttagcompound.a("UUIDLeast", this.uniqueId.getLeastSignificantBits());
nbttagcompound.a("UUIDMost", this.uniqueId.getMostSignificantBits());
// CraftBukkit end
this.b(nbttagcompound); this.b(nbttagcompound);
} }
@ -923,6 +926,19 @@ public abstract class Entity {
this.motX = ((NBTTagDouble) nbttaglist1.a(0)).a; this.motX = ((NBTTagDouble) nbttaglist1.a(0)).a;
this.motY = ((NBTTagDouble) nbttaglist1.a(1)).a; this.motY = ((NBTTagDouble) nbttaglist1.a(1)).a;
this.motZ = ((NBTTagDouble) nbttaglist1.a(2)).a; this.motZ = ((NBTTagDouble) nbttaglist1.a(2)).a;
/* CraftBukkit start - moved section down
if (Math.abs(this.motX) > 10.0D) {
this.motX = 0.0D;
}
if (Math.abs(this.motY) > 10.0D) {
this.motY = 0.0D;
}
if (Math.abs(this.motZ) > 10.0D) {
this.motZ = 0.0D;
}
// CraftBukkit end */
this.lastX = this.bo = this.locX = ((NBTTagDouble) nbttaglist.a(0)).a; this.lastX = this.bo = this.locX = ((NBTTagDouble) nbttaglist.a(0)).a;
this.lastY = this.bp = this.locY = ((NBTTagDouble) nbttaglist.a(1)).a; this.lastY = this.bp = this.locY = ((NBTTagDouble) nbttaglist.a(1)).a;

View File

@ -383,7 +383,7 @@ public class EntityBoat extends Entity {
} }
if (this.passenger != null && this.passenger.dead) { if (this.passenger != null && this.passenger.dead) {
this.passenger.vehicle = null; this.passenger.vehicle = null; // CraftBukkit
this.passenger = null; this.passenger = null;
} }
} }

View File

@ -152,6 +152,7 @@ public class EntityFireball extends Entity {
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
ExplosionPrimeEvent event = new ExplosionPrimeEvent(CraftEntity.getEntity(server, this), 1.0F, true); ExplosionPrimeEvent event = new ExplosionPrimeEvent(CraftEntity.getEntity(server, this), 1.0F, true);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
// give 'this' instead of (Entity) null so we know what causes the damage // give 'this' instead of (Entity) null so we know what causes the damage

View File

@ -602,6 +602,7 @@ public abstract class EntityHuman extends EntityLiving {
Player player = (Player) this.getBukkitEntity(); Player player = (Player) this.getBukkitEntity();
CraftServer server = ((WorldServer) world).getServer(); CraftServer server = ((WorldServer) world).getServer();
org.bukkit.block.Block bed = ((WorldServer) world).getWorld().getBlockAt(i, j, k); org.bukkit.block.Block bed = ((WorldServer) world).getWorld().getBlockAt(i, j, k);
PlayerBedEnterEvent event = new PlayerBedEnterEvent(player, bed); PlayerBedEnterEvent event = new PlayerBedEnterEvent(player, bed);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
@ -760,7 +761,7 @@ public abstract class EntityHuman extends EntityLiving {
public void a(ChunkCoordinates chunkcoordinates) { public void a(ChunkCoordinates chunkcoordinates) {
if (chunkcoordinates != null) { if (chunkcoordinates != null) {
this.b = new ChunkCoordinates(chunkcoordinates); this.b = new ChunkCoordinates(chunkcoordinates);
this.spawnWorld = world.worldData.name; this.spawnWorld = world.worldData.name; // CraftBukkit
} else { } else {
this.b = null; this.b = null;
} }

View File

@ -583,7 +583,7 @@ public class EntityMinecart extends Entity implements IInventory {
} }
if (this.passenger != null && this.passenger.dead) { if (this.passenger != null && this.passenger.dead) {
this.passenger.vehicle = null; this.passenger.vehicle = null; // CraftBukkit
this.passenger = null; this.passenger = null;
} }

View File

@ -68,20 +68,20 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
dead = false; dead = false;
ChunkCoordinates position = null; ChunkCoordinates position = null;
if (!spawnWorld.isEmpty()) { if (!spawnWorld.isEmpty()) {
CraftWorld cw = (CraftWorld)Bukkit.getServer().getWorld(spawnWorld); CraftWorld cw = (CraftWorld) Bukkit.getServer().getWorld(spawnWorld);
if (cw != null && M() != null) { if (cw != null && M() != null) {
world = cw.getHandle(); world = cw.getHandle();
position = EntityHuman.getBed(cw.getHandle(), M()); position = EntityHuman.getBed(cw.getHandle(), M());
} }
} }
if (world == null || position == null) { if (world == null || position == null) {
world = ((CraftWorld)Bukkit.getServer().getWorlds().get(0)).getHandle(); world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
position = world.getSpawn(); position = world.getSpawn();
} }
this.world = world; this.world = world;
setPosition(position.x + 0.5, position.y, position.z + 0.5); setPosition(position.x + 0.5, position.y, position.z + 0.5);
} }
this.dimension = ((WorldServer)this.world).dimension; this.dimension = ((WorldServer) this.world).dimension;
// CraftBukkit end // CraftBukkit end
this.itemInWorldManager = new ItemInWorldManager((WorldServer) world); this.itemInWorldManager = new ItemInWorldManager((WorldServer) world);
this.itemInWorldManager.player = this; this.itemInWorldManager.player = this;

View File

@ -315,6 +315,7 @@ public class EntityWolf extends EntityAnimal {
return false; return false;
} }
// CraftBukkit end // CraftBukkit end
this.d(true); this.d(true);
this.a((PathEntity) null); this.a((PathEntity) null);
this.setSitting(true); this.setSitting(true);

View File

@ -66,9 +66,9 @@ public class ItemFlintAndSteel extends Item {
itemstack.damage(1, entityhuman); itemstack.damage(1, entityhuman);
return false; return false;
} }
// CraftBukkit end
BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit BlockState blockState = CraftBlockState.getBlockState(world, i, j, k);
// CraftBukkit end
world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, b.nextFloat() * 0.4F + 0.8F); world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, b.nextFloat() * 0.4F + 0.8F);
world.setTypeId(i, j, k, Block.FIRE.id); world.setTypeId(i, j, k, Block.FIRE.id);
@ -77,7 +77,7 @@ public class ItemFlintAndSteel extends Item {
BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.FIRE.id); BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.FIRE.id);
if (placeEvent.isCancelled() || !placeEvent.canBuild()) { if (placeEvent.isCancelled() || !placeEvent.canBuild()) {
placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte)0, false); placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false);
return false; return false;
} }
// CraftBukkit end // CraftBukkit end

View File

@ -51,6 +51,7 @@ public class ItemInWorldManager {
} }
public void dig(int i, int j, int k, int l) { public void dig(int i, int j, int k, int l) {
// this.world.a((EntityHuman) null, i, j, k, l); // CraftBukkit - moved down
this.d = (int) (System.currentTimeMillis() / 50); // CraftBukkit this.d = (int) (System.currentTimeMillis() / 50); // CraftBukkit
int i1 = this.world.getTypeId(i, j, k); int i1 = this.world.getTypeId(i, j, k);
@ -60,7 +61,7 @@ public class ItemInWorldManager {
return; return;
} }
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK , i, j, k, l, this.player.inventory.getItemInHand()); PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, i, j, k, l, this.player.inventory.getItemInHand());
if (event.useInteractedBlock() == Event.Result.DENY) { if (event.useInteractedBlock() == Event.Result.DENY) {
// If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
@ -155,7 +156,7 @@ public class ItemInWorldManager {
org.bukkit.block.Block block = ((WorldServer) this.world).getWorld().getBlockAt(i, j, k); org.bukkit.block.Block block = ((WorldServer) this.world).getWorld().getBlockAt(i, j, k);
org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.player.getBukkitEntity(); org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.player.getBukkitEntity();
BlockBreakEvent event = new BlockBreakEvent(block,player); BlockBreakEvent event = new BlockBreakEvent(block, player);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {

View File

@ -437,7 +437,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
StatisticList.a(); StatisticList.a();
try { try {
MinecraftServer minecraftserver = new MinecraftServer(options); // CraftBukkit pass in the options MinecraftServer minecraftserver = new MinecraftServer(options); // CraftBukkit - pass in the options
// CraftBukkit - remove gui // CraftBukkit - remove gui

View File

@ -84,7 +84,7 @@ public class NetLoginHandler extends NetHandler {
if (entityplayer != null) { if (entityplayer != null) {
this.server.serverConfigurationManager.b(entityplayer); this.server.serverConfigurationManager.b(entityplayer);
// entityplayer.a((World) this.server.a(entityplayer.dimension)); // CraftBukkit - set by Entity // entityplayer.a((World) this.server.a(entityplayer.dimension)); // CraftBukkit - set by Entity
a.info(this.b() + " logged in with entity id " + entityplayer.id + " at ([ "+ entityplayer.world.worldData.name + "] " + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")"); a.info(this.b() + " logged in with entity id " + entityplayer.id + " at ([ " + entityplayer.world.worldData.name + "] " + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")"); // CraftBukkit
WorldServer worldserver = (WorldServer) entityplayer.world; // CraftBukkit WorldServer worldserver = (WorldServer) entityplayer.world; // CraftBukkit
ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
NetServerHandler netserverhandler = new NetServerHandler(this.server, this.networkManager, entityplayer); NetServerHandler netserverhandler = new NetServerHandler(this.server, this.networkManager, entityplayer);

View File

@ -95,7 +95,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
this.sendPacket(new Packet255KickDisconnect(s)); this.sendPacket(new Packet255KickDisconnect(s));
this.networkManager.d(); this.networkManager.d();
//CraftBukkit start // CraftBukkit start
leaveMessage = event.getLeaveMessage(); leaveMessage = event.getLeaveMessage();
if (leaveMessage != null) { if (leaveMessage != null) {
this.minecraftServer.serverConfigurationManager.sendAll(new Packet3Chat(leaveMessage)); this.minecraftServer.serverConfigurationManager.sendAll(new Packet3Chat(leaveMessage));
@ -132,10 +132,11 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
double delta = Math.pow(this.lastPosX - this.x, 2) + Math.pow(this.lastPosY - this.y, 2) + Math.pow(this.lastPosZ - this.z, 2); double delta = Math.pow(this.lastPosX - this.x, 2) + Math.pow(this.lastPosY - this.y, 2) + Math.pow(this.lastPosZ - this.z, 2);
float deltaAngle = Math.abs(this.lastYaw - this.player.yaw) + Math.abs(this.lastPitch - this.player.pitch); float deltaAngle = Math.abs(this.lastYaw - this.player.yaw) + Math.abs(this.lastPitch - this.player.pitch);
if (delta > 1f/256 || deltaAngle > 10f) { if (delta > 1f / 256 || deltaAngle > 10f) {
// Skip the first time we do this // Skip the first time we do this
if (lastPosX != Double.MAX_VALUE) { if (lastPosX != Double.MAX_VALUE) {
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
from = event.getFrom(); from = event.getFrom();
@ -297,6 +298,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit start - make the movement speed check behave properly under tick degradation. // CraftBukkit start - make the movement speed check behave properly under tick degradation.
int elapsedTicks = MinecraftServer.currentTick - this.lastTick; int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
// Added this.m condition to solve this check being triggered by teleports // Added this.m condition to solve this check being triggered by teleports
if (d8 > 100.0D * (elapsedTicks <= 0 ? 1 : elapsedTicks) && this.m) { if (d8 > 100.0D * (elapsedTicks <= 0 ? 1 : elapsedTicks) && this.m) {
a.warning(this.player.name + " moved too quickly! Elapsed ticks: " + (elapsedTicks == 0 ? 1 : elapsedTicks) + ", Distance change: " + d8); a.warning(this.player.name + " moved too quickly! Elapsed ticks: " + (elapsedTicks == 0 ? 1 : elapsedTicks) + ", Distance change: " + d8);
@ -410,7 +412,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
if (packet14blockdig.e == 4) { if (packet14blockdig.e == 4) {
this.player.E(); this.player.E();
} else { } else {
boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); // CraftBukkit
boolean flag1 = false; boolean flag1 = false;
if (packet14blockdig.e == 0) { if (packet14blockdig.e == 0) {
@ -506,7 +508,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit end // CraftBukkit end
ItemStack itemstack = this.player.inventory.getItemInHand(); ItemStack itemstack = this.player.inventory.getItemInHand();
boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); // CraftBukkit
if (packet15place.face == 255) { if (packet15place.face == 255) {
if (itemstack == null) { if (itemstack == null) {
@ -750,7 +752,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
s1 = s.substring(1); s1 = s.substring(1);
a.info(this.player.name + " tried command: " + s1); a.info(this.player.name + " tried command: " + s1);
} }
*/ // CraftBukkit end // CraftBukkit end */
} }
} }

View File

@ -5,13 +5,11 @@ import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.net.Socket; import java.net.Socket;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.io.IOException; // CraftBukkit - instead of SocketException import java.net.SocketException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.io.IOException; // CraftBukkit
// CraftBukkit
import java.net.SocketException;
public class NetworkManager { public class NetworkManager {
@ -49,8 +47,7 @@ public class NetworkManager {
// CraftBukkit start - IPv6 stack in Java on BSD/OSX doesn't support setTrafficClass // CraftBukkit start - IPv6 stack in Java on BSD/OSX doesn't support setTrafficClass
try { try {
socket.setTrafficClass(24); socket.setTrafficClass(24);
} catch (SocketException e) { } catch (SocketException e) {}
}
// CraftBukkit end // CraftBukkit end
try { try {

View File

@ -37,7 +37,7 @@ public class Packet51MapChunk extends Packet {
this.e = i1; this.e = i1;
this.f = j1; this.f = j1;
byte[] abyte = data; // CraftBukkit - uses data from above constructor byte[] abyte = data; // CraftBukkit - uses data from above constructor
Deflater deflater = new Deflater(1); Deflater deflater = new Deflater(-1);
try { try {
deflater.setInput(abyte); deflater.setInput(abyte);

View File

@ -166,7 +166,7 @@ public class PlayerManager {
List<ChunkCoordIntPair> chunksToSend = entityplayer.f; List<ChunkCoordIntPair> chunksToSend = entityplayer.f;
Collections.sort(chunksToSend, new Comparator<ChunkCoordIntPair>() { Collections.sort(chunksToSend, new Comparator<ChunkCoordIntPair>() {
public int compare(ChunkCoordIntPair a, ChunkCoordIntPair b) { public int compare(ChunkCoordIntPair a, ChunkCoordIntPair b) {
return Math.max(Math.abs(a.x-x), Math.abs(a.z-z)) - Math.max(Math.abs(b.x-x), Math.abs(b.z-z)); return Math.max(Math.abs(a.x - x), Math.abs(a.z - z)) - Math.max(Math.abs(b.x - x), Math.abs(b.z - z));
} }
}); });
} }

View File

@ -226,7 +226,7 @@ public class PortalTravelAgent {
// CraftBukkit start - portal create event // CraftBukkit start - portal create event
java.util.ArrayList<org.bukkit.block.Block> blocks = new java.util.ArrayList<org.bukkit.block.Block>(); java.util.ArrayList<org.bukkit.block.Block> blocks = new java.util.ArrayList<org.bukkit.block.Block>();
//Find out what blocks the portal is going to modify, duplicated from below // Find out what blocks the portal is going to modify, duplicated from below
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
if (d0 < 0.0D) { if (d0 < 0.0D) {
@ -269,9 +269,11 @@ public class PortalTravelAgent {
} }
} }
PortalCreateEvent event = new PortalCreateEvent(blocks,(org.bukkit.World)craftWorld); PortalCreateEvent event = new PortalCreateEvent(blocks, (org.bukkit.World) craftWorld);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if(event.isCancelled()) return true; if (event.isCancelled()) {
return true;
}
// CraftBukkit end // CraftBukkit end
if (d0 < 0.0D) { if (d0 < 0.0D) {

View File

@ -1,6 +1,6 @@
package net.minecraft.server; package net.minecraft.server;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator; // CraftBukkit
public class SecondaryWorldServer extends WorldServer { public class SecondaryWorldServer extends WorldServer {
// CraftBukkit start // CraftBukkit start

View File

@ -32,7 +32,7 @@ public class ServerConfigurationManager {
public static Logger a = Logger.getLogger("Minecraft"); public static Logger a = Logger.getLogger("Minecraft");
public List players = new ArrayList(); public List players = new ArrayList();
public MinecraftServer server; // CraftBukkit - private -> public public MinecraftServer server; // CraftBukkit - private -> public
// private PlayerManager[] d = new PlayerManager[2]; // Craftbukkit - removed // private PlayerManager[] d = new PlayerManager[2]; // CraftBukkit - removed
public int maxPlayers; // CraftBukkit - private -> public public int maxPlayers; // CraftBukkit - private -> public
private Set banByName = new HashSet(); private Set banByName = new HashSet();
private Set banByIP = new HashSet(); private Set banByIP = new HashSet();
@ -61,7 +61,7 @@ public class ServerConfigurationManager {
this.m = minecraftserver.a("white-list.txt"); this.m = minecraftserver.a("white-list.txt");
int i = minecraftserver.propertyManager.getInt("view-distance", 10); int i = minecraftserver.propertyManager.getInt("view-distance", 10);
// Craftbukkit - removed playermanagers // CraftBukkit - removed playermanagers
this.maxPlayers = minecraftserver.propertyManager.getInt("max-players", 20); this.maxPlayers = minecraftserver.propertyManager.getInt("max-players", 20);
this.o = minecraftserver.propertyManager.getBoolean("white-list", false); this.o = minecraftserver.propertyManager.getBoolean("white-list", false);
this.g(); this.g();
@ -80,9 +80,9 @@ public class ServerConfigurationManager {
} }
public void a(EntityPlayer entityplayer) { public void a(EntityPlayer entityplayer) {
// Craftbukkit - removed playermanagers // CraftBukkit - removed playermanagers
for(WorldServer world : this.server.worlds) { for (WorldServer world : this.server.worlds) {
if(world.manager.a.contains(entityplayer)) { if (world.manager.a.contains(entityplayer)) {
world.manager.removePlayer(entityplayer); world.manager.removePlayer(entityplayer);
break; break;
} }
@ -94,17 +94,17 @@ public class ServerConfigurationManager {
} }
public int a() { public int a() {
// Craftbukkit start // CraftBukkit start
if (this.server.worlds.size() == 0) { if (this.server.worlds.size() == 0) {
return this.server.propertyManager.getInt("view-distance", 10) * 16 - 16; return this.server.propertyManager.getInt("view-distance", 10) * 16 - 16;
} else { } else {
return this.server.worlds.get(0).manager.c(); return this.server.worlds.get(0).manager.c();
} }
// Craftbukkit end // CraftBukkit end
} }
private PlayerManager a(int i) { private PlayerManager a(int i) {
return server.a(i).manager; // Craftbukkit return server.a(i).manager; // CraftBukkit
} }
public void b(EntityPlayer entityplayer) { public void b(EntityPlayer entityplayer) {
@ -218,7 +218,7 @@ public class ServerConfigurationManager {
if (location == null) { if (location == null) {
CraftWorld cw = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld); CraftWorld cw = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld);
if(cw != null && chunkcoordinates != null) { if (cw != null && chunkcoordinates != null) {
ChunkCoordinates chunkcoordinates1 = EntityHuman.getBed(cw.getHandle(), chunkcoordinates); ChunkCoordinates chunkcoordinates1 = EntityHuman.getBed(cw.getHandle(), chunkcoordinates);
if (chunkcoordinates1 != null) { if (chunkcoordinates1 != null) {
location = new Location(cw, chunkcoordinates1.x + 0.5, chunkcoordinates1.y, chunkcoordinates1.z + 0.5); location = new Location(cw, chunkcoordinates1.x + 0.5, chunkcoordinates1.y, chunkcoordinates1.z + 0.5);
@ -226,14 +226,17 @@ public class ServerConfigurationManager {
entityplayer1.netServerHandler.sendPacket(new Packet70Bed(0)); entityplayer1.netServerHandler.sendPacket(new Packet70Bed(0));
} }
} }
if (location == null) { if (location == null) {
cw = (CraftWorld) this.server.server.getWorlds().get(0); cw = (CraftWorld) this.server.server.getWorlds().get(0);
chunkcoordinates = cw.getHandle().getSpawn(); chunkcoordinates = cw.getHandle().getSpawn();
location = new Location(cw, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z); location = new Location(cw, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z);
} }
Player respawnPlayer = cserver.getPlayer(entityplayer); Player respawnPlayer = cserver.getPlayer(entityplayer);
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location); PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location);
cserver.getPluginManager().callEvent(respawnEvent); cserver.getPluginManager().callEvent(respawnEvent);
location = respawnEvent.getRespawnLocation(); location = respawnEvent.getRespawnLocation();
entityplayer.health = 20; entityplayer.health = 20;
entityplayer.fireTicks = 0; entityplayer.fireTicks = 0;
@ -241,7 +244,7 @@ public class ServerConfigurationManager {
} else { } else {
location.setWorld(this.server.a(i).getWorld()); location.setWorld(this.server.a(i).getWorld());
} }
WorldServer worldserver = ((CraftWorld)location.getWorld()).getHandle(); WorldServer worldserver = ((CraftWorld) location.getWorld()).getHandle();
entityplayer1.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); entityplayer1.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
// CraftBukkit end // CraftBukkit end
@ -269,10 +272,9 @@ public class ServerConfigurationManager {
} }
public void f(EntityPlayer entityplayer) { public void f(EntityPlayer entityplayer) {
// CraftBukkit start
WorldServer worldserver = this.server.a(entityplayer.dimension); WorldServer worldserver = this.server.a(entityplayer.dimension);
boolean flag = false; // Unused boolean flag = false;
int b0; // byte -> int int b0; // CraftBukkit - byte -> int
if (entityplayer.dimension == -1) { if (entityplayer.dimension == -1) {
b0 = 0; b0 = 0;
@ -280,17 +282,19 @@ public class ServerConfigurationManager {
b0 = -1; b0 = -1;
} }
// entityplayer.dimension = b0; /* CraftBukkit start
// WorldServer worldserver1 = this.server.a(entityplayer.dimension); entityplayer.dimension = b0;
WorldServer worldserver1 = this.server.a(entityplayer.dimension);
// entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) entityplayer.dimension)); entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) entityplayer.dimension));
// worldserver.removeEntity(entityplayer); worldserver.removeEntity(entityplayer);
// entityplayer.dead = false; entityplayer.dead = false;
// CraftBukkit end */
double d0 = entityplayer.locX; double d0 = entityplayer.locX;
double d1 = entityplayer.locZ; double d1 = entityplayer.locZ;
double d2 = 8.0D; double d2 = 8.0D;
if (b0 == -1) { // entityplayer.dimension -> b0 if (b0 == -1) { // CraftBukkit - entityplayer.dimension -> b0
d0 /= d2; d0 /= d2;
d1 /= d2; d1 /= d2;
entityplayer.setPositionRotation(d0, entityplayer.locY, d1, entityplayer.yaw, entityplayer.pitch); entityplayer.setPositionRotation(d0, entityplayer.locY, d1, entityplayer.yaw, entityplayer.pitch);
@ -306,12 +310,13 @@ public class ServerConfigurationManager {
} }
} }
// CraftBukkit start
CraftWorld fromCraftWorld = worldserver.getWorld(); CraftWorld fromCraftWorld = worldserver.getWorld();
CraftWorld toCraftWorld = this.server.a(b0).getWorld(); CraftWorld toCraftWorld = this.server.a(b0).getWorld();
Location startLocation = new Location(fromCraftWorld, entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); Location startLocation = new Location(fromCraftWorld, entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
Location endLocation = new Location(toCraftWorld, d0, entityplayer.locY, d1, entityplayer.yaw, entityplayer.pitch); Location endLocation = new Location(toCraftWorld, d0, entityplayer.locY, d1, entityplayer.yaw, entityplayer.pitch);
PlayerPortalEvent event = new PlayerPortalEvent((Player)entityplayer.getBukkitEntity(),startLocation,endLocation); PlayerPortalEvent event = new PlayerPortalEvent((Player) entityplayer.getBukkitEntity(), startLocation, endLocation);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -336,21 +341,23 @@ public class ServerConfigurationManager {
} }
} }
// this.a(entityplayer); /* CraftBukkit -- not needed
// entityplayer.netServerHandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); this.a(entityplayer);
// entityplayer.a((World) worldserver1); entityplayer.netServerHandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
// this.a(entityplayer, worldserver1); entityplayer.a((World) worldserver1);
// this.g(entityplayer); this.a(entityplayer, worldserver1);
this.g(entityplayer);
// CraftBukkit */
this.a(entityplayer, b0, endLocation); this.a(entityplayer, b0, endLocation);
// CraftBukkit end // CraftBukkit end
} }
public void b() { public void b() {
// Craftbukkit start // CraftBukkit start
for (int i = 0; i < this.server.worlds.size(); ++i) { for (int i = 0; i < this.server.worlds.size(); ++i) {
this.server.worlds.get(i).manager.flush(); this.server.worlds.get(i).manager.flush();
} }
// Craftbukkit end // CraftBukkit end
} }
public void flagDirty(int i, int j, int k, int l) { public void flagDirty(int i, int j, int k, int l) {

View File

@ -165,7 +165,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
ItemStack itemstack = FurnaceRecipes.a().a(this.items[0].getItem().id); ItemStack itemstack = FurnaceRecipes.a().a(this.items[0].getItem().id);
// CraftBukkit - consider resultant count instead of current count // CraftBukkit - consider resultant count instead of current count
return itemstack == null ? false : (this.items[2] == null ? true : (!this.items[2].a(itemstack) ? false : (this.items[2].count+itemstack.count <= this.getMaxStackSize() && this.items[2].count < this.items[2].b() ? true : this.items[2].count+itemstack.count <= itemstack.b()))); return itemstack == null ? false : (this.items[2] == null ? true : (!this.items[2].a(itemstack) ? false : (this.items[2].count + itemstack.count <= this.getMaxStackSize() && this.items[2].count < this.items[2].b() ? true : this.items[2].count + itemstack.count <= itemstack.b())));
} }
} }

View File

@ -50,7 +50,7 @@ public class World implements IBlockAccess {
public int spawnMonsters; public int spawnMonsters;
public Random random = new Random(); public Random random = new Random();
public boolean s = false; public boolean s = false;
public WorldProvider worldProvider; // Craftbukkit - remove final public WorldProvider worldProvider; // CraftBukkit - remove final
protected List u = new ArrayList(); protected List u = new ArrayList();
public IChunkProvider chunkProvider; // CraftBukkit - protected -> public public IChunkProvider chunkProvider; // CraftBukkit - protected -> public
protected final IDataManager w; protected final IDataManager w;
@ -62,22 +62,36 @@ public class World implements IBlockAccess {
private int K = 0; private int K = 0;
public boolean allowMonsters = true; // CraftBukkit - private -> public public boolean allowMonsters = true; // CraftBukkit - private -> public
public boolean allowAnimals = true; // CraftBukkit - private -> public public boolean allowAnimals = true; // CraftBukkit - private -> public
public boolean pvpMode; // CraftBukkit
static int A = 0; static int A = 0;
private Set N = new HashSet(); private Set N = new HashSet();
private int O; private int O;
private List P; private List P;
public boolean isStatic; public boolean isStatic;
public ChunkGenerator generator; // Craftbukkit
public WorldChunkManager getWorldChunkManager() { public WorldChunkManager getWorldChunkManager() {
return this.worldProvider.b; return this.worldProvider.b;
} }
// Craftbukkit start - changed signature // CraftBukkit start
public boolean pvpMode;
public ChunkGenerator generator;
Chunk lastChunkAccessed;
int lastXAccessed = Integer.MIN_VALUE;
int lastZAccessed = Integer.MIN_VALUE;
final Object chunkLock = new Object();
private boolean canSpawn(int x, int z) {
if (generator != null) {
return this.generator.canSpawn(((WorldServer) this).getWorld(), x, z);
} else {
return this.worldProvider.a(x, z);
}
}
// CraftBukkit - changed signature
public World(IDataManager idatamanager, String s, long i, WorldProvider worldprovider, ChunkGenerator gen) { public World(IDataManager idatamanager, String s, long i, WorldProvider worldprovider, ChunkGenerator gen) {
this.generator = gen; this.generator = gen;
// Craftbukkit end // CraftBukkit end
this.O = this.random.nextInt(12000); this.O = this.random.nextInt(12000);
this.P = new ArrayList(); this.P = new ArrayList();
@ -126,12 +140,13 @@ public class World implements IBlockAccess {
int j; int j;
// Craftbukkit start // CraftBukkit start
if (generator != null) { if (generator != null) {
Random rand = new Random(getSeed()); Random rand = new Random(getSeed());
Location spawn = generator.getFixedSpawnLocation(((WorldServer)this).getWorld(), rand); Location spawn = generator.getFixedSpawnLocation(((WorldServer) this).getWorld(), rand);
if (spawn != null) { if (spawn != null) {
if (spawn.getWorld() != ((WorldServer)this).getWorld()) { if (spawn.getWorld() != ((WorldServer) this).getWorld()) {
throw new IllegalStateException("Cannot set spawn point for " + worldData.name + " to be in another world (" + spawn.getWorld().getName() + ")"); throw new IllegalStateException("Cannot set spawn point for " + worldData.name + " to be in another world (" + spawn.getWorld().getName() + ")");
} else { } else {
worldData.setSpawn(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()); worldData.setSpawn(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
@ -144,22 +159,12 @@ public class World implements IBlockAccess {
for (j = 0; !canSpawn(i, j); j += this.random.nextInt(64) - this.random.nextInt(64)) { for (j = 0; !canSpawn(i, j); j += this.random.nextInt(64) - this.random.nextInt(64)) {
i += this.random.nextInt(64) - this.random.nextInt(64); i += this.random.nextInt(64) - this.random.nextInt(64);
} }
// Craftbukkit end // CraftBukkit end
this.worldData.setSpawn(i, b0, j); this.worldData.setSpawn(i, b0, j);
this.isLoading = false; this.isLoading = false;
} }
// Craftbukkit start
private boolean canSpawn(int x, int z) {
if (generator != null) {
return this.generator.canSpawn(((WorldServer)this).getWorld(), x, z);
} else {
return this.worldProvider.a(x, z);
}
}
// Craftbukkit end
public int a(int i, int j) { public int a(int i, int j) {
int k; int k;
@ -239,10 +244,6 @@ public class World implements IBlockAccess {
} }
// CraftBukkit start // CraftBukkit start
Chunk lastChunkAccessed;
int lastXAccessed = Integer.MIN_VALUE;
int lastZAccessed = Integer.MIN_VALUE;
final Object chunkLock = new Object();
public Chunk getChunkAt(int i, int j) { public Chunk getChunkAt(int i, int j) {
Chunk result = null; Chunk result = null;
synchronized (chunkLock) { synchronized (chunkLock) {
@ -818,6 +819,7 @@ public class World implements IBlockAccess {
// CraftBukkit start // CraftBukkit start
if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) { if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
CreatureSpawnEvent event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity); CreatureSpawnEvent event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity);
if (event.isCancelled()) { if (event.isCancelled()) {
return false; return false;
} }
@ -1814,9 +1816,9 @@ public class World implements IBlockAccess {
i2 = chunk.getTypeId(l, k1, j1); i2 = chunk.getTypeId(l, k1, j1);
if (this.v() && i2 == 0 && Block.SNOW.canPlace(this, l + i, k1, j1 + j) && l1 != 0 && l1 != Block.ICE.id && Block.byId[l1].material.isSolid()) { if (this.v() && i2 == 0 && Block.SNOW.canPlace(this, l + i, k1, j1 + j) && l1 != 0 && l1 != Block.ICE.id && Block.byId[l1].material.isSolid()) {
// CraftBukkit start // CraftBukkit start
SnowFormEvent snow = new SnowFormEvent(((WorldServer)this).getWorld().getBlockAt(l + i, k1, j1 + j)); SnowFormEvent snow = new SnowFormEvent(((WorldServer) this).getWorld().getBlockAt(l + i, k1, j1 + j));
((WorldServer)this).getServer().getPluginManager().callEvent(snow);
((WorldServer) this).getServer().getPluginManager().callEvent(snow);
if (!snow.isCancelled()) { if (!snow.isCancelled()) {
this.setTypeId(l + i, k1, j1 + j, snow.getMaterial().getId()); this.setTypeId(l + i, k1, j1 + j, snow.getMaterial().getId());
this.setData(l + i, k1, j1 + j, snow.getData()); this.setData(l + i, k1, j1 + j, snow.getData());
@ -1946,7 +1948,6 @@ public class World implements IBlockAccess {
this.entityList.add(entity); this.entityList.add(entity);
// CraftBukkit end // CraftBukkit end
this.c((Entity) list.get(i)); this.c((Entity) list.get(i));
} }
} }
@ -1965,19 +1966,16 @@ public class World implements IBlockAccess {
axisalignedbb = null; axisalignedbb = null;
} }
// CraftBukkit - store the default action boolean defaultReturn; // CraftBukkit - store the default action
boolean defaultReturn;
if (axisalignedbb != null && !this.containsEntity(axisalignedbb)) { if (axisalignedbb != null && !this.containsEntity(axisalignedbb)) {
// CraftBukkit defaultReturn = false; // CraftBukkit
defaultReturn = false;
} else { } else {
if (block == Block.WATER || block == Block.STATIONARY_WATER || block == Block.LAVA || block == Block.STATIONARY_LAVA || block == Block.FIRE || block == Block.SNOW) { if (block == Block.WATER || block == Block.STATIONARY_WATER || block == Block.LAVA || block == Block.STATIONARY_LAVA || block == Block.FIRE || block == Block.SNOW) {
block = null; block = null;
} }
// CraftBukkit defaultReturn = i > 0 && block == null && block1.canPlace(this, j, k, l, i1); // CraftBukkit
defaultReturn = i > 0 && block == null && block1.canPlace(this, j, k, l, i1);
} }
// CraftBukkit start // CraftBukkit start

View File

@ -3,7 +3,7 @@ package net.minecraft.server;
public class WorldManager implements IWorldAccess { public class WorldManager implements IWorldAccess {
private MinecraftServer server; private MinecraftServer server;
public WorldServer world; // CraftBukkit private -> public public WorldServer world; // CraftBukkit - private -> public
public WorldManager(MinecraftServer minecraftserver, WorldServer worldserver) { public WorldManager(MinecraftServer minecraftserver, WorldServer worldserver) {
this.server = minecraftserver; this.server = minecraftserver;

View File

@ -95,6 +95,7 @@ public class WorldMap extends WorldMapBase {
byte b2 = 0; byte b2 = 0;
byte b3 = (byte) ((int) ((double) (f * 2.0F) + 0.5D)); byte b3 = (byte) ((int) ((double) (f * 2.0F) + 0.5D));
byte b4 = (byte) ((int) ((double) (f1 * 2.0F) + 0.5D)); byte b4 = (byte) ((int) ((double) (f1 * 2.0F) + 0.5D));
// CraftBukkit
byte b5 = (byte) ((int) ((double) (worldmaphumantracker1.a.yaw * 16.0F / 360.0F) + 0.5D)); byte b5 = (byte) ((int) ((double) (worldmaphumantracker1.a.yaw * 16.0F / 360.0F) + 0.5D));
if (this.d < 0) { if (this.d < 0) {

View File

@ -16,7 +16,7 @@ import org.bukkit.craftbukkit.generator.SkyLandsChunkGenerator;
import org.bukkit.event.weather.LightningStrikeEvent; import org.bukkit.event.weather.LightningStrikeEvent;
public class WorldServer extends World implements BlockChangeDelegate { public class WorldServer extends World implements BlockChangeDelegate {
// CraftBukkit end // CraftBukkit end
public ChunkProviderServer chunkProviderServer; public ChunkProviderServer chunkProviderServer;
public boolean weirdIsOpCache = false; public boolean weirdIsOpCache = false;
@ -70,7 +70,7 @@ public class WorldServer extends World implements BlockChangeDelegate {
protected IChunkProvider b() { protected IChunkProvider b() {
IChunkLoader ichunkloader = this.w.a(this.worldProvider); IChunkLoader ichunkloader = this.w.a(this.worldProvider);
// Craftbukkit start // CraftBukkit start
InternalChunkGenerator gen; InternalChunkGenerator gen;
if (this.generator != null) { if (this.generator != null) {
@ -84,7 +84,7 @@ public class WorldServer extends World implements BlockChangeDelegate {
} }
this.chunkProviderServer = new ChunkProviderServer(this, ichunkloader, gen); this.chunkProviderServer = new ChunkProviderServer(this, ichunkloader, gen);
// Craftbukkit end // CraftBukkit end
return this.chunkProviderServer; return this.chunkProviderServer;
} }
@ -162,9 +162,11 @@ public class WorldServer extends World implements BlockChangeDelegate {
return explosion; return explosion;
} }
// explosion.a = flag; /* CraftBukkit
// explosion.a(); explosion.a = flag;
// explosion.a(false); explosion.a();
explosion.a(false);
// CraftBukkit */
this.server.serverConfigurationManager.a(d0, d1, d2, 64.0D, this.dimension, new Packet60Explosion(d0, d1, d2, f, explosion.g)); this.server.serverConfigurationManager.a(d0, d1, d2, 64.0D, this.dimension, new Packet60Explosion(d0, d1, d2, f, explosion.g));
// CraftBukkit end // CraftBukkit end
return explosion; return explosion;