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

@ -1,150 +1,153 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random; import java.util.Random;
import org.bukkit.Bukkit; // CraftBukkit start
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.entity.EntityPortalEnterEvent; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.event.entity.EntityPortalEnterEvent;
public class BlockPortal extends BlockBreakable { // CraftBukkit end
public BlockPortal(int i, int j) { public class BlockPortal extends BlockBreakable {
super(i, j, Material.PORTAL, false);
} public BlockPortal(int i, int j) {
super(i, j, Material.PORTAL, false);
public AxisAlignedBB d(World world, int i, int j, int k) { }
return null;
} public AxisAlignedBB d(World world, int i, int j, int k) {
return null;
public void a(IBlockAccess iblockaccess, int i, int j, int k) { }
float f;
float f1; public void a(IBlockAccess iblockaccess, int i, int j, int k) {
float f;
if (iblockaccess.getTypeId(i - 1, j, k) != this.id && iblockaccess.getTypeId(i + 1, j, k) != this.id) { float f1;
f = 0.125F;
f1 = 0.5F; if (iblockaccess.getTypeId(i - 1, j, k) != this.id && iblockaccess.getTypeId(i + 1, j, k) != this.id) {
this.a(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1); f = 0.125F;
} else { f1 = 0.5F;
f = 0.5F; this.a(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1);
f1 = 0.125F; } else {
this.a(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1); f = 0.5F;
} f1 = 0.125F;
} this.a(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1);
}
public boolean a() { }
return false;
} public boolean a() {
return false;
public boolean b() { }
return false;
} public boolean b() {
return false;
public boolean a_(World world, int i, int j, int k) { }
byte b0 = 0;
byte b1 = 0; public boolean a_(World world, int i, int j, int k) {
byte b0 = 0;
if (world.getTypeId(i - 1, j, k) == Block.OBSIDIAN.id || world.getTypeId(i + 1, j, k) == Block.OBSIDIAN.id) { byte b1 = 0;
b0 = 1;
} if (world.getTypeId(i - 1, j, k) == Block.OBSIDIAN.id || world.getTypeId(i + 1, j, k) == Block.OBSIDIAN.id) {
b0 = 1;
if (world.getTypeId(i, j, k - 1) == Block.OBSIDIAN.id || world.getTypeId(i, j, k + 1) == Block.OBSIDIAN.id) { }
b1 = 1;
} if (world.getTypeId(i, j, k - 1) == Block.OBSIDIAN.id || world.getTypeId(i, j, k + 1) == Block.OBSIDIAN.id) {
b1 = 1;
if (b0 == b1) { }
return false;
} else { if (b0 == b1) {
if (world.getTypeId(i - b0, j, k - b1) == 0) { return false;
i -= b0; } else {
k -= b1; if (world.getTypeId(i - b0, j, k - b1) == 0) {
} i -= b0;
k -= b1;
int l; }
int i1;
int l;
for (l = -1; l <= 2; ++l) { int i1;
for (i1 = -1; i1 <= 3; ++i1) {
boolean flag = l == -1 || l == 2 || i1 == -1 || i1 == 3; for (l = -1; l <= 2; ++l) {
for (i1 = -1; i1 <= 3; ++i1) {
if (l != -1 && l != 2 || i1 != -1 && i1 != 3) { boolean flag = l == -1 || l == 2 || i1 == -1 || i1 == 3;
int j1 = world.getTypeId(i + b0 * l, j + i1, k + b1 * l);
if (l != -1 && l != 2 || i1 != -1 && i1 != 3) {
if (flag) { int j1 = world.getTypeId(i + b0 * l, j + i1, k + b1 * l);
if (j1 != Block.OBSIDIAN.id) {
return false; if (flag) {
} if (j1 != Block.OBSIDIAN.id) {
} else if (j1 != 0 && j1 != Block.FIRE.id) { return false;
return false; }
} } else if (j1 != 0 && j1 != Block.FIRE.id) {
} return false;
} }
} }
}
world.o = true; }
for (l = 0; l < 2; ++l) { world.o = true;
for (i1 = 0; i1 < 3; ++i1) {
world.setTypeId(i + b0 * l, j + i1, k + b1 * l, Block.PORTAL.id); for (l = 0; l < 2; ++l) {
} for (i1 = 0; i1 < 3; ++i1) {
} world.setTypeId(i + b0 * l, j + i1, k + b1 * l, Block.PORTAL.id);
}
world.o = false; }
return true;
} world.o = false;
} return true;
}
public void doPhysics(World world, int i, int j, int k, int l) { }
byte b0 = 0;
byte b1 = 1; public void doPhysics(World world, int i, int j, int k, int l) {
byte b0 = 0;
if (world.getTypeId(i - 1, j, k) == this.id || world.getTypeId(i + 1, j, k) == this.id) { byte b1 = 1;
b0 = 1;
b1 = 0; if (world.getTypeId(i - 1, j, k) == this.id || world.getTypeId(i + 1, j, k) == this.id) {
} b0 = 1;
b1 = 0;
int i1; }
for (i1 = j; world.getTypeId(i, i1 - 1, k) == this.id; --i1) { int i1;
;
} for (i1 = j; world.getTypeId(i, i1 - 1, k) == this.id; --i1) {
;
if (world.getTypeId(i, i1 - 1, k) != Block.OBSIDIAN.id) { }
world.setTypeId(i, j, k, 0);
} else { if (world.getTypeId(i, i1 - 1, k) != Block.OBSIDIAN.id) {
int j1; world.setTypeId(i, j, k, 0);
} else {
for (j1 = 1; j1 < 4 && world.getTypeId(i, i1 + j1, k) == this.id; ++j1) { int j1;
;
} for (j1 = 1; j1 < 4 && world.getTypeId(i, i1 + j1, k) == this.id; ++j1) {
;
if (j1 == 3 && world.getTypeId(i, i1 + j1, k) == Block.OBSIDIAN.id) { }
boolean flag = world.getTypeId(i - 1, j, k) == this.id || world.getTypeId(i + 1, j, k) == this.id;
boolean flag1 = world.getTypeId(i, j, k - 1) == this.id || world.getTypeId(i, j, k + 1) == this.id; if (j1 == 3 && world.getTypeId(i, i1 + j1, k) == Block.OBSIDIAN.id) {
boolean flag = world.getTypeId(i - 1, j, k) == this.id || world.getTypeId(i + 1, j, k) == this.id;
if (flag && flag1) { boolean flag1 = world.getTypeId(i, j, k - 1) == this.id || world.getTypeId(i, j, k + 1) == this.id;
world.setTypeId(i, j, k, 0);
} else if ((world.getTypeId(i + b0, j, k + b1) != Block.OBSIDIAN.id || world.getTypeId(i - b0, j, k - b1) != this.id) && (world.getTypeId(i - b0, j, k - b1) != Block.OBSIDIAN.id || world.getTypeId(i + b0, j, k + b1) != this.id)) { if (flag && flag1) {
world.setTypeId(i, j, k, 0); world.setTypeId(i, j, k, 0);
} } else if ((world.getTypeId(i + b0, j, k + b1) != Block.OBSIDIAN.id || world.getTypeId(i - b0, j, k - b1) != this.id) && (world.getTypeId(i - b0, j, k - b1) != Block.OBSIDIAN.id || world.getTypeId(i + b0, j, k + b1) != this.id)) {
} else { world.setTypeId(i, j, k, 0);
world.setTypeId(i, j, k, 0); }
} } else {
} world.setTypeId(i, j, k, 0);
} }
}
public int a(Random random) { }
return 0;
} public int a(Random random) {
return 0;
public void a(World world, int i, int j, int k, Entity entity) { }
if (entity.vehicle == null && entity.passenger == null) {
// CraftBukkit start - Entity in portal public void a(World world, int i, int j, int k, Entity entity) {
CraftWorld craftWorld = ((WorldServer) world).getWorld(); if (entity.vehicle == null && entity.passenger == null) {
EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(craftWorld,i, j, k)); // CraftBukkit start - Entity in portal
Bukkit.getServer().getPluginManager().callEvent(event); CraftWorld craftWorld = ((WorldServer) world).getWorld();
// CraftBukkit end EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(craftWorld, i, j, k));
entity.O(); Bukkit.getServer().getPluginManager().callEvent(event);
} // CraftBukkit end
}
} 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

@ -169,7 +169,7 @@ public abstract class Entity {
f1 = 0; f1 = 0;
} }
if ((f1 == Float.POSITIVE_INFINITY) || (f1 == Float.NEGATIVE_INFINITY)) { if ((f1 == Float.POSITIVE_INFINITY) || (f1 == Float.NEGATIVE_INFINITY)) {
if (this instanceof EntityPlayer) { if (this instanceof EntityPlayer) {
System.err.println(((CraftPlayer) this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid pitch"); System.err.println(((CraftPlayer) this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid pitch");
((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope"); ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope");
@ -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

@ -189,7 +189,7 @@ public class EntityArrow extends Entity {
stick = movingobjectposition.entity.damageEntity(this.shooter, 4); stick = movingobjectposition.entity.damageEntity(this.shooter, 4);
} }
if (stick) { if (stick) {
// CraftBukkit end // CraftBukkit end
this.world.makeSound(this, "random.drr", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); this.world.makeSound(this, "random.drr", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
this.die(); this.die();
} else { } else {

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

@ -149,16 +149,17 @@ 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);
if (!event.isCancelled()) { server.getPluginManager().callEvent(event);
// give 'this' instead of (Entity) null so we know what causes the damage if (!event.isCancelled()) {
this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); // give 'this' instead of (Entity) null so we know what causes the damage
this.die(); this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
} this.die();
// CraftBukkit end }
// CraftBukkit end
} }
// this.die() // # CraftBukkit // this.die() // # CraftBukkit

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

@ -25,7 +25,7 @@ public class EntityWeatherStorm extends EntityWeather {
} }
public EntityWeatherStorm(World world, double d0, double d1, double d2, boolean isEffect) { public EntityWeatherStorm(World world, double d0, double d1, double d2, boolean isEffect) {
// CraftBukkit end // CraftBukkit end
super(world); super(world);

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);
@ -428,4 +429,4 @@ public class EntityWolf extends EntityAnimal {
this.datawatcher.b(16, Byte.valueOf((byte) (b0 & -5))); this.datawatcher.b(16, Byte.valueOf((byte) (b0 & -5)));
} }
} }
} }

