use of com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerOpenWindowPacket in project DragonProxy by DragonetMC.
the class InventoryTranslatorRegister method open.
public static void open(UpstreamSession session, ServerOpenWindowPacket win) {
closeOpened(session, true);
if (TRANSLATORS.containsKey(win.getType())) {
CachedWindow cached = new CachedWindow(win.getWindowId(), win.getType(), win.getSlots() + 36);
session.getWindowCache().cacheWindow(cached);
final IInventoryTranslator translator = TRANSLATORS.get(win.getType());
session.getDataCache().put(CacheKey.CURRENT_WINDOW_ID, win.getWindowId());
// -36 for the player inv size
session.getDataCache().put(CacheKey.CURRENT_WINDOW_SIZE, win.getSlots());
translator.prepare(session, cached);
DragonProxy.getInstance().getGeneralThreadPool().schedule(() -> {
// with this -> double chest, without -> content....
translator.open(session, cached);
cached.isOpen = true;
com.github.steveice10.packetlib.packet.Packet[] items = session.getWindowCache().getCachedPackets(win.getWindowId());
for (com.github.steveice10.packetlib.packet.Packet item : items) if (item != null)
if (ServerWindowItemsPacket.class.isAssignableFrom(item.getClass()))
updateContent(session, (ServerWindowItemsPacket) item);
else
updateSlot(session, (ServerSetSlotPacket) item);
}, 200, TimeUnit.MILLISECONDS);
} else
// Not supported
session.getDownstream().send(new ClientCloseWindowPacket(win.getWindowId()));
}
Aggregations