From 62b5da4e3a6c9f930e08da292e603aa8b8df436e Mon Sep 17 00:00:00 2001 From: Erik Broes Date: Tue, 31 May 2011 15:55:45 +0200 Subject: [PATCH] Update for 1.6.6 --- pom.xml | 2 +- .../net/minecraft/server/CraftingManager.java | 4 +- .../net/minecraft/server/EntityArrow.java | 8 +- .../java/net/minecraft/server/EntityBoat.java | 10 +- .../net/minecraft/server/EntityHuman.java | 136 +++++++++--------- .../net/minecraft/server/EntityPlayer.java | 6 +- .../minecraft/server/EntityTrackerEntry.java | 8 ++ .../net/minecraft/server/MinecraftServer.java | 2 +- .../minecraft/server/NetServerHandler.java | 7 + .../net/minecraft/server/PlayerInstance.java | 5 +- src/main/java/net/minecraft/server/World.java | 52 +++---- .../org/bukkit/craftbukkit/CraftServer.java | 2 +- 12 files changed, 137 insertions(+), 105 deletions(-) diff --git a/pom.xml b/pom.xml index f70c0e6079..aaadb7f6da 100644 --- a/pom.xml +++ b/pom.xml @@ -39,7 +39,7 @@ org.bukkit minecraft-server - 1.6.5 + 1.6.6 jar compile diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java index 5280be2091..9bbb1c8e0a 100644 --- a/src/main/java/net/minecraft/server/CraftingManager.java +++ b/src/main/java/net/minecraft/server/CraftingManager.java @@ -31,8 +31,8 @@ public class CraftingManager { this.a(new ItemStack(Block.SNOW_BLOCK, 1), new Object[] { "##", "##", Character.valueOf('#'), Item.SNOW_BALL}); this.a(new ItemStack(Block.CLAY, 1), new Object[] { "##", "##", Character.valueOf('#'), Item.CLAY_BALL}); this.a(new ItemStack(Block.BRICK, 1), new Object[] { "##", "##", Character.valueOf('#'), Item.CLAY_BRICK}); - this.a(new ItemStack(Block.GLOWSTONE, 1), new Object[] { "###", "###", "###", Character.valueOf('#'), Item.GLOWSTONE_DUST}); - this.a(new ItemStack(Block.WOOL, 1), new Object[] { "###", "###", "###", Character.valueOf('#'), Item.STRING}); + this.a(new ItemStack(Block.GLOWSTONE, 1), new Object[] { "##", "##", Character.valueOf('#'), Item.GLOWSTONE_DUST}); + this.a(new ItemStack(Block.WOOL, 1), new Object[] { "##", "##", Character.valueOf('#'), Item.STRING}); this.a(new ItemStack(Block.TNT, 1), new Object[] { "X#X", "#X#", "X#X", Character.valueOf('X'), Item.SULPHUR, Character.valueOf('#'), Block.SAND}); this.a(new ItemStack(Block.STEP, 3, 3), new Object[] { "###", Character.valueOf('#'), Block.COBBLESTONE}); this.a(new ItemStack(Block.STEP, 3, 0), new Object[] { "###", Character.valueOf('#'), Block.STONE}); diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java index acec874e08..a85f74b9b5 100644 --- a/src/main/java/net/minecraft/server/EntityArrow.java +++ b/src/main/java/net/minecraft/server/EntityArrow.java @@ -89,7 +89,9 @@ public class EntityArrow extends Entity { if (i > 0) { Block.byId[i].a(this.world, this.d, this.e, this.f); - if (Block.byId[i].d(this.world, this.d, this.e, this.f) != null && Block.byId[i].d(this.world, this.d, this.e, this.f).a(Vec3D.create(this.locX, this.locY, this.locZ))) { + AxisAlignedBB axisalignedbb = Block.byId[i].d(this.world, this.d, this.e, this.f); + + if (axisalignedbb != null && axisalignedbb.a(Vec3D.create(this.locX, this.locY, this.locZ))) { this.i = true; } } @@ -138,8 +140,8 @@ public class EntityArrow extends Entity { if (entity1.n_() && (entity1 != this.shooter || this.k >= 5)) { f1 = 0.3F; - AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f1, (double) f1, (double) f1); - MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); + AxisAlignedBB axisalignedbb1 = entity1.boundingBox.b((double) f1, (double) f1, (double) f1); + MovingObjectPosition movingobjectposition1 = axisalignedbb1.a(vec3d, vec3d1); if (movingobjectposition1 != null) { double d1 = vec3d.a(movingobjectposition1.f); diff --git a/src/main/java/net/minecraft/server/EntityBoat.java b/src/main/java/net/minecraft/server/EntityBoat.java index 69865424c5..178c9270b2 100644 --- a/src/main/java/net/minecraft/server/EntityBoat.java +++ b/src/main/java/net/minecraft/server/EntityBoat.java @@ -129,6 +129,10 @@ public class EntityBoat extends Entity { } // CraftBukkit end + if (this.passenger != null) { + this.passenger.mount(this); + } + int j; for (j = 0; j < 3; ++j) { @@ -230,7 +234,11 @@ public class EntityBoat extends Entity { d3 = d0 * 2.0D - 1.0D; this.motY += 0.03999999910593033D * d3; } else { - this.motY += 0.0010000000474974513D; + if (this.motY < 0.0D) { + this.motY /= 2.0D; + } + + this.motY += 0.007000000216066837D; } if (this.passenger != null) { diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index 171a0d1ae7..57727cab6d 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -78,10 +78,12 @@ public abstract class EntityHuman extends EntityLiving { this.sleepTicks = 100; } - if (!this.o()) { - this.a(true, true, false); - } else if (!this.world.isStatic && this.world.d()) { - this.a(false, true, true); + if (!this.world.isStatic) { + if (!this.o()) { + this.a(true, true, false); + } else if (this.world.d()) { + this.a(false, true, true); + } } } else if (this.sleepTicks > 0) { ++this.sleepTicks; @@ -375,7 +377,7 @@ public abstract class EntityHuman extends EntityLiving { if (this.health <= 0) { return false; } else { - if (this.isSleeping()) { + if (this.isSleeping() && !this.world.isStatic) { this.a(true, true, false); } @@ -568,72 +570,78 @@ public abstract class EntityHuman extends EntityLiving { } public EnumBedError a(int i, int j, int k) { - if (!this.isSleeping() && this.S()) { + if (!this.world.isStatic) { + if (this.isSleeping() || !this.S()) { + return EnumBedError.OTHER_PROBLEM; + } + if (this.world.worldProvider.c) { return EnumBedError.NOT_POSSIBLE_HERE; - } else if (this.world.d()) { + } + + if (this.world.d()) { return EnumBedError.NOT_POSSIBLE_NOW; - } else if (Math.abs(this.locX - (double) i) <= 3.0D && Math.abs(this.locY - (double) j) <= 2.0D && Math.abs(this.locZ - (double) k) <= 3.0D) { - // CraftBukkit start - if (this.getBukkitEntity() instanceof Player) { - 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); + } - if (event.isCancelled()) { - return EnumBedError.OTHER_PROBLEM; - } - } - // CraftBukkit end - - this.b(0.2F, 0.2F); - this.height = 0.2F; - if (this.world.isLoaded(i, j, k)) { - int l = this.world.getData(i, j, k); - int i1 = BlockBed.c(l); - float f = 0.5F; - float f1 = 0.5F; - - switch (i1) { - case 0: - f1 = 0.9F; - break; - - case 1: - f = 0.1F; - break; - - case 2: - f1 = 0.1F; - break; - - case 3: - f = 0.9F; - } - - this.e(i1); - this.setPosition((double) ((float) i + f), (double) ((float) j + 0.9375F), (double) ((float) k + f1)); - } else { - this.setPosition((double) ((float) i + 0.5F), (double) ((float) j + 0.9375F), (double) ((float) k + 0.5F)); - } - - this.sleeping = true; - this.sleepTicks = 0; - this.A = new ChunkCoordinates(i, j, k); - this.motX = this.motZ = this.motY = 0.0D; - if (!this.world.isStatic) { - this.world.everyoneSleeping(); - } - - return EnumBedError.OK; - } else { + if (Math.abs(this.locX - (double) i) > 3.0D || Math.abs(this.locY - (double) j) > 2.0D || Math.abs(this.locZ - (double) k) > 3.0D) { return EnumBedError.TOO_FAR_AWAY; } - } else { - return EnumBedError.OTHER_PROBLEM; } + + // CraftBukkit start + if (this.getBukkitEntity() instanceof Player) { + 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); + + if (event.isCancelled()) { + return EnumBedError.OTHER_PROBLEM; + } + } + // CraftBukkit end + + this.b(0.2F, 0.2F); + this.height = 0.2F; + if (this.world.isLoaded(i, j, k)) { + int l = this.world.getData(i, j, k); + int i1 = BlockBed.c(l); + float f = 0.5F; + float f1 = 0.5F; + + switch (i1) { + case 0: + f1 = 0.9F; + break; + + case 1: + f = 0.1F; + break; + + case 2: + f1 = 0.1F; + break; + + case 3: + f = 0.9F; + } + + this.e(i1); + this.setPosition((double) ((float) i + f), (double) ((float) j + 0.9375F), (double) ((float) k + f1)); + } else { + this.setPosition((double) ((float) i + 0.5F), (double) ((float) j + 0.9375F), (double) ((float) k + 0.5F)); + } + + this.sleeping = true; + this.sleepTicks = 0; + this.A = new ChunkCoordinates(i, j, k); + this.motX = this.motZ = this.motY = 0.0D; + if (!this.world.isStatic) { + this.world.everyoneSleeping(); + } + + return EnumBedError.OK; } private void e(int i) { diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index 81a06ebfc8..f55f7dd703 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -298,9 +298,11 @@ public class EntityPlayer extends EntityHuman implements ICrafting { if (enumbederror == EnumBedError.OK) { EntityTracker entitytracker = this.b.b(this.dimension); + Packet17 packet17 = new Packet17(this, 0, i, j, k); - // CraftBukkit - this is not the original method called - entitytracker.b(this, new Packet17(this, 0, i, j, k)); + entitytracker.a(this, packet17); + this.netServerHandler.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch); + this.netServerHandler.sendPacket(packet17); } return enumbederror; diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java index 396ae45aa7..8263af8517 100644 --- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java +++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java @@ -179,6 +179,14 @@ public class EntityTrackerEntry { entityplayer.netServerHandler.sendPacket(new Packet5EntityEquipment(this.tracker.id, i, aitemstack[i])); } } + + if (this.tracker instanceof EntityHuman) { + EntityHuman entityhuman = (EntityHuman) this.tracker; + + if (entityhuman.isSleeping()) { + entityplayer.netServerHandler.sendPacket(new Packet17(this.tracker, 0, MathHelper.floor(this.tracker.locX), MathHelper.floor(this.tracker.locY), MathHelper.floor(this.tracker.locZ))); + } + } } } else if (this.trackedPlayers.contains(entityplayer)) { this.trackedPlayers.remove(entityplayer); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 48eb00bac3..c4a0d363ec 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -86,7 +86,7 @@ public class MinecraftServer implements Runnable, ICommandListener { System.setErr(new PrintStream(new LoggerOutputStream(log, Level.SEVERE), true)); // CraftBukkit end - log.info("Starting minecraft server version Beta 1.6.5"); + log.info("Starting minecraft server version Beta 1.6.6"); if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { log.warning("**** NOT ENOUGH RAM!"); log.warning("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index ab59e044b8..f643f8d9ef 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -240,6 +240,13 @@ public class NetServerHandler extends NetHandler implements ICommandListener { return; } + if (this.player.isSleeping()) { + this.player.a(true); + this.player.setLocation(this.x, this.y, this.z, this.player.yaw, this.player.pitch); + worldserver.playerJoinedWorld(this.player); + return; + } + d0 = this.player.locY; this.x = this.player.locX; this.y = this.player.locY; diff --git a/src/main/java/net/minecraft/server/PlayerInstance.java b/src/main/java/net/minecraft/server/PlayerInstance.java index 5f89809703..fe5f2fb0e2 100644 --- a/src/main/java/net/minecraft/server/PlayerInstance.java +++ b/src/main/java/net/minecraft/server/PlayerInstance.java @@ -47,10 +47,7 @@ class PlayerInstance { } public void b(EntityPlayer entityplayer) { - if (!this.b.contains(entityplayer)) { - // CraftBukkit - reduce console spam under certain conditions - // (new IllegalStateException("Failed to remove player. " + entityplayer + " isn\'t in chunk " + this.bF + ", " + this.bH)).printStackTrace(); - } else { + if (this.b.contains(entityplayer)) { this.b.remove(entityplayer); if (this.b.size() == 0) { long i = (long) this.chunkX + 2147483647L | (long) this.chunkZ + 2147483647L << 32; diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 5e27de7dd6..9f698e23f4 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -1482,34 +1482,34 @@ public class World implements IBlockAccess { return; } - if (!this.b(k1, l1).g()) { - int i2 = this.C.size(); - int j2; - - if (flag) { - j2 = 5; - if (j2 > i2) { - j2 = i2; - } - - for (int k2 = 0; k2 < j2; ++k2) { - MetadataChunkBlock metadatachunkblock = (MetadataChunkBlock) this.C.get(this.C.size() - k2 - 1); - - if (metadatachunkblock.a == enumskyblock && metadatachunkblock.a(i, j, k, l, i1, j1)) { - return; - } - } - } - - this.C.add(new MetadataChunkBlock(enumskyblock, i, j, k, l, i1, j1)); - j2 = 1000000; - if (this.C.size() > 1000000) { - System.out.println("More than " + j2 + " updates, aborting lighting updates"); - this.C.clear(); - } - + if (this.b(k1, l1).g()) { return; } + + int i2 = this.C.size(); + int j2; + + if (flag) { + j2 = 5; + if (j2 > i2) { + j2 = i2; + } + + for (int k2 = 0; k2 < j2; ++k2) { + MetadataChunkBlock metadatachunkblock = (MetadataChunkBlock) this.C.get(this.C.size() - k2 - 1); + + if (metadatachunkblock.a == enumskyblock && metadatachunkblock.a(i, j, k, l, i1, j1)) { + return; + } + } + } + + this.C.add(new MetadataChunkBlock(enumskyblock, i, j, k, l, i1, j1)); + j2 = 1000000; + if (this.C.size() > 1000000) { + System.out.println("More than " + j2 + " updates, aborting lighting updates"); + this.C.clear(); + } } finally { --A; } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 9355786e23..dd35d2453a 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -59,7 +59,7 @@ import org.bukkit.util.config.Configuration; public final class CraftServer implements Server { private final String serverName = "Craftbukkit"; private final String serverVersion; - private final String protocolVersion = "1.6.5"; + private final String protocolVersion = "1.6.6"; private final PluginManager pluginManager = new SimplePluginManager(this); private final ServicesManager servicesManager = new SimpleServicesManager(); private final BukkitScheduler scheduler = new CraftScheduler(this);