From 96b1b8a10cec88c724b83541aed6f87b188f5e14 Mon Sep 17 00:00:00 2001 From: Erik Broes Date: Sun, 12 Jun 2011 00:02:58 +0200 Subject: [PATCH] Generic cleanup --- .../net/minecraft/server/BlockDispenser.java | 8 +- .../java/net/minecraft/server/BlockDoor.java | 2 +- .../net/minecraft/server/BlockFlowing.java | 3 +- .../net/minecraft/server/BlockPortal.java | 303 ++++---- .../minecraft/server/BlockPressurePlate.java | 11 +- .../java/net/minecraft/server/BlockSoil.java | 2 +- src/main/java/net/minecraft/server/Chunk.java | 2 +- .../minecraft/server/ChunkProviderServer.java | 8 +- .../server/ConsoleCommandHandler.java | 22 +- .../java/net/minecraft/server/Entity.java | 30 +- .../net/minecraft/server/EntityArrow.java | 2 +- .../java/net/minecraft/server/EntityBoat.java | 2 +- .../net/minecraft/server/EntityFireball.java | 19 +- .../net/minecraft/server/EntityHuman.java | 3 +- .../net/minecraft/server/EntityMinecart.java | 2 +- .../net/minecraft/server/EntityPlayer.java | 8 +- .../minecraft/server/EntityWeatherStorm.java | 2 +- .../java/net/minecraft/server/EntityWolf.java | 3 +- .../java/net/minecraft/server/ItemBed.java | 2 +- .../java/net/minecraft/server/ItemBlock.java | 4 +- .../minecraft/server/ItemFlintAndSteel.java | 6 +- .../minecraft/server/ItemInWorldManager.java | 5 +- .../net/minecraft/server/MinecraftServer.java | 4 +- .../net/minecraft/server/NetLoginHandler.java | 2 +- .../minecraft/server/NetServerHandler.java | 18 +- .../net/minecraft/server/NetworkManager.java | 9 +- .../minecraft/server/Packet51MapChunk.java | 4 +- .../net/minecraft/server/PlayerInstance.java | 2 +- .../net/minecraft/server/PlayerManager.java | 2 +- .../minecraft/server/PortalTravelAgent.java | 658 +++++++++--------- .../server/SecondaryWorldServer.java | 2 +- .../server/ServerConfigurationManager.java | 65 +- .../minecraft/server/TileEntityFurnace.java | 2 +- src/main/java/net/minecraft/server/World.java | 68 +- .../net/minecraft/server/WorldManager.java | 2 +- .../java/net/minecraft/server/WorldMap.java | 1 + .../net/minecraft/server/WorldServer.java | 14 +- 37 files changed, 667 insertions(+), 635 deletions(-) diff --git a/src/main/java/net/minecraft/server/BlockDispenser.java b/src/main/java/net/minecraft/server/BlockDispenser.java index 4b4bb85476..04fbed78c4 100644 --- a/src/main/java/net/minecraft/server/BlockDispenser.java +++ b/src/main/java/net/minecraft/server/BlockDispenser.java @@ -114,10 +114,8 @@ public class BlockDispenser extends BlockContainer { if (itemstack == null) { world.e(1001, i, j, k, 0); } else { - double d3; - // CraftBukkit start - d3 = random.nextDouble() * 0.1D + 0.2D; + double d3 = random.nextDouble() * 0.1D + 0.2D; double motX = (double) b0 * d3; double motY = 0.20000000298023224D; double motZ = (double) b1 * d3; @@ -167,9 +165,9 @@ public class BlockDispenser extends BlockContainer { world.e(1002, i, j, k, 0); } else { EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack); - // CraftBukkit start - d3 = random.nextDouble() * 0.1D + 0.2D; + // double d3 = random.nextDouble() * 0.1D + 0.2D; // Moved up + entityitem.motX = motX; entityitem.motY = motY; entityitem.motZ = motZ; diff --git a/src/main/java/net/minecraft/server/BlockDoor.java b/src/main/java/net/minecraft/server/BlockDoor.java index 7f81129036..914a80c303 100644 --- a/src/main/java/net/minecraft/server/BlockDoor.java +++ b/src/main/java/net/minecraft/server/BlockDoor.java @@ -177,8 +177,8 @@ public class BlockDoor extends Block { int power = block.getBlockPower(); int powerTop = blockTop.getBlockPower(); 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); flag1 = eventRedstone.getNewCurrent() > 0; diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java index 9cadaa687d..e803535991 100644 --- a/src/main/java/net/minecraft/server/BlockFlowing.java +++ b/src/main/java/net/minecraft/server/BlockFlowing.java @@ -126,8 +126,9 @@ public class BlockFlowing extends BlockFluids { } // 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; + for (BlockFace currentFace: faces) { if (aboolean[index]) { BlockFromToEvent event = new BlockFromToEvent(source, currentFace); diff --git a/src/main/java/net/minecraft/server/BlockPortal.java b/src/main/java/net/minecraft/server/BlockPortal.java index dec1e9dedd..2afd50613e 100644 --- a/src/main/java/net/minecraft/server/BlockPortal.java +++ b/src/main/java/net/minecraft/server/BlockPortal.java @@ -1,150 +1,153 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.craftbukkit.block.CraftBlock; -import org.bukkit.event.entity.EntityPortalEnterEvent; - -public class BlockPortal extends BlockBreakable { - - 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 void a(IBlockAccess iblockaccess, int i, int j, int k) { - float f; - float f1; - - if (iblockaccess.getTypeId(i - 1, j, k) != this.id && iblockaccess.getTypeId(i + 1, j, k) != this.id) { - f = 0.125F; - f1 = 0.5F; - this.a(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1); - } else { - 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 b() { - return false; - } - - public boolean a_(World world, int i, int j, int k) { - byte b0 = 0; - byte b1 = 0; - - 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 (b0 == b1) { - return false; - } else { - if (world.getTypeId(i - b0, j, k - b1) == 0) { - i -= b0; - k -= b1; - } - - int l; - int i1; - - for (l = -1; l <= 2; ++l) { - for (i1 = -1; i1 <= 3; ++i1) { - boolean flag = l == -1 || l == 2 || i1 == -1 || i1 == 3; - - if (l != -1 && l != 2 || i1 != -1 && i1 != 3) { - int j1 = world.getTypeId(i + b0 * l, j + i1, k + b1 * l); - - if (flag) { - if (j1 != Block.OBSIDIAN.id) { - return false; - } - } else if (j1 != 0 && j1 != Block.FIRE.id) { - return false; - } - } - } - } - - world.o = true; - - 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; - } - } - - public void doPhysics(World world, int i, int j, int k, int l) { - byte b0 = 0; - byte b1 = 1; - - 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) { - ; - } - - if (world.getTypeId(i, i1 - 1, k) != Block.OBSIDIAN.id) { - world.setTypeId(i, j, k, 0); - } else { - 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 (flag && flag1) { - 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)) { - world.setTypeId(i, j, k, 0); - } - } else { - world.setTypeId(i, j, k, 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 - CraftWorld craftWorld = ((WorldServer) world).getWorld(); - EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(craftWorld,i, j, k)); - Bukkit.getServer().getPluginManager().callEvent(event); - // CraftBukkit end - entity.O(); - } - } -} \ No newline at end of file +package net.minecraft.server; + +import java.util.Random; + +// CraftBukkit start +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.event.entity.EntityPortalEnterEvent; +// CraftBukkit end + +public class BlockPortal extends BlockBreakable { + + 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 void a(IBlockAccess iblockaccess, int i, int j, int k) { + float f; + float f1; + + if (iblockaccess.getTypeId(i - 1, j, k) != this.id && iblockaccess.getTypeId(i + 1, j, k) != this.id) { + f = 0.125F; + f1 = 0.5F; + this.a(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1); + } else { + 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 b() { + return false; + } + + public boolean a_(World world, int i, int j, int k) { + byte b0 = 0; + byte b1 = 0; + + 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 (b0 == b1) { + return false; + } else { + if (world.getTypeId(i - b0, j, k - b1) == 0) { + i -= b0; + k -= b1; + } + + int l; + int i1; + + for (l = -1; l <= 2; ++l) { + for (i1 = -1; i1 <= 3; ++i1) { + boolean flag = l == -1 || l == 2 || i1 == -1 || i1 == 3; + + if (l != -1 && l != 2 || i1 != -1 && i1 != 3) { + int j1 = world.getTypeId(i + b0 * l, j + i1, k + b1 * l); + + if (flag) { + if (j1 != Block.OBSIDIAN.id) { + return false; + } + } else if (j1 != 0 && j1 != Block.FIRE.id) { + return false; + } + } + } + } + + world.o = true; + + 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; + } + } + + public void doPhysics(World world, int i, int j, int k, int l) { + byte b0 = 0; + byte b1 = 1; + + 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) { + ; + } + + if (world.getTypeId(i, i1 - 1, k) != Block.OBSIDIAN.id) { + world.setTypeId(i, j, k, 0); + } else { + 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 (flag && flag1) { + 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)) { + world.setTypeId(i, j, k, 0); + } + } else { + world.setTypeId(i, j, k, 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 + CraftWorld craftWorld = ((WorldServer) world).getWorld(); + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(craftWorld, i, j, k)); + Bukkit.getServer().getPluginManager().callEvent(event); + // CraftBukkit end + + entity.O(); + } + } +} diff --git a/src/main/java/net/minecraft/server/BlockPressurePlate.java b/src/main/java/net/minecraft/server/BlockPressurePlate.java index 2afbb30986..98a4a6556e 100644 --- a/src/main/java/net/minecraft/server/BlockPressurePlate.java +++ b/src/main/java/net/minecraft/server/BlockPressurePlate.java @@ -108,14 +108,15 @@ public class BlockPressurePlate extends Block { for (Object object: list) { if (object != null) { Cancellable cancellable; + if (object instanceof EntityHuman) { 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()) { return; } diff --git a/src/main/java/net/minecraft/server/BlockSoil.java b/src/main/java/net/minecraft/server/BlockSoil.java index a37b3cfd0e..43f0e432f0 100644 --- a/src/main/java/net/minecraft/server/BlockSoil.java +++ b/src/main/java/net/minecraft/server/BlockSoil.java @@ -61,7 +61,7 @@ public class BlockSoil extends Block { cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, Action.PHYSICAL, i, j, k, -1, null); } else { 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()) { diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java index 19097ec341..a3ed445236 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -362,9 +362,9 @@ public class Chunk { if (i != this.x || j != this.z) { System.out.println("Wrong location! " + entity); + // Thread.dumpStack(); // CraftBukkit // CraftBukkit 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); diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java index 40a2b91deb..57da4a8a77 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -6,10 +6,10 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Random; import java.util.Set; // CraftBukkit start +import java.util.Random; import org.bukkit.Server; import org.bukkit.craftbukkit.CraftChunk; 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; if (chunk == this.emptyChunk) return chunk; 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()); Throwable ex = new Throwable(); ex.fillInStackTrace(); @@ -175,7 +175,7 @@ public class ChunkProviderServer implements IChunkProvider { if (this.chunkProvider != null) { this.chunkProvider.getChunkAt(ichunkprovider, i, j); - // Craftbukkit start + // CraftBukkit start BlockSand.a = true; Random random = new Random(); random.setSeed(world.getSeed()); @@ -186,7 +186,7 @@ public class ChunkProviderServer implements IChunkProvider { populator.populate(world.getWorld(), random, chunk.bukkitChunk); } BlockSand.a = false; - // Craftbukkit end + // CraftBukkit end chunk.f(); } diff --git a/src/main/java/net/minecraft/server/ConsoleCommandHandler.java b/src/main/java/net/minecraft/server/ConsoleCommandHandler.java index c8d857803e..a53069ceed 100644 --- a/src/main/java/net/minecraft/server/ConsoleCommandHandler.java +++ b/src/main/java/net/minecraft/server/ConsoleCommandHandler.java @@ -4,12 +4,12 @@ import java.util.Iterator; import java.util.Set; import java.util.logging.Logger; -// Craftbukkit start +// CraftBukkit start import java.util.List; import org.bukkit.craftbukkit.command.ServerCommandListener; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.command.CommandSender; -// Craftbukkit end +// CraftBukkit end public class ConsoleCommandHandler { @@ -44,7 +44,7 @@ public class ConsoleCommandHandler { serverconfigurationmanager.savePlayers(); } - // Craftbukkit start + // CraftBukkit start for (i = 0; i < this.server.worlds.size(); ++i) { worldserver = this.server.worlds.get(i); boolean save = worldserver.E; @@ -58,15 +58,15 @@ public class ConsoleCommandHandler { } else if (s.toLowerCase().startsWith("save-off")) { this.print(s1, "Disabling level saving.."); - for (i = 0; i < this.server.worlds.size(); ++i) { // Craftbukkit start - worldserver = this.server.worlds.get(i); // Craftbukkit start + for (i = 0; i < this.server.worlds.size(); ++i) { // CraftBukkit + worldserver = this.server.worlds.get(i); // CraftBukkit worldserver.E = true; } } else if (s.toLowerCase().startsWith("save-on")) { this.print(s1, "Enabling level saving.."); - for (i = 0; i < this.server.worlds.size(); ++i) { // Craftbukkit start - worldserver = this.server.worlds.get(i); // Craftbukkit start + for (i = 0; i < this.server.worlds.size(); ++i) { // CraftBukkit + worldserver = this.server.worlds.get(i); // CraftBukkit worldserver.E = false; } } else { @@ -205,15 +205,15 @@ public class ConsoleCommandHandler { WorldServer worldserver1; if ("add".equalsIgnoreCase(s3)) { - for (k = 0; k < this.server.worlds.size(); ++k) { // Craftbukkit start - worldserver1 = this.server.worlds.get(k); // Craftbukkit start + for (k = 0; k < this.server.worlds.size(); ++k) { // CraftBukkit + worldserver1 = this.server.worlds.get(k); // CraftBukkit worldserver1.setTime(worldserver1.getTime() + (long) j); } this.print(s1, "Added " + j + " to time"); } else if ("set".equalsIgnoreCase(s3)) { - for (k = 0; k < this.server.worlds.size(); ++k) { // Craftbukkit start - worldserver1 = this.server.worlds.get(k); // Craftbukkit start + for (k = 0; k < this.server.worlds.size(); ++k) { // CraftBukkit + worldserver1 = this.server.worlds.get(k); // CraftBukkit worldserver1.setTime((long) j); } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 16fc9ebecf..d11786c931 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -169,7 +169,7 @@ public abstract class Entity { f1 = 0; } - if ((f1 == Float.POSITIVE_INFINITY) || (f1 == Float.NEGATIVE_INFINITY)) { + if ((f1 == Float.POSITIVE_INFINITY) || (f1 == Float.NEGATIVE_INFINITY)) { if (this instanceof EntityPlayer) { System.err.println(((CraftPlayer) this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid pitch"); ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope"); @@ -752,11 +752,12 @@ public abstract class Entity { public void a(World world) { // CraftBukkit start - if(world == null) { + if (world == null) { 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 } @@ -909,9 +910,11 @@ public abstract class Entity { nbttagcompound.a("Fire", (short) this.fireTicks); nbttagcompound.a("Air", (short) this.airTicks); nbttagcompound.a("OnGround", this.onGround); - nbttagcompound.setString("World", world.worldData.name); // CraftBukkit - nbttagcompound.a("UUIDLeast", this.uniqueId.getLeastSignificantBits()); // CraftBukkit - nbttagcompound.a("UUIDMost", this.uniqueId.getMostSignificantBits()); // CraftBukkit + // CraftBukkit start + nbttagcompound.setString("World", world.worldData.name); + nbttagcompound.a("UUIDLeast", this.uniqueId.getLeastSignificantBits()); + nbttagcompound.a("UUIDMost", this.uniqueId.getMostSignificantBits()); + // CraftBukkit end this.b(nbttagcompound); } @@ -923,6 +926,19 @@ public abstract class Entity { this.motX = ((NBTTagDouble) nbttaglist1.a(0)).a; this.motY = ((NBTTagDouble) nbttaglist1.a(1)).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.lastY = this.bp = this.locY = ((NBTTagDouble) nbttaglist.a(1)).a; diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java index a85f74b9b5..8d0294b5b3 100644 --- a/src/main/java/net/minecraft/server/EntityArrow.java +++ b/src/main/java/net/minecraft/server/EntityArrow.java @@ -189,7 +189,7 @@ public class EntityArrow extends Entity { stick = movingobjectposition.entity.damageEntity(this.shooter, 4); } if (stick) { - // CraftBukkit end + // CraftBukkit end this.world.makeSound(this, "random.drr", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); this.die(); } else { diff --git a/src/main/java/net/minecraft/server/EntityBoat.java b/src/main/java/net/minecraft/server/EntityBoat.java index a7b7e48cf5..5d25b27235 100644 --- a/src/main/java/net/minecraft/server/EntityBoat.java +++ b/src/main/java/net/minecraft/server/EntityBoat.java @@ -383,7 +383,7 @@ public class EntityBoat extends Entity { } if (this.passenger != null && this.passenger.dead) { - this.passenger.vehicle = null; + this.passenger.vehicle = null; // CraftBukkit this.passenger = null; } } diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java index 145d2d1c73..3b63884c71 100644 --- a/src/main/java/net/minecraft/server/EntityFireball.java +++ b/src/main/java/net/minecraft/server/EntityFireball.java @@ -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); - server.getPluginManager().callEvent(event); - if (!event.isCancelled()) { - // give 'this' instead of (Entity) null so we know what causes the damage - this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); - this.die(); - } - // CraftBukkit end + ExplosionPrimeEvent event = new ExplosionPrimeEvent(CraftEntity.getEntity(server, this), 1.0F, true); + + server.getPluginManager().callEvent(event); + if (!event.isCancelled()) { + // give 'this' instead of (Entity) null so we know what causes the damage + this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); + this.die(); + } + // CraftBukkit end } // this.die() // # CraftBukkit diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index 2c68c7c4b5..9d43ae5c2c 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -602,6 +602,7 @@ public abstract class EntityHuman extends EntityLiving { Player player = (Player) this.getBukkitEntity(); CraftServer server = ((WorldServer) world).getServer(); org.bukkit.block.Block bed = ((WorldServer) world).getWorld().getBlockAt(i, j, k); + PlayerBedEnterEvent event = new PlayerBedEnterEvent(player, bed); server.getPluginManager().callEvent(event); @@ -760,7 +761,7 @@ public abstract class EntityHuman extends EntityLiving { public void a(ChunkCoordinates chunkcoordinates) { if (chunkcoordinates != null) { this.b = new ChunkCoordinates(chunkcoordinates); - this.spawnWorld = world.worldData.name; + this.spawnWorld = world.worldData.name; // CraftBukkit } else { this.b = null; } diff --git a/src/main/java/net/minecraft/server/EntityMinecart.java b/src/main/java/net/minecraft/server/EntityMinecart.java index 44d75344c6..49397912d7 100644 --- a/src/main/java/net/minecraft/server/EntityMinecart.java +++ b/src/main/java/net/minecraft/server/EntityMinecart.java @@ -583,7 +583,7 @@ public class EntityMinecart extends Entity implements IInventory { } if (this.passenger != null && this.passenger.dead) { - this.passenger.vehicle = null; + this.passenger.vehicle = null; // CraftBukkit this.passenger = null; } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index 305132bfa3..f839b20d40 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -68,20 +68,20 @@ public class EntityPlayer extends EntityHuman implements ICrafting { dead = false; ChunkCoordinates position = null; if (!spawnWorld.isEmpty()) { - CraftWorld cw = (CraftWorld)Bukkit.getServer().getWorld(spawnWorld); + CraftWorld cw = (CraftWorld) Bukkit.getServer().getWorld(spawnWorld); if (cw != null && M() != null) { world = cw.getHandle(); position = EntityHuman.getBed(cw.getHandle(), M()); } } if (world == null || position == null) { - world = ((CraftWorld)Bukkit.getServer().getWorlds().get(0)).getHandle(); + world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); position = world.getSpawn(); } 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 this.itemInWorldManager = new ItemInWorldManager((WorldServer) world); this.itemInWorldManager.player = this; diff --git a/src/main/java/net/minecraft/server/EntityWeatherStorm.java b/src/main/java/net/minecraft/server/EntityWeatherStorm.java index 85c78b088b..c7bba5e646 100644 --- a/src/main/java/net/minecraft/server/EntityWeatherStorm.java +++ b/src/main/java/net/minecraft/server/EntityWeatherStorm.java @@ -25,7 +25,7 @@ public class EntityWeatherStorm extends EntityWeather { } public EntityWeatherStorm(World world, double d0, double d1, double d2, boolean isEffect) { - // CraftBukkit end + // CraftBukkit end super(world); diff --git a/src/main/java/net/minecraft/server/EntityWolf.java b/src/main/java/net/minecraft/server/EntityWolf.java index 68b63f2f88..4cd7ff71a3 100644 --- a/src/main/java/net/minecraft/server/EntityWolf.java +++ b/src/main/java/net/minecraft/server/EntityWolf.java @@ -315,6 +315,7 @@ public class EntityWolf extends EntityAnimal { return false; } // CraftBukkit end + this.d(true); this.a((PathEntity) null); this.setSitting(true); @@ -428,4 +429,4 @@ public class EntityWolf extends EntityAnimal { this.datawatcher.b(16, Byte.valueOf((byte) (b0 & -5))); } } -} \ No newline at end of file +} diff --git a/src/main/java/net/minecraft/server/ItemBed.java b/src/main/java/net/minecraft/server/ItemBed.java index 4d7018f40f..1e26efacb0 100644 --- a/src/main/java/net/minecraft/server/ItemBed.java +++ b/src/main/java/net/minecraft/server/ItemBed.java @@ -47,7 +47,7 @@ public class ItemBed extends Item { world.setTypeIdAndData(i, j, k, blockbed.id, i1); // 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()) { event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java index 5274da5414..dbd2d6af5b 100644 --- a/src/main/java/net/minecraft/server/ItemBlock.java +++ b/src/main/java/net/minecraft/server/ItemBlock.java @@ -57,7 +57,7 @@ public class ItemBlock extends Item { // CraftBukkit start - This executes the placement of the block BlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k); - + // 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 // 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)) { blockStateBelow = CraftBlockState.getBlockState(world, i, j - 1, k); } - + /** * @see net.minecraft.server.World#setTypeIdAndData(int i, int j, int k, int l, int i1) * diff --git a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java index 7bae873c39..b13ae95fb0 100644 --- a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java +++ b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java @@ -66,9 +66,9 @@ public class ItemFlintAndSteel extends Item { itemstack.damage(1, entityhuman); 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.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); if (placeEvent.isCancelled() || !placeEvent.canBuild()) { - placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte)0, false); + placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false); return false; } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/ItemInWorldManager.java b/src/main/java/net/minecraft/server/ItemInWorldManager.java index 052a29a9f1..0b22996dbe 100644 --- a/src/main/java/net/minecraft/server/ItemInWorldManager.java +++ b/src/main/java/net/minecraft/server/ItemInWorldManager.java @@ -51,6 +51,7 @@ public class ItemInWorldManager { } 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 int i1 = this.world.getTypeId(i, j, k); @@ -60,7 +61,7 @@ public class ItemInWorldManager { 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 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.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); if (event.isCancelled()) { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 98221345b7..e313307333 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -62,7 +62,7 @@ public class MinecraftServer implements Runnable, ICommandListener { public MinecraftServer(OptionSet options) { // CraftBukkit - adds argument OptionSet new ThreadSleepForever(this); - // CraftBukkit start + // CraftBukkit start this.options = options; try { this.reader = new ConsoleReader(); @@ -437,7 +437,7 @@ public class MinecraftServer implements Runnable, ICommandListener { StatisticList.a(); try { - MinecraftServer minecraftserver = new MinecraftServer(options); // CraftBukkit pass in the options + MinecraftServer minecraftserver = new MinecraftServer(options); // CraftBukkit - pass in the options // CraftBukkit - remove gui diff --git a/src/main/java/net/minecraft/server/NetLoginHandler.java b/src/main/java/net/minecraft/server/NetLoginHandler.java index b7c8473cea..dead7047d6 100644 --- a/src/main/java/net/minecraft/server/NetLoginHandler.java +++ b/src/main/java/net/minecraft/server/NetLoginHandler.java @@ -84,7 +84,7 @@ public class NetLoginHandler extends NetHandler { if (entityplayer != null) { this.server.serverConfigurationManager.b(entityplayer); // 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 ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); NetServerHandler netserverhandler = new NetServerHandler(this.server, this.networkManager, entityplayer); diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 6a2eb2f745..0e2fb265a4 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -95,7 +95,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { this.sendPacket(new Packet255KickDisconnect(s)); this.networkManager.d(); - //CraftBukkit start + // CraftBukkit start leaveMessage = event.getLeaveMessage(); if (leaveMessage != null) { 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 >.> 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 if (lastPosX != Double.MAX_VALUE) { PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); + server.getPluginManager().callEvent(event); from = event.getFrom(); @@ -191,7 +192,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } if (this.m && !this.player.dead) { - // CraftBukkit end + // CraftBukkit end double d1; double d2; 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. int elapsedTicks = MinecraftServer.currentTick - this.lastTick; + // Added this.m condition to solve this check being triggered by teleports 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?)"); return; } @@ -410,7 +412,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { if (packet14blockdig.e == 4) { this.player.E(); } 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; if (packet14blockdig.e == 0) { @@ -506,7 +508,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { // CraftBukkit end 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 (itemstack == null) { @@ -750,7 +752,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { s1 = s.substring(1); a.info(this.player.name + " tried command: " + s1); } - */ // CraftBukkit end + // CraftBukkit end */ } } diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java index 04300731d1..00df2a0fd0 100644 --- a/src/main/java/net/minecraft/server/NetworkManager.java +++ b/src/main/java/net/minecraft/server/NetworkManager.java @@ -5,13 +5,11 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.net.Socket; import java.net.SocketAddress; -import java.io.IOException; // CraftBukkit - instead of SocketException +import java.net.SocketException; import java.util.ArrayList; import java.util.Collections; import java.util.List; - -// CraftBukkit -import java.net.SocketException; +import java.io.IOException; // CraftBukkit public class NetworkManager { @@ -49,8 +47,7 @@ public class NetworkManager { // CraftBukkit start - IPv6 stack in Java on BSD/OSX doesn't support setTrafficClass try { socket.setTrafficClass(24); - } catch (SocketException e) { - } + } catch (SocketException e) {} // CraftBukkit end try { diff --git a/src/main/java/net/minecraft/server/Packet51MapChunk.java b/src/main/java/net/minecraft/server/Packet51MapChunk.java index a46d050fc0..ea9e87760f 100644 --- a/src/main/java/net/minecraft/server/Packet51MapChunk.java +++ b/src/main/java/net/minecraft/server/Packet51MapChunk.java @@ -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) { - // CraftBukkit - end + // CraftBukkit - end this.k = true; this.a = i; this.b = j; @@ -37,7 +37,7 @@ public class Packet51MapChunk extends Packet { this.e = i1; this.f = j1; byte[] abyte = data; // CraftBukkit - uses data from above constructor - Deflater deflater = new Deflater(1); + Deflater deflater = new Deflater(-1); try { deflater.setInput(abyte); diff --git a/src/main/java/net/minecraft/server/PlayerInstance.java b/src/main/java/net/minecraft/server/PlayerInstance.java index fe5f2fb0e2..28727cfcdc 100644 --- a/src/main/java/net/minecraft/server/PlayerInstance.java +++ b/src/main/java/net/minecraft/server/PlayerInstance.java @@ -61,7 +61,7 @@ class PlayerInstance { } entityplayer.f.remove(this.e); - // CraftBukkit - contains -> remove -- TODO VERIFY!!!! + // CraftBukkit - contains -> remove -- TODO VERIFY!!!! if (entityplayer.g.remove(this.e)) { entityplayer.netServerHandler.sendPacket(new Packet50PreChunk(this.chunkX, this.chunkZ, false)); } diff --git a/src/main/java/net/minecraft/server/PlayerManager.java b/src/main/java/net/minecraft/server/PlayerManager.java index ff0aac4570..9b1dc50474 100644 --- a/src/main/java/net/minecraft/server/PlayerManager.java +++ b/src/main/java/net/minecraft/server/PlayerManager.java @@ -166,7 +166,7 @@ public class PlayerManager { List chunksToSend = entityplayer.f; Collections.sort(chunksToSend, new Comparator() { 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)); } }); } diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java index 85c77400d8..371ba17f8e 100644 --- a/src/main/java/net/minecraft/server/PortalTravelAgent.java +++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java @@ -1,328 +1,330 @@ -package net.minecraft.server; - -import java.util.Random; - -// CraftBukkit start -import org.bukkit.event.world.PortalCreateEvent; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.Bukkit; -// CraftBukkit end - -public class PortalTravelAgent { - - private Random a = new Random(); - - public PortalTravelAgent() {} - - public void a(World world, Entity entity) { - if (!this.b(world, entity)) { - this.c(world, entity); - this.b(world, entity); - } - } - - public boolean b(World world, Entity entity) { - short short1 = 128; - double d0 = -1.0D; - int i = 0; - int j = 0; - int k = 0; - int l = MathHelper.floor(entity.locX); - int i1 = MathHelper.floor(entity.locZ); - - double d1; - - for (int j1 = l - short1; j1 <= l + short1; ++j1) { - double d2 = (double) j1 + 0.5D - entity.locX; - - for (int k1 = i1 - short1; k1 <= i1 + short1; ++k1) { - double d3 = (double) k1 + 0.5D - entity.locZ; - - for (int l1 = 127; l1 >= 0; --l1) { - if (world.getTypeId(j1, l1, k1) == Block.PORTAL.id) { - while (world.getTypeId(j1, l1 - 1, k1) == Block.PORTAL.id) { - --l1; - } - - d1 = (double) l1 + 0.5D - entity.locY; - double d4 = d2 * d2 + d1 * d1 + d3 * d3; - - if (d0 < 0.0D || d4 < d0) { - d0 = d4; - i = j1; - j = l1; - k = k1; - } - } - } - } - } - - if (d0 >= 0.0D) { - double d5 = (double) i + 0.5D; - double d6 = (double) j + 0.5D; - - d1 = (double) k + 0.5D; - if (world.getTypeId(i - 1, j, k) == Block.PORTAL.id) { - d5 -= 0.5D; - } - - if (world.getTypeId(i + 1, j, k) == Block.PORTAL.id) { - d5 += 0.5D; - } - - if (world.getTypeId(i, j, k - 1) == Block.PORTAL.id) { - d1 -= 0.5D; - } - - if (world.getTypeId(i, j, k + 1) == Block.PORTAL.id) { - d1 += 0.5D; - } - - entity.setPositionRotation(d5, d6, d1, entity.yaw, 0.0F); - entity.motX = entity.motY = entity.motZ = 0.0D; - return true; - } else { - return false; - } - } - - public boolean c(World world, Entity entity) { - byte b0 = 16; - double d0 = -1.0D; - int i = MathHelper.floor(entity.locX); - int j = MathHelper.floor(entity.locY); - int k = MathHelper.floor(entity.locZ); - int l = i; - int i1 = j; - int j1 = k; - int k1 = 0; - int l1 = this.a.nextInt(4); - - int i2; - double d1; - int j2; - double d2; - int k2; - int l2; - int i3; - int j3; - int k3; - int l3; - int i4; - int j4; - int k4; - double d3; - double d4; - - for (i2 = i - b0; i2 <= i + b0; ++i2) { - d1 = (double) i2 + 0.5D - entity.locX; - - for (j2 = k - b0; j2 <= k + b0; ++j2) { - d2 = (double) j2 + 0.5D - entity.locZ; - - label271: - for (l2 = 127; l2 >= 0; --l2) { - if (world.isEmpty(i2, l2, j2)) { - while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) { - --l2; - } - - for (k2 = l1; k2 < l1 + 4; ++k2) { - j3 = k2 % 2; - i3 = 1 - j3; - if (k2 % 4 >= 2) { - j3 = -j3; - i3 = -i3; - } - - for (l3 = 0; l3 < 3; ++l3) { - for (k3 = 0; k3 < 4; ++k3) { - for (j4 = -1; j4 < 4; ++j4) { - i4 = i2 + (k3 - 1) * j3 + l3 * i3; - k4 = l2 + j4; - int l4 = j2 + (k3 - 1) * i3 - l3 * j3; - - if (j4 < 0 && !world.getMaterial(i4, k4, l4).isBuildable() || j4 >= 0 && !world.isEmpty(i4, k4, l4)) { - continue label271; - } - } - } - } - - d3 = (double) l2 + 0.5D - entity.locY; - d4 = d1 * d1 + d3 * d3 + d2 * d2; - if (d0 < 0.0D || d4 < d0) { - d0 = d4; - l = i2; - i1 = l2; - j1 = j2; - k1 = k2 % 4; - } - } - } - } - } - } - - if (d0 < 0.0D) { - for (i2 = i - b0; i2 <= i + b0; ++i2) { - d1 = (double) i2 + 0.5D - entity.locX; - - for (j2 = k - b0; j2 <= k + b0; ++j2) { - d2 = (double) j2 + 0.5D - entity.locZ; - - label219: - for (l2 = 127; l2 >= 0; --l2) { - if (world.isEmpty(i2, l2, j2)) { - while (world.isEmpty(i2, l2 - 1, j2)) { - --l2; - } - - for (k2 = l1; k2 < l1 + 2; ++k2) { - j3 = k2 % 2; - i3 = 1 - j3; - - for (l3 = 0; l3 < 4; ++l3) { - for (k3 = -1; k3 < 4; ++k3) { - j4 = i2 + (l3 - 1) * j3; - i4 = l2 + k3; - k4 = j2 + (l3 - 1) * i3; - if (k3 < 0 && !world.getMaterial(j4, i4, k4).isBuildable() || k3 >= 0 && !world.isEmpty(j4, i4, k4)) { - continue label219; - } - } - } - - d3 = (double) l2 + 0.5D - entity.locY; - d4 = d1 * d1 + d3 * d3 + d2 * d2; - if (d0 < 0.0D || d4 < d0) { - d0 = d4; - l = i2; - i1 = l2; - j1 = j2; - k1 = k2 % 2; - } - } - } - } - } - } - } - - int i5 = l; - int j5 = i1; - - j2 = j1; - int k5 = k1 % 2; - int l5 = 1 - k5; - - if (k1 % 4 >= 2) { - k5 = -k5; - l5 = -l5; - } - - boolean flag; - - // CraftBukkit start - portal create event - java.util.ArrayList blocks = new java.util.ArrayList(); - //Find out what blocks the portal is going to modify, duplicated from below - CraftWorld craftWorld = ((WorldServer) world).getWorld(); - - if (d0 < 0.0D) { - if (i1 < 70) { - i1 = 70; - } - - if (i1 > 118) { - i1 = 118; - } - - j5 = i1; - - for (l2 = -1; l2 <= 1; ++l2) { - for (k2 = 1; k2 < 3; ++k2) { - for (j3 = -1; j3 < 3; ++j3) { - i3 = i5 + (k2 - 1) * k5 + l2 * l5; - l3 = j5 + j3; - k3 = j2 + (k2 - 1) * l5 - l2 * k5; - org.bukkit.block.Block b = craftWorld.getBlockAt(i3, l3, k3); - if (!blocks.contains(b)) { - blocks.add(b); - } - } - } - } - } - - for (l2 = 0; l2 < 4; ++l2) { - for (k2 = 0; k2 < 4; ++k2) { - for (j3 = -1; j3 < 4; ++j3) { - i3 = i5 + (k2 - 1) * k5; - l3 = j5 + j3; - k3 = j2 + (k2 - 1) * l5; - org.bukkit.block.Block b = craftWorld.getBlockAt(i3, l3, k3); - if (!blocks.contains(b)) { - blocks.add(b); - } - } - } - } - - PortalCreateEvent event = new PortalCreateEvent(blocks,(org.bukkit.World)craftWorld); - Bukkit.getServer().getPluginManager().callEvent(event); - if(event.isCancelled()) return true; - // CraftBukkit end - - if (d0 < 0.0D) { - if (i1 < 70) { - i1 = 70; - } - - if (i1 > 118) { - i1 = 118; - } - - j5 = i1; - - for (l2 = -1; l2 <= 1; ++l2) { - for (k2 = 1; k2 < 3; ++k2) { - for (j3 = -1; j3 < 3; ++j3) { - i3 = i5 + (k2 - 1) * k5 + l2 * l5; - l3 = j5 + j3; - 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 (k2 = 0; k2 < 4; ++k2) { - for (j3 = -1; j3 < 4; ++j3) { - i3 = i5 + (k2 - 1) * k5; - l3 = j5 + j3; - 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) { - for (j3 = -1; j3 < 4; ++j3) { - i3 = i5 + (k2 - 1) * k5; - l3 = j5 + j3; - k3 = j2 + (k2 - 1) * l5; - world.applyPhysics(i3, l3, k3, world.getTypeId(i3, l3, k3)); - } - } - } - - return true; - } -} \ No newline at end of file +package net.minecraft.server; + +import java.util.Random; + +// CraftBukkit start +import org.bukkit.event.world.PortalCreateEvent; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.Bukkit; +// CraftBukkit end + +public class PortalTravelAgent { + + private Random a = new Random(); + + public PortalTravelAgent() {} + + public void a(World world, Entity entity) { + if (!this.b(world, entity)) { + this.c(world, entity); + this.b(world, entity); + } + } + + public boolean b(World world, Entity entity) { + short short1 = 128; + double d0 = -1.0D; + int i = 0; + int j = 0; + int k = 0; + int l = MathHelper.floor(entity.locX); + int i1 = MathHelper.floor(entity.locZ); + + double d1; + + for (int j1 = l - short1; j1 <= l + short1; ++j1) { + double d2 = (double) j1 + 0.5D - entity.locX; + + for (int k1 = i1 - short1; k1 <= i1 + short1; ++k1) { + double d3 = (double) k1 + 0.5D - entity.locZ; + + for (int l1 = 127; l1 >= 0; --l1) { + if (world.getTypeId(j1, l1, k1) == Block.PORTAL.id) { + while (world.getTypeId(j1, l1 - 1, k1) == Block.PORTAL.id) { + --l1; + } + + d1 = (double) l1 + 0.5D - entity.locY; + double d4 = d2 * d2 + d1 * d1 + d3 * d3; + + if (d0 < 0.0D || d4 < d0) { + d0 = d4; + i = j1; + j = l1; + k = k1; + } + } + } + } + } + + if (d0 >= 0.0D) { + double d5 = (double) i + 0.5D; + double d6 = (double) j + 0.5D; + + d1 = (double) k + 0.5D; + if (world.getTypeId(i - 1, j, k) == Block.PORTAL.id) { + d5 -= 0.5D; + } + + if (world.getTypeId(i + 1, j, k) == Block.PORTAL.id) { + d5 += 0.5D; + } + + if (world.getTypeId(i, j, k - 1) == Block.PORTAL.id) { + d1 -= 0.5D; + } + + if (world.getTypeId(i, j, k + 1) == Block.PORTAL.id) { + d1 += 0.5D; + } + + entity.setPositionRotation(d5, d6, d1, entity.yaw, 0.0F); + entity.motX = entity.motY = entity.motZ = 0.0D; + return true; + } else { + return false; + } + } + + public boolean c(World world, Entity entity) { + byte b0 = 16; + double d0 = -1.0D; + int i = MathHelper.floor(entity.locX); + int j = MathHelper.floor(entity.locY); + int k = MathHelper.floor(entity.locZ); + int l = i; + int i1 = j; + int j1 = k; + int k1 = 0; + int l1 = this.a.nextInt(4); + + int i2; + double d1; + int j2; + double d2; + int k2; + int l2; + int i3; + int j3; + int k3; + int l3; + int i4; + int j4; + int k4; + double d3; + double d4; + + for (i2 = i - b0; i2 <= i + b0; ++i2) { + d1 = (double) i2 + 0.5D - entity.locX; + + for (j2 = k - b0; j2 <= k + b0; ++j2) { + d2 = (double) j2 + 0.5D - entity.locZ; + + label271: + for (l2 = 127; l2 >= 0; --l2) { + if (world.isEmpty(i2, l2, j2)) { + while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) { + --l2; + } + + for (k2 = l1; k2 < l1 + 4; ++k2) { + j3 = k2 % 2; + i3 = 1 - j3; + if (k2 % 4 >= 2) { + j3 = -j3; + i3 = -i3; + } + + for (l3 = 0; l3 < 3; ++l3) { + for (k3 = 0; k3 < 4; ++k3) { + for (j4 = -1; j4 < 4; ++j4) { + i4 = i2 + (k3 - 1) * j3 + l3 * i3; + k4 = l2 + j4; + int l4 = j2 + (k3 - 1) * i3 - l3 * j3; + + if (j4 < 0 && !world.getMaterial(i4, k4, l4).isBuildable() || j4 >= 0 && !world.isEmpty(i4, k4, l4)) { + continue label271; + } + } + } + } + + d3 = (double) l2 + 0.5D - entity.locY; + d4 = d1 * d1 + d3 * d3 + d2 * d2; + if (d0 < 0.0D || d4 < d0) { + d0 = d4; + l = i2; + i1 = l2; + j1 = j2; + k1 = k2 % 4; + } + } + } + } + } + } + + if (d0 < 0.0D) { + for (i2 = i - b0; i2 <= i + b0; ++i2) { + d1 = (double) i2 + 0.5D - entity.locX; + + for (j2 = k - b0; j2 <= k + b0; ++j2) { + d2 = (double) j2 + 0.5D - entity.locZ; + + label219: + for (l2 = 127; l2 >= 0; --l2) { + if (world.isEmpty(i2, l2, j2)) { + while (world.isEmpty(i2, l2 - 1, j2)) { + --l2; + } + + for (k2 = l1; k2 < l1 + 2; ++k2) { + j3 = k2 % 2; + i3 = 1 - j3; + + for (l3 = 0; l3 < 4; ++l3) { + for (k3 = -1; k3 < 4; ++k3) { + j4 = i2 + (l3 - 1) * j3; + i4 = l2 + k3; + k4 = j2 + (l3 - 1) * i3; + if (k3 < 0 && !world.getMaterial(j4, i4, k4).isBuildable() || k3 >= 0 && !world.isEmpty(j4, i4, k4)) { + continue label219; + } + } + } + + d3 = (double) l2 + 0.5D - entity.locY; + d4 = d1 * d1 + d3 * d3 + d2 * d2; + if (d0 < 0.0D || d4 < d0) { + d0 = d4; + l = i2; + i1 = l2; + j1 = j2; + k1 = k2 % 2; + } + } + } + } + } + } + } + + int i5 = l; + int j5 = i1; + + j2 = j1; + int k5 = k1 % 2; + int l5 = 1 - k5; + + if (k1 % 4 >= 2) { + k5 = -k5; + l5 = -l5; + } + + boolean flag; + + // CraftBukkit start - portal create event + java.util.ArrayList blocks = new java.util.ArrayList(); + // Find out what blocks the portal is going to modify, duplicated from below + CraftWorld craftWorld = ((WorldServer) world).getWorld(); + + if (d0 < 0.0D) { + if (i1 < 70) { + i1 = 70; + } + + if (i1 > 118) { + i1 = 118; + } + + j5 = i1; + + for (l2 = -1; l2 <= 1; ++l2) { + for (k2 = 1; k2 < 3; ++k2) { + for (j3 = -1; j3 < 3; ++j3) { + i3 = i5 + (k2 - 1) * k5 + l2 * l5; + l3 = j5 + j3; + k3 = j2 + (k2 - 1) * l5 - l2 * k5; + org.bukkit.block.Block b = craftWorld.getBlockAt(i3, l3, k3); + if (!blocks.contains(b)) { + blocks.add(b); + } + } + } + } + } + + for (l2 = 0; l2 < 4; ++l2) { + for (k2 = 0; k2 < 4; ++k2) { + for (j3 = -1; j3 < 4; ++j3) { + i3 = i5 + (k2 - 1) * k5; + l3 = j5 + j3; + k3 = j2 + (k2 - 1) * l5; + org.bukkit.block.Block b = craftWorld.getBlockAt(i3, l3, k3); + if (!blocks.contains(b)) { + blocks.add(b); + } + } + } + } + + PortalCreateEvent event = new PortalCreateEvent(blocks, (org.bukkit.World) craftWorld); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return true; + } + // CraftBukkit end + + if (d0 < 0.0D) { + if (i1 < 70) { + i1 = 70; + } + + if (i1 > 118) { + i1 = 118; + } + + j5 = i1; + + for (l2 = -1; l2 <= 1; ++l2) { + for (k2 = 1; k2 < 3; ++k2) { + for (j3 = -1; j3 < 3; ++j3) { + i3 = i5 + (k2 - 1) * k5 + l2 * l5; + l3 = j5 + j3; + 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 (k2 = 0; k2 < 4; ++k2) { + for (j3 = -1; j3 < 4; ++j3) { + i3 = i5 + (k2 - 1) * k5; + l3 = j5 + j3; + 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) { + for (j3 = -1; j3 < 4; ++j3) { + i3 = i5 + (k2 - 1) * k5; + l3 = j5 + j3; + k3 = j2 + (k2 - 1) * l5; + world.applyPhysics(i3, l3, k3, world.getTypeId(i3, l3, k3)); + } + } + } + + return true; + } +} diff --git a/src/main/java/net/minecraft/server/SecondaryWorldServer.java b/src/main/java/net/minecraft/server/SecondaryWorldServer.java index d36af3f826..e4b26bddcd 100644 --- a/src/main/java/net/minecraft/server/SecondaryWorldServer.java +++ b/src/main/java/net/minecraft/server/SecondaryWorldServer.java @@ -1,6 +1,6 @@ package net.minecraft.server; -import org.bukkit.generator.ChunkGenerator; +import org.bukkit.generator.ChunkGenerator; // CraftBukkit public class SecondaryWorldServer extends WorldServer { // CraftBukkit start diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java index 695db357cc..24183bfcc6 100644 --- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java +++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java @@ -32,7 +32,7 @@ public class ServerConfigurationManager { public static Logger a = Logger.getLogger("Minecraft"); public List players = new ArrayList(); 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 private Set banByName = new HashSet(); private Set banByIP = new HashSet(); @@ -61,7 +61,7 @@ public class ServerConfigurationManager { this.m = minecraftserver.a("white-list.txt"); int i = minecraftserver.propertyManager.getInt("view-distance", 10); - // Craftbukkit - removed playermanagers + // CraftBukkit - removed playermanagers this.maxPlayers = minecraftserver.propertyManager.getInt("max-players", 20); this.o = minecraftserver.propertyManager.getBoolean("white-list", false); this.g(); @@ -80,9 +80,9 @@ public class ServerConfigurationManager { } public void a(EntityPlayer entityplayer) { - // Craftbukkit - removed playermanagers - for(WorldServer world : this.server.worlds) { - if(world.manager.a.contains(entityplayer)) { + // CraftBukkit - removed playermanagers + for (WorldServer world : this.server.worlds) { + if (world.manager.a.contains(entityplayer)) { world.manager.removePlayer(entityplayer); break; } @@ -94,17 +94,17 @@ public class ServerConfigurationManager { } public int a() { - // Craftbukkit start + // CraftBukkit start if (this.server.worlds.size() == 0) { return this.server.propertyManager.getInt("view-distance", 10) * 16 - 16; } else { return this.server.worlds.get(0).manager.c(); } - // Craftbukkit end + // CraftBukkit end } private PlayerManager a(int i) { - return server.a(i).manager; // Craftbukkit + return server.a(i).manager; // CraftBukkit } public void b(EntityPlayer entityplayer) { @@ -218,7 +218,7 @@ public class ServerConfigurationManager { if (location == null) { 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); if (chunkcoordinates1 != null) { 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)); } } + if (location == null) { cw = (CraftWorld) this.server.server.getWorlds().get(0); chunkcoordinates = cw.getHandle().getSpawn(); location = new Location(cw, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z); } + Player respawnPlayer = cserver.getPlayer(entityplayer); PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location); cserver.getPluginManager().callEvent(respawnEvent); + location = respawnEvent.getRespawnLocation(); entityplayer.health = 20; entityplayer.fireTicks = 0; @@ -241,7 +244,7 @@ public class ServerConfigurationManager { } else { 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()); // CraftBukkit end @@ -269,10 +272,9 @@ public class ServerConfigurationManager { } public void f(EntityPlayer entityplayer) { - // CraftBukkit start WorldServer worldserver = this.server.a(entityplayer.dimension); - boolean flag = false; // Unused - int b0; // byte -> int + boolean flag = false; + int b0; // CraftBukkit - byte -> int if (entityplayer.dimension == -1) { b0 = 0; @@ -280,17 +282,19 @@ public class ServerConfigurationManager { b0 = -1; } - // entityplayer.dimension = b0; - // WorldServer worldserver1 = this.server.a(entityplayer.dimension); + /* CraftBukkit start + entityplayer.dimension = b0; + WorldServer worldserver1 = this.server.a(entityplayer.dimension); - // entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) entityplayer.dimension)); - // worldserver.removeEntity(entityplayer); - // entityplayer.dead = false; + entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) entityplayer.dimension)); + worldserver.removeEntity(entityplayer); + entityplayer.dead = false; + // CraftBukkit end */ double d0 = entityplayer.locX; double d1 = entityplayer.locZ; double d2 = 8.0D; - if (b0 == -1) { // entityplayer.dimension -> b0 + if (b0 == -1) { // CraftBukkit - entityplayer.dimension -> b0 d0 /= d2; d1 /= d2; entityplayer.setPositionRotation(d0, entityplayer.locY, d1, entityplayer.yaw, entityplayer.pitch); @@ -306,12 +310,13 @@ public class ServerConfigurationManager { } } - CraftWorld fromCraftWorld = worldserver.getWorld(); - CraftWorld toCraftWorld = this.server.a(b0).getWorld(); + // CraftBukkit start + 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 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); if (event.isCancelled()) { return; @@ -336,21 +341,23 @@ public class ServerConfigurationManager { } } - // this.a(entityplayer); - // entityplayer.netServerHandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); - // entityplayer.a((World) worldserver1); - // this.a(entityplayer, worldserver1); - // this.g(entityplayer); + /* CraftBukkit -- not needed + this.a(entityplayer); + entityplayer.netServerHandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); + entityplayer.a((World) worldserver1); + this.a(entityplayer, worldserver1); + this.g(entityplayer); + // CraftBukkit */ this.a(entityplayer, b0, endLocation); // CraftBukkit end } public void b() { - // Craftbukkit start + // CraftBukkit start for (int i = 0; i < this.server.worlds.size(); ++i) { this.server.worlds.get(i).manager.flush(); } - // Craftbukkit end + // CraftBukkit end } public void flagDirty(int i, int j, int k, int l) { diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java index 6087fb33f0..65d23e5809 100644 --- a/src/main/java/net/minecraft/server/TileEntityFurnace.java +++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java @@ -165,7 +165,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory { ItemStack itemstack = FurnaceRecipes.a().a(this.items[0].getItem().id); // 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()))); } } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 19fd0a1a63..f26ff76b1a 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -50,7 +50,7 @@ public class World implements IBlockAccess { public int spawnMonsters; public Random random = new Random(); public boolean s = false; - public WorldProvider worldProvider; // Craftbukkit - remove final + public WorldProvider worldProvider; // CraftBukkit - remove final protected List u = new ArrayList(); public IChunkProvider chunkProvider; // CraftBukkit - protected -> public protected final IDataManager w; @@ -62,22 +62,36 @@ public class World implements IBlockAccess { private int K = 0; public boolean allowMonsters = true; // CraftBukkit - private -> public public boolean allowAnimals = true; // CraftBukkit - private -> public - public boolean pvpMode; // CraftBukkit static int A = 0; private Set N = new HashSet(); private int O; private List P; public boolean isStatic; - public ChunkGenerator generator; // Craftbukkit public WorldChunkManager getWorldChunkManager() { 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) { this.generator = gen; - // Craftbukkit end + // CraftBukkit end this.O = this.random.nextInt(12000); this.P = new ArrayList(); @@ -126,12 +140,13 @@ public class World implements IBlockAccess { int j; - // Craftbukkit start + // CraftBukkit start if (generator != null) { 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.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() + ")"); } else { 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)) { i += this.random.nextInt(64) - this.random.nextInt(64); } - // Craftbukkit end + // CraftBukkit end this.worldData.setSpawn(i, b0, j); 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) { int k; @@ -239,10 +244,6 @@ public class World implements IBlockAccess { } // 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) { Chunk result = null; synchronized (chunkLock) { @@ -818,9 +819,10 @@ public class World implements IBlockAccess { // CraftBukkit start if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) { CreatureSpawnEvent event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity); - if (event.isCancelled()) { - return false; - } + + if (event.isCancelled()) { + return false; + } } else if (entity instanceof EntityItem) { ItemSpawnEvent event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity); if (event.isCancelled()) { @@ -1814,9 +1816,9 @@ public class World implements IBlockAccess { 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()) { // CraftBukkit start - SnowFormEvent snow = new SnowFormEvent(((WorldServer)this).getWorld().getBlockAt(l + i, k1, j1 + j)); - ((WorldServer)this).getServer().getPluginManager().callEvent(snow); + SnowFormEvent snow = new SnowFormEvent(((WorldServer) this).getWorld().getBlockAt(l + i, k1, j1 + j)); + ((WorldServer) this).getServer().getPluginManager().callEvent(snow); if (!snow.isCancelled()) { this.setTypeId(l + i, k1, j1 + j, snow.getMaterial().getId()); this.setData(l + i, k1, j1 + j, snow.getData()); @@ -1946,7 +1948,6 @@ public class World implements IBlockAccess { this.entityList.add(entity); // CraftBukkit end - this.c((Entity) list.get(i)); } } @@ -1965,19 +1966,16 @@ public class World implements IBlockAccess { axisalignedbb = null; } - // CraftBukkit - store the default action - boolean defaultReturn; + boolean defaultReturn; // CraftBukkit - store the default action if (axisalignedbb != null && !this.containsEntity(axisalignedbb)) { - // CraftBukkit - defaultReturn = false; + defaultReturn = false; // CraftBukkit } else { if (block == Block.WATER || block == Block.STATIONARY_WATER || block == Block.LAVA || block == Block.STATIONARY_LAVA || block == Block.FIRE || block == Block.SNOW) { block = null; } - // CraftBukkit - defaultReturn = i > 0 && block == null && block1.canPlace(this, j, k, l, i1); + defaultReturn = i > 0 && block == null && block1.canPlace(this, j, k, l, i1); // CraftBukkit } // CraftBukkit start diff --git a/src/main/java/net/minecraft/server/WorldManager.java b/src/main/java/net/minecraft/server/WorldManager.java index 737db0fe22..3a76b53d94 100644 --- a/src/main/java/net/minecraft/server/WorldManager.java +++ b/src/main/java/net/minecraft/server/WorldManager.java @@ -3,7 +3,7 @@ package net.minecraft.server; public class WorldManager implements IWorldAccess { private MinecraftServer server; - public WorldServer world; // CraftBukkit private -> public + public WorldServer world; // CraftBukkit - private -> public public WorldManager(MinecraftServer minecraftserver, WorldServer worldserver) { this.server = minecraftserver; diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java index 6033bb04ef..38551c170e 100644 --- a/src/main/java/net/minecraft/server/WorldMap.java +++ b/src/main/java/net/minecraft/server/WorldMap.java @@ -95,6 +95,7 @@ public class WorldMap extends WorldMapBase { byte b2 = 0; byte b3 = (byte) ((int) ((double) (f * 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)); if (this.d < 0) { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index 4548d90b6f..6fc168a03d 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -16,7 +16,7 @@ import org.bukkit.craftbukkit.generator.SkyLandsChunkGenerator; import org.bukkit.event.weather.LightningStrikeEvent; public class WorldServer extends World implements BlockChangeDelegate { -// CraftBukkit end + // CraftBukkit end public ChunkProviderServer chunkProviderServer; public boolean weirdIsOpCache = false; @@ -70,7 +70,7 @@ public class WorldServer extends World implements BlockChangeDelegate { protected IChunkProvider b() { IChunkLoader ichunkloader = this.w.a(this.worldProvider); - // Craftbukkit start + // CraftBukkit start InternalChunkGenerator gen; if (this.generator != null) { @@ -84,7 +84,7 @@ public class WorldServer extends World implements BlockChangeDelegate { } this.chunkProviderServer = new ChunkProviderServer(this, ichunkloader, gen); - // Craftbukkit end + // CraftBukkit end return this.chunkProviderServer; } @@ -162,9 +162,11 @@ public class WorldServer extends World implements BlockChangeDelegate { return explosion; } - // explosion.a = flag; - // explosion.a(); - // explosion.a(false); + /* CraftBukkit + explosion.a = flag; + 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)); // CraftBukkit end return explosion;