mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Merge pull request #452 from Moulberry/master
Fix cursor being set to air due to incorrect window items packet
This commit is contained in:
commit
7c043b163e
@ -130,7 +130,9 @@ public class Inventory extends AbstractInventory implements Viewable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
sendPacketToViewers(createNewWindowItemsPacket());
|
for(Player player : viewers) {
|
||||||
|
player.getPlayerConnection().sendPacket(createNewWindowItemsPacket(player));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,7 +147,7 @@ public class Inventory extends AbstractInventory implements Viewable {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
final PlayerConnection playerConnection = player.getPlayerConnection();
|
final PlayerConnection playerConnection = player.getPlayerConnection();
|
||||||
playerConnection.sendPacket(createNewWindowItemsPacket());
|
playerConnection.sendPacket(createNewWindowItemsPacket(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@ -227,8 +229,8 @@ public class Inventory extends AbstractInventory implements Viewable {
|
|||||||
*
|
*
|
||||||
* @return a new {@link WindowItemsPacket} packet
|
* @return a new {@link WindowItemsPacket} packet
|
||||||
*/
|
*/
|
||||||
private @NotNull WindowItemsPacket createNewWindowItemsPacket() {
|
private @NotNull WindowItemsPacket createNewWindowItemsPacket(Player player) {
|
||||||
return new WindowItemsPacket(getWindowId(), 0, getItemStacks(), ItemStack.AIR);
|
return new WindowItemsPacket(getWindowId(), 0, getItemStacks(), cursorPlayersItem.getOrDefault(player, ItemStack.AIR));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,6 +53,6 @@ public class SetSlotPacket implements ServerPacket {
|
|||||||
* @return a set slot packet to change a player cursor item
|
* @return a set slot packet to change a player cursor item
|
||||||
*/
|
*/
|
||||||
public static @NotNull SetSlotPacket createCursorPacket(@NotNull ItemStack cursorItem) {
|
public static @NotNull SetSlotPacket createCursorPacket(@NotNull ItemStack cursorItem) {
|
||||||
return new SetSlotPacket((byte) -1, -1, (short) 0, cursorItem);
|
return new SetSlotPacket((byte) -1, 0, (short) -1, cursorItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user