Search in sources :

Example 1 with SkyblockAddons

use of codes.biscuit.skyblockaddons.SkyblockAddons in project SkyblockAddons by BiscuitDevelopment.

the class GuiChestHook method drawScreen.

public static void drawScreen(int guiLeft, int guiTop) {
    InventoryType inventoryType = SkyblockAddons.getInstance().getInventoryUtils().updateInventoryType();
    if (textFieldMatch != null && (inventoryType == InventoryType.ENCHANTMENT_TABLE || inventoryType == InventoryType.BASIC_REFORGING || inventoryType == InventoryType.BASIC_ACCESSORY_BAG_REFORGING)) {
        Minecraft mc = Minecraft.getMinecraft();
        SkyblockAddons main = SkyblockAddons.getInstance();
        String typeToMatch = inventoryType == InventoryType.ENCHANTMENT_TABLE ? Message.MESSAGE_ENCHANTS.getMessage() : Message.MESSAGE_REFORGES.getMessage();
        String inclusionExample;
        String exclusionExample;
        int defaultBlue = main.getUtils().getDefaultBlue(255);
        float scale = 0.75F;
        int x = guiLeft - 160;
        if (x < 0) {
            x = 20;
        }
        if (inventoryType == InventoryType.ENCHANTMENT_TABLE) {
            inclusionExample = Message.MESSAGE_ENCHANTMENT_INCLUSION_EXAMPLE.getMessage();
            exclusionExample = Message.MESSAGE_ENCHANTMENT_EXCLUSION_EXAMPLE.getMessage();
        } else {
            inclusionExample = Message.MESSAGE_REFORGE_INCLUSION_EXAMPLE.getMessage();
            exclusionExample = Message.MESSAGE_REFORGE_EXCLUSION_EXAMPLE.getMessage();
        }
        GlStateManager.color(1F, 1F, 1F);
        GlStateManager.pushMatrix();
        GlStateManager.scale(scale, scale, 1);
        mc.fontRendererObj.drawString(Message.MESSAGE_TYPE_ENCHANTMENTS.getMessage(typeToMatch), Math.round(x / scale), Math.round((guiTop + 40) / scale), defaultBlue);
        mc.fontRendererObj.drawString(Message.MESSAGE_SEPARATE_ENCHANTMENTS.getMessage(), Math.round(x / scale), Math.round((guiTop + 50) / scale), defaultBlue);
        mc.fontRendererObj.drawString(Message.MESSAGE_ENCHANTS_TO_MATCH.getMessage(typeToMatch), Math.round(x / scale), Math.round((guiTop + 70) / scale), defaultBlue);
        mc.fontRendererObj.drawString(Message.MESSAGE_ENCHANTS_TO_EXCLUDE.getMessage(typeToMatch), Math.round(x / scale), Math.round((guiTop + 110) / scale), defaultBlue);
        GlStateManager.popMatrix();
        textFieldMatch.drawTextBox();
        if (StringUtils.isEmpty(textFieldMatch.getText())) {
            mc.fontRendererObj.drawString(inclusionExample, x + 4, guiTop + 86, ColorCode.DARK_GRAY.getRGB());
        }
        textFieldExclusions.drawTextBox();
        if (StringUtils.isEmpty(textFieldExclusions.getText())) {
            mc.fontRendererObj.drawString(exclusionExample, x + 4, guiTop + 126, ColorCode.DARK_GRAY.getRGB());
        }
    }
}
Also used : InventoryType(codes.biscuit.skyblockaddons.core.InventoryType) Minecraft(net.minecraft.client.Minecraft) SkyblockAddons(codes.biscuit.skyblockaddons.SkyblockAddons)

Example 2 with SkyblockAddons

use of codes.biscuit.skyblockaddons.SkyblockAddons in project SkyblockAddons by BiscuitDevelopment.

the class GuiChestHook method onRenderChestForegroundLayer.

