Search in sources :

Example 1 with InventoryScreen

use of net.minecraft.client.gui.screens.inventory.InventoryScreen in project Regeneration by Suff99.

the class TabRegistry method openInventoryGui.

public static void openInventoryGui() {
    Minecraft mc = Minecraft.getInstance();
    mc.player.connection.send(new ServerboundContainerClosePacket(mc.player.containerMenu.containerId));
    InventoryScreen inventory = new InventoryScreen(mc.player);
    mc.setScreen(inventory);
}
Also used : ServerboundContainerClosePacket(net.minecraft.network.protocol.game.ServerboundContainerClosePacket) InventoryScreen(net.minecraft.client.gui.screens.inventory.InventoryScreen) Minecraft(net.minecraft.client.Minecraft)

Example 2 with InventoryScreen

use of net.minecraft.client.gui.screens.inventory.InventoryScreen in project Tweak-My-Client by Hendrix-Shen.

the class AutoDropUtils method doDrop.

public static void doDrop() {
    Minecraft minecraftClient = TweakMyClient.getMinecraftClient();
    MultiPlayerGameMode interactionManager = minecraftClient.gameMode;
    if (minecraftClient.screen instanceof AbstractContainerScreen && !(minecraftClient.screen instanceof InventoryScreen)) {
        return;
    }
    for (int slot = 9; slot < 45; slot++) {
        int adjustedSlot = slot;
        if (adjustedSlot >= 36)
            adjustedSlot -= 36;
        assert minecraftClient.player != null;
        ItemStack stack = minecraftClient.player.inventory.getItem(adjustedSlot);
        if (stack.isEmpty())
            continue;
        Configs.AutoDropListType mode = (Configs.AutoDropListType) Configs.List.LIST_AUTO_DROP_TYPE.getOptionListValue();
        switch(mode) {
            case BLACKLIST:
                if (!itemStacksBlackList.contains(stack.getItem())) {
                    assert interactionManager != null;
                    interactionManager.handleInventoryMouseClick(0, slot, 1, ClickType.THROW, TweakMyClient.getMinecraftClient().player);
                }
                break;
            case WHITELIST:
                if (itemStacksWhitelist.contains(stack.getItem())) {
                    assert interactionManager != null;
                    interactionManager.handleInventoryMouseClick(0, slot, 1, ClickType.THROW, TweakMyClient.getMinecraftClient().player);
                }
                break;
        }
    }
}
Also used : AbstractContainerScreen(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen) Configs(top.hendrixshen.TweakMyClient.config.Configs) InventoryScreen(net.minecraft.client.gui.screens.inventory.InventoryScreen) ItemStack(net.minecraft.world.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) MultiPlayerGameMode(net.minecraft.client.multiplayer.MultiPlayerGameMode)

Example 3 with InventoryScreen

use of net.minecraft.client.gui.screens.inventory.InventoryScreen 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)

Example 4 with InventoryScreen

use of net.minecraft.client.gui.screens.inventory.InventoryScreen in project TerraFirmaCraft by TerraFirmaCraft.

the class CalendarScreen method init.

@Override
public void init() {
    super.init();
    addRenderableWidget(new PlayerInventoryTabButton(leftPos, topPos, 176, 4, 20, 22, 128, 0, 1, 3, 0, 0, button -> {
        playerInventory.player.containerMenu = playerInventory.player.inventoryMenu;
        Minecraft.getInstance().setScreen(new InventoryScreen(playerInventory.player));
        PacketHandler.send(PacketDistributor.SERVER.noArg(), new SwitchInventoryTabPacket(SwitchInventoryTabPacket.Type.INVENTORY));
    }));
    addRenderableWidget(new PlayerInventoryTabButton(leftPos, topPos, 176 - 3, 27, 20 + 3, 22, 128 + 20, 0, 1, 3, 32, 0, button -> {
    }));
    addRenderableWidget(new PlayerInventoryTabButton(leftPos, topPos, 176, 50, 20, 22, 128, 0, 1, 3, 64, 0, SwitchInventoryTabPacket.Type.NUTRITION));
    addRenderableWidget(new PlayerInventoryTabButton(leftPos, topPos, 176, 73, 20, 22, 128, 0, 1, 3, 96, 0, SwitchInventoryTabPacket.Type.CLIMATE));
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) SwitchInventoryTabPacket(net.dries007.tfc.network.SwitchInventoryTabPacket) Month(net.dries007.tfc.util.calendar.Month) Component(net.minecraft.network.chat.Component) Inventory(net.minecraft.world.entity.player.Inventory) PoseStack(com.mojang.blaze3d.vertex.PoseStack) I18n(net.minecraft.client.resources.language.I18n) Minecraft(net.minecraft.client.Minecraft) Calendars(net.dries007.tfc.util.calendar.Calendars) PacketDistributor(net.minecraftforge.network.PacketDistributor) Container(net.dries007.tfc.common.container.Container) InventoryScreen(net.minecraft.client.gui.screens.inventory.InventoryScreen) PacketHandler(net.dries007.tfc.network.PacketHandler) MOD_ID(net.dries007.tfc.TerraFirmaCraft.MOD_ID) PlayerInventoryTabButton(net.dries007.tfc.client.screen.button.PlayerInventoryTabButton) PlayerInventoryTabButton(net.dries007.tfc.client.screen.button.PlayerInventoryTabButton) SwitchInventoryTabPacket(net.dries007.tfc.network.SwitchInventoryTabPacket) InventoryScreen(net.minecraft.client.gui.screens.inventory.InventoryScreen)

