aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2021-03-09 23:55:43 -0500
committerbowser0000 <bowser0000@gmail.com>2021-03-09 23:55:43 -0500
commitec35b6f8d7583f9c92eb212bfe4cf8d2206fc403 (patch)
tree83530782f1e3c3ab10f49faf291ed1ffe896b609 /src/main/java
parente7237307e71c649b4b7c880259ff1781fcc7c435 (diff)
downloadSkyblockMod-ec35b6f8d7583f9c92eb212bfe4cf8d2206fc403.tar.gz
SkyblockMod-ec35b6f8d7583f9c92eb212bfe4cf8d2206fc403.tar.bz2
SkyblockMod-ec35b6f8d7583f9c92eb212bfe4cf8d2206fc403.zip
Add silverfish puzzle solver
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/me/Danker/DankersSkyblockMod.java3
-rw-r--r--src/main/java/me/Danker/commands/DHelpCommand.java2
-rw-r--r--src/main/java/me/Danker/commands/DankerGuiCommand.java1
-rw-r--r--src/main/java/me/Danker/commands/ToggleCommand.java26
-rw-r--r--src/main/java/me/Danker/features/puzzlesolvers/SilverfishSolver.java183
-rw-r--r--src/main/java/me/Danker/gui/PuzzleSolversGui.java17
-rw-r--r--src/main/java/me/Danker/handlers/ConfigHandler.java4
-rw-r--r--src/main/java/me/Danker/utils/SilverfishUtils.java104
8 files changed, 324 insertions, 16 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java
index 0920520..dbb79dc 100644
--- a/src/main/java/me/Danker/DankersSkyblockMod.java
+++ b/src/main/java/me/Danker/DankersSkyblockMod.java
@@ -59,7 +59,7 @@ import java.util.Map;
@Mod(modid = DankersSkyblockMod.MODID, version = DankersSkyblockMod.VERSION, clientSideOnly = true)
public class DankersSkyblockMod {
public static final String MODID = "Danker's Skyblock Mod";
- public static final String VERSION = "1.8.6-beta1";
+ public static final String VERSION = "1.8.6-beta2";
public static int titleTimer = -1;
public static boolean showTitle = false;
public static String titleText = "";
@@ -114,6 +114,7 @@ public class DankersSkyblockMod {
MinecraftForge.EVENT_BUS.register(new PetColours());
MinecraftForge.EVENT_BUS.register(new Reparty());
MinecraftForge.EVENT_BUS.register(new SelectAllColourSolver());
+ MinecraftForge.EVENT_BUS.register(new SilverfishSolver());
MinecraftForge.EVENT_BUS.register(new Skill50Display());
MinecraftForge.EVENT_BUS.register(new SkillTracker());
MinecraftForge.EVENT_BUS.register(new SpamHider());
diff --git a/src/main/java/me/Danker/commands/DHelpCommand.java b/src/main/java/me/Danker/commands/DHelpCommand.java
index 6272a60..71e2414 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 <gparty/coords/golden/slayercount/rngesusalerts/splitfishing/chatmaddox/spiritbearalerts/aotd/lividdagger/flowerweapons/sceptremessages/midasstaffmessages/implosionmessages/healmessages/petcolors/dungeontimer/golemalerts/expertiselore/skill50display/outlinetext/caketimer/lowhealthnotify/lividsolver/stopsalvagestarred/notifyslayerslain/autoskilltracker/necronnotifications/bonzotimer/threemanpuzzle/oruopuzzle/blazepuzzle/creeperpuzzle/waterpuzzle/tictactoepuzzle/boulderpuzzle/watchermessage/startswithterminal/selectallterminal/clickinorderterminal/blockwrongterminalclicks/itemframeonsealanterns/ultrasequencer/chronomatron/superpairs/hidetooltipsinaddons/pickblock/list>" + EnumChatFormatting.AQUA + " - Toggles features. /toggle list returns values of every toggle.\n" +
+ EnumChatFormatting.GOLD + " /toggle <gparty/coords/golden/slayercount/rngesusalerts/splitfishing/chatmaddox/spiritbearalerts/aotd/lividdagger/flowerweapons/sceptremessages/midasstaffmessages/implosionmessages/healmessages/petcolors/dungeontimer/golemalerts/expertiselore/skill50display/outlinetext/caketimer/lowhealthnotify/lividsolver/stopsalvagestarred/notifyslayerslain/autoskilltracker/necronnotifications/bonzotimer/threemanpuzzle/oruopuzzle/blazepuzzle/creeperpuzzle/waterpuzzle/tictactoepuzzle/boulderpuzzle/silverfishpuzzle/watchermessage/startswithterminal/selectallterminal/clickinorderterminal/blockwrongterminalclicks/itemframeonsealanterns/ultrasequencer/chronomatron/superpairs/hidetooltipsinaddons/pickblock/list>" + EnumChatFormatting.AQUA + " - Toggles features. /toggle list returns values of every toggle.\n" +
EnumChatFormatting.GOLD + " /setkey <key>" + 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 <zombie/spider/wolf/fishing/catacombs/mythological/> [winter/festival/spooky/f(1-7)/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/DankerGuiCommand.java b/src/main/java/me/Danker/commands/DankerGuiCommand.java
index 9ba86da..dddc662 100644
--- a/src/main/java/me/Danker/commands/DankerGuiCommand.java
+++ b/src/main/java/me/Danker/commands/DankerGuiCommand.java
@@ -73,6 +73,7 @@ public class DankerGuiCommand extends CommandBase {
debug.append("[waterpuzzle][").append(ToggleCommand.waterToggled).append("]\n");
debug.append("[tictactoepuzzle][").append(ToggleCommand.ticTacToeToggled).append("]\n");
debug.append("[boulderpuzzle][").append(ToggleCommand.boulderToggled).append("]\n");
+ debug.append("[silverfishpuzzle][").append(ToggleCommand.silverfishToggled).append("]\n");
debug.append("[watchermessage][").append(ToggleCommand.watcherReadyToggled).append("]\n");
debug.append("[startswithterminal][").append(ToggleCommand.startsWithToggled).append("]\n");
debug.append("[selectallterminal][").append(ToggleCommand.selectAllToggled).append("]\n");
diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java
index 77dc82e..a69457f 100644
--- a/src/main/java/me/Danker/commands/ToggleCommand.java
+++ b/src/main/java/me/Danker/commands/ToggleCommand.java
@@ -56,6 +56,7 @@ public class ToggleCommand extends CommandBase implements ICommand {
public static boolean waterToggled;
public static boolean ticTacToeToggled;
public static boolean boulderToggled;
+ public static boolean silverfishToggled;
// Terminal Helpers
public static boolean startsWithToggled;
public static boolean selectAllToggled;
@@ -81,9 +82,9 @@ public class ToggleCommand extends CommandBase implements ICommand {
"skill50display/outlinetext/midasstaffmessages/implosionmessages/healmessages/cooldownmessages/" +
"manamessages/caketimer/lowhealthnotify/lividsolver/stopsalvagestarred/notifyslayerslain/" +
"necronnotifications/bonzotimer/threemanpuzzle/oruopuzzle/blazepuzzle/creeperpuzzle/waterpuzzle/" +
- "tictactoepuzzle/boulderpuzzle/watchermessage/startswithterminal/selectallterminal/" +
- "clickinorderterminal/blockwrongterminalclicks/itemframeonsealanterns/ultrasequencer/" +
- "chronomatron/superpairs/hidetooltipsinaddons/pickblock/list>";
+ "tictactoepuzzle/boulderpuzzle/silverfishpuzzle/watchermessage/startswithterminal/" +
+ "selectallterminal/clickinorderterminal/blockwrongterminalclicks/itemframeonsealanterns/" +
+ "ultrasequencer/chronomatron/superpairs/hidetooltipsinaddons/pickblock/list>";
}
@Override
@@ -98,12 +99,15 @@ public class ToggleCommand extends CommandBase implements ICommand {
"splitfishing", "chatmaddox", "spiritbearalerts", "aotd", "lividdagger",
"flowerweapons", "sceptremessages", "petcolors", "dungeontimer", "golemalerts",
"expertiselore", "skill50display", "outlinetext", "midasstaffmessages",
- "implosionmessages", "healmessages", "cooldownmessages", "manamessages", "caketimer", "lowhealthnotify", "autoskilltracker",
- "lividsolver", "stopsalvagestarred", "notifyslayerslain", "necronnotifications",
+ "implosionmessages", "healmessages", "cooldownmessages", "manamessages",
+ "caketimer", "lowhealthnotify", "autoskilltracker", "lividsolver",
+ "stopsalvagestarred", "notifyslayerslain", "necronnotifications",
"bonzotimer", "threemanpuzzle", "oruopuzzle", "blazepuzzle",
- "creeperpuzzle", "waterpuzzle", "tictactoepuzzle", "watchermessage", "startswithterminal",
- "selectallterminal", "clickinorderterminal", "blockwrongterminalclicks", "itemframeonsealanterns", "ultrasequencer",
- "chronomatron", "superpairs", "hidetooltipsinaddons", "pickblock", "list");
+ "creeperpuzzle", "waterpuzzle", "tictactoepuzzle", "boulderpuzzle",
+ "silverfishpuzzle", "watchermessage", "startswithterminal",
+ "selectallterminal", "clickinorderterminal", "blockwrongterminalclicks",
+ "itemframeonsealanterns", "ultrasequencer", "chronomatron", "superpairs",
+ "hidetooltipsinaddons", "pickblock", "list");
}
return null;
}
@@ -309,6 +313,11 @@ public class ToggleCommand extends CommandBase implements ICommand {
ConfigHandler.writeBooleanConfig("toggles", "BoulderPuzzle", boulderToggled);
player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Boulder puzzle solver has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + boulderToggled + DankersSkyblockMod.MAIN_COLOUR + "."));
break;
+ case "silverfishpuzzle":
+ silverfishToggled = !silverfishToggled;
+ ConfigHandler.writeBooleanConfig("toggles", "SilverfishPuzzle", silverfishToggled);
+ player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Silverfish puzzle solver has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + silverfishToggled + DankersSkyblockMod.MAIN_COLOUR + "."));
+ break;
case "watchermessage":
watcherReadyToggled = !watcherReadyToggled;
ConfigHandler.writeBooleanConfig("toggles", "WatcherReadyMessage", watcherReadyToggled);
@@ -399,6 +408,7 @@ public class ToggleCommand extends CommandBase implements ICommand {
DankersSkyblockMod.TYPE_COLOUR + " Water puzzle solver: " + DankersSkyblockMod.VALUE_COLOUR + waterToggled + "\n" +
DankersSkyblockMod.TYPE_COLOUR + " Tic tac toe puzzle solver: " + DankersSkyblockMod.VALUE_COLOUR + ticTacToeToggled + "\n" +
DankersSkyblockMod.TYPE_COLOUR + " Boulder puzzle solver: " + DankersSkyblockMod.VALUE_COLOUR + boulderToggled + "\n" +
+ DankersSkyblockMod.TYPE_COLOUR + " Silverfish puzzle solver: " + DankersSkyblockMod.VALUE_COLOUR + silverfishToggled + "\n" +
DankersSkyblockMod.TYPE_COLOUR + " Watcher ready message: " + DankersSkyblockMod.VALUE_COLOUR + watcherReadyToggled + "\n" +
DankersSkyblockMod.TYPE_COLOUR + " Starts with letter terminal solver: " + DankersSkyblockMod.VALUE_COLOUR + startsWithToggled + "\n" +
DankersSkyblockMod.TYPE_COLOUR + " Select all color items terminal solver: " + DankersSkyblockMod.VALUE_COLOUR + selectAllToggled + "\n" +
diff --git a/src/main/java/me/Danker/features/puzzlesolvers/SilverfishSolver.java b/src/main/java/me/Danker/features/puzzlesolvers/SilverfishSolver.java
new file mode 100644
index 0000000..c07524d
--- /dev/null
+++ b/src/main/java/me/Danker/features/puzzlesolvers/SilverfishSolver.java
@@ -0,0 +1,183 @@
+package me.Danker.features.puzzlesolvers;
+
+import me.Danker.DankersSkyblockMod;
+import me.Danker.commands.ToggleCommand;
+import me.Danker.utils.SilverfishUtils;
+import me.Danker.utils.Utils;
+import net.minecraft.block.BlockHopper;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.monster.EntitySilverfish;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.*;
+import net.minecraft.world.World;
+import net.minecraftforge.client.event.RenderWorldLastEvent;
+import net.minecraftforge.event.world.WorldEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class SilverfishSolver {
+
+ static boolean prevInSilverfishRoom = false;
+ static boolean inSilverfishRoom = false;
+ static BlockPos chest = null;
+ static EnumFacing silverfishRoomDirection = null;
+ static List<SilverfishUtils.Point> route = new ArrayList<>();
+ public static int SILVERFISH_LINE_COLOUR;
+
+ @SubscribeEvent
+ public void onWorldChange(WorldEvent.Load event) {
+ reset();
+ }
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ if (event.phase != TickEvent.Phase.START) return;
+
+ Minecraft mc = Minecraft.getMinecraft();
+ World world = mc.theWorld;
+ EntityPlayerSP player = mc.thePlayer;
+ if (DankersSkyblockMod.tickAmount % 20 == 0) {
+ if (ToggleCommand.silverfishToggled && Utils.inDungeons && world != null && player != null) {
+ new Thread(() -> {
+ boolean foundRoom = false;
+ prevInSilverfishRoom = inSilverfishRoom;
+ double x = player.posX;
+ double z = player.posZ;
+ // Find creepers nearby
+ AxisAlignedBB entityScan = new AxisAlignedBB(x - 25, 67, z - 25, x + 25, 68, z + 25); // 50x1x50
+ List<EntitySilverfish> silverfishes = world.getEntitiesWithinAABB(EntitySilverfish.class, entityScan);
+ List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, entityScan);
+ if (silverfishes.size() > 0 && items.size() > 0) {
+ double silverfishX = silverfishes.get(0).posX;
+ double silverfishZ = silverfishes.get(0).posZ;
+ for (EntityItem item : items) {
+ if (Item.getIdFromItem(item.getEntityItem().getItem()) == 46 && Math.abs(item.posX - silverfishX) < 1 && Math.abs(item.posZ - silverfishZ) < 1) {
+ Iterable<BlockPos> blocks = BlockPos.getAllInBox(new BlockPos(player.posX - 27, 67, player.posZ - 27), new BlockPos(player.posX + 27, 67, player.posZ + 27));
+ for (BlockPos blockPos : blocks) {
+ if (world.getBlockState(blockPos).getBlock() == Blocks.chest && world.getBlockState(blockPos.add(0, 2, 0)).getBlock() == Blocks.hopper) {
+ foundRoom = true;
+ inSilverfishRoom = true;
+ if (!prevInSilverfishRoom) {
+ chest = blockPos;
+ BlockPos silverfishBlock = new BlockPos(silverfishX, 67, silverfishZ);
+ TileEntity hopper = world.getTileEntity(blockPos.add(0, 2, 0));
+ silverfishRoomDirection = BlockHopper.getFacing(hopper.getBlockMetadata());
+ char[][] board = new char[19][19];
+ SilverfishUtils.Point silverfishPoint = null;
+
+ switch (silverfishRoomDirection) {
+ case NORTH:
+ for (int row = chest.getZ() + 3, xIteration = 0; xIteration < 19; row++, xIteration++) {
+ for (int column = chest.getX() - 9, yIteration = 0; yIteration < 19; column++, yIteration++) {
+ if (world.getBlockState(new BlockPos(column, 67, row)).getBlock() != Blocks.air) {
+ board[xIteration][yIteration] = 'X';
+ } else if (silverfishBlock.equals(new BlockPos(column, 67, row))) {
+ silverfishPoint = new SilverfishUtils.Point(xIteration, yIteration);
+ }
+ }
+ }
+ break;
+ case EAST:
+ for (int row = chest.getX() - 3, xIteration = 0; xIteration < 19; row--, xIteration++) {
+ for (int column = chest.getZ() - 9, yIteration = 0; yIteration < 19; column++, yIteration++) {
+ if (world.getBlockState(new BlockPos(row, 67, column)).getBlock() != Blocks.air) {
+ board[xIteration][yIteration] = 'X';
+ } else if (silverfishBlock.equals(new BlockPos(row, 67, column))) {
+ silverfishPoint = new SilverfishUtils.Point(xIteration, yIteration);
+ }
+ }
+ }
+ break;
+ case SOUTH:
+ for (int row = chest.getZ() - 3, xIteration = 0; xIteration < 19; row--, xIteration++) {
+ for (int column = chest.getX() + 9, yIteration = 0; yIteration < 19; column--, yIteration++) {
+ if (world.getBlockState(new BlockPos(column, 67, row)).getBlock() != Blocks.air) {
+ board[xIteration][yIteration] = 'X';
+ } else if (silverfishBlock.equals(new BlockPos(column, 67, row))) {
+ silverfishPoint = new SilverfishUtils.Point(xIteration, yIteration);
+ }
+ }
+ }
+ break;
+ case WEST:
+ for (int row = chest.getX() + 3, xIteration = 0; xIteration < 19; row++, xIteration++) {
+ for (int column = chest.getZ() + 9, yIteration = 0; yIteration < 19; column--, yIteration++) {
+ if (world.getBlockState(new BlockPos(row, 67, column)).getBlock() != Blocks.air) {
+ board[xIteration][yIteration] = 'X';
+ } else if (silverfishBlock.equals(new BlockPos(row, 67, column))) {
+ board[xIteration][yIteration] = 'S';
+ silverfishPoint = new SilverfishUtils.Point(xIteration, yIteration);
+ }
+ }
+ }
+ break;
+ default:
+ return;
+ }
+ System.out.println(Arrays.deepToString(board));
+
+ List<SilverfishUtils.Point> endPoints = new ArrayList<>();
+ for (int column = 0; column < 19; column++) {
+ if (board[0][column] != 'X') endPoints.add(new SilverfishUtils.Point(0, column));
+ }
+
+ route = SilverfishUtils.solve(board, silverfishPoint, endPoints);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (!foundRoom) reset();
+ }).start();
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onWorldRender(RenderWorldLastEvent event) {
+ if (ToggleCommand.silverfishToggled && Utils.inDungeons && route != null && route.size() > 0 && chest != null) {
+ for (int i = 0; i < route.size() - 1; i++) {
+ Vec3 pos1 = null;
+ Vec3 pos2 = null;
+ switch (silverfishRoomDirection) {
+ case NORTH:
+ pos1 = new Vec3(chest.getX() - 8.5 + route.get(i).column, 67.5, chest.getZ() + 3.5 + route.get(i).row);
+ pos2 = new Vec3(chest.getX() - 8.5 + route.get(i + 1).column, 67.5, chest.getZ() + 3.5 + route.get(i + 1).row);
+ break;
+ case EAST:
+ pos1 = new Vec3(chest.getX() - 2.5 - route.get(i).row, 67.5, chest.getZ() - 8.5 + route.get(i).column);
+ pos2 = new Vec3(chest.getX() - 2.5 - route.get(i + 1).row, 67.5, chest.getZ() - 8.5 + route.get(i + 1).column);
+ break;
+ case SOUTH:
+ pos1 = new Vec3(chest.getX() + 9.5 - route.get(i).column, 67.5, chest.getZ() - 2.5 - route.get(i).row);
+ pos2 = new Vec3(chest.getX() + 9.5 - route.get(i + 1).column, 67.5, chest.getZ() - 2.5 - route.get(i + 1).row);
+ break;
+ case WEST:
+ pos1 = new Vec3(chest.getX() + 3.5 + route.get(i).row, 67.5, chest.getZ() + 9.5 - route.get(i).column);
+ pos2 = new Vec3(chest.getX() + 3.5 + route.get(i + 1).row, 67.5, chest.getZ() + 9.5 - route.get(i + 1).column);
+ break;
+ default:
+ return;
+ }
+ Utils.draw3DLine(pos1, pos2, SILVERFISH_LINE_COLOUR, 5, true, event.partialTicks);
+ }
+ }
+ }
+
+ static void reset() {
+ inSilverfishRoom = false;
+ chest = null;
+ silverfishRoomDirection = null;
+ route.clear();
+ }
+
+}
diff --git a/src/main/java/me/Danker/gui/PuzzleSolversGui.java b/src/main/java/me/Danker/gui/PuzzleSolversGui.java
index f502df9..3864b80 100644
--- a/src/main/java/me/Danker/gui/PuzzleSolversGui.java
+++ b/src/main/java/me/Danker/gui/PuzzleSolversGui.java
@@ -23,6 +23,7 @@ public class PuzzleSolversGui extends GuiScreen {
private GuiButton water;
private GuiButton ticTacToe;
private GuiButton boulder;
+ private GuiButton silverfish;
private GuiButton startsWith;
private GuiButton selectAll;
private GuiButton clickOrder;
@@ -59,11 +60,12 @@ public class PuzzleSolversGui extends GuiScreen {
ticTacToe = new GuiButton(0, width / 2 - 100, (int) (height * 0.6), "Tic Tac Toe Solver: " + Utils.getColouredBoolean(ToggleCommand.ticTacToeToggled));
boulder = new GuiButton(0, width / 2 - 100, (int) (height * 0.7), "Boulder Solver: " + Utils.getColouredBoolean(ToggleCommand.boulderToggled));
// Page 2
- startsWith = new GuiButton(0, width / 2 - 100, (int) (height * 0.1), "Starts With Letter Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.startsWithToggled));
- selectAll = new GuiButton(0, width / 2 - 100, (int) (height * 0.2), "Select All Color Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.selectAllToggled));
- clickOrder = new GuiButton(0, width / 2 - 100, (int) (height * 0.3), "Click in Order Terminal Helper: " + Utils.getColouredBoolean(ToggleCommand.clickInOrderToggled));
- blockClicks = new GuiButton(0, width / 2 - 100, (int) (height * 0.4), "Block Wrong Clicks on Terminals: " + Utils.getColouredBoolean(ToggleCommand.blockWrongTerminalClicksToggled));
- itemFrameOnSeaLanterns = new GuiButton(0, width / 2 - 100, (int) (height * 0.5), "Ignore Arrows On Sea Lanterns: " + Utils.getColouredBoolean(ToggleCommand.itemFrameOnSeaLanternsToggled));
+ silverfish = new GuiButton(0, width / 2 - 100, (int) (height * 0.1), "Silverfish Solver: " + Utils.getColouredBoolean(ToggleCommand.silverfishToggled));
+ startsWith = new GuiButton(0, width / 2 - 100, (int) (height * 0.2), "Starts With Letter Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.startsWithToggled));
+ selectAll = new GuiButton(0, width / 2 - 100, (int) (height * 0.3), "Select All Color Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.selectAllToggled));
+ clickOrder = new GuiButton(0, width / 2 - 100, (int) (height * 0.4), "Click in Order Terminal Helper: " + Utils.getColouredBoolean(ToggleCommand.clickInOrderToggled));
+ blockClicks = new GuiButton(0, width / 2 - 100, (int) (height * 0.5), "Block Wrong Clicks on Terminals: " + Utils.getColouredBoolean(ToggleCommand.blockWrongTerminalClicksToggled));
+ itemFrameOnSeaLanterns = new GuiButton(0, width / 2 - 100, (int) (height * 0.6), "Ignore Arrows On Sea Lanterns: " + Utils.getColouredBoolean(ToggleCommand.itemFrameOnSeaLanternsToggled));
switch (page) {
case 1:
@@ -77,6 +79,7 @@ public class PuzzleSolversGui extends GuiScreen {
this.buttonList.add(nextPage);
break;
case 2:
+ this.buttonList.add(silverfish);
this.buttonList.add(startsWith);
this.buttonList.add(selectAll);
this.buttonList.add(clickOrder);
@@ -130,6 +133,10 @@ public class PuzzleSolversGui extends GuiScreen {
ToggleCommand.boulderToggled = !ToggleCommand.boulderToggled;
ConfigHandler.writeBooleanConfig("toggles", "BoulderPuzzle", ToggleCommand.boulderToggled);
boulder.displayString = "Boulder Solver: " + Utils.getColouredBoolean(ToggleCommand.boulderToggled);
+ } else if (button == silverfish) {
+ ToggleCommand.silverfishToggled = !ToggleCommand.silverfishToggled;
+ ConfigHandler.writeBooleanConfig("toggles", "SilverfishPuzzle", ToggleCommand.silverfishToggled);
+ silverfish.displayString = "Silverfish Solver: " + Utils.getColouredBoolean(ToggleCommand.silverfishToggled);
} else if (button == startsWith) {
ToggleCommand.startsWithToggled = !ToggleCommand.startsWithToggled;
ConfigHandler.writeBooleanConfig("toggles", "StartsWithTerminal", ToggleCommand.startsWithToggled);
diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java
index 30778e7..96c0e75 100644
--- a/src/main/java/me/Danker/handlers/ConfigHandler.java
+++ b/src/main/java/me/Danker/handlers/ConfigHandler.java
@@ -90,7 +90,7 @@ public class ConfigHandler {
}
return true;
}
-
+
public static void writeIntConfig(String category, String key, int value) {
config = new Configuration(new File(file));
try {
@@ -252,6 +252,7 @@ public class ConfigHandler {
ToggleCommand.waterToggled = initBoolean("toggles", "WaterPuzzle", false);
ToggleCommand.ticTacToeToggled = initBoolean("toggles", "TicTacToePuzzle", false);
ToggleCommand.boulderToggled = initBoolean("toggles", "BoulderPuzzle", false);
+ ToggleCommand.silverfishToggled = initBoolean("toggles", "SilverfishPuzzle", false);
ToggleCommand.startsWithToggled = initBoolean("toggles", "StartsWithTerminal", false);
ToggleCommand.selectAllToggled = initBoolean("toggles", "SelectAllTerminal", false);
ToggleCommand.clickInOrderToggled = initBoolean("toggles", "ClickInOrderTerminal", false);
@@ -510,6 +511,7 @@ public class ConfigHandler {
ClickInOrderSolver.CLICK_IN_ORDER_NEXT_TO_NEXT = initInt("colors", "clickInOrderNextToNext", 0x0BEFE7);
BoulderSolver.BOULDER_COLOUR = initInt("colors", "boulder", 0x197F19);
BoulderSolver.BOULDER_ARROW_COLOUR = initInt("colors", "boulderArrow", 0x006000);
+ SilverfishSolver.SILVERFISH_LINE_COLOUR = initInt("colors", "silverfishLine", 0x40FF40);
// Commands
if (!hasKey("commands", "reparty")) writeBooleanConfig("commands", "reparty", false);
diff --git a/src/main/java/me/Danker/utils/SilverfishUtils.java b/src/main/java/me/Danker/utils/SilverfishUtils.java
new file mode 100644
index 0000000..e495da5
--- /dev/null
+++ b/src/main/java/me/Danker/utils/SilverfishUtils.java
@@ -0,0 +1,104 @@
+package me.Danker.utils;
+
+import java.util.*;
+
+public class SilverfishUtils {
+
+ // bfs
+ public static List<Point> solve(char[][] board, Point startPos, List<Point> endColumns) {
+ LinkedList<Point> queue = new LinkedList<>();
+ Map<Point, Point> visited = new HashMap<>();
+ queue.add(startPos);
+ visited.put(startPos, null);
+ while (!queue.isEmpty()) {
+ if (queue.size() > 1000000) break;
+ Point position = queue.pollFirst();
+ for (Direction direction : Direction.values()) {
+ Point pushedPoint = push(board, position, direction);
+ if (visited.containsKey(pushedPoint)) continue;
+ queue.add(pushedPoint);
+ visited.put(pushedPoint, position);
+ for (Point endColumn : endColumns) {
+ if (pushedPoint.equals(endColumn)) {
+ List<Point> route = new ArrayList<>();
+ Point lastPoint = pushedPoint;
+ while (lastPoint != null) {
+ route.add(0, lastPoint);
+ lastPoint = visited.get(lastPoint);
+ }
+ return route;
+ }
+ }
+ }
+ }
+ return new ArrayList<>();
+ }
+
+ public static Point push(char[][] board, Point pos, Direction direction) {
+ switch (direction) {
+ case UP:
+ for (int row = pos.row; row >= 0; row--) {
+ if (board[row][pos.column] == 'X') {
+ return new Point(row + 1, pos.column);
+ }
+ }
+ return new Point(0, pos.column);
+ case DOWN:
+ for (int row = pos.row; row <= 18; row++) {
+ if (board[row][pos.column] == 'X') {
+ return new Point(row - 1, pos.column);
+ }
+ }
+ return new Point(18, pos.column);
+ case LEFT:
+ for (int column = pos.column; column >= 0; column--) {
+ if (board[pos.row][column] == 'X') {
+ return new Point(pos.row, column + 1);
+ }
+ }
+ return new Point(pos.row, 0);
+ case RIGHT:
+ for (int column = pos.column; column <= 18; column++) {
+ if (board[pos.row][column] == 'X') {
+ return new Point(pos.row, column - 1);
+ }
+ }
+ return new Point(pos.row, 18);
+ }
+ return null;
+ }
+
+ public static class Point {
+
+ public int row;
+ public int column;
+
+ public Point(int row, int column) {
+ this.row = row;
+ this.column = column;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(row, column);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Point) {
+ Point point = (Point) obj;
+ return row == point.row && column == point.column;
+ }
+ return false;
+ }
+
+ }
+
+ enum Direction {
+ UP,
+ DOWN,
+ LEFT,
+ RIGHT
+ }
+
+}