public static void onRenderChestForegroundLayer(GuiChest guiChest) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    if (main.getConfigValues().isEnabled(Feature.SHOW_ENCHANTMENTS_REFORGES)) {
        Minecraft mc = Minecraft.getMinecraft();
        for (Slot slot : guiChest.inventorySlots.inventorySlots) {
            ItemStack itemStack = slot.getStack();
            if (itemStack != null && itemStack.hasDisplayName()) {
                if (itemStack.getDisplayName().startsWith(ColorCode.GREEN + "Enchant Item")) {
                    List<String> lore = ItemUtils.getItemLore(itemStack);
                    if (lore.size() > 1) {
                        String enchantLine = TextUtils.stripColor(lore.get(1));
                        Matcher matcher = ENCHANTMENT_PATTERN.matcher(enchantLine);
                        if (matcher.matches()) {
                            String enchantment = matcher.group("enchantment");
                            int color = ColorCode.YELLOW.getRGB();
                            if (!main.getUtils().getEnchantmentMatches().isEmpty() && main.getUtils().enchantReforgeMatches(enchantment)) {
                                color = ColorCode.RED.getRGB();
                            }
                            boolean expandLeft = false;
                            boolean expandRight = false;
                            int stringWidth = mc.fontRendererObj.getStringWidth(enchantment);
                            float scale = 0.8F;
                            float yOffset = 23;
                            if (slot.slotNumber == 29) {
                                yOffset = 38;
                                // If over the width of 3 glass panes + spacing, expand left
                                if (stringWidth > 50) {
                                    expandLeft = true;
                                }
                            } else if (slot.slotNumber == 33) {
                                yOffset = 38;
                                // If over the width of 3 glass panes + spacing, expand right
                                if (stringWidth > 50) {
                                    expandRight = true;
                                }
                            }
                            int x = slot.xDisplayPosition;
                            int y = slot.yDisplayPosition;
                            GlStateManager.pushMatrix();
                            GlStateManager.scale(scale, scale, 1);
                            float renderX;
                            float renderY = (y + yOffset) / scale;
                            if (expandLeft) {
                                renderX = (x + 32 - 2) / scale - stringWidth;
                            } else if (expandRight) {
                                renderX = (x - 16 + 2) / scale;
                            } else {
                                renderX = (x + 8) / scale - stringWidth / 2F;
                            }
                            GlStateManager.disableDepth();
                            drawTooltipBackground(renderX, renderY, stringWidth, 8);
                            mc.fontRendererObj.drawString(enchantment, renderX, renderY, color, true);
                            GlStateManager.enableDepth();
                            GlStateManager.popMatrix();
                        }
                    }
                }
            }
        }
        if (guiChest.inventorySlots.inventorySlots.size() > 13) {
            Slot slot = guiChest.inventorySlots.inventorySlots.get(13);
            if (slot != null) {
                ItemStack item = slot.getStack();
                if (item != null) {
                    String reforge = null;
                    if (main.getInventoryUtils().getInventoryType() == InventoryType.BASIC_REFORGING) {
                        reforge = main.getUtils().getReforgeFromItem(item);
                    } else if (main.getInventoryUtils().getInventoryType() == InventoryType.BASIC_ACCESSORY_BAG_REFORGING) {
                        reforge = GuiChestHook.getLastAccessoryBagReforge();
                    }
                    if (reforge != null) {
                        int color = ColorCode.YELLOW.getRGB();
                        if (!main.getUtils().getEnchantmentMatches().isEmpty() && main.getUtils().enchantReforgeMatches(reforge)) {
                            color = ColorCode.RED.getRGB();
                        }
                        int x = slot.xDisplayPosition;
                        int y = slot.yDisplayPosition;
                        int stringWidth = mc.fontRendererObj.getStringWidth(reforge);
                        float renderX = x - 28 - stringWidth / 2F;
                        int renderY = y + 22;
                        GlStateManager.disableDepth();
                        drawTooltipBackground(renderX, renderY, stringWidth, 8);
                        mc.fontRendererObj.drawString(reforge, renderX, renderY, color, true);
                        GlStateManager.enableDepth();
                    }
                }
            }
        }
    }
}
Also used : Matcher(java.util.regex.Matcher) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) SkyblockAddons(codes.biscuit.skyblockaddons.SkyblockAddons)

Example 3 with SkyblockAddons

use of codes.biscuit.skyblockaddons.SkyblockAddons in project SkyblockAddons by BiscuitDevelopment.

the class GuiContainerHook method drawGradientRect.

public static void drawGradientRect(GuiContainer guiContainer, int left, int top, int right, int bottom, int startColor, int endColor, Slot theSlot) {
    if (freezeBackpack)
        return;
    SkyblockAddons main = SkyblockAddons.getInstance();
    Container container = Minecraft.getMinecraft().thePlayer.openContainer;
    if (theSlot != null) {
        int slotNum = theSlot.slotNumber + main.getInventoryUtils().getSlotDifference(container);
        main.getUtils().setLastHoveredSlot(slotNum);
        if (main.getConfigValues().isEnabled(Feature.LOCK_SLOTS) && main.getUtils().isOnSkyblock() && main.getConfigValues().getLockedSlots().contains(slotNum) && (slotNum >= 9 || container instanceof ContainerPlayer && slotNum >= 5)) {
            guiContainer.drawGradientRect(left, top, right, bottom, OVERLAY_RED, OVERLAY_RED);
            return;
        }
    }
    guiContainer.drawGradientRect(left, top, right, bottom, startColor, endColor);
}
Also used : ContainerPlayer(net.minecraft.inventory.ContainerPlayer) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) Container(net.minecraft.inventory.Container) SkyblockAddons(codes.biscuit.skyblockaddons.SkyblockAddons)

Example 4 with SkyblockAddons

use of codes.biscuit.skyblockaddons.SkyblockAddons in project SkyblockAddons by BiscuitDevelopment.

the class GuiContainerHook method keyTyped.

