SPIGOT-123: Force inventory updates on crafting to correctly support custom recipes

This commit is contained in:
Thinkofdeath 2014-12-05 15:04:01 +00:00
parent bab0e8bc70
commit 3f6a1db4f6

View file

@ -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-05 15:03:49.462262206 +0000
+++ src/main/java/net/minecraft/server/PlayerConnection.java 2014-12-05 15:03:44.490262316 +0000
@@ -16,6 +16,48 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -631,7 +631,7 @@
+ return null;
+ }
+ };
+
+ this.minecraftServer.processQueue.add(waitable);
+
+ try {
@ -646,8 +646,8 @@
+ }
+ // CraftBukkit end
+ }
}
}
+ }
+ }
+
+ // CraftBukkit start - add method
+ public void chat(String s, boolean async) {
@ -672,7 +672,7 @@
+ @Override
+ protected Object evaluate() {
+ org.bukkit.Bukkit.getPluginManager().callEvent(queueEvent);
+
+ if (queueEvent.isCancelled()) {
+ return null;
+ }
@ -719,8 +719,8 @@
+ }
+ }
+ }
+ }
+ }
}
}
+ // CraftBukkit end
private void handleCommand(String s) {
@ -931,7 +931,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 +1285,269 @@
this.player.a(this.player.activeContainer, (List) arraylist);
} else {
@ -1191,12 +1191,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 +1608,50 @@
}
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize();
@ -1248,7 +1254,7 @@
if (flag1 && flag2 && flag3) {
if (itemstack == null) {
@@ -796,6 +1668,7 @@
@@ -796,6 +1674,7 @@
}
public void a(PacketPlayInTransaction packetplayintransaction) {
@ -1256,7 +1262,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u());
Short oshort = (Short) this.n.get(this.player.activeContainer.windowId);
@@ -806,6 +1679,7 @@
@@ -806,6 +1685,7 @@
}
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
@ -1264,7 +1270,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 +1702,24 @@
if (!tileentitysign.b() || tileentitysign.c() != this.player) {
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
@ -1290,7 +1296,7 @@
tileentitysign.update();
worldserver.notify(blockposition);
}
@@ -847,11 +1735,28 @@
@@ -847,11 +1741,28 @@
public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u());
@ -1320,7 +1326,7 @@
ArrayList arraylist = Lists.newArrayList();
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator();
@@ -891,13 +1796,15 @@
@@ -891,13 +1802,15 @@
itemstack1 = this.player.inventory.getItemInHand();
if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
@ -1337,7 +1343,7 @@
return;
} finally {
packetdataserializer.release();
@@ -909,27 +1816,31 @@
@@ -909,27 +1822,31 @@
try {
itemstack = packetdataserializer.i();
@ -1381,7 +1387,7 @@
return;
} finally {
packetdataserializer.release();
@@ -946,6 +1857,7 @@
@@ -946,6 +1863,7 @@
}
} catch (Exception exception2) {
PlayerConnection.c.error("Couldn\'t select trade", exception2);
@ -1389,7 +1395,7 @@
}
} else if ("MC|AdvCdm".equals(packetplayincustompayload.a())) {
if (!this.minecraftServer.getEnableCommandBlock()) {
@@ -986,6 +1898,7 @@
@@ -986,6 +1904,7 @@
}
} catch (Exception exception3) {
PlayerConnection.c.error("Couldn\'t set command block", exception3);
@ -1397,7 +1403,7 @@
} finally {
packetdataserializer.release();
}
@@ -1011,6 +1924,7 @@
@@ -1011,6 +1930,7 @@
}
} catch (Exception exception4) {
PlayerConnection.c.error("Couldn\'t set beacon", exception4);
@ -1405,7 +1411,7 @@
}
}
} else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) {
@@ -1026,6 +1940,27 @@
@@ -1026,6 +1946,27 @@
containeranvil.a("");
}
}