diff options
Diffstat (limited to 'src/main')
8 files changed, 213 insertions, 53 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index 353247d..39653ca 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -142,6 +142,7 @@ public class DankersSkyblockMod { MinecraftForge.EVENT_BUS.register(new NotifySlayerSlain()); MinecraftForge.EVENT_BUS.register(new PetColours()); MinecraftForge.EVENT_BUS.register(new Reparty()); + MinecraftForge.EVENT_BUS.register(new SameColourSolver()); MinecraftForge.EVENT_BUS.register(new SelectAllColourSolver()); MinecraftForge.EVENT_BUS.register(new SilverfishSolver()); MinecraftForge.EVENT_BUS.register(new Skill50Display()); diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java index 2281a0a..8bce0b3 100644 --- a/src/main/java/me/Danker/commands/ToggleCommand.java +++ b/src/main/java/me/Danker/commands/ToggleCommand.java @@ -82,6 +82,7 @@ public class ToggleCommand extends CommandBase implements ICommand { public static boolean startsWithToggled; public static boolean selectAllToggled; public static boolean clickInOrderToggled; + public static boolean sameColourToggled; public static boolean blockWrongTerminalClicksToggled; public static boolean itemFrameOnSeaLanternsToggled; // Experiments diff --git a/src/main/java/me/Danker/features/AutoSwapToPickBlock.java b/src/main/java/me/Danker/features/AutoSwapToPickBlock.java index ccabbce..9a4c839 100644 --- a/src/main/java/me/Danker/features/AutoSwapToPickBlock.java +++ b/src/main/java/me/Danker/features/AutoSwapToPickBlock.java @@ -1,6 +1,7 @@ package me.Danker.features; import me.Danker.commands.ToggleCommand; +import me.Danker.utils.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.settings.GameSettings; @@ -17,6 +18,8 @@ public class AutoSwapToPickBlock { @SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { + if (!ToggleCommand.swapToPickBlockToggled || !Utils.inSkyblock) return; + Minecraft mc = Minecraft.getMinecraft(); GameSettings gameSettings = mc.gameSettings; if (event.gui instanceof GuiChest) { @@ -25,18 +28,16 @@ public class AutoSwapToPickBlock { IInventory inventory = ((ContainerChest) containerChest).getLowerChestInventory(); String inventoryName = inventory.getDisplayName().getUnformattedText(); - if (ToggleCommand.swapToPickBlockToggled) { - if (inventoryName.startsWith("Chronomatron (") || inventoryName.startsWith("Superpairs (") || inventoryName.startsWith("Ultrasequencer (") || inventoryName.startsWith("What starts with:") || inventoryName.startsWith("Select all the") || inventoryName.startsWith("Navigate the maze!") || inventoryName.startsWith("Correct all the panes!") || inventoryName.startsWith("Click in order!") || inventoryName.startsWith("Harp -")) { - if (!pickBlockBindSwapped) { - pickBlockBind = gameSettings.keyBindPickBlock.getKeyCode(); - gameSettings.keyBindPickBlock.setKeyCode(-100); - pickBlockBindSwapped = true; - } - } else { - if (pickBlockBindSwapped) { - gameSettings.keyBindPickBlock.setKeyCode(pickBlockBind); - pickBlockBindSwapped = false; - } + if (inventoryName.startsWith("Chronomatron (") || inventoryName.startsWith("Superpairs (") || inventoryName.startsWith("Ultrasequencer (") || inventoryName.startsWith("What starts with:") || inventoryName.startsWith("Select all the") || inventoryName.startsWith("Change all to same color!") || inventoryName.startsWith("Correct all the panes!") || inventoryName.startsWith("Click in order!") || inventoryName.startsWith("Click the button on time!") || inventoryName.startsWith("Harp -")) { + if (!pickBlockBindSwapped) { + pickBlockBind = gameSettings.keyBindPickBlock.getKeyCode(); + gameSettings.keyBindPickBlock.setKeyCode(-100); + pickBlockBindSwapped = true; + } + } else { + if (pickBlockBindSwapped) { + gameSettings.keyBindPickBlock.setKeyCode(pickBlockBind); + pickBlockBindSwapped = false; } } } diff --git a/src/main/java/me/Danker/features/puzzlesolvers/BlockWrongTerminalClicks.java b/src/main/java/me/Danker/features/puzzlesolvers/BlockWrongTerminalClicks.java index 5176e8b..7f76059 100644 --- a/src/main/java/me/Danker/features/puzzlesolvers/BlockWrongTerminalClicks.java +++ b/src/main/java/me/Danker/features/puzzlesolvers/BlockWrongTerminalClicks.java @@ -31,44 +31,6 @@ public class BlockWrongTerminalClicks { case "Correct all the panes!": shouldCancel = !StringUtils.stripControlCodes(item.getDisplayName()).startsWith("Off"); break; - case "Navigate the maze!": - if (item.getItem() != Item.getItemFromBlock(Blocks.stained_glass_pane)) { - shouldCancel = true; - break; - } - - if (item.getItemDamage() != 0) { - shouldCancel = true; - break; - } - - boolean isValid = false; - - int slotIndex = slot.getSlotIndex(); - - if (slotIndex % 9 != 8 && slotIndex != 53) { - ItemStack itemStack = inventory.getStackInSlot(slotIndex + 1); - if (itemStack != null && itemStack.getItemDamage() == 5) isValid = true; - } - - if (!isValid && slotIndex % 9 != 0 && slotIndex != 0) { - ItemStack itemStack = inventory.getStackInSlot(slotIndex - 1); - if (itemStack != null && itemStack.getItemDamage() == 5) isValid = true; - } - - if (!isValid && slotIndex <= 44) { - ItemStack itemStack = inventory.getStackInSlot(slotIndex + 9); - if (itemStack != null && itemStack.getItemDamage() == 5) isValid = true; - } - - if (!isValid && slotIndex >= 9) { - ItemStack itemStack = inventory.getStackInSlot(slotIndex - 9); - if (itemStack != null && itemStack.getItemDamage() == 5) isValid = true; - } - - shouldCancel = !isValid; - - break; case "Click in order!": if (slot.getSlotIndex() > 35) { @@ -87,6 +49,25 @@ public class BlockWrongTerminalClicks { if (needed == 0) break; shouldCancel = needed != -1 && item.stackSize != needed; break; + case "Change all to same color!": + if (SameColourSolver.foundColour) { + shouldCancel = SameColourSolver.getDistance(item.getItemDamage(), SameColourSolver.correctColour) == 0; + } + break; + case "Click the button on time!": + int correctPos = -1; + for (int i = 0; i <= 50; i++) { + ItemStack stack = inventory.getStackInSlot(i); + if (stack == null || stack.getItem() != Item.getItemFromBlock(Blocks.stained_glass_pane)) continue; + + if (stack.getItemDamage() == 10) { + correctPos = i % 9; + } else if (stack.getItemDamage() == 5 && correctPos != -1) { + shouldCancel = i % 9 != correctPos; + break; + } + } + break; } if (!shouldCancel) { diff --git a/src/main/java/me/Danker/features/puzzlesolvers/SameColourSolver.java b/src/main/java/me/Danker/features/puzzlesolvers/SameColourSolver.java new file mode 100644 index 0000000..9b0066b --- /dev/null +++ b/src/main/java/me/Danker/features/puzzlesolvers/SameColourSolver.java @@ -0,0 +1,152 @@ +package me.Danker.features.puzzlesolvers; + +import me.Danker.commands.ToggleCommand; +import me.Danker.events.GuiChestBackgroundDrawnEvent; +import me.Danker.utils.RenderUtils; +import me.Danker.utils.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.apache.commons.lang3.math.NumberUtils; + +import java.util.Arrays; +import java.util.List; + +public class SameColourSolver { + + public static boolean foundColour = false; + public static int correctColour = 0; + static List<Integer> colourLoop = Arrays.asList(14, 1, 4, 13, 11); + + @SubscribeEvent(priority = EventPriority.LOW) + public void onTooltipLow(ItemTooltipEvent event) { + if (!ToggleCommand.sameColourToggled || !Utils.inDungeons) return; + if (event.toolTip == null) return; + + Minecraft mc = Minecraft.getMinecraft(); + EntityPlayerSP player = mc.thePlayer; + + if (mc.currentScreen instanceof GuiChest) { + ContainerChest chest = (ContainerChest) player.openContainer; + IInventory inv = chest.getLowerChestInventory(); + String chestName = inv.getDisplayName().getUnformattedText(); + + if (chestName.equals("Change all to same color!")) { + event.toolTip.clear(); + } + } + } + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent event) { + if (!ToggleCommand.sameColourToggled || foundColour || !Utils.inDungeons) return; + if (event.phase != TickEvent.Phase.START) return; + + Minecraft mc = Minecraft.getMinecraft(); + EntityPlayerSP player = mc.thePlayer; + if (mc.currentScreen instanceof GuiChest) { + if (player == null) return; + ContainerChest chest = (ContainerChest) player.openContainer; + List<Slot> invSlots = ((GuiChest) mc.currentScreen).inventorySlots.inventorySlots; + String chestName = chest.getLowerChestInventory().getDisplayName().getUnformattedText().trim(); + + if (chestName.equals("Change all to same color!")) { + int red = 0; + int orange = 0; + int yellow = 0; + int green = 0; + int blue = 0; + + for (int i = 12; i <= 32; i++) { + ItemStack stack = invSlots.get(i).getStack(); + if (stack == null || stack.getItem() != Item.getItemFromBlock(Blocks.stained_glass_pane)) continue; + if (stack.getItemDamage() == 7) continue; + + switch (stack.getItemDamage()) { + case 1: + orange++; + break; + case 4: + yellow++; + break; + case 11: + blue++; + break; + case 13: + green++; + break; + case 14: + red++; + break; + } + } + + int max = NumberUtils.max(new int[]{red, orange, yellow, green, blue}); + if (max == red) { + correctColour = 14; + } else if (max == orange) { + correctColour = 1; + } else if (max == yellow) { + correctColour = 4; + } else if (max == green) { + correctColour = 13; + } else { + correctColour = 11; + } + foundColour = true; + } + } + } + + @SubscribeEvent + public void onGuiRender(GuiChestBackgroundDrawnEvent event) { + if (!ToggleCommand.sameColourToggled || !foundColour || !Utils.inDungeons) return; + + if (event.displayName.equals("Change all to same color!")) { + int chestSize = event.chestSize; + List<Slot> invSlots = event.slots; + + for (int i = 12; i <= 32; i++) { + Slot slot = invSlots.get(i); + ItemStack stack = slot.getStack(); + if (stack == null || stack.getItem() != Item.getItemFromBlock(Blocks.stained_glass_pane)) continue; + if (stack.getItemDamage() == 7) continue; + + int distance = getDistance(stack.getItemDamage(), correctColour); + if (distance == 0) continue; + + RenderUtils.drawTextOnSlot(chestSize, slot.xDisplayPosition, slot.yDisplayPosition, "" + distance); + } + } + } + + @SubscribeEvent + public void onGuiOpen(GuiOpenEvent event) { + foundColour = false; + correctColour = 0; + } + + public static int getDistance(int colour, int endColour) { + int index = colourLoop.indexOf(colour); + int finalIndex = colourLoop.indexOf(endColour); + if (index == -1 || finalIndex == -1) return 0; + + if (finalIndex < index) { + return finalIndex - index + 5; + } + return finalIndex - index; + } + +} diff --git a/src/main/java/me/Danker/gui/PuzzleSolversGui.java b/src/main/java/me/Danker/gui/PuzzleSolversGui.java index 0cfa72b..2f87630 100644 --- a/src/main/java/me/Danker/gui/PuzzleSolversGui.java +++ b/src/main/java/me/Danker/gui/PuzzleSolversGui.java @@ -28,6 +28,7 @@ public class PuzzleSolversGui extends GuiScreen { private GuiButton startsWith; private GuiButton selectAll; private GuiButton clickOrder; + private GuiButton sameColour; private GuiButton blockClicks; private GuiButton itemFrameOnSeaLanterns; @@ -67,9 +68,10 @@ public class PuzzleSolversGui extends GuiScreen { startsWith = new GuiButton(0, width / 2 - 100, (int) (height * 0.4), "Starts With Letter Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.startsWithToggled)); selectAll = new GuiButton(0, width / 2 - 100, (int) (height * 0.5), "Select All Color Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.selectAllToggled)); clickOrder = new GuiButton(0, width / 2 - 100, (int) (height * 0.6), "Click in Order Terminal Helper: " + Utils.getColouredBoolean(ToggleCommand.clickInOrderToggled)); - blockClicks = new GuiButton(0, width / 2 - 100, (int) (height * 0.7), "Block Wrong Clicks on Terminals: " + Utils.getColouredBoolean(ToggleCommand.blockWrongTerminalClicksToggled)); + sameColour = new GuiButton(0, width / 2 - 100, (int) (height * 0.7), "Same Colour Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.sameColourToggled)); // Page 3 - itemFrameOnSeaLanterns = new GuiButton(0, width / 2 - 100, (int) (height * 0.1), "Ignore Arrows On Sea Lanterns: " + Utils.getColouredBoolean(ToggleCommand.itemFrameOnSeaLanternsToggled)); + blockClicks = new GuiButton(0, width / 2 - 100, (int) (height * 0.1), "Block Wrong Clicks on Terminals: " + Utils.getColouredBoolean(ToggleCommand.blockWrongTerminalClicksToggled)); + itemFrameOnSeaLanterns = new GuiButton(0, width / 2 - 100, (int) (height * 0.2), "Ignore Arrows On Sea Lanterns: " + Utils.getColouredBoolean(ToggleCommand.itemFrameOnSeaLanternsToggled)); switch (page) { case 1: @@ -89,11 +91,12 @@ public class PuzzleSolversGui extends GuiScreen { this.buttonList.add(startsWith); this.buttonList.add(selectAll); this.buttonList.add(clickOrder); - this.buttonList.add(blockClicks); + this.buttonList.add(sameColour); this.buttonList.add(nextPage); this.buttonList.add(backPage); break; case 3: + this.buttonList.add(blockClicks); this.buttonList.add(itemFrameOnSeaLanterns); this.buttonList.add(backPage); } @@ -174,6 +177,10 @@ public class PuzzleSolversGui extends GuiScreen { ToggleCommand.itemFrameOnSeaLanternsToggled = !ToggleCommand.itemFrameOnSeaLanternsToggled; ConfigHandler.writeBooleanConfig("toggles", "IgnoreItemFrameOnSeaLanterns", ToggleCommand.itemFrameOnSeaLanternsToggled); itemFrameOnSeaLanterns.displayString = "Ignore Arrows On Sea Lanterns: " + Utils.getColouredBoolean(ToggleCommand.itemFrameOnSeaLanternsToggled); + } else if (button == sameColour) { + ToggleCommand.sameColourToggled = !ToggleCommand.sameColourToggled; + ConfigHandler.writeBooleanConfig("toggles", "SameColourTerminal", ToggleCommand.sameColourToggled); + sameColour.displayString = "Same Colour Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.sameColourToggled); } } diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index ed28704..14386e4 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -264,6 +264,7 @@ public class ConfigHandler { ToggleCommand.startsWithToggled = initBoolean("toggles", "StartsWithTerminal", false); ToggleCommand.selectAllToggled = initBoolean("toggles", "SelectAllTerminal", false); ToggleCommand.clickInOrderToggled = initBoolean("toggles", "ClickInOrderTerminal", false); + ToggleCommand.sameColourToggled = initBoolean("toggles", "SameColourTerminal", false); ToggleCommand.blockWrongTerminalClicksToggled = initBoolean("toggles", "BlockWrongTerminalClicks", false); ToggleCommand.itemFrameOnSeaLanternsToggled = initBoolean("toggles", "IgnoreItemFrameOnSeaLanterns", false); // Experiment Solvers diff --git a/src/main/java/me/Danker/utils/RenderUtils.java b/src/main/java/me/Danker/utils/RenderUtils.java index 50b9786..b5ede19 100644 --- a/src/main/java/me/Danker/utils/RenderUtils.java +++ b/src/main/java/me/Danker/utils/RenderUtils.java @@ -59,6 +59,22 @@ public class RenderUtils { GL11.glTranslated(0, 0, -1); } + public static void drawTextOnSlot(int size, int xSlotPos, int ySlotPos, String text) { + Minecraft mc = Minecraft.getMinecraft(); + ScaledResolution sr = new ScaledResolution(mc); + int guiLeft = (sr.getScaledWidth() - 176) / 2; + int guiTop = (sr.getScaledHeight() - 222) / 2; + int x = guiLeft + xSlotPos; + int y = guiTop + ySlotPos; + // Move down when chest isn't 6 rows + if (size != 90) y += (6 - (size - 36) / 9) * 9; + + int width = mc.fontRendererObj.getStringWidth(text); + GL11.glTranslated(0, 0, 1); + mc.fontRendererObj.drawString(text, x + 8 - width / 2, y + 5, 0xFFFFFF, true); + GL11.glTranslated(0, 0, -1); + } + public static void draw3DLine(Vec3 pos1, Vec3 pos2, int colourInt, int lineWidth, boolean depth, float partialTicks) { Entity render = Minecraft.getMinecraft().getRenderViewEntity(); WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer(); |