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 };
}
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;
}
Aggregations