Example 5 with InventoryScreen

use of net.minecraft.client.gui.screens.inventory.InventoryScreen in project TerraFirmaCraft by TerraFirmaCraft.

the class ClimateScreen method init.

@Override
public void init() {
    super.init();
    addRenderableWidget(new PlayerInventoryTabButton(leftPos, topPos, 176, 4, 20, 22, 128, 0, 1, 3, 0, 0, button -> {
        playerInventory.player.containerMenu = playerInventory.player.inventoryMenu;
        Minecraft.getInstance().setScreen(new InventoryScreen(playerInventory.player));
        PacketHandler.send(PacketDistributor.SERVER.noArg(), new SwitchInventoryTabPacket(SwitchInventoryTabPacket.Type.INVENTORY));
    }));
    addRenderableWidget(new PlayerInventoryTabButton(leftPos, topPos, 176, 27, 20, 22, 128, 0, 1, 3, 32, 0, SwitchInventoryTabPacket.Type.CALENDAR));
    addRenderableWidget(new PlayerInventoryTabButton(leftPos, topPos, 176, 50, 20, 22, 128, 0, 1, 3, 64, 0, SwitchInventoryTabPacket.Type.NUTRITION));
    addRenderableWidget(new PlayerInventoryTabButton(leftPos, topPos, 176 - 3, 73, 20 + 3, 22, 128 + 20, 0, 1, 3, 96, 0, button -> {
    }));
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) SwitchInventoryTabPacket(net.dries007.tfc.network.SwitchInventoryTabPacket) Component(net.minecraft.network.chat.Component) ClimateRenderCache(net.dries007.tfc.client.ClimateRenderCache) Inventory(net.minecraft.world.entity.player.Inventory) PoseStack(com.mojang.blaze3d.vertex.PoseStack) I18n(net.minecraft.client.resources.language.I18n) Minecraft(net.minecraft.client.Minecraft) KoppenClimateClassification(net.dries007.tfc.util.climate.KoppenClimateClassification) PacketDistributor(net.minecraftforge.network.PacketDistributor) Container(net.dries007.tfc.common.container.Container) InventoryScreen(net.minecraft.client.gui.screens.inventory.InventoryScreen) PacketHandler(net.dries007.tfc.network.PacketHandler) Helpers(net.dries007.tfc.util.Helpers) MOD_ID(net.dries007.tfc.TerraFirmaCraft.MOD_ID) PlayerInventoryTabButton(net.dries007.tfc.client.screen.button.PlayerInventoryTabButton) PlayerInventoryTabButton(net.dries007.tfc.client.screen.button.PlayerInventoryTabButton) SwitchInventoryTabPacket(net.dries007.tfc.network.SwitchInventoryTabPacket) InventoryScreen(net.minecraft.client.gui.screens.inventory.InventoryScreen)

Aggregations

Minecraft (net.minecraft.client.Minecraft)5 InventoryScreen (net.minecraft.client.gui.screens.inventory.InventoryScreen)5 PoseStack (com.mojang.blaze3d.vertex.PoseStack)2 MOD_ID (net.dries007.tfc.TerraFirmaCraft.MOD_ID)2 PlayerInventoryTabButton (net.dries007.tfc.client.screen.button.PlayerInventoryTabButton)2 Container (net.dries007.tfc.common.container.Container)2 PacketHandler (net.dries007.tfc.network.PacketHandler)2 SwitchInventoryTabPacket (net.dries007.tfc.network.SwitchInventoryTabPacket)2 AbstractContainerScreen (net.minecraft.client.gui.screens.inventory.AbstractContainerScreen)2 I18n (net.minecraft.client.resources.language.I18n)2 Component (net.minecraft.network.chat.Component)2 ResourceLocation (net.minecraft.resources.ResourceLocation)2 Inventory (net.minecraft.world.entity.player.Inventory)2 ItemStack (net.minecraft.world.item.ItemStack)2 PacketDistributor (net.minecraftforge.network.PacketDistributor)2 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