Search in sources :

Example 1 with WindowOpenPacket

use of org.dragonet.net.packet.minecraft.WindowOpenPacket in project Dragonet-Legacy by DragonetMC.

the class OpenWindowMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(OpenWindowMessage packet) {
    byte typePE = InventoryType.PEInventory.toPEInventory(InventoryType.PCInventory.fromString(packet.type), packet.slots);
    if (typePE == (byte) 0xFF) {
        //Not supported, close it
        CloseWindowMessage msgCloseWindow = new CloseWindowMessage(packet.id);
        this.getSession().messageReceived(msgCloseWindow);
        return null;
    }
    WindowOpenPacket pkOpenWindow = new WindowOpenPacket();
    pkOpenWindow.windowID = (byte) (packet.id & 0xFF);
    pkOpenWindow.type = typePE;
    pkOpenWindow.slots = (byte) (packet.slots & 0xFFFF);
    pkOpenWindow.x = this.getSession().getPlayer().getLocation().getBlockX();
    pkOpenWindow.y = this.getSession().getPlayer().getLocation().getBlockY();
    pkOpenWindow.z = this.getSession().getPlayer().getLocation().getBlockZ();
    getSession().getOpenedWindows().add(packet.id);
    this.getTranslator().cachedWindowType[packet.id & 0xFF] = typePE;
    return new PEPacket[] { pkOpenWindow };
}
Also used : CloseWindowMessage(net.glowstone.net.message.play.inv.CloseWindowMessage) PEPacket(org.dragonet.net.packet.minecraft.PEPacket) WindowOpenPacket(org.dragonet.net.packet.minecraft.WindowOpenPacket)

Aggregations

CloseWindowMessage (net.glowstone.net.message.play.inv.CloseWindowMessage)1 PEPacket (org.dragonet.net.packet.minecraft.PEPacket)1 WindowOpenPacket (org.dragonet.net.packet.minecraft.WindowOpenPacket)1