public static void keyTyped(int keyCode) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    if (keyCode == 1 || keyCode == Minecraft.getMinecraft().gameSettings.keyBindInventory.getKeyCode()) {
        freezeBackpack = false;
        main.getUtils().setBackpackToPreview(null);
    }
    if (keyCode == main.getFreezeBackpackKey().getKeyCode() && freezeBackpack && System.currentTimeMillis() - GuiScreenHook.getLastBackpackFreezeKey() > 500) {
        GuiScreenHook.setLastBackpackFreezeKey(System.currentTimeMillis());
        freezeBackpack = false;
    }
}
Also used : SkyblockAddons(codes.biscuit.skyblockaddons.SkyblockAddons)

Example 5 with SkyblockAddons

use of codes.biscuit.skyblockaddons.SkyblockAddons in project SkyblockAddons by BiscuitDevelopment.

the class GuiContainerHook method drawSlot.

public static void drawSlot(GuiContainer guiContainer, Slot slot) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    Minecraft mc = Minecraft.getMinecraft();
    Container container = mc.thePlayer.openContainer;
    if (slot != null) {
        // Draw crafting pattern overlays inside the crafting grid.
        if (main.getConfigValues().isEnabled(Feature.CRAFTING_PATTERNS) && main.getUtils().isOnSkyblock() && slot.inventory.getDisplayName().getUnformattedText().equals(CraftingPattern.CRAFTING_TABLE_DISPLAYNAME) && main.getPersistentValues().getSelectedCraftingPattern() != CraftingPattern.FREE) {
            int craftingGridIndex = CraftingPattern.slotToCraftingGridIndex(slot.getSlotIndex());
            if (craftingGridIndex >= 0) {
                int slotLeft = slot.xDisplayPosition;
                int slotTop = slot.yDisplayPosition;
                int slotRight = slotLeft + 16;
                int slotBottom = slotTop + 16;
                if (main.getPersistentValues().getSelectedCraftingPattern().isSlotInPattern(craftingGridIndex)) {
                    if (!slot.getHasStack()) {
                        guiContainer.drawGradientRect(slotLeft, slotTop, slotRight, slotBottom, OVERLAY_GREEN, OVERLAY_GREEN);
                    }
                } else {
                    if (slot.getHasStack()) {
                        guiContainer.drawGradientRect(slotLeft, slotTop, slotRight, slotBottom, OVERLAY_RED, OVERLAY_RED);
                    }
                }
            }
        }
        if (main.getConfigValues().isEnabled(Feature.LOCK_SLOTS) && main.getUtils().isOnSkyblock()) {
            int slotNum = slot.slotNumber + main.getInventoryUtils().getSlotDifference(container);
            if (main.getConfigValues().getLockedSlots().contains(slotNum) && (slotNum >= 9 || container instanceof ContainerPlayer && slotNum >= 5)) {
                GlStateManager.disableLighting();
                GlStateManager.disableDepth();
                GlStateManager.color(1, 1, 1, 0.4F);
                GlStateManager.enableBlend();
                mc.getTextureManager().bindTexture(LOCK);
                mc.ingameGUI.drawTexturedModalRect(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16);
                GlStateManager.enableLighting();
                GlStateManager.enableDepth();
            }
        }
    }
}
Also used : ContainerPlayer(net.minecraft.inventory.ContainerPlayer) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) Container(net.minecraft.inventory.Container) Minecraft(net.minecraft.client.Minecraft) SkyblockAddons(codes.biscuit.skyblockaddons.SkyblockAddons)

Aggregations

SkyblockAddons (codes.biscuit.skyblockaddons.SkyblockAddons)33 Minecraft (net.minecraft.client.Minecraft)15 ItemStack (net.minecraft.item.ItemStack)12 ContainerPlayer (net.minecraft.inventory.ContainerPlayer)6 Matcher (java.util.regex.Matcher)4 Container (net.minecraft.inventory.Container)4 Slot (net.minecraft.inventory.Slot)4 Backpack (codes.biscuit.skyblockaddons.features.backpacks.Backpack)3 Entity (net.minecraft.entity.Entity)3 EntityItemFrame (net.minecraft.entity.item.EntityItemFrame)3 BackpackColor (codes.biscuit.skyblockaddons.features.backpacks.BackpackColor)2 IOException (java.io.IOException)2 Block (net.minecraft.block.Block)2 EntityOtherPlayerMP (net.minecraft.client.entity.EntityOtherPlayerMP)2 GuiContainer (net.minecraft.client.gui.inventory.GuiContainer)2 InventoryType (codes.biscuit.skyblockaddons.core.InventoryType)1 Location (codes.biscuit.skyblockaddons.core.Location)1 CraftingPattern (codes.biscuit.skyblockaddons.features.craftingpatterns.CraftingPattern)1 CraftingPatternResult (codes.biscuit.skyblockaddons.features.craftingpatterns.CraftingPatternResult)1 ButtonToggleNew (codes.biscuit.skyblockaddons.gui.buttons.ButtonToggleNew)1