2017-07-30 22:41:08 +00:00
|
|
|
From 69aecad8ffaaa88760f8c3b0b152cc80ec669eb0 Mon Sep 17 00:00:00 2001
|
2017-07-27 01:12:40 +00:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Wed, 26 Jul 2017 21:12:15 -0400
|
|
|
|
Subject: [PATCH] Fix Recipe Books
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2017-07-30 22:41:08 +00:00
|
|
|
index 682211cdd..034081cbe 100644
|
2017-07-27 01:12:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
@@ -2027,12 +2027,6 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
|
|
|
public void a(PacketPlayInAutoRecipe packetplayinautorecipe) {
|
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinautorecipe, this, this.player.x());
|
|
|
|
this.player.resetIdleTimer();
|
|
|
|
- // CraftBukkit start
|
|
|
|
- if (!player.getBukkitEntity().hasPermission("minecraft.autocraft")) {
|
|
|
|
- player.getBukkitEntity().updateInventory();
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- // CraftBukkit end
|
|
|
|
if (this.player.activeContainer.windowId == packetplayinautorecipe.a() && this.player.activeContainer.c(this.player)) {
|
|
|
|
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinautorecipe.a(), packetplayinautorecipe.b(), true));
|
|
|
|
Iterator iterator;
|
2017-07-30 22:41:08 +00:00
|
|
|
@@ -2046,10 +2040,19 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
2017-07-27 01:12:40 +00:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
packetplayinautorecipe_a = (PacketPlayInAutoRecipe.a) iterator.next();
|
|
|
|
itemstack = this.player.activeContainer.getSlot(packetplayinautorecipe_a.b).getItem();
|
|
|
|
- if (this.a(packetplayinautorecipe_a.a, itemstack)) {
|
|
|
|
+ // Paper start - improve validation
|
2017-07-30 22:41:08 +00:00
|
|
|
+ int toSlot = packetplayinautorecipe_a.c;
|
|
|
|
+ ItemStack to = toSlot != -1 ? this.player.inventory.getItem(toSlot) : ItemStack.a;
|
2017-07-27 07:13:13 +00:00
|
|
|
+ ItemStack ref = packetplayinautorecipe_a.a;
|
|
|
|
+ if (this.a(ref, itemstack) && (to.isEmpty() || this.a(ref, to)) && (ref.getCount() + to.getCount() <= ref.getMaxStackSize())) {
|
2017-07-27 01:12:40 +00:00
|
|
|
+ // Paper end
|
|
|
|
i = packetplayinautorecipe_a.a.getCount();
|
|
|
|
if (packetplayinautorecipe_a.c == -1) {
|
2017-07-30 22:41:08 +00:00
|
|
|
- this.player.drop(packetplayinautorecipe_a.a, true);
|
|
|
|
+ // Paper start
|
|
|
|
+ this.player.drop(itemstack, true);
|
|
|
|
+ this.player.activeContainer.setItem(packetplayinautorecipe_a.b, ItemStack.a);
|
|
|
|
+ continue;
|
|
|
|
+ // Paper end
|
|
|
|
} else {
|
|
|
|
ItemStack itemstack1 = this.player.inventory.getItem(packetplayinautorecipe_a.c);
|
|
|
|
|
|
|
|
@@ -2066,6 +2069,12 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
2017-07-27 01:12:40 +00:00
|
|
|
itemstack.subtract(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ // Paper start
|
|
|
|
+ else {
|
|
|
|
+ this.player.getBukkitEntity().updateInventory();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-30 22:41:08 +00:00
|
|
|
@@ -2075,7 +2084,11 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
2017-07-28 03:39:31 +00:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
packetplayinautorecipe_a = (PacketPlayInAutoRecipe.a) iterator.next();
|
|
|
|
itemstack = this.player.inventory.getItem(packetplayinautorecipe_a.c);
|
|
|
|
- if (this.a(packetplayinautorecipe_a.a, itemstack)) {
|
2017-07-28 04:04:01 +00:00
|
|
|
+ // Paper start
|
|
|
|
+ ItemStack ref = packetplayinautorecipe_a.a;
|
|
|
|
+ ItemStack to = this.player.activeContainer.getSlot(packetplayinautorecipe_a.b).getItem();
|
2017-07-30 22:41:08 +00:00
|
|
|
+ if (this.a(ref, itemstack) && (to.isEmpty() || this.a(ref, to)) && (ref.getCount() + to.getCount() <= ref.getMaxStackSize())) {
|
2017-07-28 04:04:01 +00:00
|
|
|
+ // Paper end
|
2017-07-28 03:39:31 +00:00
|
|
|
i = packetplayinautorecipe_a.a.getCount();
|
|
|
|
if (itemstack.getCount() == i) {
|
|
|
|
this.player.inventory.splitWithoutUpdate(packetplayinautorecipe_a.c);
|
2017-07-30 22:41:08 +00:00
|
|
|
@@ -2083,8 +2096,17 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
2017-07-28 04:04:01 +00:00
|
|
|
itemstack.subtract(i);
|
|
|
|
}
|
2017-07-28 03:39:31 +00:00
|
|
|
|
2017-07-28 04:04:01 +00:00
|
|
|
- this.player.activeContainer.b(packetplayinautorecipe_a.b, packetplayinautorecipe_a.a);
|
|
|
|
+ // Paper start
|
|
|
|
+ if (to.isEmpty()) {
|
|
|
|
+ this.player.activeContainer.b(packetplayinautorecipe_a.b, packetplayinautorecipe_a.a);
|
|
|
|
+ } else {
|
|
|
|
+ to.add(i);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
2017-07-28 03:39:31 +00:00
|
|
|
+ this.player.getBukkitEntity().updateInventory();
|
|
|
|
+ return;
|
2017-07-28 04:04:01 +00:00
|
|
|
}
|
2017-07-28 03:39:31 +00:00
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-27 01:12:40 +00:00
|
|
|
--
|
2017-07-30 22:41:08 +00:00
|
|
|
2.13.0
|
2017-07-27 01:12:40 +00:00
|
|
|
|