use of com.nukkitx.protocol.bedrock.packet.ContainerClosePacket in project Geyser by GeyserMC.
the class DoubleChestInventoryTranslator method closeInventory.
@Override
public void closeInventory(GeyserSession session, Inventory inventory) {
if (((Container) inventory).isUsingRealBlock()) {
// No need to reset a block since we didn't change any blocks
// But send a container close packet because we aren't destroying the original.
ContainerClosePacket packet = new ContainerClosePacket();
packet.setId((byte) inventory.getId());
// TODO needs to be changed in Protocol to "server-side" or something
packet.setUnknownBool0(true);
session.sendUpstreamPacket(packet);
return;
}
Vector3i holderPos = inventory.getHolderPosition();
int realBlock = session.getGeyser().getWorldManager().getBlockAt(session, holderPos);
UpdateBlockPacket blockPacket = new UpdateBlockPacket();
blockPacket.setDataLayer(0);
blockPacket.setBlockPosition(holderPos);
blockPacket.setRuntimeId(session.getBlockMappings().getBedrockBlockId(realBlock));
session.sendUpstreamPacket(blockPacket);
holderPos = holderPos.add(Vector3i.UNIT_X);
realBlock = session.getGeyser().getWorldManager().getBlockAt(session, holderPos);
blockPacket = new UpdateBlockPacket();
blockPacket.setDataLayer(0);
blockPacket.setBlockPosition(holderPos);
blockPacket.setRuntimeId(session.getBlockMappings().getBedrockBlockId(realBlock));
session.sendUpstreamPacket(blockPacket);
}
use of com.nukkitx.protocol.bedrock.packet.ContainerClosePacket in project Geyser by GeyserMC.
the class BlockInventoryHolder method closeInventory.
@Override
public void closeInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) {
if (((Container) inventory).isUsingRealBlock()) {
// No need to reset a block since we didn't change any blocks
// But send a container close packet because we aren't destroying the original.
ContainerClosePacket packet = new ContainerClosePacket();
packet.setId((byte) inventory.getId());
// TODO needs to be changed in Protocol to "server-side" or something
packet.setUnknownBool0(true);
session.sendUpstreamPacket(packet);
return;
}
Vector3i holderPos = inventory.getHolderPosition();
Position pos = new Position(holderPos.getX(), holderPos.getY(), holderPos.getZ());
int realBlock = session.getGeyser().getWorldManager().getBlockAt(session, pos.getX(), pos.getY(), pos.getZ());
UpdateBlockPacket blockPacket = new UpdateBlockPacket();
blockPacket.setDataLayer(0);
blockPacket.setBlockPosition(holderPos);
blockPacket.setRuntimeId(session.getBlockMappings().getBedrockBlockId(realBlock));
blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY);
session.sendUpstreamPacket(blockPacket);
}
Aggregations