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