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());
}
}
}
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();
}
}
}
}
}
}
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);
}
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;
}
}
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();
}
}
}
}
Aggregations