From 68646a34ea9080228dfe437fedcec84a41c1fd6d Mon Sep 17 00:00:00 2001 From: bowser0000 Date: Thu, 19 Nov 2020 12:05:38 -0500 Subject: Add water puzzle solver, bug fixes Update trivia solutions Limit skills from achievement API to 50 Fix typo in puzzle solvers GUI --- src/main/java/me/Danker/TheMod.java | 131 +++++++++++++++++++-- src/main/java/me/Danker/commands/DHelpCommand.java | 2 +- .../java/me/Danker/commands/SkillsCommand.java | 14 +-- .../java/me/Danker/commands/ToggleCommand.java | 13 +- src/main/java/me/Danker/gui/PuzzleSolversGui.java | 9 +- .../java/me/Danker/handlers/ConfigHandler.java | 2 + 6 files changed, 148 insertions(+), 23 deletions(-) (limited to 'src/main') diff --git a/src/main/java/me/Danker/TheMod.java b/src/main/java/me/Danker/TheMod.java index bed2b69..56dd272 100644 --- a/src/main/java/me/Danker/TheMod.java +++ b/src/main/java/me/Danker/TheMod.java @@ -78,6 +78,7 @@ import net.minecraft.util.IChatComponent; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StringUtils; import net.minecraft.util.Vec3; +import net.minecraft.world.World; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.GuiScreenEvent; @@ -136,10 +137,12 @@ public class TheMod static Entity highestBlaze = null; static Entity lowestBlaze = null; // Among Us colours - static int[] creeperLineColours = {0x50EF39, 0xC51111, 0x132ED1, 0x117F2D, 0xED54BA, 0xEF7D0D, 0xF5F557, 0xD6E0F0, 0x6B2FBB, 0x39FEDC}; + static final int[] CREEPER_COLOURS = {0x50EF39, 0xC51111, 0x132ED1, 0x117F2D, 0xED54BA, 0xEF7D0D, 0xF5F557, 0xD6E0F0, 0x6B2FBB, 0x39FEDC}; static boolean drawCreeperLines = false; static Vec3 creeperLocation = new Vec3(0, 0, 0); static List creeperLines = new ArrayList(); + static boolean prevInWaterRoom = false; + static boolean inWaterRoom = false; static boolean foundLivid = false; static Entity livid = null; public static double cakeTime; @@ -242,7 +245,7 @@ public class TheMod triviaSolutions.put("How many unique minions are there?", new String[]{"52 Minions"}); triviaSolutions.put("Which of these enemies does not spawn in the Spider's Den?", new String[]{"Zombie Spider", "Cave Spider", "Wither Skeleton", "Dashing Spooder", "Broodfather", "Night Spider"}); triviaSolutions.put("Which of these monsters only spawns at night?", new String[]{"Zombie Villager", "Ghast"}); - triviaSolutions.put("Which of these is not a dragon in The End?", new String[]{"Zoomer Dragon", "Weak Dragon", "Stonk Dragon", "Holy Dragon", "Boomer Dragon", "Booger Dragon", "Older Dragon"}); + triviaSolutions.put("Which of these is not a dragon in The End?", new String[]{"Zoomer Dragon", "Weak Dragon", "Stonk Dragon", "Holy Dragon", "Boomer Dragon", "Booger Dragon", "Older Dragon", "Elder Dragon"}); String patternString = "(" + String.join("|", t6Enchants.keySet()) + ")"; pattern = Pattern.compile(patternString); @@ -1930,6 +1933,7 @@ public class TheMod @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { Minecraft mc = Minecraft.getMinecraft(); + World world = mc.theWorld; EntityPlayerSP player = mc.thePlayer; // Checks every second @@ -1940,7 +1944,7 @@ public class TheMod Utils.checkForDungeons(); } - if (DisplayCommand.auto && mc != null && mc.theWorld != null) { + if (DisplayCommand.auto && mc != null && world != null) { List scoreboard = ScoreboardHandler.getSidebarLines(); boolean found = false; for (String s : scoreboard) { @@ -1975,13 +1979,13 @@ public class TheMod ConfigHandler.writeStringConfig("misc", "display", DisplayCommand.display); } - if (ToggleCommand.creeperToggled && Utils.inDungeons && mc.theWorld != null) { + if (ToggleCommand.creeperToggled && Utils.inDungeons && world != null) { double x = player.posX; double y = player.posY; double z = player.posZ; // Find creepers nearby AxisAlignedBB creeperScan = new AxisAlignedBB(x - 14, y - 8, z - 13, x + 14, y + 8, z + 13); // 28x16x26 cube - List creepers = mc.theWorld.getEntitiesWithinAABB(EntityCreeper.class, creeperScan); + List creepers = world.getEntitiesWithinAABB(EntityCreeper.class, creeperScan); // Check if creeper is nearby if (creepers.size() > 0) { EntityCreeper creeper = creepers.get(0); @@ -1994,7 +1998,7 @@ public class TheMod BlockPos point2 = new BlockPos(creeper.posX + 14, creeper.posY + 10, creeper.posZ + 13); Iterable blocks = BlockPos.getAllInBox(point1, point2); for (BlockPos blockPos : blocks) { - Block block = mc.theWorld.getBlockState(blockPos).getBlock(); + Block block = world.getBlockState(blockPos).getBlock(); if (block == Blocks.sea_lantern || block == Blocks.prismarine) { // Connect block to nearest block on opposite side Vec3 startBlock = new Vec3(blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5); @@ -2012,7 +2016,112 @@ public class TheMod } } - if (ToggleCommand.lividSolverToggled && Utils.inDungeons && !foundLivid && mc.theWorld != null) { + if (ToggleCommand.waterToggled && Utils.inDungeons && world != null) { + // multi thread block checking + new Thread(() -> { + prevInWaterRoom = inWaterRoom; + inWaterRoom = false; + boolean done = false; + for (int x = (int) (player.posX - 25); x < player.posX + 25; x++) { + for (int z = (int) (player.posZ - 25); z < player.posZ + 25; z++) { + BlockPos blockPos = new BlockPos(x, 82, z); + if (world.getBlockState(blockPos).getBlock() == Blocks.piston_head) { + inWaterRoom = true; + if (!prevInWaterRoom && inWaterRoom) { + boolean foundGold = false; + boolean foundClay = false; + boolean foundEmerald = false; + boolean foundQuartz = false; + boolean foundDiamond = false; + + // Detect first blocks near water stream + BlockPos scan1 = new BlockPos(x + 1, 78, z + 1); + BlockPos scan2 = new BlockPos(x - 1, 77, z - 1); + Iterable blocks = BlockPos.getAllInBox(scan1, scan2); + for (BlockPos puzzleBlockPos : blocks) { + Block block = world.getBlockState(puzzleBlockPos).getBlock(); + if (block == Blocks.gold_block) { + foundGold = true; + } else if (block == Blocks.hardened_clay) { + foundClay = true; + } else if (block == Blocks.emerald_block) { + foundEmerald = true; + } else if (block == Blocks.quartz_block) { + foundQuartz = true; + } else if (block == Blocks.diamond_block) { + foundDiamond = true; + } + } + + int variant = 0; + if (foundGold && foundClay) { + variant = 1; + } else if (foundEmerald && foundQuartz) { + variant = 2; + } else if (foundQuartz && foundDiamond) { + variant = 3; + } else if (foundGold && foundQuartz) { + variant = 4; + } + + // Return solution + String purple = ""; + String orange = ""; + String blue = ""; + String green = ""; + String red = ""; + switch (variant) { + case 1: + purple = EnumChatFormatting.WHITE + "Quartz, " + EnumChatFormatting.YELLOW + "Gold, " + EnumChatFormatting.AQUA + "Diamond, " + EnumChatFormatting.RED + "Clay"; + orange = EnumChatFormatting.YELLOW + "Gold, " + EnumChatFormatting.DARK_GRAY + "Coal, " + EnumChatFormatting.GREEN + "Emerald"; + blue = EnumChatFormatting.WHITE + "Quartz, " + EnumChatFormatting.YELLOW + "Gold, " + EnumChatFormatting.GREEN + "Emerald" + EnumChatFormatting.RED + "Clay"; + green = EnumChatFormatting.GREEN + "Emerald"; + red = EnumChatFormatting.GRAY + "None"; + break; + case 2: + purple = EnumChatFormatting.DARK_GRAY + "Coal"; + orange = EnumChatFormatting.WHITE + "Quartz, " + EnumChatFormatting.YELLOW + "Gold, " + EnumChatFormatting.GREEN + "Emerald, " + EnumChatFormatting.RED + "Clay"; + blue = EnumChatFormatting.WHITE + "Quartz, " + EnumChatFormatting.AQUA + "Diamond, " + EnumChatFormatting.GREEN + "Emerald"; + green = EnumChatFormatting.WHITE + "Quartz, " + EnumChatFormatting.GREEN + "Emerald"; + red = EnumChatFormatting.WHITE + "Quartz, " + EnumChatFormatting.DARK_GRAY + "Coal, " + EnumChatFormatting.GREEN + "Emerald"; + break; + case 3: + purple = EnumChatFormatting.WHITE + "Quartz, " + EnumChatFormatting.AQUA + "Diamond"; + orange = EnumChatFormatting.YELLOW + "Gold, " + EnumChatFormatting.GREEN + "Emerald"; + blue = EnumChatFormatting.WHITE + "Quartz, " + EnumChatFormatting.YELLOW + "Gold, " + EnumChatFormatting.AQUA + "Diamond"; + green = EnumChatFormatting.YELLOW + "Gold"; + red = EnumChatFormatting.GREEN + "Emerald"; + break; + case 4: + purple = EnumChatFormatting.WHITE + "Quartz, " + EnumChatFormatting.YELLOW + "Gold, " + EnumChatFormatting.GREEN + "Emerald, " + EnumChatFormatting.RED + "Clay"; + orange = EnumChatFormatting.YELLOW + "Gold, " + EnumChatFormatting.DARK_GRAY + "Coal"; + blue = EnumChatFormatting.WHITE + "Quartz, " + EnumChatFormatting.YELLOW + "Gold, " + EnumChatFormatting.DARK_GRAY + "Coal, " + EnumChatFormatting.GREEN + "Emerald, " + EnumChatFormatting.RED + "Clay"; + green = EnumChatFormatting.YELLOW + "Gold, " + EnumChatFormatting.GREEN + "Emerald"; + red = EnumChatFormatting.YELLOW + "Gold, " + EnumChatFormatting.AQUA + "Diamond, " + EnumChatFormatting.GREEN + "Emerald, " + EnumChatFormatting.RED + "Clay"; + break; + default: + player.addChatMessage(new ChatComponentText(ERROR_COLOUR + "Error detecting water puzzle variant.")); + break; + } + player.addChatMessage(new ChatComponentText(DELIMITER_COLOUR + EnumChatFormatting.BOLD + "-------------------\n" + + MAIN_COLOUR + " The following levers must be down:\n " + + EnumChatFormatting.DARK_PURPLE + "Purple: " + purple + "\n " + + EnumChatFormatting.GOLD + "Orange: " + orange + "\n " + + EnumChatFormatting.BLUE + "Blue: " + blue + "\n " + + EnumChatFormatting.GREEN + "Green: " + green + "\n " + + EnumChatFormatting.RED + "Red: " + red + "\n" + + DELIMITER_COLOUR + EnumChatFormatting.BOLD + " -------------------")); + done = true; + break; + } + } + } + if (done) break; + } + }).start(); + } + + if (ToggleCommand.lividSolverToggled && Utils.inDungeons && !foundLivid && world != null) { boolean inF5 = false; List scoreboard = ScoreboardHandler.getSidebarLines(); @@ -2026,7 +2135,7 @@ public class TheMod if (inF5) { List loadedLivids = new ArrayList(); - List entities = mc.theWorld.getLoadedEntityList(); + List entities = world.getLoadedEntityList(); for (Entity entity : entities) { String name = entity.getName(); if (name.contains("Livid") && name.length() > 5 && name.charAt(1) == name.charAt(5) && !loadedLivids.contains(entity)) { @@ -2045,8 +2154,8 @@ public class TheMod // Checks 5 times per second if (tickAmount % 4 == 0) { - if (ToggleCommand.blazeToggled && Utils.inDungeons && mc.theWorld != null) { - List entities = mc.theWorld.getLoadedEntityList(); + if (ToggleCommand.blazeToggled && Utils.inDungeons && world != null) { + List entities = world.getLoadedEntityList(); int highestHealth = 0; highestBlaze = null; int lowestHealth = 99999999; @@ -2126,7 +2235,7 @@ public class TheMod } if (ToggleCommand.creeperToggled && drawCreeperLines && !creeperLines.isEmpty()) { for (int i = 0; i < creeperLines.size(); i++) { - Utils.draw3DLine(creeperLines.get(i)[0], creeperLines.get(i)[1], creeperLineColours[i % 10], event.partialTicks); + Utils.draw3DLine(creeperLines.get(i)[0], creeperLines.get(i)[1], CREEPER_COLOURS[i % 10], event.partialTicks); } } } diff --git a/src/main/java/me/Danker/commands/DHelpCommand.java b/src/main/java/me/Danker/commands/DHelpCommand.java index abbc3c8..b3bdbbf 100644 --- a/src/main/java/me/Danker/commands/DHelpCommand.java +++ b/src/main/java/me/Danker/commands/DHelpCommand.java @@ -34,7 +34,7 @@ public class DHelpCommand extends CommandBase { EnumChatFormatting.GOLD + " Commands, " + EnumChatFormatting.GREEN + " Keybinds.\n" + EnumChatFormatting.GOLD + " /dhelp" + EnumChatFormatting.AQUA + " - Returns this message.\n" + EnumChatFormatting.GOLD + " /dsm" + EnumChatFormatting.AQUA + " - Opens the GUI for Danker's Skyblock Mod.\n" + - EnumChatFormatting.GOLD + " /toggle " + EnumChatFormatting.AQUA + " - Toggles features. /toggle list returns values of every toggle.\n" + + EnumChatFormatting.GOLD + " /toggle " + EnumChatFormatting.AQUA + " - Toggles features. /toggle list returns values of every toggle.\n" + EnumChatFormatting.GOLD + " /setkey " + EnumChatFormatting.AQUA + " - Sets API key.\n" + EnumChatFormatting.GOLD + " /getkey" + EnumChatFormatting.AQUA + " - Returns key set with /setkey and copies it to your clipboard.\n" + EnumChatFormatting.GOLD + " /loot [winter/festival/spooky/f(1-6)/session]" + EnumChatFormatting.AQUA + " - Returns loot received from slayer quests or fishing stats. /loot fishing winter returns winter sea creatures instead.\n" + diff --git a/src/main/java/me/Danker/commands/SkillsCommand.java b/src/main/java/me/Danker/commands/SkillsCommand.java index 7405a84..12bfd93 100644 --- a/src/main/java/me/Danker/commands/SkillsCommand.java +++ b/src/main/java/me/Danker/commands/SkillsCommand.java @@ -144,25 +144,25 @@ public class SkillsCommand extends CommandBase { farmingLevel = achievementObject.get("skyblock_harvester").getAsInt(); } if (achievementObject.has("skyblock_excavator")) { - miningLevel = achievementObject.get("skyblock_excavator").getAsInt(); + miningLevel = Math.min(achievementObject.get("skyblock_excavator").getAsInt(), 50); } if (achievementObject.has("skyblock_combat")) { - combatLevel = achievementObject.get("skyblock_combat").getAsInt(); + combatLevel = Math.min(achievementObject.get("skyblock_combat").getAsInt(), 50); } if (achievementObject.has("skyblock_gatherer")) { - foragingLevel = achievementObject.get("skyblock_gatherer").getAsInt(); + foragingLevel = Math.min(achievementObject.get("skyblock_gatherer").getAsInt(), 50); } if (achievementObject.has("skyblock_angler")) { - fishingLevel = achievementObject.get("skyblock_angler").getAsInt(); + fishingLevel = Math.min(achievementObject.get("skyblock_angler").getAsInt(), 50); } if (achievementObject.has("skyblock_augmentation")) { - enchantingLevel = achievementObject.get("skyblock_augmentation").getAsInt(); + enchantingLevel = Math.min(achievementObject.get("skyblock_augmentation").getAsInt(), 50); } if (achievementObject.has("skyblock_concoctor")) { - alchemyLevel = achievementObject.get("skyblock_concoctor").getAsInt(); + alchemyLevel = Math.min(achievementObject.get("skyblock_concoctor").getAsInt(), 50); } if (achievementObject.has("skyblock_domesticator")) { - tamingLevel = achievementObject.get("skyblock_domesticator").getAsInt(); + tamingLevel = Math.min(achievementObject.get("skyblock_domesticator").getAsInt(), 50); } } diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java index 25b3ff3..df39af6 100644 --- a/src/main/java/me/Danker/commands/ToggleCommand.java +++ b/src/main/java/me/Danker/commands/ToggleCommand.java @@ -41,6 +41,7 @@ public class ToggleCommand extends CommandBase implements ICommand { public static boolean oruoToggled; public static boolean blazeToggled; public static boolean creeperToggled; + public static boolean waterToggled; @Override public String getCommandName() { @@ -51,7 +52,8 @@ public class ToggleCommand extends CommandBase implements ICommand { public String getCommandUsage(ICommandSender arg0) { return "/" + getCommandName() + " "; + "outlinetext/midasstaffmessages/healmessages/caketimer/lividsolver/threemanpuzzle/oruopuzzle/" + + "blazepuzzle/creeperpuzzle/waterpuzzle/list>"; } @Override @@ -67,7 +69,7 @@ public class ToggleCommand extends CommandBase implements ICommand { "sceptremessages", "petcolors", "dungeontimer", "golemalerts", "expertiselore", "skill50display", "outlinetext", "midasstaffmessages", "healmessages", "caketimer", "lividsolver", "threemanpuzzle", "oruopuzzle", - "blazepuzzle", "creeperpuzzle", "list"); + "blazepuzzle", "creeperpuzzle", "waterpuzzle", "list"); } return null; } @@ -182,6 +184,10 @@ public class ToggleCommand extends CommandBase implements ICommand { creeperToggled = !creeperToggled; cf.writeBooleanConfig("creeperpuzzle", "CreeperPuzzle", creeperToggled); player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Creeper puzzle solver has been set to " + TheMod.SECONDARY_COLOUR + creeperToggled + TheMod.MAIN_COLOUR + ".")); + } else if (arg1[0].equalsIgnoreCase("waterpuzzle")) { + waterToggled = !waterToggled; + cf.writeBooleanConfig("waterpuzzle", "WaterPuzzle", waterToggled); + player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Water puzzle solver has been set to " + TheMod.SECONDARY_COLOUR + waterToggled + TheMod.MAIN_COLOUR + ".")); } else if (arg1[0].equalsIgnoreCase("list")) { player.addChatMessage(new ChatComponentText(TheMod.TYPE_COLOUR + "Guild party notifications: " + TheMod.VALUE_COLOUR + gpartyToggled + "\n" + TheMod.TYPE_COLOUR + " Coord/Angle display: " + TheMod.VALUE_COLOUR + coordsToggled + "\n" + @@ -207,7 +213,8 @@ public class ToggleCommand extends CommandBase implements ICommand { TheMod.TYPE_COLOUR + " Three man puzzle solver: " + TheMod.VALUE_COLOUR + threeManToggled + "\n" + TheMod.TYPE_COLOUR + " Oruo trivia solver: " + TheMod.VALUE_COLOUR + oruoToggled + "\n" + TheMod.TYPE_COLOUR + " Blaze puzzle solver: " + TheMod.VALUE_COLOUR + blazeToggled + "\n" + - TheMod.TYPE_COLOUR + " Creeper puzzle solver: " + TheMod.VALUE_COLOUR + creeperToggled)); + TheMod.TYPE_COLOUR + " Creeper puzzle solver: " + TheMod.VALUE_COLOUR + creeperToggled + "\n" + + TheMod.TYPE_COLOUR + " Water puzzle solver: " + TheMod.VALUE_COLOUR + waterToggled)); } else { player.addChatMessage(new ChatComponentText(TheMod.ERROR_COLOUR + "Usage: " + getCommandUsage(arg0))); } diff --git a/src/main/java/me/Danker/gui/PuzzleSolversGui.java b/src/main/java/me/Danker/gui/PuzzleSolversGui.java index e2fa4ef..4ae97bb 100644 --- a/src/main/java/me/Danker/gui/PuzzleSolversGui.java +++ b/src/main/java/me/Danker/gui/PuzzleSolversGui.java @@ -16,6 +16,7 @@ public class PuzzleSolversGui extends GuiScreen { private GuiButton trivia; private GuiButton blaze; private GuiButton creeper; + private GuiButton water; @Override public boolean doesGuiPauseGame() { @@ -34,13 +35,15 @@ public class PuzzleSolversGui extends GuiScreen { riddle = new GuiButton(0, width / 2 - 100, (int) (height * 0.1), "Riddle Solver: " + Utils.getColouredBoolean(ToggleCommand.threeManToggled)); trivia = new GuiButton(0, width / 2 - 100, (int) (height * 0.2), "Trivia Solver: " + Utils.getColouredBoolean(ToggleCommand.oruoToggled)); blaze = new GuiButton(0, width / 2 - 100, (int) (height * 0.3), "Blaze Solver: " + Utils.getColouredBoolean(ToggleCommand.blazeToggled)); - creeper = new GuiButton(0, width / 2 - 100, (int) (height * 0.4), "Creeper Solver : " + Utils.getColouredBoolean(ToggleCommand.creeperToggled)); + creeper = new GuiButton(0, width / 2 - 100, (int) (height * 0.4), "Creeper Solver: " + Utils.getColouredBoolean(ToggleCommand.creeperToggled)); + water = new GuiButton(0, width / 2 - 100, (int) (height * 0.5), "Water Solver: " + Utils.getColouredBoolean(ToggleCommand.waterToggled)); this.buttonList.add(goBack); this.buttonList.add(riddle); this.buttonList.add(trivia); this.buttonList.add(blaze); this.buttonList.add(creeper); + this.buttonList.add(water); } @Override @@ -69,6 +72,10 @@ public class PuzzleSolversGui extends GuiScreen { ToggleCommand.creeperToggled = !ToggleCommand.creeperToggled; ConfigHandler.writeBooleanConfig("toggles", "CreeperPuzzle", ToggleCommand.creeperToggled); creeper.displayString = "Creeper Solver: " + Utils.getColouredBoolean(ToggleCommand.creeperToggled); + } else if (button == water) { + ToggleCommand.waterToggled = !ToggleCommand.waterToggled; + ConfigHandler.writeBooleanConfig("toggles", "WaterPuzzle", ToggleCommand.waterToggled); + water.displayString = "Water Solver: " + Utils.getColouredBoolean(ToggleCommand.waterToggled); } } diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index 131076d..408849c 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -199,6 +199,7 @@ public class ConfigHandler { if (!hasKey("toggles", "OruoPuzzle")) writeBooleanConfig("toggles", "OruoPuzzle", false); if (!hasKey("toggles", "BlazePuzzle")) writeBooleanConfig("toggles", "BlazePuzzle", false); if (!hasKey("toggles", "CreeperPuzzle")) writeBooleanConfig("toggles", "CreeperPuzzle", false); + if (!hasKey("toggles", "WaterPuzzle")) writeBooleanConfig("toggles", "WaterPuzzle", false); if (!hasKey("api", "APIKey")) writeStringConfig("api", "APIKey", ""); @@ -400,6 +401,7 @@ public class ConfigHandler { tf.oruoToggled = getBoolean("toggles", "OruoPuzzle"); tf.blazeToggled = getBoolean("toggles", "BlazePuzzle"); tf.creeperToggled = getBoolean("toggles", "CreeperPuzzle"); + tf.waterToggled = getBoolean("toggles", "WaterPuzzle"); final BlockSlayerCommand bs = new BlockSlayerCommand(); String onlySlayer = getString("toggles", "BlockSlayer"); -- cgit