mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 14:34:59 +01:00
Should resolve https://github.com/GeyserMC/Geyser/issues/4121 (#4481)
This commit is contained in:
parent
1af24e5547
commit
32f66371d9
2 changed files with 13 additions and 10 deletions
|
@ -44,6 +44,8 @@ import org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.request.action
|
|||
import org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.request.action.SwapAction;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.request.action.TransferItemStackRequestAction;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.itemstack.response.ItemStackResponse;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.ContainerClosePacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.ContainerOpenPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.InventoryContentPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.InventorySlotPacket;
|
||||
import org.geysermc.geyser.inventory.*;
|
||||
|
@ -534,10 +536,20 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
|||
|
||||
@Override
|
||||
public void openInventory(GeyserSession session, Inventory inventory) {
|
||||
ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket();
|
||||
containerOpenPacket.setId((byte) 0);
|
||||
containerOpenPacket.setType(org.cloudburstmc.protocol.bedrock.data.inventory.ContainerType.INVENTORY);
|
||||
containerOpenPacket.setUniqueEntityId(-1);
|
||||
containerOpenPacket.setBlockPosition(session.getPlayerEntity().getPosition().toInt());
|
||||
session.sendUpstreamPacket(containerOpenPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(GeyserSession session, Inventory inventory) {
|
||||
ContainerClosePacket packet = new ContainerClosePacket();
|
||||
packet.setServerInitiated(true);
|
||||
packet.setId((byte) ContainerId.INVENTORY);
|
||||
session.sendUpstreamPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,8 +33,6 @@ import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.Server
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerCommandPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityLinkData;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerType;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.ContainerOpenPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.InteractPacket;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.SetEntityLinkPacket;
|
||||
import org.geysermc.geyser.entity.type.Entity;
|
||||
|
@ -126,14 +124,7 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
|
|||
ServerboundPlayerCommandPacket openVehicleWindowPacket = new ServerboundPlayerCommandPacket(session.getPlayerEntity().getEntityId(), PlayerState.OPEN_VEHICLE_INVENTORY);
|
||||
session.sendDownstreamGamePacket(openVehicleWindowPacket);
|
||||
} else {
|
||||
session.setOpenInventory(session.getPlayerInventory());
|
||||
|
||||
ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket();
|
||||
containerOpenPacket.setId((byte) 0);
|
||||
containerOpenPacket.setType(ContainerType.INVENTORY);
|
||||
containerOpenPacket.setUniqueEntityId(-1);
|
||||
containerOpenPacket.setBlockPosition(entity.getPosition().toInt());
|
||||
session.sendUpstreamPacket(containerOpenPacket);
|
||||
InventoryUtils.openInventory(session, session.getPlayerInventory());
|
||||
}
|
||||
} else {
|
||||
// Case: Player opens a player inventory, while we think it shouldn't have!
|
||||
|
|
Loading…
Reference in a new issue