InventoryUtils: Don't send Java packet on hotbar item selection (#1301)

The Bedrock client sends a confirmation packet we translate regardless.
This commit is contained in:
Camotoy 2020-09-17 23:07:20 -04:00 committed by GitHub
parent 99e72f35b3
commit 2f2164f387
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,7 +27,6 @@ package org.geysermc.connector.utils;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerChangeHeldItemPacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCreativeInventoryActionPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCreativeInventoryActionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientMoveItemToHotbarPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientMoveItemToHotbarPacket;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
@ -241,8 +240,6 @@ public class InventoryUtils {
hotbarPacket.setSelectedHotbarSlot(slot - 36); hotbarPacket.setSelectedHotbarSlot(slot - 36);
hotbarPacket.setSelectHotbarSlot(true); hotbarPacket.setSelectHotbarSlot(true);
session.sendUpstreamPacket(hotbarPacket); session.sendUpstreamPacket(hotbarPacket);
ClientPlayerChangeHeldItemPacket heldItemPacket = new ClientPlayerChangeHeldItemPacket(slot); // No need to send a Java packet as Bedrock sends a confirmation packet back that we translate
session.sendDownstreamPacket(heldItemPacket);
session.getInventory().setHeldItemSlot(slot - 36);
} }
} }