View File

@ -47,7 +47,7 @@ public class ItemBed extends Item {
world.setTypeIdAndData(i, j, k, blockbed.id, i1); world.setTypeIdAndData(i, j, k, blockbed.id, i1);
// CraftBukkit start - bed // CraftBukkit start - bed
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, blockbed); BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, blockbed);
if (event.isCancelled() || !event.canBuild()) { if (event.isCancelled() || !event.canBuild()) {
event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false);

View File

@ -57,7 +57,7 @@ public class ItemBlock extends Item {
// CraftBukkit start - This executes the placement of the block // CraftBukkit start - This executes the placement of the block
BlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k); BlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k);
// There are like 30 combinations you can mix and match steps and double steps // There are like 30 combinations you can mix and match steps and double steps
// of different materials, so there are a lot of different cases of what // of different materials, so there are a lot of different cases of what
// would happen if you place x step onto another y step, so let's just keep // would happen if you place x step onto another y step, so let's just keep
@ -67,7 +67,7 @@ public class ItemBlock extends Item {
&& (itemstack.id == Block.DOUBLE_STEP.id || itemstack.id == Block.STEP.id)) { && (itemstack.id == Block.DOUBLE_STEP.id || itemstack.id == Block.STEP.id)) {
blockStateBelow = CraftBlockState.getBlockState(world, i, j - 1, k); blockStateBelow = CraftBlockState.getBlockState(world, i, j - 1, k);
} }
/** /**
* @see net.minecraft.server.World#setTypeIdAndData(int i, int j, int k, int l, int i1) * @see net.minecraft.server.World#setTypeIdAndData(int i, int j, int k, int l, int i1)
* *

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

@ -62,7 +62,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
public MinecraftServer(OptionSet options) { // CraftBukkit - adds argument OptionSet public MinecraftServer(OptionSet options) { // CraftBukkit - adds argument OptionSet
new ThreadSleepForever(this); new ThreadSleepForever(this);
// CraftBukkit start // CraftBukkit start
this.options = options; this.options = options;
try { try {
this.reader = new ConsoleReader(); this.reader = new ConsoleReader();
@ -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));
@ -130,12 +130,13 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// Prevent 40 event-calls for less than b single pixel of movement >.> // Prevent 40 event-calls for less than b single pixel of movement >.>
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();
@ -191,7 +192,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
} }
if (this.m && !this.player.dead) { if (this.m && !this.player.dead) {
// CraftBukkit end // CraftBukkit end
double d1; double d1;
double d2; double d2;
double d3; double d3;
@ -297,9 +298,10 @@ 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);
this.disconnect("You moved too quickly :( (Hacking?)"); this.disconnect("You moved too quickly :( (Hacking?)");
return; return;
} }
@ -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

@ -28,7 +28,7 @@ public class Packet51MapChunk extends Packet {
} }
public Packet51MapChunk(int i, int j, int k, int l, int i1, int j1, byte[] data) { public Packet51MapChunk(int i, int j, int k, int l, int i1, int j1, byte[] data) {
// CraftBukkit - end // CraftBukkit - end
this.k = true; this.k = true;
this.a = i; this.a = i;
this.b = j; this.b = j;
@ -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

@ -61,7 +61,7 @@ class PlayerInstance {
} }
entityplayer.f.remove(this.e); entityplayer.f.remove(this.e);
// CraftBukkit - contains -> remove -- TODO VERIFY!!!! // CraftBukkit - contains -> remove -- TODO VERIFY!!!!
if (entityplayer.g.remove(this.e)) { if (entityplayer.g.remove(this.e)) {
entityplayer.netServerHandler.sendPacket(new Packet50PreChunk(this.chunkX, this.chunkZ, false)); entityplayer.netServerHandler.sendPacket(new Packet50PreChunk(this.chunkX, this.chunkZ, false));
} }

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

@ -1,328 +1,330 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random; import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.event.world.PortalCreateEvent; import org.bukkit.event.world.PortalCreateEvent;
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
// CraftBukkit end // CraftBukkit end
public class PortalTravelAgent { public class PortalTravelAgent {
private Random a = new Random(); private Random a = new Random();
public PortalTravelAgent() {} public PortalTravelAgent() {}
public void a(World world, Entity entity) { public void a(World world, Entity entity) {
if (!this.b(world, entity)) { if (!this.b(world, entity)) {
this.c(world, entity); this.c(world, entity);
this.b(world, entity); this.b(world, entity);
} }
} }
public boolean b(World world, Entity entity) { public boolean b(World world, Entity entity) {
short short1 = 128; short short1 = 128;
double d0 = -1.0D; double d0 = -1.0D;
int i = 0; int i = 0;
int j = 0; int j = 0;
int k = 0; int k = 0;
int l = MathHelper.floor(entity.locX); int l = MathHelper.floor(entity.locX);
int i1 = MathHelper.floor(entity.locZ); int i1 = MathHelper.floor(entity.locZ);
double d1; double d1;
for (int j1 = l - short1; j1 <= l + short1; ++j1) { for (int j1 = l - short1; j1 <= l + short1; ++j1) {
double d2 = (double) j1 + 0.5D - entity.locX; double d2 = (double) j1 + 0.5D - entity.locX;
for (int k1 = i1 - short1; k1 <= i1 + short1; ++k1) { for (int k1 = i1 - short1; k1 <= i1 + short1; ++k1) {
double d3 = (double) k1 + 0.5D - entity.locZ; double d3 = (double) k1 + 0.5D - entity.locZ;
for (int l1 = 127; l1 >= 0; --l1) { for (int l1 = 127; l1 >= 0; --l1) {
if (world.getTypeId(j1, l1, k1) == Block.PORTAL.id) { if (world.getTypeId(j1, l1, k1) == Block.PORTAL.id) {
while (world.getTypeId(j1, l1 - 1, k1) == Block.PORTAL.id) { while (world.getTypeId(j1, l1 - 1, k1) == Block.PORTAL.id) {
--l1; --l1;
} }
d1 = (double) l1 + 0.5D - entity.locY; d1 = (double) l1 + 0.5D - entity.locY;
double d4 = d2 * d2 + d1 * d1 + d3 * d3; double d4 = d2 * d2 + d1 * d1 + d3 * d3;
if (d0 < 0.0D || d4 < d0) { if (d0 < 0.0D || d4 < d0) {
d0 = d4; d0 = d4;
i = j1; i = j1;
j = l1; j = l1;
k = k1; k = k1;
} }
} }
} }
} }
} }
if (d0 >= 0.0D) { if (d0 >= 0.0D) {
double d5 = (double) i + 0.5D; double d5 = (double) i + 0.5D;
double d6 = (double) j + 0.5D; double d6 = (double) j + 0.5D;
d1 = (double) k + 0.5D; d1 = (double) k + 0.5D;
if (world.getTypeId(i - 1, j, k) == Block.PORTAL.id) { if (world.getTypeId(i - 1, j, k) == Block.PORTAL.id) {
d5 -= 0.5D; d5 -= 0.5D;
} }
if (world.getTypeId(i + 1, j, k) == Block.PORTAL.id) { if (world.getTypeId(i + 1, j, k) == Block.PORTAL.id) {
d5 += 0.5D; d5 += 0.5D;
} }
if (world.getTypeId(i, j, k - 1) == Block.PORTAL.id) { if (world.getTypeId(i, j, k - 1) == Block.PORTAL.id) {
d1 -= 0.5D; d1 -= 0.5D;
} }
if (world.getTypeId(i, j, k + 1) == Block.PORTAL.id) { if (world.getTypeId(i, j, k + 1) == Block.PORTAL.id) {
d1 += 0.5D; d1 += 0.5D;
} }
entity.setPositionRotation(d5, d6, d1, entity.yaw, 0.0F); entity.setPositionRotation(d5, d6, d1, entity.yaw, 0.0F);
entity.motX = entity.motY = entity.motZ = 0.0D; entity.motX = entity.motY = entity.motZ = 0.0D;
return true; return true;
} else { } else {
return false; return false;
} }
} }
public boolean c(World world, Entity entity) { public boolean c(World world, Entity entity) {
byte b0 = 16; byte b0 = 16;
double d0 = -1.0D; double d0 = -1.0D;
int i = MathHelper.floor(entity.locX); int i = MathHelper.floor(entity.locX);
int j = MathHelper.floor(entity.locY); int j = MathHelper.floor(entity.locY);
int k = MathHelper.floor(entity.locZ); int k = MathHelper.floor(entity.locZ);
int l = i; int l = i;
int i1 = j; int i1 = j;
int j1 = k; int j1 = k;
int k1 = 0; int k1 = 0;
int l1 = this.a.nextInt(4); int l1 = this.a.nextInt(4);
int i2; int i2;
double d1; double d1;
int j2; int j2;
double d2; double d2;
int k2; int k2;
int l2; int l2;
int i3; int i3;
int j3; int j3;
int k3; int k3;
int l3; int l3;
int i4; int i4;
int j4; int j4;
int k4; int k4;
double d3; double d3;
double d4; double d4;
for (i2 = i - b0; i2 <= i + b0; ++i2) { for (i2 = i - b0; i2 <= i + b0; ++i2) {
d1 = (double) i2 + 0.5D - entity.locX; d1 = (double) i2 + 0.5D - entity.locX;
for (j2 = k - b0; j2 <= k + b0; ++j2) { for (j2 = k - b0; j2 <= k + b0; ++j2) {
d2 = (double) j2 + 0.5D - entity.locZ; d2 = (double) j2 + 0.5D - entity.locZ;
label271: label271:
for (l2 = 127; l2 >= 0; --l2) { for (l2 = 127; l2 >= 0; --l2) {
if (world.isEmpty(i2, l2, j2)) { if (world.isEmpty(i2, l2, j2)) {
while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) { while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) {
--l2; --l2;
} }
for (k2 = l1; k2 < l1 + 4; ++k2) { for (k2 = l1; k2 < l1 + 4; ++k2) {
j3 = k2 % 2; j3 = k2 % 2;
i3 = 1 - j3; i3 = 1 - j3;
if (k2 % 4 >= 2) { if (k2 % 4 >= 2) {
j3 = -j3; j3 = -j3;
i3 = -i3; i3 = -i3;
} }
for (l3 = 0; l3 < 3; ++l3) { for (l3 = 0; l3 < 3; ++l3) {
for (k3 = 0; k3 < 4; ++k3) { for (k3 = 0; k3 < 4; ++k3) {
for (j4 = -1; j4 < 4; ++j4) { for (j4 = -1; j4 < 4; ++j4) {
i4 = i2 + (k3 - 1) * j3 + l3 * i3; i4 = i2 + (k3 - 1) * j3 + l3 * i3;
k4 = l2 + j4; k4 = l2 + j4;
int l4 = j2 + (k3 - 1) * i3 - l3 * j3; int l4 = j2 + (k3 - 1) * i3 - l3 * j3;
if (j4 < 0 && !world.getMaterial(i4, k4, l4).isBuildable() || j4 >= 0 && !world.isEmpty(i4, k4, l4)) { if (j4 < 0 && !world.getMaterial(i4, k4, l4).isBuildable() || j4 >= 0 && !world.isEmpty(i4, k4, l4)) {
continue label271; continue label271;
} }
} }
} }
} }
d3 = (double) l2 + 0.5D - entity.locY; d3 = (double) l2 + 0.5D - entity.locY;
d4 = d1 * d1 + d3 * d3 + d2 * d2; d4 = d1 * d1 + d3 * d3 + d2 * d2;
if (d0 < 0.0D || d4 < d0) { if (d0 < 0.0D || d4 < d0) {
d0 = d4; d0 = d4;
l = i2; l = i2;
i1 = l2; i1 = l2;
j1 = j2; j1 = j2;
k1 = k2 % 4; k1 = k2 % 4;
} }
} }
} }
} }
} }
} }
if (d0 < 0.0D) { if (d0 < 0.0D) {
for (i2 = i - b0; i2 <= i + b0; ++i2) { for (i2 = i - b0; i2 <= i + b0; ++i2) {
d1 = (double) i2 + 0.5D - entity.locX; d1 = (double) i2 + 0.5D - entity.locX;
for (j2 = k - b0; j2 <= k + b0; ++j2) { for (j2 = k - b0; j2 <= k + b0; ++j2) {
d2 = (double) j2 + 0.5D - entity.locZ; d2 = (double) j2 + 0.5D - entity.locZ;
label219: label219:
for (l2 = 127; l2 >= 0; --l2) { for (l2 = 127; l2 >= 0; --l2) {
if (world.isEmpty(i2, l2, j2)) { if (world.isEmpty(i2, l2, j2)) {
while (world.isEmpty(i2, l2 - 1, j2)) { while (world.isEmpty(i2, l2 - 1, j2)) {
--l2; --l2;
} }
for (k2 = l1; k2 < l1 + 2; ++k2) { for (k2 = l1; k2 < l1 + 2; ++k2) {
j3 = k2 % 2; j3 = k2 % 2;
i3 = 1 - j3; i3 = 1 - j3;
for (l3 = 0; l3 < 4; ++l3) { for (l3 = 0; l3 < 4; ++l3) {
for (k3 = -1; k3 < 4; ++k3) { for (k3 = -1; k3 < 4; ++k3) {
j4 = i2 + (l3 - 1) * j3; j4 = i2 + (l3 - 1) * j3;
i4 = l2 + k3; i4 = l2 + k3;
k4 = j2 + (l3 - 1) * i3; k4 = j2 + (l3 - 1) * i3;
if (k3 < 0 && !world.getMaterial(j4, i4, k4).isBuildable() || k3 >= 0 && !world.isEmpty(j4, i4, k4)) { if (k3 < 0 && !world.getMaterial(j4, i4, k4).isBuildable() || k3 >= 0 && !world.isEmpty(j4, i4, k4)) {
continue label219; continue label219;
} }
} }
} }
d3 = (double) l2 + 0.5D - entity.locY; d3 = (double) l2 + 0.5D - entity.locY;
d4 = d1 * d1 + d3 * d3 + d2 * d2; d4 = d1 * d1 + d3 * d3 + d2 * d2;
if (d0 < 0.0D || d4 < d0) { if (d0 < 0.0D || d4 < d0) {
d0 = d4; d0 = d4;
l = i2; l = i2;
i1 = l2; i1 = l2;
j1 = j2; j1 = j2;
k1 = k2 % 2; k1 = k2 % 2;
} }
} }
} }
} }
} }
} }
} }
int i5 = l; int i5 = l;
int j5 = i1; int j5 = i1;
j2 = j1; j2 = j1;
int k5 = k1 % 2; int k5 = k1 % 2;
int l5 = 1 - k5; int l5 = 1 - k5;
if (k1 % 4 >= 2) { if (k1 % 4 >= 2) {
k5 = -k5; k5 = -k5;
l5 = -l5; l5 = -l5;
} }
boolean flag; boolean flag;
// 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) {
if (i1 < 70) { if (i1 < 70) {
i1 = 70; i1 = 70;
} }
if (i1 > 118) { if (i1 > 118) {
i1 = 118; i1 = 118;
} }
j5 = i1; j5 = i1;
for (l2 = -1; l2 <= 1; ++l2) { for (l2 = -1; l2 <= 1; ++l2) {
for (k2 = 1; k2 < 3; ++k2) { for (k2 = 1; k2 < 3; ++k2) {
for (j3 = -1; j3 < 3; ++j3) { for (j3 = -1; j3 < 3; ++j3) {
i3 = i5 + (k2 - 1) * k5 + l2 * l5; i3 = i5 + (k2 - 1) * k5 + l2 * l5;
l3 = j5 + j3; l3 = j5 + j3;
k3 = j2 + (k2 - 1) * l5 - l2 * k5; k3 = j2 + (k2 - 1) * l5 - l2 * k5;
org.bukkit.block.Block b = craftWorld.getBlockAt(i3, l3, k3); org.bukkit.block.Block b = craftWorld.getBlockAt(i3, l3, k3);
if (!blocks.contains(b)) { if (!blocks.contains(b)) {
blocks.add(b); blocks.add(b);
} }
} }
} }
} }
} }
for (l2 = 0; l2 < 4; ++l2) { for (l2 = 0; l2 < 4; ++l2) {
for (k2 = 0; k2 < 4; ++k2) { for (k2 = 0; k2 < 4; ++k2) {
for (j3 = -1; j3 < 4; ++j3) { for (j3 = -1; j3 < 4; ++j3) {
i3 = i5 + (k2 - 1) * k5; i3 = i5 + (k2 - 1) * k5;
l3 = j5 + j3; l3 = j5 + j3;
k3 = j2 + (k2 - 1) * l5; k3 = j2 + (k2 - 1) * l5;
org.bukkit.block.Block b = craftWorld.getBlockAt(i3, l3, k3); org.bukkit.block.Block b = craftWorld.getBlockAt(i3, l3, k3);
if (!blocks.contains(b)) { if (!blocks.contains(b)) {
blocks.add(b); blocks.add(b);
} }
} }
} }
} }
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()) {
// CraftBukkit end return true;
}
if (d0 < 0.0D) { // CraftBukkit end
if (i1 < 70) {
i1 = 70; if (d0 < 0.0D) {
} if (i1 < 70) {
i1 = 70;
if (i1 > 118) { }
i1 = 118;
} if (i1 > 118) {
i1 = 118;
j5 = i1; }
for (l2 = -1; l2 <= 1; ++l2) { j5 = i1;
for (k2 = 1; k2 < 3; ++k2) {
for (j3 = -1; j3 < 3; ++j3) { for (l2 = -1; l2 <= 1; ++l2) {
i3 = i5 + (k2 - 1) * k5 + l2 * l5; for (k2 = 1; k2 < 3; ++k2) {
l3 = j5 + j3; for (j3 = -1; j3 < 3; ++j3) {
k3 = j2 + (k2 - 1) * l5 - l2 * k5; i3 = i5 + (k2 - 1) * k5 + l2 * l5;
flag = j3 < 0; l3 = j5 + j3;
world.setTypeId(i3, l3, k3, flag ? Block.OBSIDIAN.id : 0); k3 = j2 + (k2 - 1) * l5 - l2 * k5;
} flag = j3 < 0;
} world.setTypeId(i3, l3, k3, flag ? Block.OBSIDIAN.id : 0);
} }
} }
}
for (l2 = 0; l2 < 4; ++l2) { }
world.o = true;
for (l2 = 0; l2 < 4; ++l2) {
for (k2 = 0; k2 < 4; ++k2) { world.o = true;
for (j3 = -1; j3 < 4; ++j3) {
i3 = i5 + (k2 - 1) * k5; for (k2 = 0; k2 < 4; ++k2) {
l3 = j5 + j3; for (j3 = -1; j3 < 4; ++j3) {
k3 = j2 + (k2 - 1) * l5; i3 = i5 + (k2 - 1) * k5;
flag = k2 == 0 || k2 == 3 || j3 == -1 || j3 == 3; l3 = j5 + j3;
world.setTypeId(i3, l3, k3, flag ? Block.OBSIDIAN.id : Block.PORTAL.id); k3 = j2 + (k2 - 1) * l5;
} flag = k2 == 0 || k2 == 3 || j3 == -1 || j3 == 3;
} world.setTypeId(i3, l3, k3, flag ? Block.OBSIDIAN.id : Block.PORTAL.id);
}
world.o = false; }
for (k2 = 0; k2 < 4; ++k2) { world.o = false;
for (j3 = -1; j3 < 4; ++j3) {
i3 = i5 + (k2 - 1) * k5; for (k2 = 0; k2 < 4; ++k2) {
l3 = j5 + j3; for (j3 = -1; j3 < 4; ++j3) {
k3 = j2 + (k2 - 1) * l5; i3 = i5 + (k2 - 1) * k5;
world.applyPhysics(i3, l3, k3, world.getTypeId(i3, l3, k3)); l3 = j5 + j3;
} k3 = j2 + (k2 - 1) * l5;
} world.applyPhysics(i3, l3, k3, world.getTypeId(i3, l3, k3));
} }
}
return true; }
}
} return true;
}
}

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 {
} }
} }
CraftWorld fromCraftWorld = worldserver.getWorld(); // CraftBukkit start
CraftWorld toCraftWorld = this.server.a(b0).getWorld(); CraftWorld fromCraftWorld = worldserver.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,9 +819,10 @@ 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()) {
return false; if (event.isCancelled()) {
} return false;
}
} else if (entity instanceof EntityItem) { } else if (entity instanceof EntityItem) {
ItemSpawnEvent event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity); ItemSpawnEvent event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
if (event.isCancelled()) { if (event.isCancelled()) {
@ -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;