Search in sources :

Example 1 with WindowClosePacket

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

the class CloseWindowMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(CloseWindowMessage packet) {
    if (packet.id != 0) {
        this.getTranslator().cachedWindowType[packet.id & 0xFF] = -1;
    }
    WindowClosePacket pkCloseWindow = new WindowClosePacket();
    pkCloseWindow.windowID = (byte) (packet.id & 0xFF);
    getSession().getOpenedWindows().remove(packet.id);
    return new PEPacket[] { pkCloseWindow };
}
Also used : WindowClosePacket(org.dragonet.net.packet.minecraft.WindowClosePacket) PEPacket(org.dragonet.net.packet.minecraft.PEPacket)

Example 2 with WindowClosePacket

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

the class CraftingEventPacketTranslator method handleSpecific.

@Override
public Message[] handleSpecific(CraftingEventPacket packet) {
    //TODO: From ln.2561
    if (!getSession().getOpenedWindows().contains(packet.windowId & 0xFF)) {
        WindowClosePacket pkClose = new WindowClosePacket();
        pkClose.windowID = packet.windowId;
        getSession().send(pkClose);
        return null;
    }
    int targetID = (int) ((packet.uuid.getMostSignificantBits() >> 32) & 0xFFFFFFFF);
    short targetDura = (short) ((packet.uuid.getMostSignificantBits() >> 16) | 0xFFFF);
    int amount = (int) (packet.uuid.getMostSignificantBits() & 0xFFFF);
    //Client wants to craft this
    ItemStack target = new ItemStack(targetID, amount, targetDura);
    Recipe[] r = getSession().getServer().getCraftingManager().getRecipesFor(target).toArray(new Recipe[0]);
    //If faild, resend the inventory. 
    return null;
}
Also used : WindowClosePacket(org.dragonet.net.packet.minecraft.WindowClosePacket) Recipe(org.bukkit.inventory.Recipe) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

WindowClosePacket (org.dragonet.net.packet.minecraft.WindowClosePacket)2 ItemStack (org.bukkit.inventory.ItemStack)1 Recipe (org.bukkit.inventory.Recipe)1 PEPacket (org.dragonet.net.packet.minecraft.PEPacket)1