Search in sources :

Example 1 with AbstractContainerScreen

use of net.minecraft.client.gui.screens.inventory.AbstractContainerScreen in project Balm by ModdingForBlockheads.

the class AbstractContainerScreenMixin method renderForeground.

@Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;IIF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;renderLabels(Lcom/mojang/blaze3d/vertex/PoseStack;II)V", shift = At.Shift.AFTER))
public void renderForeground(PoseStack poseStack, int mouseX, int mouseY, float partialTicks, CallbackInfo callbackInfo) {
    Screen screen = (Screen) (Object) this;
    Balm.getEvents().fireEvent(new ContainerScreenDrawEvent.Foreground(screen, poseStack, mouseX, mouseY));
}
Also used : Screen(net.minecraft.client.gui.screens.Screen) AbstractContainerScreen(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen) ContainerScreenDrawEvent(net.blay09.mods.balm.api.event.client.screen.ContainerScreenDrawEvent) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with AbstractContainerScreen

use of net.minecraft.client.gui.screens.inventory.AbstractContainerScreen in project Botania by VazkiiMods.

the class JEIBotaniaPlugin method onRuntimeAvailable.

@Override
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
    IRecipeManager recipeRegistry = jeiRuntime.getRecipeManager();
    // Hide the return recipes (iron ingot/diamond/ender pearl returns, not lexicon)
    for (IElvenTradeRecipe recipe : TileAlfPortal.elvenTradeRecipes(Minecraft.getInstance().level)) {
        if (recipe instanceof LexiconElvenTradeRecipe) {
            continue;
        }
        List<Ingredient> inputs = recipe.getIngredients();
        List<ItemStack> outputs = recipe.getOutputs();
        if (inputs.size() == 1 && outputs.size() == 1 && recipe.containsItem(outputs.get(0))) {
            recipeRegistry.hideRecipe(recipe, ElvenTradeRecipeCategory.UID);
        }
    }
    RecipeManager recipeManager = Minecraft.getInstance().level.getRecipeManager();
    recipeManager.byKey(prefix("petal_apothecary/daybloom_motif")).ifPresent(r -> recipeRegistry.hideRecipe(r, PetalApothecaryRecipeCategory.UID));
    recipeManager.byKey(prefix("petal_apothecary/nightshade_motif")).ifPresent(r -> recipeRegistry.hideRecipe(r, PetalApothecaryRecipeCategory.UID));
    CorporeaInputHandler.jeiPanelSupplier = () -> {
        ItemStack stack = jeiRuntime.getIngredientListOverlay().getIngredientUnderMouse(VanillaTypes.ITEM);
        if (stack == null && Minecraft.getInstance().screen == jeiRuntime.getRecipesGui()) {
            stack = jeiRuntime.getRecipesGui().getIngredientUnderMouse(VanillaTypes.ITEM);
        }
        if (stack == null) {
            stack = jeiRuntime.getBookmarkOverlay().getIngredientUnderMouse(VanillaTypes.ITEM);
        }
        if (stack != null) {
            return stack;
        }
        return ItemStack.EMPTY;
    };
    CorporeaInputHandler.supportedGuiFilter = gui -> gui instanceof AbstractContainerScreen<?> || gui instanceof IRecipesGui;
}
Also used : IRecipeManager(mezz.jei.api.recipe.IRecipeManager) IElvenTradeRecipe(vazkii.botania.api.recipe.IElvenTradeRecipe) StateIngredient(vazkii.botania.api.recipe.StateIngredient) Ingredient(net.minecraft.world.item.crafting.Ingredient) AbstractContainerScreen(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen) RecipeManager(net.minecraft.world.item.crafting.RecipeManager) IRecipeManager(mezz.jei.api.recipe.IRecipeManager) LexiconElvenTradeRecipe(vazkii.botania.common.crafting.LexiconElvenTradeRecipe) ItemStack(net.minecraft.world.item.ItemStack) IRecipesGui(mezz.jei.api.runtime.IRecipesGui)

Example 3 with AbstractContainerScreen

use of net.minecraft.client.gui.screens.inventory.AbstractContainerScreen 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 4 with AbstractContainerScreen

use of net.minecraft.client.gui.screens.inventory.AbstractContainerScreen in project LightmansCurrency by Lightman314.

the class ItemRenderUtil method drawItemStack.

/**
 * Draws an ItemStack.
 */
public static void drawItemStack(GuiComponent gui, Font font, ItemStack stack, int x, int y) {
    Minecraft minecraft = Minecraft.getInstance();
    ItemRenderer itemRenderer = minecraft.getItemRenderer();
    Player player = minecraft.player;
    Screen screen = minecraft.screen;
    int imageWidth = 0;
    if (screen != null) {
        imageWidth = screen.width;
        if (screen instanceof AbstractContainerScreen<?>)
            imageWidth = ((AbstractContainerScreen<?>) screen).getXSize();
    }
    if (font == null)
        font = minecraft.font;
    gui.setBlitOffset(100);
    itemRenderer.blitOffset = 100.0F;
    RenderSystem.enableDepthTest();
    itemRenderer.renderAndDecorateItem(player, stack, x, y, x + y * imageWidth);
    itemRenderer.renderGuiItemDecorations(font, stack, x, y, null);
    itemRenderer.blitOffset = 0.0F;
    gui.setBlitOffset(0);
}
Also used : Player(net.minecraft.world.entity.player.Player) Screen(net.minecraft.client.gui.screens.Screen) AbstractContainerScreen(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen) AbstractContainerScreen(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen) ItemRenderer(net.minecraft.client.renderer.entity.ItemRenderer) Minecraft(net.minecraft.client.Minecraft)

Example 5 with AbstractContainerScreen

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

AbstractContainerScreen (net.minecraft.client.gui.screens.inventory.AbstractContainerScreen)9 Screen (net.minecraft.client.gui.screens.Screen)6 ItemStack (net.minecraft.world.item.ItemStack)4 Minecraft (net.minecraft.client.Minecraft)3 Slot (net.minecraft.world.inventory.Slot)3 ContainerScreenDrawEvent (net.blay09.mods.balm.api.event.client.screen.ContainerScreenDrawEvent)2 InventoryScreen (net.minecraft.client.gui.screens.inventory.InventoryScreen)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 IHasClickToggle (com.lothrazar.cyclic.api.IHasClickToggle)1 ItemStorageBag (com.lothrazar.cyclic.item.storagebag.ItemStorageBag)1 PacketItemGui (com.lothrazar.cyclic.net.PacketItemGui)1 PacketItemToggle (com.lothrazar.cyclic.net.PacketItemToggle)1 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