use of com.nukkitx.protocol.bedrock.packet.UpdateEquipPacket in project Geyser by GeyserMC.
the class JavaHorseScreenOpenTranslator method translate.
@Override
public void translate(GeyserSession session, ClientboundHorseScreenOpenPacket packet) {
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
if (entity == null) {
return;
}
UpdateEquipPacket updateEquipPacket = new UpdateEquipPacket();
updateEquipPacket.setWindowId((short) packet.getContainerId());
updateEquipPacket.setWindowType((short) ContainerType.HORSE.getId());
updateEquipPacket.setUniqueEntityId(entity.getGeyserId());
NbtMapBuilder builder = NbtMap.builder();
List<NbtMap> slots = new ArrayList<>();
InventoryTranslator inventoryTranslator;
if (entity instanceof LlamaEntity) {
inventoryTranslator = new LlamaInventoryTranslator(packet.getNumberOfSlots());
slots.add(CARPET_SLOT);
} else if (entity instanceof ChestedHorseEntity) {
inventoryTranslator = new DonkeyInventoryTranslator(packet.getNumberOfSlots());
slots.add(SADDLE_SLOT);
} else {
inventoryTranslator = new HorseInventoryTranslator(packet.getNumberOfSlots());
slots.add(SADDLE_SLOT);
slots.add(ARMOR_SLOT);
}
// Build the NbtMap that sets the icons for Bedrock (e.g. sets the saddle outline on the saddle slot)
builder.putList("slots", NbtType.COMPOUND, slots);
updateEquipPacket.setTag(builder.build());
session.sendUpstreamPacket(updateEquipPacket);
session.setInventoryTranslator(inventoryTranslator);
InventoryUtils.openInventory(session, new Container(entity.getNametag(), packet.getContainerId(), packet.getNumberOfSlots(), null, session.getPlayerInventory()));
}
Aggregations