use of io.github.lightman314.lightmanscurrency.network.message.wallet.MessageOpenWallet in project LightmansCurrency by Lightman314.
the class MessageOpenWallet method handle.
public static void handle(MessageOpenWallet message, Supplier<Context> supplier) {
supplier.get().enqueueWork(() -> {
ServerPlayer player = supplier.get().getSender();
if (player != null) {
NetworkHooks.openGui(player, new WalletMenuProvider(-1), new DataWriter(-1));
}
});
supplier.get().setPacketHandled(true);
}
use of io.github.lightman314.lightmanscurrency.network.message.wallet.MessageOpenWallet in project LightmansCurrency by Lightman314.
the class ClientEvents method onInventoryGuiInit.
// Add the wallet button to the gui
@SubscribeEvent
public static void onInventoryGuiInit(ScreenEvent.InitScreenEvent.Post event) {
if (!Config.CLIENT.renderWalletButton.get())
return;
Screen screen = event.getScreen();
if (screen instanceof InventoryScreen || screen instanceof CreativeModeInventoryScreen) {
AbstractContainerScreen<?> gui = (AbstractContainerScreen<?>) screen;
boolean isCreative = screen instanceof CreativeModeInventoryScreen;
int xPos = isCreative ? Config.CLIENT.walletButtonCreativeX.get() : Config.CLIENT.walletButtonX.get();
int yPos = isCreative ? Config.CLIENT.walletButtonCreativeY.get() : Config.CLIENT.walletButtonY.get();
;
event.addListener(new WalletButton(gui, xPos, yPos, button -> LightmansCurrencyPacketHandler.instance.sendToServer(new MessageOpenWallet())));
}
}
Aggregations