SPIGOT-3272: Fix duplicate creative inventory
This change properly identifies the creative inventory as one with 5 crafting slots (as that's the default set in ContainerPlayer, and handled properly in other containers), instead of having the same inventory twice (which breaks slot identification).
This commit is contained in:
parent
274304b8ca
commit
44dd60ac27
@ -1421,7 +1421,7 @@
|
|||||||
this.player.resetIdleTimer();
|
this.player.resetIdleTimer();
|
||||||
if (this.player.activeContainer.windowId == packetplayinenchantitem.a() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
|
if (this.player.activeContainer.windowId == packetplayinenchantitem.a() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
|
||||||
this.player.activeContainer.a(this.player, packetplayinenchantitem.b());
|
this.player.activeContainer.a(this.player, packetplayinenchantitem.b());
|
||||||
@@ -993,7 +2001,46 @@
|
@@ -993,7 +2001,45 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() <= 45;
|
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() <= 45;
|
||||||
@ -1430,8 +1430,7 @@
|
|||||||
+ boolean flag2 = itemstack.isEmpty() || itemstack.getData() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty() && !invalidItems.contains(Item.getId(itemstack.getItem()));
|
+ boolean flag2 = itemstack.isEmpty() || itemstack.getData() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty() && !invalidItems.contains(Item.getId(itemstack.getItem()));
|
||||||
+ if (flag || (flag1 && !ItemStack.matches(this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.a()).getItem(), packetplayinsetcreativeslot.getItemStack()))) { // Insist on valid slot
|
+ if (flag || (flag1 && !ItemStack.matches(this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.a()).getItem(), packetplayinsetcreativeslot.getItemStack()))) { // Insist on valid slot
|
||||||
+ // CraftBukkit start - Call click event
|
+ // CraftBukkit start - Call click event
|
||||||
+ org.bukkit.entity.HumanEntity player = this.player.getBukkitEntity();
|
+ InventoryView inventory = this.player.defaultContainer.getBukkitView();
|
||||||
+ InventoryView inventory = new CraftInventoryView(player, player.getInventory(), this.player.defaultContainer);
|
|
||||||
+ org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot.getItemStack());
|
+ org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot.getItemStack());
|
||||||
+
|
+
|
||||||
+ SlotType type = SlotType.QUICKBAR;
|
+ SlotType type = SlotType.QUICKBAR;
|
||||||
@ -1469,7 +1468,7 @@
|
|||||||
|
|
||||||
if (flag1 && flag2) {
|
if (flag1 && flag2) {
|
||||||
if (itemstack.isEmpty()) {
|
if (itemstack.isEmpty()) {
|
||||||
@@ -1017,6 +2064,7 @@
|
@@ -1017,6 +2063,7 @@
|
||||||
|
|
||||||
public void a(PacketPlayInTransaction packetplayintransaction) {
|
public void a(PacketPlayInTransaction packetplayintransaction) {
|
||||||
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x());
|
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x());
|
||||||
@ -1477,7 +1476,7 @@
|
|||||||
Short oshort = (Short) this.k.get(this.player.activeContainer.windowId);
|
Short oshort = (Short) this.k.get(this.player.activeContainer.windowId);
|
||||||
|
|
||||||
if (oshort != null && packetplayintransaction.b() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.a() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
|
if (oshort != null && packetplayintransaction.b() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.a() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
|
||||||
@@ -1027,6 +2075,7 @@
|
@@ -1027,6 +2074,7 @@
|
||||||
|
|
||||||
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
|
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
|
||||||
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x());
|
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x());
|
||||||
@ -1485,7 +1484,7 @@
|
|||||||
this.player.resetIdleTimer();
|
this.player.resetIdleTimer();
|
||||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||||
BlockPosition blockposition = packetplayinupdatesign.a();
|
BlockPosition blockposition = packetplayinupdatesign.a();
|
||||||
@@ -1043,14 +2092,30 @@
|
@@ -1043,14 +2091,30 @@
|
||||||
|
|
||||||
if (!tileentitysign.a() || tileentitysign.e() != this.player) {
|
if (!tileentitysign.a() || tileentitysign.e() != this.player) {
|
||||||
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
|
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
|
||||||
@ -1517,7 +1516,7 @@
|
|||||||
|
|
||||||
tileentitysign.update();
|
tileentitysign.update();
|
||||||
worldserver.notify(blockposition, iblockdata, iblockdata, 3);
|
worldserver.notify(blockposition, iblockdata, iblockdata, 3);
|
||||||
@@ -1073,11 +2138,27 @@
|
@@ -1073,11 +2137,27 @@
|
||||||
|
|
||||||
public void a(PacketPlayInAbilities packetplayinabilities) {
|
public void a(PacketPlayInAbilities packetplayinabilities) {
|
||||||
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x());
|
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x());
|
||||||
@ -1546,7 +1545,7 @@
|
|||||||
ArrayList arraylist = Lists.newArrayList();
|
ArrayList arraylist = Lists.newArrayList();
|
||||||
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b(), packetplayintabcomplete.c()).iterator();
|
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b(), packetplayintabcomplete.c()).iterator();
|
||||||
|
|
||||||
@@ -1103,6 +2184,13 @@
|
@@ -1103,6 +2183,13 @@
|
||||||
ItemStack itemstack1;
|
ItemStack itemstack1;
|
||||||
|
|
||||||
if ("MC|BEdit".equals(s)) {
|
if ("MC|BEdit".equals(s)) {
|
||||||
@ -1560,7 +1559,7 @@
|
|||||||
packetdataserializer = packetplayincustompayload.b();
|
packetdataserializer = packetplayincustompayload.b();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1121,15 +2209,25 @@
|
@@ -1121,15 +2208,25 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
|
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
|
||||||
@ -1586,7 +1585,7 @@
|
|||||||
packetdataserializer = packetplayincustompayload.b();
|
packetdataserializer = packetplayincustompayload.b();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1163,10 +2261,11 @@
|
@@ -1163,10 +2260,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
itemstack2.a("pages", (NBTBase) nbttaglist);
|
itemstack2.a("pages", (NBTBase) nbttaglist);
|
||||||
@ -1599,7 +1598,7 @@
|
|||||||
}
|
}
|
||||||
} else if ("MC|TrSel".equals(s)) {
|
} else if ("MC|TrSel".equals(s)) {
|
||||||
try {
|
try {
|
||||||
@@ -1178,6 +2277,7 @@
|
@@ -1178,6 +2276,7 @@
|
||||||
}
|
}
|
||||||
} catch (Exception exception2) {
|
} catch (Exception exception2) {
|
||||||
PlayerConnection.LOGGER.error("Couldn\'t select trade", exception2);
|
PlayerConnection.LOGGER.error("Couldn\'t select trade", exception2);
|
||||||
@ -1607,7 +1606,7 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TileEntity tileentity;
|
TileEntity tileentity;
|
||||||
@@ -1227,6 +2327,7 @@
|
@@ -1227,6 +2326,7 @@
|
||||||
}
|
}
|
||||||
} catch (Exception exception3) {
|
} catch (Exception exception3) {
|
||||||
PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3);
|
PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3);
|
||||||
@ -1615,7 +1614,7 @@
|
|||||||
}
|
}
|
||||||
} else if ("MC|AutoCmd".equals(s)) {
|
} else if ("MC|AutoCmd".equals(s)) {
|
||||||
if (!this.minecraftServer.getEnableCommandBlock()) {
|
if (!this.minecraftServer.getEnableCommandBlock()) {
|
||||||
@@ -1294,6 +2395,7 @@
|
@@ -1294,6 +2394,7 @@
|
||||||
}
|
}
|
||||||
} catch (Exception exception4) {
|
} catch (Exception exception4) {
|
||||||
PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4);
|
PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4);
|
||||||
@ -1623,7 +1622,7 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int k;
|
int k;
|
||||||
@@ -1317,6 +2419,7 @@
|
@@ -1317,6 +2418,7 @@
|
||||||
}
|
}
|
||||||
} catch (Exception exception5) {
|
} catch (Exception exception5) {
|
||||||
PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5);
|
PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5);
|
||||||
@ -1631,7 +1630,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ("MC|ItemName".equals(s)) {
|
} else if ("MC|ItemName".equals(s)) {
|
||||||
@@ -1403,6 +2506,7 @@
|
@@ -1403,6 +2505,7 @@
|
||||||
}
|
}
|
||||||
} catch (Exception exception6) {
|
} catch (Exception exception6) {
|
||||||
PlayerConnection.LOGGER.error("Couldn\'t set structure block", exception6);
|
PlayerConnection.LOGGER.error("Couldn\'t set structure block", exception6);
|
||||||
@ -1639,7 +1638,7 @@
|
|||||||
}
|
}
|
||||||
} else if ("MC|PickItem".equals(s)) {
|
} else if ("MC|PickItem".equals(s)) {
|
||||||
packetdataserializer = packetplayincustompayload.b();
|
packetdataserializer = packetplayincustompayload.b();
|
||||||
@@ -1415,11 +2519,49 @@
|
@@ -1415,11 +2518,49 @@
|
||||||
this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
|
this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
|
||||||
} catch (Exception exception7) {
|
} catch (Exception exception7) {
|
||||||
PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7);
|
PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7);
|
||||||
|
@ -127,7 +127,7 @@ public class CraftInventoryView extends InventoryView {
|
|||||||
} else {
|
} else {
|
||||||
if (slot == -999 || slot == -1) {
|
if (slot == -999 || slot == -1) {
|
||||||
type = SlotType.OUTSIDE;
|
type = SlotType.OUTSIDE;
|
||||||
} else if (inventory.getType() == InventoryType.CRAFTING) {
|
} else if (inventory.getType() == InventoryType.CRAFTING) { // Also includes creative inventory
|
||||||
if (slot < 9) {
|
if (slot < 9) {
|
||||||
type = SlotType.ARMOR;
|
type = SlotType.ARMOR;
|
||||||
} else if (slot > 35) {
|
} else if (slot > 35) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user