Search in sources :

Example 1 with WalletButton

use of io.github.lightman314.lightmanscurrency.client.gui.widget.button.WalletButton 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())));
    }
}
Also used : CurrencySoundEvents(io.github.lightman314.lightmanscurrency.CurrencySoundEvents) CreativeModeInventoryScreen(net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen) WalletButton(io.github.lightman314.lightmanscurrency.client.gui.widget.button.WalletButton) WalletItem(io.github.lightman314.lightmanscurrency.items.WalletItem) Screen(net.minecraft.client.gui.screens.Screen) LightmansCurrency(io.github.lightman314.lightmanscurrency.LightmansCurrency) AbstractContainerScreen(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen) LocalPlayer(net.minecraft.client.player.LocalPlayer) SimpleSoundInstance(net.minecraft.client.resources.sounds.SimpleSoundInstance) LightmansCurrencyPacketHandler(io.github.lightman314.lightmanscurrency.network.LightmansCurrencyPacketHandler) GLFW(org.lwjgl.glfw.GLFW) WalletScreen(io.github.lightman314.lightmanscurrency.client.gui.screen.inventory.WalletScreen) Dist(net.minecraftforge.api.distmarker.Dist) ScreenEvent(net.minecraftforge.client.event.ScreenEvent) Minecraft(net.minecraft.client.Minecraft) KeyMapping(net.minecraft.client.KeyMapping) Config(io.github.lightman314.lightmanscurrency.Config) SoundEvents(net.minecraft.sounds.SoundEvents) Mod(net.minecraftforge.fml.common.Mod) InventoryScreen(net.minecraft.client.gui.screens.inventory.InventoryScreen) ItemStack(net.minecraft.world.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent) InputEvent(net.minecraftforge.client.event.InputEvent) MessageOpenWallet(io.github.lightman314.lightmanscurrency.network.message.wallet.MessageOpenWallet) MessageOpenWallet(io.github.lightman314.lightmanscurrency.network.message.wallet.MessageOpenWallet) CreativeModeInventoryScreen(net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen) Screen(net.minecraft.client.gui.screens.Screen) AbstractContainerScreen(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen) WalletScreen(io.github.lightman314.lightmanscurrency.client.gui.screen.inventory.WalletScreen) InventoryScreen(net.minecraft.client.gui.screens.inventory.InventoryScreen) AbstractContainerScreen(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen) WalletButton(io.github.lightman314.lightmanscurrency.client.gui.widget.button.WalletButton) CreativeModeInventoryScreen(net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen) CreativeModeInventoryScreen(net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen) InventoryScreen(net.minecraft.client.gui.screens.inventory.InventoryScreen) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

Config (io.github.lightman314.lightmanscurrency.Config)1 CurrencySoundEvents (io.github.lightman314.lightmanscurrency.CurrencySoundEvents)1 LightmansCurrency (io.github.lightman314.lightmanscurrency.LightmansCurrency)1 WalletScreen (io.github.lightman314.lightmanscurrency.client.gui.screen.inventory.WalletScreen)1 WalletButton (io.github.lightman314.lightmanscurrency.client.gui.widget.button.WalletButton)1 WalletItem (io.github.lightman314.lightmanscurrency.items.WalletItem)1 LightmansCurrencyPacketHandler (io.github.lightman314.lightmanscurrency.network.LightmansCurrencyPacketHandler)1 MessageOpenWallet (io.github.lightman314.lightmanscurrency.network.message.wallet.MessageOpenWallet)1 KeyMapping (net.minecraft.client.KeyMapping)1 Minecraft (net.minecraft.client.Minecraft)1 Screen (net.minecraft.client.gui.screens.Screen)1 AbstractContainerScreen (net.minecraft.client.gui.screens.inventory.AbstractContainerScreen)1 CreativeModeInventoryScreen (net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen)1 InventoryScreen (net.minecraft.client.gui.screens.inventory.InventoryScreen)1 LocalPlayer (net.minecraft.client.player.LocalPlayer)1 SimpleSoundInstance (net.minecraft.client.resources.sounds.SimpleSoundInstance)1 SoundEvents (net.minecraft.sounds.SoundEvents)1 ItemStack (net.minecraft.world.item.ItemStack)1 Dist (net.minecraftforge.api.distmarker.Dist)1 InputEvent (net.minecraftforge.client.event.InputEvent)1