summaryrefslogtreecommitdiffstats
path: root/nms-patches
diff options
context:
space:
mode:
Diffstat (limited to 'nms-patches')
-rw-r--r--nms-patches/BlockPiston.patch19
-rw-r--r--nms-patches/CommandBlockListenerAbstract.patch200
-rw-r--r--nms-patches/CommandGamerule.patch25
-rw-r--r--nms-patches/CommandWorldBorder.patch28
-rw-r--r--nms-patches/DispenseBehaviorFireworks.patch52
-rw-r--r--nms-patches/EnchantmentThorns.patch11
-rw-r--r--nms-patches/EntityEnderCrystal.patch16
-rw-r--r--nms-patches/EntityHuman.patch94
-rw-r--r--nms-patches/EntityTrackerEntry.patch19
-rw-r--r--nms-patches/ICommand.patch6
-rw-r--r--nms-patches/MinecraftServer.patch60
-rw-r--r--nms-patches/PlayerConnection.patch131
-rw-r--r--nms-patches/PlayerInteractManager.patch16
-rw-r--r--nms-patches/PlayerList.patch75
-rw-r--r--nms-patches/SecondaryWorldServer.patch12
-rw-r--r--nms-patches/TileEntitySign.patch16
-rw-r--r--nms-patches/World.patch6
-rw-r--r--nms-patches/WorldServer.patch33
18 files changed, 517 insertions, 302 deletions
diff --git a/nms-patches/BlockPiston.patch b/nms-patches/BlockPiston.patch
index 70fac0b8..fb9b9e09 100644
--- a/nms-patches/BlockPiston.patch
+++ b/nms-patches/BlockPiston.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/BlockPiston.java 2014-11-28 17:43:42.933707439 +0000
-+++ src/main/java/net/minecraft/server/BlockPiston.java 2014-11-28 17:38:20.000000000 +0000
+--- ../work/decompile-8eb82bde//net/minecraft/server/BlockPiston.java 2014-12-05 15:10:57.106252715 +0000
++++ src/main/java/net/minecraft/server/BlockPiston.java 2014-12-05 15:10:54.834252765 +0000
@@ -1,6 +1,16 @@
package net.minecraft.server;
@@ -38,7 +38,7 @@
world.setTypeAndData(blockposition, iblockdata.set(BlockPiston.EXTENDED, Boolean.valueOf(false)), 2);
world.playBlockAction(blockposition, this, 1, enumdirection.a());
}
-@@ -286,6 +305,35 @@
+@@ -286,10 +305,40 @@
if (!pistonextendschecker.a()) {
return false;
} else {
@@ -64,13 +64,18 @@
+ }
+ };
+
-+ BlockPistonExtendEvent event = new BlockPistonExtendEvent(bblock, blocks, CraftBlock.notchToBlockFace(enumdirection));
+ int i = list.size() + list1.size();
+ Block[] ablock = new Block[i];
+ EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite();
+
++ BlockPistonExtendEvent event = new BlockPistonExtendEvent(bblock, blocks, CraftBlock.notchToBlockFace(enumdirection1));
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
+ }
+ // CraftBukkit end
- int i = list.size() + list1.size();
- Block[] ablock = new Block[i];
- EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite();
++
+ int j;
+ BlockPosition blockposition1;
+
diff --git a/nms-patches/CommandBlockListenerAbstract.patch b/nms-patches/CommandBlockListenerAbstract.patch
index aacf5ff8..e38c7440 100644
--- a/nms-patches/CommandBlockListenerAbstract.patch
+++ b/nms-patches/CommandBlockListenerAbstract.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/CommandBlockListenerAbstract.java 2014-12-02 20:23:51.921621335 +0000
-+++ src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java 2014-12-02 20:23:10.809622247 +0000
+--- ../work/decompile-8eb82bde//net/minecraft/server/CommandBlockListenerAbstract.java 2014-12-05 23:10:24.921614234 +0000
++++ src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java 2014-12-05 23:04:53.325621594 +0000
@@ -4,6 +4,13 @@
import java.util.Date;
import java.util.concurrent.Callable;
@@ -22,132 +22,128 @@
public CommandBlockListenerAbstract() {}
-@@ -79,7 +87,110 @@
+@@ -79,7 +87,10 @@
try {
this.d = null;
- this.b = icommandhandler.a(this, this.e);
+ // this.b = icommandhandler.a(this, this.e);
+ // CraftBukkit start - Handle command block commands using Bukkit dispatcher
-+ org.bukkit.command.SimpleCommandMap commandMap = minecraftserver.server.getCommandMap();
-+ Joiner joiner = Joiner.on(" ");
-+ String command = this.e;
-+ if (this.e.startsWith("/")) {
-+ command = this.e.substring(1);
-+ }
-+ String[] args = command.split(" ");
-+ ArrayList<String[]> commands = new ArrayList<String[]>();
++ this.b= executeCommand(this, sender, this.e);
++ // CraftBukkit end
+ } catch (Throwable throwable) {
+ CrashReport crashreport = CrashReport.a(throwable, "Executing command block");
+ CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed");
+@@ -91,8 +102,123 @@
+ } else {
+ this.b = 0;
+ }
++ }
++
++ // CraftBukkit start
++
++ public static int executeCommand(ICommandListener sender, org.bukkit.command.CommandSender bSender, String command) {
++ org.bukkit.command.SimpleCommandMap commandMap = sender.getWorld().getServer().getCommandMap();
++ Joiner joiner = Joiner.on(" ");
++ if (command.startsWith("/")) {
++ command = command.substring(1);
++ }
++ String[] args = command.split(" ");
++ ArrayList<String[]> commands = new ArrayList<String[]>();
+
-+ // Block disallowed commands
-+ if (args[0].equalsIgnoreCase("stop") || args[0].equalsIgnoreCase("kick") || args[0].equalsIgnoreCase("op") ||
-+ args[0].equalsIgnoreCase("deop") || args[0].equalsIgnoreCase("ban") || args[0].equalsIgnoreCase("ban-ip") ||
-+ args[0].equalsIgnoreCase("pardon") || args[0].equalsIgnoreCase("pardon-ip") || args[0].equalsIgnoreCase("reload")) {
-+ this.b = 0;
-+ return;
-+ }
++ // Block disallowed commands
++ if (args[0].equalsIgnoreCase("stop") || args[0].equalsIgnoreCase("kick") || args[0].equalsIgnoreCase("op")
++ || args[0].equalsIgnoreCase("deop") || args[0].equalsIgnoreCase("ban") || args[0].equalsIgnoreCase("ban-ip")
++ || args[0].equalsIgnoreCase("pardon") || args[0].equalsIgnoreCase("pardon-ip") || args[0].equalsIgnoreCase("reload")) {
++ return 0;
++ }
+
-+ // If the world has no players don't run
-+ if (this.getWorld().players.isEmpty()) {
-+ this.b = 0;
-+ return;
-+ }
++ // If the world has no players don't run
++ if (sender.getWorld().players.isEmpty()) {
++ return 0;
++ }
+
-+ // Handle vanilla commands;
-+ org.bukkit.command.Command commandBlockCommand = commandMap.getCommand(args[0]);
-+ if (minecraftserver.server.getCommandBlockOverride(args[0])) {
-+ commandBlockCommand = commandMap.getCommand("minecraft:" + args[0]);
-+ }
-+ if (commandBlockCommand instanceof VanillaCommandWrapper) {
-+ this.b = ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommandBlock(this, this.e);
-+ return;
-+ }
++ // Handle vanilla commands;
++ org.bukkit.command.Command commandBlockCommand = commandMap.getCommand(args[0]);
++ if (sender.getWorld().getServer().getCommandBlockOverride(args[0])) {
++ commandBlockCommand = commandMap.getCommand("minecraft:" + args[0]);
++ }
++ if (commandBlockCommand instanceof VanillaCommandWrapper) {
++ return ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommandBlock(sender, command);
++ }
+
-+ // Make sure this is a valid command
-+ if (commandMap.getCommand(args[0]) == null) {
-+ this.b = 0;
-+ return;
-+ }
++ // Make sure this is a valid command
++ if (commandMap.getCommand(args[0]) == null) {
++ return 0;
++ }
+
-+ // testfor command requires special handling
-+ if (args[0].equalsIgnoreCase("testfor")) {
-+ if (args.length < 2) {
-+ this.b = 0;
-+ return;
-+ }
++ // testfor command requires special handling
++ if (args[0].equalsIgnoreCase("testfor")) {
++ if (args.length < 2) {
++ return 0;
++ }
+
-+ EntityPlayer[] players = ((java.util.List<EntityPlayer>)PlayerSelector.getPlayers(this, args[1], EntityPlayer.class)).toArray(new EntityPlayer[0]);
++ EntityPlayer[] players = ((java.util.List<EntityPlayer>) PlayerSelector.getPlayers(sender, args[1], EntityPlayer.class)).toArray(new EntityPlayer[0]);
+
-+ if (players != null && players.length > 0) {
-+ this.b = players.length;
-+ return;
-+ } else {
-+ EntityPlayer player = MinecraftServer.getServer().getPlayerList().getPlayer(args[1]);
-+ if (player == null) {
-+ this.b = 0;
-+ return;
-+ } else {
-+ this.b = 1;
-+ return;
-+ }
-+ }
++ if (players != null && players.length > 0) {
++ return players.length;
++ } else {
++ EntityPlayer player = MinecraftServer.getServer().getPlayerList().getPlayer(args[1]);
++ if (player == null) {
++ return 0;
++ } else {
++ return 1;
+ }
++ }
++ }
+
-+ commands.add(args);
++ commands.add(args);
+
-+ // Find positions of command block syntax, if any
-+ ArrayList<String[]> newCommands = new ArrayList<String[]>();
-+ for (int i = 0; i < args.length; i++) {
-+ if (PlayerSelector.isPattern(args[i])) {
-+ for (int j = 0; j < commands.size(); j++) {
-+ newCommands.addAll(this.buildCommands(commands.get(j), i));
-+ }
-+ ArrayList<String[]> temp = commands;
-+ commands = newCommands;
-+ newCommands = temp;
-+ newCommands.clear();
-+ }
++ // Find positions of command block syntax, if any
++ ArrayList<String[]> newCommands = new ArrayList<String[]>();
++ for (int i = 0; i < args.length; i++) {
++ if (PlayerSelector.isPattern(args[i])) {
++ for (int j = 0; j < commands.size(); j++) {
++ newCommands.addAll(buildCommands(sender, commands.get(j), i));
+ }
++ ArrayList<String[]> temp = commands;
++ commands = newCommands;
++ newCommands = temp;
++ newCommands.clear();
++ }
++ }
+
-+ int completed = 0;
++ int completed = 0;
+
-+ // Now dispatch all of the commands we ended up with
-+ for (int i = 0; i < commands.size(); i++) {
-+ try {
-+ if (commandMap.dispatch(sender, joiner.join(java.util.Arrays.asList(commands.get(i))))) {
-+ completed++;
-+ }
-+ } catch (Throwable exception) {
-+ if(this instanceof TileEntityCommandListener) {
-+ TileEntityCommandListener listener = (TileEntityCommandListener) this;
-+ MinecraftServer.getLogger().log(Level.WARN, String.format("CommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().getX(), listener.getChunkCoordinates().getY(), listener.getChunkCoordinates().getZ()), exception);
-+ } else if (this instanceof EntityMinecartCommandBlockListener) {
-+ EntityMinecartCommandBlockListener listener = (EntityMinecartCommandBlockListener) this;
-+ MinecraftServer.getLogger().log(Level.WARN, String.format("MinecartCommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().getX(), listener.getChunkCoordinates().getY(), listener.getChunkCoordinates().getZ()), exception);
-+ } else {
-+ MinecraftServer.getLogger().log(Level.WARN, String.format("Unknown CommandBlock failed to handle command"), exception);
-+ }
-+ }
++ // Now dispatch all of the commands we ended up with
++ for (int i = 0; i < commands.size(); i++) {
++ try {
++ if (commandMap.dispatch(bSender, joiner.join(java.util.Arrays.asList(commands.get(i))))) {
++ completed++;
+ }
++ } catch (Throwable exception) {
++ if (sender instanceof TileEntityCommandListener) {
++ TileEntityCommandListener listener = (TileEntityCommandListener) sender;
++ MinecraftServer.getLogger().log(Level.WARN, String.format("CommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().getX(), listener.getChunkCoordinates().getY(), listener.getChunkCoordinates().getZ()), exception);
++ } else if (sender instanceof EntityMinecartCommandBlockListener) {
++ EntityMinecartCommandBlockListener listener = (EntityMinecartCommandBlockListener) sender;
++ MinecraftServer.getLogger().log(Level.WARN, String.format("MinecartCommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().getX(), listener.getChunkCoordinates().getY(), listener.getChunkCoordinates().getZ()), exception);
++ } else {
++ MinecraftServer.getLogger().log(Level.WARN, String.format("Unknown CommandBlock failed to handle command"), exception);
++ }
++ }
++ }
+
-+ this.b = completed;
-+ // CraftBukkit end
- } catch (Throwable throwable) {
- CrashReport crashreport = CrashReport.a(throwable, "Executing command block");
- CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed");
-@@ -91,8 +202,27 @@
- } else {
- this.b = 0;
- }
++ return completed;
+ }
-+
-+ // CraftBukkit start
-+ private ArrayList<String[]> buildCommands(String[] args, int pos) {
++
++ private static ArrayList<String[]> buildCommands(ICommandListener sender, String[] args, int pos) {
+ ArrayList<String[]> commands = new ArrayList<String[]>();
-+ java.util.List<EntityPlayer> players = (java.util.List<EntityPlayer>)PlayerSelector.getPlayers(this, args[pos], EntityPlayer.class);
++ java.util.List<EntityPlayer> players = (java.util.List<EntityPlayer>)PlayerSelector.getPlayers(sender, args[pos], EntityPlayer.class);
+
+ if (players != null) {
+ for (EntityPlayer player : players) {
-+ if (player.world != this.getWorld()) {
++ if (player.world != sender.getWorld()) {
+ continue;
+ }
+ String[] command = args.clone();
diff --git a/nms-patches/CommandGamerule.patch b/nms-patches/CommandGamerule.patch
new file mode 100644
index 00000000..30d67f7f
--- /dev/null
+++ b/nms-patches/CommandGamerule.patch
@@ -0,0 +1,25 @@
+--- ../work/decompile-8eb82bde/net/minecraft/server/CommandGamerule.java 2014-12-10 16:21:38.404579167 +0000
++++ src/main/java/net/minecraft/server/CommandGamerule.java 2014-12-10 16:18:45.268581046 +0000
+@@ -19,8 +19,8 @@
+ return "commands.gamerule.usage";
+ }
+
+- public void execute(ICommandListener icommandlistener, String[] astring) {
+- GameRules gamerules = this.d();
++ public void execute(ICommandListener icommandlistener, String[] astring) throws CommandException { // CraftBukkit - added throws
++ GameRules gamerules = icommandlistener.getWorld().getGameRules(); // Use current world
+ String s = astring.length > 0 ? astring[0] : "";
+ String s1 = astring.length > 1 ? a(astring, 1) : "";
+
+@@ -85,4 +85,11 @@
+ private GameRules d() {
+ return MinecraftServer.getServer().getWorldServer(0).getGameRules();
+ }
++
++ // CraftBukkit start - fix decompile error
++ @Override
++ public int compareTo(Object o) {
++ return a((ICommand) o);
++ }
++ // CraftBukkit end
+ }
diff --git a/nms-patches/CommandWorldBorder.patch b/nms-patches/CommandWorldBorder.patch
deleted file mode 100644
index dbb2dfc7..00000000
--- a/nms-patches/CommandWorldBorder.patch
+++ /dev/null
@@ -1,28 +0,0 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/CommandWorldBorder.java 2014-11-29 00:40:43.197707433 +0000
-+++ src/main/java/net/minecraft/server/CommandWorldBorder.java 2014-11-29 00:40:17.000000000 +0000
-@@ -18,11 +18,11 @@
- return "commands.worldborder.usage";
- }
-
-- public void execute(ICommandListener icommandlistener, String[] astring) {
-+ public void execute(ICommandListener icommandlistener, String[] astring) throws ExceptionUsage { // CraftBukkit - Add Exception
- if (astring.length < 1) {
- throw new ExceptionUsage("commands.worldborder.usage", new Object[0]);
- } else {
-- WorldBorder worldborder = this.d();
-+ WorldBorder worldborder = icommandlistener.getWorld().af(); // CraftBukkit - Use the world the player is in instead of the first in Minecraft
- double d0;
- double d1;
- long i;
-@@ -141,4 +141,11 @@
- public List tabComplete(ICommandListener icommandlistener, String[] astring, BlockPosition blockposition) {
- return astring.length == 1 ? a(astring, new String[] { "set", "center", "damage", "warning", "add", "get"}) : (astring.length == 2 && astring[0].equals("damage") ? a(astring, new String[] { "buffer", "amount"}) : (astring.length == 2 && astring[0].equals("warning") ? a(astring, new String[] { "time", "distance"}) : null));
- }
-+
-+ // CraftBukkit start - Implement compareTo since obfuscation has renamed it to a(ICommand)
-+ @Override
-+ public int compareTo( Object o ) {
-+ return a((ICommand) o);
-+ }
-+ // CraftBukkit end
- }
diff --git a/nms-patches/DispenseBehaviorFireworks.patch b/nms-patches/DispenseBehaviorFireworks.patch
new file mode 100644
index 00000000..b4896bbb
--- /dev/null
+++ b/nms-patches/DispenseBehaviorFireworks.patch
@@ -0,0 +1,52 @@
+--- ../work/decompile-8eb82bde//net/minecraft/server/DispenseBehaviorFireworks.java Sat Dec 6 21:12:00 2014
++++ src/main/java/net/minecraft/server/DispenseBehaviorFireworks.java Sat Dec 6 21:11:47 2014
+@@ -1,5 +1,8 @@
+ package net.minecraft.server;
+
++import org.bukkit.craftbukkit.inventory.CraftItemStack;
++import org.bukkit.event.block.BlockDispenseEvent;
++
+ final class DispenseBehaviorFireworks extends DispenseBehaviorItem {
+
+ DispenseBehaviorFireworks() {}
+@@ -9,10 +12,38 @@
+ double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX();
+ double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F);
+ double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ();
+- EntityFireworks entityfireworks = new EntityFireworks(isourceblock.i(), d0, d1, d2, itemstack);
+
++ // CraftBukkit start
++ World world = isourceblock.i();
++ ItemStack itemstack1 = itemstack.a(1);
++ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
++
++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2));
++ if (!BlockDispenser.eventFired) {
++ world.getServer().getPluginManager().callEvent(event);
++ }
++
++ if (event.isCancelled()) {
++ itemstack.count++;
++ return itemstack;
++ }
++
++ if (!event.getItem().equals(craftItem)) {
++ itemstack.count++;
++ // Chain to handler for new item
++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
++ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
++ idispensebehavior.a(isourceblock, eventStack);
++ return itemstack;
++ }
++ }
++
++ EntityFireworks entityfireworks = new EntityFireworks(isourceblock.i(), d0, d1, d2, itemstack);
+ isourceblock.i().addEntity(entityfireworks);
+- itemstack.a(1);
++ // itemstack.a(1); // Handled during event processing
++ // CraftBukkit end
+ return itemstack;
+ }
+
diff --git a/nms-patches/EnchantmentThorns.patch b/nms-patches/EnchantmentThorns.patch
new file mode 100644
index 00000000..13386c76
--- /dev/null
+++ b/nms-patches/EnchantmentThorns.patch
@@ -0,0 +1,11 @@
+--- ../work/decompile-8eb82bde/net/minecraft/server/EnchantmentThorns.java 2014-12-10 15:53:01.980344940 +1100
++++ src/main/java/net/minecraft/server/EnchantmentThorns.java 2014-12-10 15:52:50.688364236 +1100
+@@ -29,7 +29,7 @@
+ Random random = entityliving.bb();
+ ItemStack itemstack = EnchantmentManager.a(Enchantment.THORNS, entityliving);
+
+- if (a(i, random)) {
++ if (entity != null && a(i, random)) { // CraftBukkit
+ entity.damageEntity(DamageSource.a(entityliving), (float) b(i, random));
+ entity.makeSound("damage.thorns", 0.5F, 1.0F);
+ if (itemstack != null) {
diff --git a/nms-patches/EntityEnderCrystal.patch b/nms-patches/EntityEnderCrystal.patch
index 5a165ce2..3a95eb74 100644
--- a/nms-patches/EntityEnderCrystal.patch
+++ b/nms-patches/EntityEnderCrystal.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/EntityEnderCrystal.java 2014-11-28 17:43:43.081707435 +0000
-+++ src/main/java/net/minecraft/server/EntityEnderCrystal.java 2014-11-28 17:38:19.000000000 +0000
+--- ../work/decompile-8eb82bde//net/minecraft/server/EntityEnderCrystal.java 2014-12-05 23:41:59.577572184 +0000
++++ src/main/java/net/minecraft/server/EntityEnderCrystal.java 2014-12-05 23:41:54.069572306 +0000
@@ -1,5 +1,10 @@
package net.minecraft.server;
@@ -24,7 +24,17 @@
}
}
-@@ -54,7 +63,15 @@
+@@ -50,11 +59,25 @@
+ return false;
+ } else {
+ if (!this.dead && !this.world.isStatic) {
++ // CraftBukkit start - All non-living entities need this
++ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
++ return false;
++ }
++ // CraftBukkit end
++
+ this.b = 0;
if (this.b <= 0) {
this.die();
if (!this.world.isStatic) {
diff --git a/nms-patches/EntityHuman.patch b/nms-patches/EntityHuman.patch
index 91bae5ac..ca770d2c 100644
--- a/nms-patches/EntityHuman.patch
+++ b/nms-patches/EntityHuman.patch
@@ -1,6 +1,6 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/EntityHuman.java 2014-11-30 16:35:27.792804607 +0000
-+++ src/main/java/net/minecraft/server/EntityHuman.java 2014-11-30 16:34:50.780805428 +0000
-@@ -8,13 +8,25 @@
+--- ../work/decompile-8eb82bde/net/minecraft/server/EntityHuman.java 2014-12-10 16:27:47.832575157 +0000
++++ src/main/java/net/minecraft/server/EntityHuman.java 2014-12-10 16:27:27.556575377 +0000
+@@ -8,13 +8,27 @@
import java.util.List;
import java.util.UUID;
@@ -14,6 +14,8 @@
+import org.bukkit.event.player.PlayerBedLeaveEvent;
+import org.bukkit.event.player.PlayerDropItemEvent;
+import org.bukkit.event.player.PlayerItemConsumeEvent;
++import org.bukkit.event.player.PlayerVelocityEvent;
++import org.bukkit.util.Vector;
+// CraftBukkit end
+
public abstract class EntityHuman extends EntityLiving {
@@ -27,7 +29,7 @@
protected int bk;
public float bl;
public float bm;
-@@ -34,6 +46,7 @@
+@@ -34,6 +48,7 @@
private boolean d;
private BlockPosition e;
public PlayerAbilities abilities = new PlayerAbilities();
@@ -35,7 +37,7 @@
public int expLevel;
public int expTotal;
public float exp;
-@@ -46,6 +59,16 @@
+@@ -46,6 +61,16 @@
private final GameProfile bF;
private boolean bG = false;
public EntityFishingHook hookedFish;
@@ -52,7 +54,7 @@
public EntityHuman(World world, GameProfile gameprofile) {
super(world);
-@@ -265,6 +288,32 @@
+@@ -265,6 +290,32 @@
if (this.g != null) {
this.b(this.g, 16);
int i = this.g.count;
@@ -85,7 +87,7 @@
ItemStack itemstack = this.g.b(this.world, this);
if (itemstack != this.g || itemstack != null && itemstack.count != i) {
-@@ -324,7 +373,8 @@
+@@ -324,7 +375,8 @@
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean("naturalRegeneration")) {
if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) {
@@ -95,7 +97,7 @@
}
if (this.foodData.c() && this.ticksLived % 10 == 0) {
-@@ -348,7 +398,7 @@
+@@ -348,7 +400,7 @@
this.j((float) attributeinstance.getValue());
float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
@@ -104,24 +106,24 @@
if (f > 0.1F) {
f = 0.1F;
-@@ -438,11 +488,14 @@
+@@ -438,11 +490,14 @@
public void b(Entity entity, int i) {
this.addScore(i);
- Collection collection = this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.f);
+ // CraftBukkit - Get our scores instead
-+ Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, this.getName(), new java.util.ArrayList<ScoreboardScore>());
++ Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.f, this.getName(), new java.util.ArrayList<ScoreboardScore>());
+
if (entity instanceof EntityHuman) {
this.b(StatisticList.B);
- collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e));
+ // CraftBukkit - Get our scores instead
-+ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.d, this.getName(), collection);
++ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, this.getName(), collection);
collection.addAll(this.e(entity));
} else {
this.b(StatisticList.z);
-@@ -451,8 +504,7 @@
+@@ -451,8 +506,7 @@
Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
@@ -131,7 +133,7 @@
scoreboardscore.incrementScore();
}
-@@ -491,6 +543,7 @@
+@@ -491,6 +545,7 @@
}
public EntityItem a(boolean flag) {
@@ -139,7 +141,7 @@
return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && this.inventory.getItemInHand() != null ? this.inventory.getItemInHand().count : 1), false, true);
}
-@@ -532,6 +585,30 @@
+@@ -532,6 +587,30 @@
entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
entityitem.motZ += Math.sin((double) f1) * (double) f;
}
@@ -170,7 +172,7 @@
this.a(entityitem);
if (flag1) {
-@@ -623,10 +700,18 @@
+@@ -623,10 +702,18 @@
this.bv = new BlockPosition(this);
this.a(true, true, false);
}
@@ -189,7 +191,7 @@
}
this.foodData.a(nbttagcompound);
-@@ -684,7 +769,7 @@
+@@ -684,7 +771,7 @@
if (damagesource.r()) {
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) {
@@ -198,7 +200,7 @@
}
if (this.world.getDifficulty() == EnumDifficulty.EASY) {
-@@ -696,7 +781,7 @@
+@@ -696,7 +783,7 @@
}
}
@@ -207,7 +209,7 @@
return false;
} else {
Entity entity = damagesource.getEntity();
-@@ -712,10 +797,29 @@
+@@ -712,10 +799,29 @@
}
public boolean a(EntityHuman entityhuman) {
@@ -240,7 +242,7 @@
}
protected void damageArmor(float f) {
-@@ -742,7 +846,12 @@
+@@ -742,7 +848,12 @@
return (float) i / (float) this.inventory.armor.length;
}
@@ -254,7 +256,7 @@
if (!this.isInvulnerable(damagesource)) {
if (!damagesource.ignoresArmor() && this.isBlocking() && f > 0.0F) {
f = (1.0F + f) * 0.5F;
-@@ -766,6 +875,7 @@
+@@ -766,6 +877,7 @@
}
}
@@ -262,7 +264,7 @@
}
public void openSign(TileEntitySign tileentitysign) {}
-@@ -800,7 +910,8 @@
+@@ -800,7 +912,8 @@
}
if (itemstack.a(this, (EntityLiving) entity)) {
@@ -272,7 +274,7 @@
this.bZ();
}
-@@ -866,8 +977,15 @@
+@@ -866,8 +979,15 @@
int j = EnchantmentManager.getFireAspectEnchantmentLevel(this);
if (entity instanceof EntityLiving && j > 0 && !entity.isBurning()) {
@@ -290,7 +292,41 @@
}
double d0 = entity.motX;
-@@ -922,7 +1040,8 @@
+@@ -884,11 +1004,28 @@
+ }
+
+ if (entity instanceof EntityPlayer && entity.velocityChanged) {
+- ((EntityPlayer) entity).playerConnection.sendPacket(new PacketPlayOutEntityVelocity(entity));
+- entity.velocityChanged = false;
+- entity.motX = d0;
+- entity.motY = d1;
+- entity.motZ = d2;
++ // CraftBukkit start - Add Velocity Event
++ boolean cancelled = false;
++ Player player = (Player) entity.getBukkitEntity();
++ org.bukkit.util.Vector velocity = new Vector( d0, d1, d2 );
++
++ PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
++ world.getServer().getPluginManager().callEvent(event);
++
++ if (event.isCancelled()) {
++ cancelled = true;
++ } else if (!velocity.equals(event.getVelocity())) {
++ player.setVelocity(velocity);
++ }
++
++ if (!cancelled) {
++ ( (EntityPlayer) entity ).playerConnection.sendPacket( new PacketPlayOutEntityVelocity( entity ) );
++ entity.velocityChanged = false;
++ entity.motX = d0;
++ entity.motY = d1;
++ entity.motZ = d2;
++ }
++ // CraftBukkit end
+ }
+
+ if (flag) {
+@@ -922,7 +1059,8 @@
if (itemstack != null && object instanceof EntityLiving) {
itemstack.a((EntityLiving) object, this);
@@ -300,7 +336,7 @@
this.bZ();
}
}
-@@ -930,7 +1049,14 @@
+@@ -930,7 +1068,14 @@
if (entity instanceof EntityLiving) {
this.a(StatisticList.w, Math.round(f * 10.0F));
if (j > 0) {
@@ -316,7 +352,7 @@
}
}
-@@ -995,6 +1121,20 @@
+@@ -995,6 +1140,20 @@
if (this.av()) {
this.mount((Entity) null);
}
@@ -337,7 +373,7 @@
this.a(0.2F, 0.2F);
if (this.world.isLoaded(blockposition)) {
-@@ -1077,6 +1217,23 @@
+@@ -1077,6 +1236,23 @@
if (!this.world.isStatic && flag1) {
this.world.everyoneSleeping();
}
@@ -361,7 +397,7 @@
this.sleepTicks = flag ? 0 : 100;
if (flag2) {
-@@ -1090,6 +1247,7 @@
+@@ -1090,6 +1266,7 @@
}
public static BlockPosition getBed(World world, BlockPosition blockposition, boolean flag) {
@@ -369,7 +405,7 @@
if (world.getType(blockposition).getBlock() != Blocks.BED) {
if (!flag) {
return null;
-@@ -1128,9 +1286,11 @@
+@@ -1128,9 +1305,11 @@
if (blockposition != null) {
this.c = blockposition;
this.d = flag;
@@ -381,7 +417,7 @@
}
}
-@@ -1477,6 +1637,7 @@
+@@ -1477,6 +1656,7 @@
}
public IChatBaseComponent getScoreboardDisplayName() {
diff --git a/nms-patches/EntityTrackerEntry.patch b/nms-patches/EntityTrackerEntry.patch
index 187f133a..6703a119 100644
--- a/nms-patches/EntityTrackerEntry.patch
+++ b/nms-patches/EntityTrackerEntry.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/EntityTrackerEntry.java 2014-11-28 17:43:43.173707433 +0000
-+++ src/main/java/net/minecraft/server/EntityTrackerEntry.java 2014-11-28 17:38:21.000000000 +0000
+--- ../work/decompile-8eb82bde//net/minecraft/server/EntityTrackerEntry.java 2014-12-06 20:17:40.567361225 +0000
++++ src/main/java/net/minecraft/server/EntityTrackerEntry.java 2014-12-06 20:17:33.983361371 +0000
@@ -8,6 +8,11 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -162,7 +162,20 @@
if (this.tracker instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) this.tracker;
-@@ -356,7 +427,10 @@
+@@ -337,8 +408,10 @@
+ }
+
+ public boolean c(EntityPlayer entityplayer) {
+- double d0 = entityplayer.locX - (double) (this.xLoc / 32);
+- double d1 = entityplayer.locZ - (double) (this.zLoc / 32);
++ // CraftBukkit start - this.*Loc / 30 -> this.tracker.loc*
++ double d0 = entityplayer.locX - this.tracker.locX;
++ double d1 = entityplayer.locZ - this.tracker.locZ;
++ // CraftBukkit end
+
+ return d0 >= (double) (-this.b) && d0 <= (double) this.b && d1 >= (double) (-this.b) && d1 <= (double) this.b && this.tracker.a(entityplayer);
+ }
+@@ -356,7 +429,10 @@
private Packet c() {
if (this.tracker.dead) {
diff --git a/nms-patches/ICommand.patch b/nms-patches/ICommand.patch
index f42a35f4..f3f78b5e 100644
--- a/nms-patches/ICommand.patch
+++ b/nms-patches/ICommand.patch
@@ -1,11 +1,11 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/ICommand.java 2014-11-29 00:40:43.197707433 +0000
-+++ src/main/java/net/minecraft/server/ICommand.java 2014-11-29 00:40:17.000000000 +0000
+--- ../work/decompile-8eb82bde/net/minecraft/server/ICommand.java 2014-12-10 16:21:38.812579162 +0000
++++ src/main/java/net/minecraft/server/ICommand.java 2014-12-10 16:18:07.164581460 +0000
@@ -10,7 +10,7 @@
List b();
- void execute(ICommandListener icommandlistener, String[] astring);
-+ void execute(ICommandListener icommandlistener, String[] astring) throws ExceptionUsage; // CraftBukkit - Add exception
++ void execute(ICommandListener icommandlistener, String[] astring) throws ExceptionUsage, CommandException; // CraftBukkit - Add exception
boolean canUse(ICommandListener icommandlistener);
diff --git a/nms-patches/MinecraftServer.patch b/nms-patches/MinecraftServer.patch
index ea9982db..e5605805 100644
--- a/nms-patches/MinecraftServer.patch
+++ b/nms-patches/MinecraftServer.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/MinecraftServer.java Sat Nov 29 19:31:45 2014
-+++ src/main/java/net/minecraft/server/MinecraftServer.java Sat Nov 29 19:27:57 2014
+--- ../decompile-8eb82bde//net/minecraft/server/MinecraftServer.java 2014-12-03 14:33:55.037564649 -0500
++++ src/main/java/net/minecraft/server/MinecraftServer.java 2014-12-03 14:33:47.061564766 -0500
@@ -37,6 +37,18 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -276,7 +276,7 @@
this.q();
}
-@@ -247,35 +390,42 @@
+@@ -247,35 +390,38 @@
protected void q() {
this.e = null;
this.f = 0;
@@ -309,10 +309,6 @@
- }
+ worldserver.save(true, (IProgressUpdate) null);
+ worldserver.saveLevel();
-+
-+ WorldSaveEvent event = new WorldSaveEvent(worldserver.getWorld());
-+ this.server.getPluginManager().callEvent(event);
-+ // CraftBukkit end
}
}
@@ -331,7 +327,7 @@
if (this.ao() != null) {
this.ao().b();
}
-@@ -290,11 +440,13 @@
+@@ -290,11 +436,13 @@
MinecraftServer.LOGGER.info("Saving worlds");
this.saveChunks(false);
@@ -345,7 +341,7 @@
}
if (this.m.d()) {
-@@ -335,6 +487,7 @@
+@@ -335,6 +483,7 @@
long k = j - this.ab;
if (k > 2000L && this.ab - this.R >= 15000L) {
@@ -353,7 +349,7 @@
MinecraftServer.LOGGER.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", new Object[] { Long.valueOf(k), Long.valueOf(k / 50L)});
k = 2000L;
this.R = this.ab;
-@@ -347,11 +500,12 @@
+@@ -347,11 +496,12 @@
i += k;
this.ab = j;
@@ -367,7 +363,7 @@
i -= 50L;
this.y();
}
-@@ -389,6 +543,12 @@
+@@ -389,6 +539,12 @@
} catch (Throwable throwable1) {
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
} finally {
@@ -380,7 +376,7 @@
this.x();
}
-@@ -428,7 +588,7 @@
+@@ -428,7 +584,7 @@
protected void x() {}
@@ -389,7 +385,7 @@
long i = System.nanoTime();
++this.ticks;
-@@ -454,7 +614,7 @@
+@@ -454,7 +610,7 @@
this.r.b().a(agameprofile);
}
@@ -398,7 +394,7 @@
this.methodProfiler.a("save");
this.v.savePlayers();
this.saveChunks(true);
-@@ -493,20 +653,40 @@
+@@ -493,20 +649,40 @@
this.methodProfiler.c("levels");
@@ -442,7 +438,7 @@
this.methodProfiler.a("tick");
-@@ -533,9 +713,9 @@
+@@ -533,9 +709,9 @@
worldserver.getTracker().updatePlayers();
this.methodProfiler.b();
this.methodProfiler.b();
@@ -454,7 +450,7 @@
}
this.methodProfiler.c("connection");
-@@ -559,10 +739,11 @@
+@@ -559,10 +735,11 @@
this.o.add(iupdateplayerlistbox);
}
@@ -467,7 +463,7 @@
boolean flag = true;
String s = null;
String s1 = ".";
-@@ -636,6 +817,27 @@
+@@ -636,6 +813,27 @@
dedicatedserver.B();
Runtime.getRuntime().addShutdownHook(new ThreadShutdown("Server Shutdown Thread", dedicatedserver));
@@ -495,7 +491,7 @@
} catch (Exception exception) {
MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception);
}
-@@ -643,8 +845,10 @@
+@@ -643,8 +841,10 @@
}
public void B() {
@@ -506,7 +502,7 @@
}
public File d(String s) {
-@@ -660,7 +864,14 @@
+@@ -660,7 +860,14 @@
}
public WorldServer getWorldServer(int i) {
@@ -522,7 +518,7 @@
}
public String C() {
-@@ -696,17 +907,62 @@
+@@ -696,17 +903,62 @@
}
public String getPlugins() {
@@ -592,7 +588,7 @@
}
public void h(String s) {
-@@ -721,7 +977,7 @@
+@@ -721,7 +973,7 @@
}
public String getServerModName() {
@@ -601,7 +597,7 @@
}
public CrashReport b(CrashReport crashreport) {
-@@ -734,6 +990,7 @@
+@@ -734,6 +986,7 @@
}
public List tabCompleteCommand(ICommandListener icommandlistener, String s, BlockPosition blockposition) {
@@ -609,7 +605,7 @@
ArrayList arraylist = Lists.newArrayList();
if (s.startsWith("/")) {
-@@ -772,6 +1029,9 @@
+@@ -772,6 +1025,9 @@
return arraylist;
}
@@ -619,7 +615,7 @@
}
public static MinecraftServer getServer() {
-@@ -779,7 +1039,7 @@
+@@ -779,7 +1035,7 @@
}
public boolean N() {
@@ -628,7 +624,7 @@
}
public String getName() {
-@@ -835,8 +1095,10 @@
+@@ -835,8 +1091,10 @@
}
public void a(EnumDifficulty enumdifficulty) {
@@ -641,7 +637,7 @@
if (worldserver != null) {
if (worldserver.getWorldData().isHardcore()) {
-@@ -878,15 +1140,17 @@
+@@ -878,15 +1136,17 @@
this.N = true;
this.getConvertable().d();
@@ -662,7 +658,7 @@
this.safeShutdown();
}
-@@ -919,9 +1183,11 @@
+@@ -919,9 +1179,11 @@
int i = 0;
if (this.worldServer != null) {
@@ -677,7 +673,7 @@
WorldData worlddata = worldserver.getWorldData();
mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimension()));
-@@ -954,7 +1220,7 @@
+@@ -954,7 +1216,7 @@
public abstract boolean ad();
public boolean getOnlineMode() {
@@ -686,7 +682,7 @@
}
public void setOnlineMode(boolean flag) {
-@@ -1024,8 +1290,10 @@
+@@ -1024,8 +1286,10 @@
}
public void setGamemode(EnumGamemode enumgamemode) {
@@ -699,7 +695,7 @@
}
}
-@@ -1057,7 +1325,7 @@
+@@ -1057,7 +1321,7 @@
}
public World getWorld() {
@@ -708,7 +704,7 @@
}
public Entity f() {
-@@ -1125,11 +1393,10 @@
+@@ -1125,11 +1389,10 @@
}
public Entity a(UUID uuid) {
@@ -724,7 +720,7 @@
if (worldserver != null) {
Entity entity = worldserver.getEntity(uuid);
-@@ -1144,7 +1411,7 @@
+@@ -1144,7 +1407,7 @@
}
public boolean getSendCommandFeedback() {
diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch
index 4bf78c5d..841ff572 100644
--- a/nms-patches/PlayerConnection.patch
+++ b/nms-patches/PlayerConnection.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/PlayerConnection.java 2014-12-02 20:39:19.177600755 +0000
-+++ src/main/java/net/minecraft/server/PlayerConnection.java 2014-12-02 20:38:47.001601469 +0000
+--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerConnection.java 2014-12-09 12:20:29.531617451 +0000
++++ src/main/java/net/minecraft/server/PlayerConnection.java 2014-12-09 12:20:21.823617622 +0000
@@ -16,6 +16,48 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -115,7 +115,7 @@
if (this.m > 0) {
--this.m;
-@@ -76,11 +151,27 @@
+@@ -76,11 +151,28 @@
}
public void disconnect(String s) {
@@ -137,6 +137,7 @@
+ // CraftBukkit end
ChatComponentText chatcomponenttext = new ChatComponentText(s);
++ this.a(chatcomponenttext); // CraftBukkit - fire quit instantly
this.networkManager.a(new PacketPlayOutKickDisconnect(chatcomponenttext), new PlayerConnectionFuture(this, chatcomponenttext), new GenericFutureListener[0]);
this.networkManager.k();
- Futures.getUnchecked(this.minecraftServer.postToMainThread(new PlayerConnectionDisconnector(this)));
@@ -144,7 +145,7 @@
}
public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) {
-@@ -90,6 +181,13 @@
+@@ -90,6 +182,13 @@
public void a(PacketPlayInFlying packetplayinflying) {
PlayerConnectionUtils.ensureMainThread(packetplayinflying, this, this.player.u());
@@ -158,7 +159,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
this.h = true;
-@@ -108,8 +206,65 @@
+@@ -108,8 +207,65 @@
this.checkMovement = true;
}
}
@@ -225,7 +226,7 @@
this.f = this.e;
double d7;
double d8;
-@@ -203,12 +358,14 @@
+@@ -203,12 +359,14 @@
double d11 = d7 - this.player.locX;
double d12 = d8 - this.player.locY;
double d13 = d9 - this.player.locZ;
@@ -244,7 +245,7 @@
PlayerConnection.c.warn(this.player.getName() + " moved too quickly! " + d11 + "," + d12 + "," + d13 + " (" + d14 + ", " + d15 + ", " + d16 + ")");
this.a(this.o, this.p, this.q, this.player.yaw, this.player.pitch);
return;
-@@ -281,6 +438,49 @@
+@@ -281,6 +439,49 @@
}
public void a(double d0, double d1, double d2, float f, float f1, Set set) {
@@ -294,7 +295,7 @@
this.checkMovement = false;
this.o = d0;
this.p = d1;
-@@ -314,32 +514,49 @@
+@@ -314,32 +515,49 @@
public void a(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.u());
@@ -350,7 +351,7 @@
double d0 = this.player.locX - ((double) blockposition.getX() + 0.5D);
double d1 = this.player.locY - ((double) blockposition.getY() + 0.5D) + 1.5D;
double d2 = this.player.locZ - ((double) blockposition.getZ() + 0.5D);
-@@ -354,7 +571,15 @@
+@@ -354,7 +572,15 @@
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.af().a(blockposition)) {
this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b());
} else {
@@ -366,7 +367,7 @@
}
} else {
if (packetplayinblockdig.c() == EnumPlayerDigType.STOP_DESTROY_BLOCK) {
-@@ -374,11 +599,22 @@
+@@ -374,11 +600,22 @@
default:
throw new IllegalArgumentException("Invalid player action");
}
@@ -389,15 +390,47 @@
ItemStack itemstack = this.player.inventory.getItemInHand();
boolean flag = false;
BlockPosition blockposition = packetplayinblockplace.a();
-@@ -390,7 +626,18 @@
+@@ -390,7 +627,50 @@
return;
}
- this.player.playerInteractManager.useItem(this.player, worldserver, itemstack);
+ // CraftBukkit start
+ int itemstackAmount = itemstack.count;
-+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack);
-+ if (event.useItemInHand() != Event.Result.DENY) {
++
++ // Raytrace to look for 'rogue armswings'
++ float f1 = this.player.pitch;
++ float f2 = this.player.yaw;
++ double d0 = this.player.locX;
++ double d1 = this.player.locY + (double) this.player.getHeadHeight();
++ double d2 = this.player.locZ;
++ Vec3D vec3d = new Vec3D(d0, d1, d2);
++
++ float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
++ float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
++ float f5 = -MathHelper.cos(-f1 * 0.017453292F);
++ float f6 = MathHelper.sin(-f1 * 0.017453292F);
++ float f7 = f4 * f5;
++ float f8 = f3 * f5;
++ double d3 = player.playerInteractManager.getGameMode() == EnumGamemode.CREATIVE ? 5.0D : 4.5D;
++ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
++ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false);
++
++ boolean cancelled = false;
++ if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.BLOCK) {
++ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack);
++ cancelled = event.useItemInHand() == Event.Result.DENY;
++ } else {
++ if (player.playerInteractManager.firedInteract) {
++ player.playerInteractManager.firedInteract = false;
++ cancelled = player.playerInteractManager.interactResult;
++ } else {
++ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectposition.a(), movingobjectposition.direction, itemstack, true);
++ cancelled = event.useItemInHand() == Event.Result.DENY;
++ }
++ }
++
++ if (!cancelled) {
+ this.player.playerInteractManager.useItem(this.player, this.player.world, itemstack);
+ }
+
@@ -409,7 +442,7 @@
} else if (blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && (enumdirection == EnumDirection.UP || blockposition.getY() >= this.minecraftServer.getMaxBuildHeight())) {
ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight())});
-@@ -398,9 +645,21 @@
+@@ -398,9 +678,21 @@
this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage));
flag = true;
} else {
@@ -432,7 +465,7 @@
flag = true;
}
-@@ -423,7 +682,8 @@
+@@ -423,7 +715,8 @@
this.player.activeContainer.b();
this.player.g = false;
@@ -442,7 +475,7 @@
this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand()));
}
}
-@@ -437,8 +697,8 @@
+@@ -437,8 +730,8 @@
WorldServer[] aworldserver = this.minecraftServer.worldServer;
int i = aworldserver.length;
@@ -453,7 +486,7 @@
if (worldserver != null) {
entity = packetplayinspectate.a(worldserver);
-@@ -455,6 +715,7 @@
+@@ -455,6 +748,7 @@
WorldServer worldserver1 = this.player.u();
WorldServer worldserver2 = (WorldServer) entity.world;
@@ -461,7 +494,7 @@
this.player.dimension = entity.dimension;
this.sendPacket(new PacketPlayOutRespawn(this.player.dimension, worldserver1.getDifficulty(), worldserver1.getWorldData().getType(), this.player.playerInteractManager.getGameMode()));
worldserver1.removeEntity(this.player);
-@@ -472,6 +733,9 @@
+@@ -472,6 +766,9 @@
this.player.playerInteractManager.a(worldserver2);
this.minecraftServer.getPlayerList().b(this.player, worldserver2);
this.minecraftServer.getPlayerList().updateClient(this.player);
@@ -471,7 +504,7 @@
} else {
this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ);
}
-@@ -483,14 +747,29 @@
+@@ -483,14 +780,29 @@
public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {}
public void a(IChatBaseComponent ichatbasecomponent) {
@@ -503,7 +536,7 @@
if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) {
PlayerConnection.c.info("Stopping singleplayer server as player logged out");
this.minecraftServer.safeShutdown();
-@@ -511,6 +790,15 @@
+@@ -511,6 +823,15 @@
return;
}
}
@@ -519,7 +552,7 @@
try {
this.networkManager.handle(packet);
-@@ -524,18 +812,34 @@
+@@ -524,18 +845,34 @@
}
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
@@ -556,7 +589,7 @@
ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]);
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
-@@ -548,39 +852,247 @@
+@@ -548,39 +885,247 @@
for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
@@ -631,7 +664,7 @@
+ return null;
+ }
+ };
-
++
+ this.minecraftServer.processQueue.add(waitable);
+
+ try {
@@ -646,8 +679,8 @@
+ }
+ // CraftBukkit end
+ }
- }
- }
++ }
++ }
+
+ // CraftBukkit start - add method
+ public void chat(String s, boolean async) {
@@ -706,7 +739,7 @@
+ if (event.isCancelled()) {
+ return;
+ }
-+
+
+ s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
+ minecraftServer.console.sendMessage(s);
+ if (((LazyPlayerSet) event.getRecipients()).isLazy()) {
@@ -719,8 +752,8 @@
+ }
+ }
+ }
-+ }
-+ }
+ }
+ }
+ // CraftBukkit end
private void handleCommand(String s) {
@@ -768,7 +801,7 @@
+ float f6 = MathHelper.sin(-f1 * 0.017453292F);
+ float f7 = f4 * f5;
+ float f8 = f3 * f5;
-+ double d3 = 5.0D;
++ double d3 = player.playerInteractManager.getGameMode() == EnumGamemode.CREATIVE ? 5.0D : 4.5D;
+ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
+ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false);
+
@@ -812,7 +845,7 @@
this.player.z();
switch (SwitchHelperCommandActionType.b[packetplayinentityaction.b().ordinal()]) {
case 1:
-@@ -601,7 +1113,7 @@
+@@ -601,7 +1146,7 @@
case 5:
this.player.a(false, true, true);
@@ -821,7 +854,7 @@
break;
case 6:
-@@ -623,6 +1135,7 @@
+@@ -623,6 +1168,7 @@
}
public void a(PacketPlayInUseEntity packetplayinuseentity) {
@@ -829,7 +862,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.u());
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver);
-@@ -637,18 +1150,72 @@
+@@ -637,18 +1183,72 @@
}
if (this.player.h(entity) < d0) {
@@ -903,7 +936,7 @@
}
}
}
-@@ -663,7 +1230,8 @@
+@@ -663,7 +1263,8 @@
switch (SwitchHelperCommandActionType.c[enumclientcommand.ordinal()]) {
case 1:
if (this.player.viewingCredits) {
@@ -913,7 +946,7 @@
} else if (this.player.u().getWorldData().isHardcore()) {
if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) {
this.player.playerConnection.disconnect("You have died. Game over, man, it\'s game over!");
-@@ -694,11 +1262,17 @@
+@@ -694,11 +1295,17 @@
}
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
@@ -931,7 +964,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.u());
this.player.z();
if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) {
-@@ -711,7 +1285,263 @@
+@@ -711,7 +1318,269 @@
this.player.a(this.player.activeContainer, (List) arraylist);
} else {
@@ -1191,12 +1224,18 @@
+ }
+ return;
+ }
++
++ if (event instanceof CraftItemEvent) {
++ // Need to update the inventory on crafting to
++ // correctly support custom recipes
++ player.updateInventory(player.activeContainer);
++ }
+ }
+ // CraftBukkit end
if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) {
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true));
-@@ -772,8 +1602,50 @@
+@@ -772,8 +1641,50 @@
}
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize();
@@ -1248,7 +1287,7 @@
if (flag1 && flag2 && flag3) {
if (itemstack == null) {
-@@ -796,6 +1668,7 @@
+@@ -796,6 +1707,7 @@
}
public void a(PacketPlayInTransaction packetplayintransaction) {
@@ -1256,7 +1295,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u());
Short oshort = (Short) this.n.get(this.player.activeContainer.windowId);
-@@ -806,6 +1679,7 @@
+@@ -806,6 +1718,7 @@
}
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
@@ -1264,7 +1303,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u());
this.player.z();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
-@@ -822,10 +1696,24 @@
+@@ -822,10 +1735,24 @@
if (!tileentitysign.b() || tileentitysign.c() != this.player) {
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
@@ -1290,7 +1329,7 @@
tileentitysign.update();
worldserver.notify(blockposition);
}
-@@ -847,11 +1735,28 @@
+@@ -847,11 +1774,28 @@
public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u());
@@ -1320,7 +1359,7 @@
ArrayList arraylist = Lists.newArrayList();
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator();
-@@ -891,13 +1796,15 @@
+@@ -891,13 +1835,15 @@
itemstack1 = this.player.inventory.getItemInHand();
if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
@@ -1337,7 +1376,7 @@
return;
} finally {
packetdataserializer.release();
-@@ -909,27 +1816,31 @@
+@@ -909,27 +1855,31 @@
try {
itemstack = packetdataserializer.i();
@@ -1381,7 +1420,7 @@
return;
} finally {
packetdataserializer.release();
-@@ -946,6 +1857,7 @@
+@@ -946,6 +1896,7 @@
}
} catch (Exception exception2) {
PlayerConnection.c.error("Couldn\'t select trade", exception2);
@@ -1389,7 +1428,7 @@
}
} else if ("MC|AdvCdm".equals(packetplayincustompayload.a())) {
if (!this.minecraftServer.getEnableCommandBlock()) {
-@@ -986,6 +1898,7 @@
+@@ -986,6 +1937,7 @@
}
} catch (Exception exception3) {
PlayerConnection.c.error("Couldn\'t set command block", exception3);
@@ -1397,7 +1436,7 @@
} finally {
packetdataserializer.release();
}
-@@ -1011,6 +1924,7 @@
+@@ -1011,6 +1963,7 @@
}
} catch (Exception exception4) {
PlayerConnection.c.error("Couldn\'t set beacon", exception4);
@@ -1405,7 +1444,7 @@
}
}
} else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) {
-@@ -1026,6 +1940,27 @@
+@@ -1026,6 +1979,27 @@
containeranvil.a("");
}
}
diff --git a/nms-patches/PlayerInteractManager.patch b/nms-patches/PlayerInteractManager.patch
index e1a0777f..f5662ce3 100644
--- a/nms-patches/PlayerInteractManager.patch
+++ b/nms-patches/PlayerInteractManager.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/PlayerInteractManager.java 2014-11-28 23:05:41.725278672 +0000
-+++ src/main/java/net/minecraft/server/PlayerInteractManager.java 2014-11-28 22:57:12.389289000 +0000
+--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerInteractManager.java 2014-12-09 12:19:57.555618161 +0000
++++ src/main/java/net/minecraft/server/PlayerInteractManager.java 2014-12-09 12:16:26.307622849 +0000
@@ -1,5 +1,13 @@
package net.minecraft.server;
@@ -202,15 +202,21 @@
return flag;
}
-@@ -268,6 +394,7 @@
+@@ -267,7 +393,13 @@
+ }
}
++ // CraftBukkit start
++ public boolean interactResult = false;
++ public boolean firedInteract = false;
++ // CraftBukkit end
++
public boolean interact(EntityHuman entityhuman, World world, ItemStack itemstack, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) {
+ /* CraftBukkit start - whole method
if (this.gamemode == EnumGamemode.SPECTATOR) {
TileEntity tileentity = world.getTileEntity(blockposition);
-@@ -312,6 +439,66 @@
+@@ -312,6 +444,68 @@
return itemstack.placeItem(entityhuman, world, blockposition, enumdirection, f, f1, f2);
}
}
@@ -226,6 +232,8 @@
+ }
+
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, blockposition, enumdirection, itemstack, cancelledBlock);
++ firedInteract = true;
++ interactResult = event.useItemInHand() == 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.
diff --git a/nms-patches/PlayerList.patch b/nms-patches/PlayerList.patch
index ce5cc7d7..162f7417 100644
--- a/nms-patches/PlayerList.patch
+++ b/nms-patches/PlayerList.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/PlayerList.java 2014-12-03 11:08:25.244137435 +0000
-+++ src/main/java/net/minecraft/server/PlayerList.java 2014-12-03 11:08:02.624137937 +0000
+--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerList.java 2014-12-06 22:26:41.687189417 +0000
++++ src/main/java/net/minecraft/server/PlayerList.java 2014-12-06 22:25:44.071190696 +0000
@@ -18,6 +18,25 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -188,7 +188,7 @@
worldserver.removeEntity(entityplayer.vehicle);
PlayerList.h.debug("removing player mount");
}
-@@ -238,13 +312,40 @@
+@@ -238,13 +312,61 @@
this.players.remove(entityplayer);
this.f.remove(entityplayer.getUniqueID());
this.o.remove(entityplayer.getUniqueID());
@@ -217,6 +217,27 @@
- public String attemptLogin(SocketAddress socketaddress, GameProfile gameprofile) {
+ // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer
+ public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) {
++ // Moved from processLogin
++ UUID uuid = EntityHuman.a(gameprofile);
++ ArrayList arraylist = Lists.newArrayList();
++
++ EntityPlayer entityplayer;
++
++ for (int i = 0; i < this.players.size(); ++i) {
++ entityplayer = (EntityPlayer) this.players.get(i);
++ if (entityplayer.getUniqueID().equals(uuid)) {
++ arraylist.add(entityplayer);
++ }
++ }
++
++ Iterator iterator = arraylist.iterator();
++
++ while (iterator.hasNext()) {
++ entityplayer = (EntityPlayer) iterator.next();
++ savePlayerFile(entityplayer); // CraftBukkit - Force the player's inventory to be saved
++ entityplayer.playerConnection.disconnect("You logged in from another location");
++ }
++
+ // Instead of kicking then returning, we need to store the kick reason
+ // in the event, check with plugins to see if it's ok, and THEN kick
+ // depending on the outcome.
@@ -232,7 +253,7 @@
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.k.get(gameprofile);
s = "You are banned from this server!\nReason: " + gameprofilebanentry.getReason();
-@@ -252,10 +353,12 @@
+@@ -252,10 +374,12 @@
s = s + "\nYour ban will be removed on " + PlayerList.i.format(gameprofilebanentry.getExpires());
}
@@ -248,7 +269,7 @@
IpBanEntry ipbanentry = this.l.get(socketaddress);
s = "Your IP address is banned from this server!\nReason: " + ipbanentry.getReason();
-@@ -263,13 +366,24 @@
+@@ -263,13 +387,25 @@
s = s + "\nYour ban will be removed on " + PlayerList.i.format(ipbanentry.getExpires());
}
@@ -273,18 +294,24 @@
- public EntityPlayer processLogin(GameProfile gameprofile) {
+ public EntityPlayer processLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
++ /* CraftBukkit startMoved up
UUID uuid = EntityHuman.a(gameprofile);
ArrayList arraylist = Lists.newArrayList();
-@@ -289,6 +403,7 @@
+@@ -286,9 +422,12 @@
+
+ while (iterator.hasNext()) {
+ entityplayer = (EntityPlayer) iterator.next();
++ savePlayerFile(entityplayer); // CraftBukkit - Force the player's inventory to be saved
entityplayer.playerConnection.disconnect("You logged in from another location");
}
++ // CraftBukkit end */
+ /* CraftBukkit start
Object object;
if (this.server.W()) {
-@@ -298,17 +413,25 @@
+@@ -298,17 +437,25 @@
}
return new EntityPlayer(this.server, this.server.getWorldServer(0), gameprofile, (PlayerInteractManager) object);
@@ -311,7 +338,7 @@
entityplayer.dimension = i;
Object object;
-@@ -319,80 +442,270 @@
+@@ -319,80 +466,270 @@
}
EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.getWorldServer(entityplayer.dimension), entityplayer.getProfile(), (PlayerInteractManager) object);
@@ -553,7 +580,8 @@
+ */
+ } else {
+ BlockPosition blockposition;
-+
+
+- entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobeffect));
+ if (i == 1) {
+ // use default NORMAL world spawn instead of target
+ worldserver1 = this.server.worlds.get(0);
@@ -571,9 +599,8 @@
+ worldserver.entityJoinedWorld(entity, false);
+ }
+ */
-+ }
+ }
-- entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobeffect));
+ // worldserver.methodProfiler.b();
+ if (i != 1) {
+ worldserver.methodProfiler.a("placing");
@@ -589,8 +616,8 @@
+
+ worldserver.methodProfiler.b();
+ */
- }
-
++ }
++
+ // entity.spawnIn(worldserver1);
+ return new Location(worldserver1.getWorld(), d0, y, d1, yaw, pitch);
}
@@ -618,7 +645,7 @@
if (entity.dimension == -1) {
d0 = MathHelper.a(d0 / d2, worldserver1.af().b() + 16.0D, worldserver1.af().d() - 16.0D);
d1 = MathHelper.a(d1 / d2, worldserver1.af().c() + 16.0D, worldserver1.af().e() - 16.0D);
-@@ -411,6 +724,8 @@
+@@ -411,6 +748,8 @@
BlockPosition blockposition;
if (i == 1) {
@@ -627,7 +654,7 @@
blockposition = worldserver1.getSpawn();
} else {
blockposition = worldserver1.getDimensionSpawn();
-@@ -424,15 +739,26 @@
+@@ -424,15 +763,26 @@
worldserver.entityJoinedWorld(entity, false);
}
}
@@ -656,7 +683,7 @@
worldserver1.addEntity(entity);
worldserver1.entityJoinedWorld(entity, false);
}
-@@ -441,6 +767,7 @@
+@@ -441,6 +791,7 @@
}
entity.spawnIn(worldserver1);
@@ -664,7 +691,7 @@
}
public void tick() {
-@@ -549,10 +876,24 @@
+@@ -549,10 +900,24 @@
public void addOp(GameProfile gameprofile) {
this.operators.add(new OpListEntry(gameprofile, this.server.p()));
@@ -689,7 +716,7 @@
}
public boolean isWhitelisted(GameProfile gameprofile) {
-@@ -560,7 +901,7 @@
+@@ -560,7 +925,7 @@
}
public boolean isOp(GameProfile gameprofile) {
@@ -698,7 +725,7 @@
}
public EntityPlayer getPlayer(String s) {
-@@ -587,6 +928,12 @@
+@@ -587,6 +952,12 @@
for (int j = 0; j < this.players.size(); ++j) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
@@ -711,12 +738,12 @@
if (entityplayer != entityhuman && entityplayer.dimension == i) {
double d4 = d0 - entityplayer.locX;
double d5 = d1 - entityplayer.locY;
-@@ -634,21 +981,26 @@
+@@ -634,21 +1005,26 @@
public void reloadWhitelist() {}
public void b(EntityPlayer entityplayer, WorldServer worldserver) {
- WorldBorder worldborder = this.server.worldServer[0].af();
-+ WorldBorder worldborder = this.server.worlds.get(0).af(); // CraftBukkit
++ WorldBorder worldborder = entityplayer.world.af(); // CraftBukkit
entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, EnumWorldBorderAction.INITIALIZE));
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle")));
@@ -743,7 +770,7 @@
entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
}
-@@ -661,7 +1013,7 @@
+@@ -661,7 +1037,7 @@
}
public String[] getSeenPlayers() {
@@ -752,7 +779,7 @@
}
public boolean getHasWhitelist() {
-@@ -711,10 +1063,17 @@
+@@ -711,10 +1087,17 @@
public void v() {
for (int i = 0; i < this.players.size(); ++i) {
@@ -771,7 +798,7 @@
public void sendMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
this.server.sendMessage(ichatbasecomponent);
-@@ -754,11 +1113,10 @@
+@@ -754,11 +1137,10 @@
public void a(int i) {
this.r = i;
if (this.server.worldServer != null) {
diff --git a/nms-patches/SecondaryWorldServer.patch b/nms-patches/SecondaryWorldServer.patch
index 4cbd0717..9cd69d5a 100644
--- a/nms-patches/SecondaryWorldServer.patch
+++ b/nms-patches/SecondaryWorldServer.patch
@@ -1,6 +1,6 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/SecondaryWorldServer.java 2014-11-28 17:43:43.369707429 +0000
-+++ src/main/java/net/minecraft/server/SecondaryWorldServer.java 2014-11-28 17:38:18.000000000 +0000
-@@ -4,8 +4,10 @@
+--- /home/antony/work/spigot-BuildTools/work/decompile-8eb82bde//net/minecraft/server/SecondaryWorldServer.java 2014-12-03 12:27:34.906671655 +0200
++++ src/main/java/net/minecraft/server/SecondaryWorldServer.java 2014-12-10 18:20:15.598416391 +0200
+@@ -4,13 +4,15 @@
private WorldServer a;
@@ -13,3 +13,9 @@
this.a = worldserver;
worldserver.af().a((IWorldBorderListener) (new SecondaryWorldServerInnerClass1(this)));
}
+
+- protected void a() {}
++ // protected void a() {} // CraftBukkit
+
+ public World b() {
+ this.worldMaps = this.a.T();
diff --git a/nms-patches/TileEntitySign.patch b/nms-patches/TileEntitySign.patch
index ce9d878f..56bcc1fe 100644
--- a/nms-patches/TileEntitySign.patch
+++ b/nms-patches/TileEntitySign.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/TileEntitySign.java 2014-11-30 11:23:30.317220028 +0000
-+++ src/main/java/net/minecraft/server/TileEntitySign.java 2014-11-30 11:22:37.521221199 +0000
+--- ../work/decompile-8eb82bde//net/minecraft/server/TileEntitySign.java 2014-12-05 23:10:25.877614213 +0000
++++ src/main/java/net/minecraft/server/TileEntitySign.java 2014-12-05 23:06:56.609618857 +0000
@@ -20,6 +20,12 @@
nbttagcompound.setString("Text" + (i + 1), s);
@@ -41,3 +41,15 @@
} catch (CommandException commandexception) {
this.lines[i] = ichatbasecomponent;
}
+@@ -77,7 +96,10 @@
+ ChatClickable chatclickable = chatmodifier.h();
+
+ if (chatclickable.a() == EnumClickAction.RUN_COMMAND) {
+- MinecraftServer.getServer().getCommandHandler().a(tileentitysignplayerwrapper, chatclickable.b());
++ // CraftBukkit start
++ // MinecraftServer.getServer().getCommandHandler().a(tileentitysignplayerwrapper, chatclickable.b());
++ CommandBlockListenerAbstract.executeCommand(tileentitysignplayerwrapper, (org.bukkit.entity.Player) entityhuman.getBukkitEntity(), chatclickable.b());
++ // CraftBukkit ebd
+ }
+ }
+ }
diff --git a/nms-patches/World.patch b/nms-patches/World.patch
index 3131a603..0effef5f 100644
--- a/nms-patches/World.patch
+++ b/nms-patches/World.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/World.java 2014-12-02 15:12:18.222036228 +0000
-+++ src/main/java/net/minecraft/server/World.java 2014-12-02 15:04:12.678047004 +0000
+--- ../work/decompile-8eb82bde//net/minecraft/server/World.java 2014-12-05 11:17:35.806563463 +0000
++++ src/main/java/net/minecraft/server/World.java 2014-12-05 11:16:59.838564261 +0000
@@ -13,6 +13,22 @@
import java.util.UUID;
import java.util.concurrent.Callable;
@@ -579,6 +579,6 @@
short short0 = 128;
- return k >= -short0 && k <= short0 && l >= -short0 && l <= short0;
-+ return k >= -short0 && k <= short0 && l >= -short0 && l <= short0 || !this.keepSpawnInMemory; // CraftBukkit - Added 'this.world.keepSpawnInMemory'
++ return k >= -short0 && k <= short0 && l >= -short0 && l <= short0 && this.keepSpawnInMemory; // CraftBukkit - Added 'this.keepSpawnInMemory'
}
}
diff --git a/nms-patches/WorldServer.patch b/nms-patches/WorldServer.patch
index d7463e8a..61fce35e 100644
--- a/nms-patches/WorldServer.patch
+++ b/nms-patches/WorldServer.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/WorldServer.java 2014-12-02 15:12:18.246036227 +0000
-+++ src/main/java/net/minecraft/server/WorldServer.java 2014-12-02 15:02:48.310048877 +0000
+--- /home/antony/work/spigot-BuildTools/work/decompile-8eb82bde//net/minecraft/server/WorldServer.java 2014-12-10 18:45:26.490705797 +0200
++++ src/main/java/net/minecraft/server/WorldServer.java 2014-12-10 18:45:11.770706183 +0200
@@ -16,6 +16,20 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -415,16 +415,18 @@
i += random.nextInt(64) - random.nextInt(64);
k += random.nextInt(64) - random.nextInt(64);
++l;
-@@ -648,7 +859,7 @@
+@@ -648,8 +859,9 @@
return this.worldProvider.h();
}
- public void save(boolean flag, IProgressUpdate iprogressupdate) {
+ public void save(boolean flag, IProgressUpdate iprogressupdate) throws ExceptionWorldConflict { // CraftBukkit - added throws
if (this.chunkProvider.canSave()) {
++ org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
if (iprogressupdate != null) {
iprogressupdate.a("Saving level");
-@@ -660,7 +871,8 @@
+ }
+@@ -660,7 +872,8 @@
}
this.chunkProvider.saveChunks(flag, iprogressupdate);
@@ -434,7 +436,7 @@
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
-@@ -680,7 +892,7 @@
+@@ -680,7 +893,7 @@
}
}
@@ -443,20 +445,25 @@
this.checkSession();
this.worldData.a(this.af().h());
this.worldData.d(this.af().f());
-@@ -692,7 +904,11 @@
+@@ -691,8 +904,15 @@
+ this.worldData.k(this.af().p());
this.worldData.b(this.af().j());
this.worldData.e(this.af().i());
- this.dataManager.saveWorldData(this.worldData, this.server.getPlayerList().u());
+- this.dataManager.saveWorldData(this.worldData, this.server.getPlayerList().u());
- this.worldMaps.a();
+ // CraftBukkit start - save worldMaps once, rather than once per shared world
++ // Only save players for the primary world.
+ if (!(this instanceof SecondaryWorldServer)) {
+ this.worldMaps.a();
++ this.dataManager.saveWorldData(this.worldData);
++ } else {
++ this.dataManager.saveWorldData(this.worldData, this.server.getPlayerList().u());
+ }
+ // CraftBukkit end
}
protected void a(Entity entity) {
-@@ -724,8 +940,16 @@
+@@ -724,8 +944,16 @@
}
public boolean strikeLightning(Entity entity) {
@@ -474,7 +481,7 @@
return true;
} else {
return false;
-@@ -737,10 +961,20 @@
+@@ -737,10 +965,20 @@
}
public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
@@ -495,7 +502,7 @@
if (!flag1) {
explosion.clearBlocks();
}
-@@ -786,7 +1020,8 @@
+@@ -786,7 +1024,8 @@
BlockActionData blockactiondata = (BlockActionData) iterator.next();
if (this.a(blockactiondata)) {
@@ -505,7 +512,7 @@
}
}
-@@ -809,6 +1044,7 @@
+@@ -809,6 +1048,7 @@
boolean flag = this.S();
super.p();
@@ -513,7 +520,7 @@
if (this.o != this.p) {
this.server.getPlayerList().a(new PacketPlayOutGameStateChange(7, this.p), this.worldProvider.getDimension());
}
-@@ -827,7 +1063,21 @@
+@@ -827,7 +1067,21 @@
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.p));
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.r));
}
@@ -536,7 +543,7 @@
}
protected int q() {
-@@ -855,10 +1105,17 @@
+@@ -855,10 +1109,17 @@
}
public void a(EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) {