From 668a2e184c270d01b259bd3f9269892a05bcc870 Mon Sep 17 00:00:00 2001 From: bowser0000 Date: Sat, 13 Mar 2021 21:38:33 -0500 Subject: Add ice walk puzzle solver --- src/main/java/me/Danker/DankersSkyblockMod.java | 3 +- src/main/java/me/Danker/commands/DHelpCommand.java | 2 +- .../java/me/Danker/commands/DankerGuiCommand.java | 1 + .../java/me/Danker/commands/ToggleCommand.java | 11 +- .../me/Danker/features/BlockPlacingFlowers.java | 44 ++++ .../puzzlesolvers/BlockPlacingFlowers.java | 44 ---- .../features/puzzlesolvers/IceWalkSolver.java | 287 +++++++++++++++++++++ .../features/puzzlesolvers/SilverfishSolver.java | 5 +- src/main/java/me/Danker/gui/PuzzleSolversGui.java | 17 +- .../java/me/Danker/handlers/ConfigHandler.java | 2 + src/main/java/me/Danker/utils/IceWalkUtils.java | 99 +++++++ 11 files changed, 461 insertions(+), 54 deletions(-) create mode 100644 src/main/java/me/Danker/features/BlockPlacingFlowers.java delete mode 100644 src/main/java/me/Danker/features/puzzlesolvers/BlockPlacingFlowers.java create mode 100644 src/main/java/me/Danker/features/puzzlesolvers/IceWalkSolver.java create mode 100644 src/main/java/me/Danker/utils/IceWalkUtils.java (limited to 'src') diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index dbb79dc..ab042d6 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-beta2"; + public static final String VERSION = "1.8.6-beta3"; public static int titleTimer = -1; public static boolean showTitle = false; public static String titleText = ""; @@ -104,6 +104,7 @@ public class DankersSkyblockMod { MinecraftForge.EVENT_BUS.register(new GolemSpawningAlert()); MinecraftForge.EVENT_BUS.register(new GpartyNotifications()); MinecraftForge.EVENT_BUS.register(new HideTooltipsInExperiments()); + MinecraftForge.EVENT_BUS.register(new IceWalkSolver()); MinecraftForge.EVENT_BUS.register(new LividSolver()); MinecraftForge.EVENT_BUS.register(new LootDisplay()); MinecraftForge.EVENT_BUS.register(new LootTracker()); diff --git a/src/main/java/me/Danker/commands/DHelpCommand.java b/src/main/java/me/Danker/commands/DHelpCommand.java index c1ae5af..841d0b5 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-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 fff1ce7..bd92b3e 100644 --- a/src/main/java/me/Danker/commands/DankerGuiCommand.java +++ b/src/main/java/me/Danker/commands/DankerGuiCommand.java @@ -77,6 +77,7 @@ public class DankerGuiCommand extends CommandBase { 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("[icewalkpuzzle][").append(ToggleCommand.iceWalkToggled).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 294cf1a..06619ac 100644 --- a/src/main/java/me/Danker/commands/ToggleCommand.java +++ b/src/main/java/me/Danker/commands/ToggleCommand.java @@ -58,6 +58,7 @@ public class ToggleCommand extends CommandBase implements ICommand { public static boolean ticTacToeToggled; public static boolean boulderToggled; public static boolean silverfishToggled; + public static boolean iceWalkToggled; // Terminal Helpers public static boolean startsWithToggled; public static boolean selectAllToggled; @@ -83,7 +84,7 @@ public class ToggleCommand extends CommandBase implements ICommand { "skill50display/outlinetext/midasstaffmessages/implosionmessages/healmessages/cooldownmessages/" + "manamessages/killcombomessages/caketimer/lowhealthnotify/lividsolver/stopsalvagestarred/" + "notifyslayerslain/necronnotifications/bonzotimer/threemanpuzzle/oruopuzzle/blazepuzzle/" + - "creeperpuzzle/waterpuzzle/tictactoepuzzle/boulderpuzzle/silverfishpuzzle/watchermessage/" + + "creeperpuzzle/waterpuzzle/tictactoepuzzle/boulderpuzzle/silverfishpuzzle/icewalkpuzzle/watchermessage/" + "startswithterminal/selectallterminal/clickinorderterminal/blockwrongterminalclicks/" + "itemframeonsealanterns/ultrasequencer/chronomatron/superpairs/hidetooltipsinaddons/pickblock/list>"; } @@ -105,7 +106,7 @@ public class ToggleCommand extends CommandBase implements ICommand { "stopsalvagestarred", "notifyslayerslain", "necronnotifications", "bonzotimer", "threemanpuzzle", "oruopuzzle", "blazepuzzle", "creeperpuzzle", "waterpuzzle", "tictactoepuzzle", "boulderpuzzle", - "silverfishpuzzle", "watchermessage", "startswithterminal", + "silverfishpuzzle", "icewalkpuzzle", "watchermessage", "startswithterminal", "selectallterminal", "clickinorderterminal", "blockwrongterminalclicks", "itemframeonsealanterns", "ultrasequencer", "chronomatron", "superpairs", "hidetooltipsinaddons", "pickblock", "list"); @@ -324,6 +325,11 @@ public class ToggleCommand extends CommandBase implements ICommand { 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 "icewalkpuzzle": + iceWalkToggled = !iceWalkToggled; + ConfigHandler.writeBooleanConfig("toggles", "IceWalkPuzzle", iceWalkToggled); + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Ice walk puzzle solver has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + iceWalkToggled + DankersSkyblockMod.MAIN_COLOUR + ".")); + break; case "watchermessage": watcherReadyToggled = !watcherReadyToggled; ConfigHandler.writeBooleanConfig("toggles", "WatcherReadyMessage", watcherReadyToggled); @@ -416,6 +422,7 @@ public class ToggleCommand extends CommandBase implements ICommand { 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 + " Ice walk puzzle solver: " + DankersSkyblockMod.VALUE_COLOUR + iceWalkToggled + "\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/BlockPlacingFlowers.java b/src/main/java/me/Danker/features/BlockPlacingFlowers.java new file mode 100644 index 0000000..9bfc986 --- /dev/null +++ b/src/main/java/me/Danker/features/BlockPlacingFlowers.java @@ -0,0 +1,44 @@ +package me.Danker.features; + +import me.Danker.commands.ToggleCommand; +import me.Danker.utils.Utils; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.ArrayList; +import java.util.Arrays; + +public class BlockPlacingFlowers { + + @SubscribeEvent + public void onInteract(PlayerInteractEvent event) { + if (!Utils.inSkyblock || Minecraft.getMinecraft().thePlayer != event.entityPlayer) return; + ItemStack item = event.entityPlayer.getHeldItem(); + if (item == null) return; + + if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { + Block block = Minecraft.getMinecraft().theWorld.getBlockState(event.pos).getBlock(); + + ArrayList flowerPlaceable = new ArrayList<>(Arrays.asList( + Blocks.grass, + Blocks.dirt, + Blocks.flower_pot, + Blocks.tallgrass, + Blocks.double_plant + )); + if (flowerPlaceable.contains(block)) { + if (ToggleCommand.flowerWeaponsToggled && item.getDisplayName().contains("Flower of Truth")) { + event.setCanceled(true); + } + if (ToggleCommand.flowerWeaponsToggled && item.getDisplayName().contains("Spirit Sceptre")) { + event.setCanceled(true); + } + } + } + } + +} diff --git a/src/main/java/me/Danker/features/puzzlesolvers/BlockPlacingFlowers.java b/src/main/java/me/Danker/features/puzzlesolvers/BlockPlacingFlowers.java deleted file mode 100644 index fe89fef..0000000 --- a/src/main/java/me/Danker/features/puzzlesolvers/BlockPlacingFlowers.java +++ /dev/null @@ -1,44 +0,0 @@ -package me.Danker.features.puzzlesolvers; - -import me.Danker.commands.ToggleCommand; -import me.Danker.utils.Utils; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.util.ArrayList; -import java.util.Arrays; - -public class BlockPlacingFlowers { - - @SubscribeEvent - public void onInteract(PlayerInteractEvent event) { - if (!Utils.inSkyblock || Minecraft.getMinecraft().thePlayer != event.entityPlayer) return; - ItemStack item = event.entityPlayer.getHeldItem(); - if (item == null) return; - - if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { - Block block = Minecraft.getMinecraft().theWorld.getBlockState(event.pos).getBlock(); - - ArrayList flowerPlaceable = new ArrayList<>(Arrays.asList( - Blocks.grass, - Blocks.dirt, - Blocks.flower_pot, - Blocks.tallgrass, - Blocks.double_plant - )); - if (flowerPlaceable.contains(block)) { - if (ToggleCommand.flowerWeaponsToggled && item.getDisplayName().contains("Flower of Truth")) { - event.setCanceled(true); - } - if (ToggleCommand.flowerWeaponsToggled && item.getDisplayName().contains("Spirit Sceptre")) { - event.setCanceled(true); - } - } - } - } - -} diff --git a/src/main/java/me/Danker/features/puzzlesolvers/IceWalkSolver.java b/src/main/java/me/Danker/features/puzzlesolvers/IceWalkSolver.java new file mode 100644 index 0000000..eaabf6e --- /dev/null +++ b/src/main/java/me/Danker/features/puzzlesolvers/IceWalkSolver.java @@ -0,0 +1,287 @@ +package me.Danker.features.puzzlesolvers; + +import me.Danker.DankersSkyblockMod; +import me.Danker.commands.ToggleCommand; +import me.Danker.utils.IceWalkUtils; +import me.Danker.utils.Utils; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Vec3; +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 IceWalkSolver { + + static boolean prevInIceWalkRoom = false; + static boolean inIceWalkRoom = false; + static BlockPos chest = null; + static EnumFacing silverfishRoomDirection = null; + static List threeByThreeRoute = new ArrayList<>(); + static List fiveByFiveRoute = new ArrayList<>(); + static List sevenBySevenRoute = new ArrayList<>(); + public static int ICE_WALK_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(); + EntityPlayerSP player = mc.thePlayer; + World world = mc.theWorld; + if (DankersSkyblockMod.tickAmount % 20 == 0) { + if (ToggleCommand.iceWalkToggled && Utils.inDungeons && world != null && player != null) { + // multi thread block checking + new Thread(() -> { + boolean foundRoom = false; + prevInIceWalkRoom = inIceWalkRoom; + Iterable blocks = BlockPos.getAllInBox(new BlockPos(player.posX - 27, 75, player.posZ - 27), new BlockPos(player.posX + 27, 75, player.posZ + 27)); + for (BlockPos blockPos : blocks) { + Block block = world.getBlockState(blockPos).getBlock(); + if (block == Blocks.chest) { + char[][] threeByThreeBoard = new char[4][3]; + char[][] fiveByFiveBoard = new char[6][5]; + char[][] sevenBySevenBoard = new char[8][7]; + + if (world.getBlockState(blockPos.add(0, 7, 2)).getBlock() == Blocks.iron_bars && world.getBlockState(blockPos.add(0, -3, 2)).getBlock() == Blocks.stone_brick_stairs) { + silverfishRoomDirection = EnumFacing.NORTH; + } else if (world.getBlockState(blockPos.add(-2, 7, 0)).getBlock() == Blocks.iron_bars && world.getBlockState(blockPos.add(-2, -3, 0)).getBlock() == Blocks.stone_brick_stairs) { + silverfishRoomDirection = EnumFacing.EAST; + } else if (world.getBlockState(blockPos.add(0, 7, -2)).getBlock() == Blocks.iron_bars && world.getBlockState(blockPos.add(0, -3, -2)).getBlock() == Blocks.stone_brick_stairs) { + silverfishRoomDirection = EnumFacing.SOUTH; + } else if (world.getBlockState(blockPos.add(2, 7, 0)).getBlock() == Blocks.iron_bars && world.getBlockState(blockPos.add(2, -3, 0)).getBlock() == Blocks.stone_brick_stairs) { + silverfishRoomDirection = EnumFacing.WEST; + } else { + return; + } + + foundRoom = true; + inIceWalkRoom = true; + if (!prevInIceWalkRoom) { + chest = blockPos; + switch (silverfishRoomDirection) { + case NORTH: + for (int row = chest.getZ() + 3, xIteration = 0; xIteration < 8; row++, xIteration++) { + for (int column = chest.getX() - 3, yIteration = 0; yIteration < 7; column++, yIteration++) { + if (world.getBlockState(new BlockPos(column, 72, row)).getBlock() != Blocks.air) { + sevenBySevenBoard[xIteration][yIteration] = 'X'; + } + } + } + for (int row = chest.getZ() + 12, xIteration = 0; xIteration < 6; row++, xIteration++) { + for (int column = chest.getX() - 2, yIteration = 0; yIteration < 5; column++, yIteration++) { + if (world.getBlockState(new BlockPos(column, 71, row)).getBlock() != Blocks.air) { + fiveByFiveBoard[xIteration][yIteration] = 'X'; + } + } + } + for (int row = chest.getZ() + 19, xIteration = 0; xIteration < 4; row++, xIteration++) { + for (int column = chest.getX() - 1, yIteration = 0; yIteration < 3; column++, yIteration++) { + if (world.getBlockState(new BlockPos(column, 70, row)).getBlock() != Blocks.air) { + threeByThreeBoard[xIteration][yIteration] = 'X'; + } + } + } + break; + case EAST: + for (int row = chest.getX() - 3, xIteration = 0; xIteration < 8; row--, xIteration++) { + for (int column = chest.getZ() - 3, yIteration = 0; yIteration < 7; column++, yIteration++) { + if (world.getBlockState(new BlockPos(row, 72, column)).getBlock() != Blocks.air) { + sevenBySevenBoard[xIteration][yIteration] = 'X'; + } + } + } + for (int row = chest.getX() - 12, xIteration = 0; xIteration < 6; row--, xIteration++) { + for (int column = chest.getZ() - 2, yIteration = 0; yIteration < 5; column++, yIteration++) { + if (world.getBlockState(new BlockPos(row, 71, column)).getBlock() != Blocks.air) { + fiveByFiveBoard[xIteration][yIteration] = 'X'; + } + } + } + for (int row = chest.getX() - 19, xIteration = 0; xIteration < 4; row--, xIteration++) { + for (int column = chest.getZ() - 1, yIteration = 0; yIteration < 3; column++, yIteration++) { + if (world.getBlockState(new BlockPos(row, 70, column)).getBlock() != Blocks.air) { + threeByThreeBoard[xIteration][yIteration] = 'X'; + } + } + } + break; + case SOUTH: + for (int row = chest.getZ() - 3, xIteration = 0; xIteration < 8; row--, xIteration++) { + for (int column = chest.getX() + 3, yIteration = 0; yIteration < 7; column--, yIteration++) { + if (world.getBlockState(new BlockPos(column, 72, row)).getBlock() != Blocks.air) { + sevenBySevenBoard[xIteration][yIteration] = 'X'; + } + } + } + for (int row = chest.getZ() - 12, xIteration = 0; xIteration < 6; row--, xIteration++) { + for (int column = chest.getX() + 2, yIteration = 0; yIteration < 5; column--, yIteration++) { + if (world.getBlockState(new BlockPos(column, 71, row)).getBlock() != Blocks.air) { + fiveByFiveBoard[xIteration][yIteration] = 'X'; + } + } + } + for (int row = chest.getZ() - 19, xIteration = 0; xIteration < 4; row--, xIteration++) { + for (int column = chest.getX() + 1, yIteration = 0; yIteration < 3; column--, yIteration++) { + if (world.getBlockState(new BlockPos(column, 70, row)).getBlock() != Blocks.air) { + threeByThreeBoard[xIteration][yIteration] = 'X'; + } + } + } + break; + case WEST: + for (int row = chest.getX() + 3, xIteration = 0; xIteration < 8; row++, xIteration++) { + for (int column = chest.getZ() + 3, yIteration = 0; yIteration < 7; column--, yIteration++) { + if (world.getBlockState(new BlockPos(row, 72, column)).getBlock() != Blocks.air) { + sevenBySevenBoard[xIteration][yIteration] = 'X'; + } + } + } + for (int row = chest.getX() + 12, xIteration = 0; xIteration < 6; row++, xIteration++) { + for (int column = chest.getZ() + 2, yIteration = 0; yIteration < 5; column--, yIteration++) { + if (world.getBlockState(new BlockPos(row, 71, column)).getBlock() != Blocks.air) { + fiveByFiveBoard[xIteration][yIteration] = 'X'; + } + } + } + for (int row = chest.getX() + 19, xIteration = 0; xIteration < 4; row++, xIteration++) { + for (int column = chest.getZ() + 1, yIteration = 0; yIteration < 3; column--, yIteration++) { + if (world.getBlockState(new BlockPos(row, 70, column)).getBlock() != Blocks.air) { + threeByThreeBoard[xIteration][yIteration] = 'X'; + } + } + } + break; + } + System.out.println(Arrays.deepToString(threeByThreeBoard)); + System.out.println(Arrays.deepToString(fiveByFiveBoard)); + System.out.println(Arrays.deepToString(sevenBySevenBoard)); + + threeByThreeRoute = IceWalkUtils.solve(threeByThreeBoard); + fiveByFiveRoute = IceWalkUtils.solve(fiveByFiveBoard); + sevenBySevenRoute = IceWalkUtils.solve(sevenBySevenBoard); + } + } + } + if (!foundRoom) { + inIceWalkRoom = false; + reset(); + } + }).start(); + } + } + } + + @SubscribeEvent + public void onWorldRender(RenderWorldLastEvent event) { + if (ToggleCommand.iceWalkToggled && Utils.inDungeons && chest != null) { + if (threeByThreeRoute != null && threeByThreeRoute.size() > 1) { + for (int i = 0; i < threeByThreeRoute.size() - 1; i++) { + Vec3 pos1; + Vec3 pos2; + switch (silverfishRoomDirection) { + case NORTH: + pos1 = new Vec3(chest.getX() - 0.5 + threeByThreeRoute.get(i).column, 70.5, chest.getZ() + 19.5 + threeByThreeRoute.get(i).row); + pos2 = new Vec3(chest.getX() - 0.5 + threeByThreeRoute.get(i + 1).column, 70.5, chest.getZ() + 19.5 + threeByThreeRoute.get(i + 1).row); + break; + case EAST: + pos1 = new Vec3(chest.getX() - 18.5 - threeByThreeRoute.get(i).row, 70.5, chest.getZ() - 0.5 + threeByThreeRoute.get(i).column); + pos2 = new Vec3(chest.getX() - 18.5 - threeByThreeRoute.get(i + 1).row, 70.5, chest.getZ() - 0.5 + threeByThreeRoute.get(i + 1).column); + break; + case SOUTH: + pos1 = new Vec3(chest.getX() + 1.5 - threeByThreeRoute.get(i).column, 70.5, chest.getZ() - 18.5 - threeByThreeRoute.get(i).row); + pos2 = new Vec3(chest.getX() + 1.5 - threeByThreeRoute.get(i + 1).column, 70.5, chest.getZ() - 18.5 - threeByThreeRoute.get(i + 1).row); + break; + case WEST: + pos1 = new Vec3(chest.getX() + 19.5 + threeByThreeRoute.get(i).row, 70.5, chest.getZ() + 1.5 - threeByThreeRoute.get(i).column); + pos2 = new Vec3(chest.getX() + 19.5 + threeByThreeRoute.get(i + 1).row, 70.5, chest.getZ() + 1.5 - threeByThreeRoute.get(i + 1).column); + break; + default: + return; + } + Utils.draw3DLine(pos1, pos2, ICE_WALK_LINE_COLOUR, 5, true, event.partialTicks); + } + } + + if (fiveByFiveRoute != null && fiveByFiveRoute.size() > 1) { + for (int i = 0; i < fiveByFiveRoute.size() - 1; i++) { + Vec3 pos1; + Vec3 pos2; + switch (silverfishRoomDirection) { + case NORTH: + pos1 = new Vec3(chest.getX() - 1.5 + fiveByFiveRoute.get(i).column, 71.5, chest.getZ() + 12.5 + fiveByFiveRoute.get(i).row); + pos2 = new Vec3(chest.getX() - 1.5 + fiveByFiveRoute.get(i + 1).column, 71.5, chest.getZ() + 12.5 + fiveByFiveRoute.get(i + 1).row); + break; + case EAST: + pos1 = new Vec3(chest.getX() - 11.5 - fiveByFiveRoute.get(i).row, 71.5, chest.getZ() - 1.5 + fiveByFiveRoute.get(i).column); + pos2 = new Vec3(chest.getX() - 11.5 - fiveByFiveRoute.get(i + 1).row, 71.5, chest.getZ() - 1.5 + fiveByFiveRoute.get(i + 1).column); + break; + case SOUTH: + pos1 = new Vec3(chest.getX() + 2.5 - fiveByFiveRoute.get(i).column, 71.5, chest.getZ() - 11.5 - fiveByFiveRoute.get(i).row); + pos2 = new Vec3(chest.getX() + 2.5 - fiveByFiveRoute.get(i + 1).column, 71.5, chest.getZ() - 11.5 - fiveByFiveRoute.get(i + 1).row); + break; + case WEST: + pos1 = new Vec3(chest.getX() + 12.5 + fiveByFiveRoute.get(i).row, 71.5, chest.getZ() + 2.5 - fiveByFiveRoute.get(i).column); + pos2 = new Vec3(chest.getX() + 12.5 + fiveByFiveRoute.get(i + 1).row, 71.5, chest.getZ() + 2.5 - fiveByFiveRoute.get(i + 1).column); + break; + default: + return; + } + Utils.draw3DLine(pos1, pos2, ICE_WALK_LINE_COLOUR, 5, true, event.partialTicks); + } + } + + if (sevenBySevenRoute != null && sevenBySevenRoute.size() > 1) { + for (int i = 0; i < sevenBySevenRoute.size() - 1; i++) { + Vec3 pos1; + Vec3 pos2; + switch (silverfishRoomDirection) { + case NORTH: + pos1 = new Vec3(chest.getX() - 2.5 + sevenBySevenRoute.get(i).column, 72.5, chest.getZ() + 3.5 + sevenBySevenRoute.get(i).row); + pos2 = new Vec3(chest.getX() - 2.5 + sevenBySevenRoute.get(i + 1).column, 72.5, chest.getZ() + 3.5 + sevenBySevenRoute.get(i + 1).row); + break; + case EAST: + pos1 = new Vec3(chest.getX() - 2.5 - sevenBySevenRoute.get(i).row, 72.5, chest.getZ() - 2.5 + sevenBySevenRoute.get(i).column); + pos2 = new Vec3(chest.getX() - 2.5 - sevenBySevenRoute.get(i + 1).row, 72.5, chest.getZ() - 2.5 + sevenBySevenRoute.get(i + 1).column); + break; + case SOUTH: + pos1 = new Vec3(chest.getX() + 3.5 - sevenBySevenRoute.get(i).column, 72.5, chest.getZ() - 2.5 - sevenBySevenRoute.get(i).row); + pos2 = new Vec3(chest.getX() + 3.5 - sevenBySevenRoute.get(i + 1).column, 72.5, chest.getZ() - 2.5 - sevenBySevenRoute.get(i + 1).row); + break; + case WEST: + pos1 = new Vec3(chest.getX() + 3.5 + sevenBySevenRoute.get(i).row, 72.5, chest.getZ() + 3.5 - sevenBySevenRoute.get(i).column); + pos2 = new Vec3(chest.getX() + 3.5 + sevenBySevenRoute.get(i + 1).row, 72.5, chest.getZ() + 3.5 - sevenBySevenRoute.get(i + 1).column); + break; + default: + return; + } + Utils.draw3DLine(pos1, pos2, ICE_WALK_LINE_COLOUR, 5, true, event.partialTicks); + } + } + } + } + + static void reset() { + silverfishRoomDirection = null; + chest = null; + threeByThreeRoute.clear(); + fiveByFiveRoute.clear(); + sevenBySevenRoute.clear(); + } + +} diff --git a/src/main/java/me/Danker/features/puzzlesolvers/SilverfishSolver.java b/src/main/java/me/Danker/features/puzzlesolvers/SilverfishSolver.java index c07524d..575dcd3 100644 --- a/src/main/java/me/Danker/features/puzzlesolvers/SilverfishSolver.java +++ b/src/main/java/me/Danker/features/puzzlesolvers/SilverfishSolver.java @@ -12,7 +12,10 @@ 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.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.event.world.WorldEvent; diff --git a/src/main/java/me/Danker/gui/PuzzleSolversGui.java b/src/main/java/me/Danker/gui/PuzzleSolversGui.java index 3864b80..3bb16a0 100644 --- a/src/main/java/me/Danker/gui/PuzzleSolversGui.java +++ b/src/main/java/me/Danker/gui/PuzzleSolversGui.java @@ -24,6 +24,7 @@ public class PuzzleSolversGui extends GuiScreen { private GuiButton ticTacToe; private GuiButton boulder; private GuiButton silverfish; + private GuiButton iceWalk; private GuiButton startsWith; private GuiButton selectAll; private GuiButton clickOrder; @@ -61,11 +62,12 @@ public class PuzzleSolversGui extends GuiScreen { boulder = new GuiButton(0, width / 2 - 100, (int) (height * 0.7), "Boulder Solver: " + Utils.getColouredBoolean(ToggleCommand.boulderToggled)); // Page 2 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)); + iceWalk = new GuiButton(0, width / 2 - 100, (int) (height * 0.2), "Ice Walk Solver: " + Utils.getColouredBoolean(ToggleCommand.iceWalkToggled)); + startsWith = new GuiButton(0, width / 2 - 100, (int) (height * 0.3), "Starts With Letter Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.startsWithToggled)); + selectAll = new GuiButton(0, width / 2 - 100, (int) (height * 0.4), "Select All Color Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.selectAllToggled)); + clickOrder = new GuiButton(0, width / 2 - 100, (int) (height * 0.5), "Click in Order Terminal Helper: " + Utils.getColouredBoolean(ToggleCommand.clickInOrderToggled)); + blockClicks = new GuiButton(0, width / 2 - 100, (int) (height * 0.6), "Block Wrong Clicks on Terminals: " + Utils.getColouredBoolean(ToggleCommand.blockWrongTerminalClicksToggled)); + itemFrameOnSeaLanterns = new GuiButton(0, width / 2 - 100, (int) (height * 0.7), "Ignore Arrows On Sea Lanterns: " + Utils.getColouredBoolean(ToggleCommand.itemFrameOnSeaLanternsToggled)); switch (page) { case 1: @@ -80,6 +82,7 @@ public class PuzzleSolversGui extends GuiScreen { break; case 2: this.buttonList.add(silverfish); + this.buttonList.add(iceWalk); this.buttonList.add(startsWith); this.buttonList.add(selectAll); this.buttonList.add(clickOrder); @@ -137,6 +140,10 @@ public class PuzzleSolversGui extends GuiScreen { ToggleCommand.silverfishToggled = !ToggleCommand.silverfishToggled; ConfigHandler.writeBooleanConfig("toggles", "SilverfishPuzzle", ToggleCommand.silverfishToggled); silverfish.displayString = "Silverfish Solver: " + Utils.getColouredBoolean(ToggleCommand.silverfishToggled); + } else if (button == iceWalk) { + ToggleCommand.iceWalkToggled = !ToggleCommand.iceWalkToggled; + ConfigHandler.writeBooleanConfig("toggles", "IceWalkPuzzle", ToggleCommand.iceWalkToggled); + iceWalk.displayString = "Ice Walk Solver: " + Utils.getColouredBoolean(ToggleCommand.iceWalkToggled); } 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 52b1883..19edeff 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -254,6 +254,7 @@ public class ConfigHandler { ToggleCommand.ticTacToeToggled = initBoolean("toggles", "TicTacToePuzzle", false); ToggleCommand.boulderToggled = initBoolean("toggles", "BoulderPuzzle", false); ToggleCommand.silverfishToggled = initBoolean("toggles", "SilverfishPuzzle", false); + ToggleCommand.iceWalkToggled = initBoolean("toggles", "IceWalkPuzzle", false); ToggleCommand.startsWithToggled = initBoolean("toggles", "StartsWithTerminal", false); ToggleCommand.selectAllToggled = initBoolean("toggles", "SelectAllTerminal", false); ToggleCommand.clickInOrderToggled = initBoolean("toggles", "ClickInOrderTerminal", false); @@ -513,6 +514,7 @@ public class ConfigHandler { BoulderSolver.BOULDER_COLOUR = initInt("colors", "boulder", 0x197F19); BoulderSolver.BOULDER_ARROW_COLOUR = initInt("colors", "boulderArrow", 0x006000); SilverfishSolver.SILVERFISH_LINE_COLOUR = initInt("colors", "silverfishLine", 0x40FF40); + IceWalkSolver.ICE_WALK_LINE_COLOUR = initInt("colors", "iceWalkLine", 0x40FF40); // Commands if (!hasKey("commands", "reparty")) writeBooleanConfig("commands", "reparty", false); diff --git a/src/main/java/me/Danker/utils/IceWalkUtils.java b/src/main/java/me/Danker/utils/IceWalkUtils.java new file mode 100644 index 0000000..8164fe1 --- /dev/null +++ b/src/main/java/me/Danker/utils/IceWalkUtils.java @@ -0,0 +1,99 @@ +package me.Danker.utils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class IceWalkUtils { + + public static List solve(char[][] board) { + Point startPos = new Point(board.length - 1, board[0].length / 2); + Point endPos = new Point(0, board[0].length / 2); + List route = new ArrayList<>(); + route.add(startPos); + return findSolution(board, startPos, endPos, route); + } + + public static List findSolution(char[][] board, Point startPos, Point endPos, List route) { + for (Direction direction : Direction.values()) { + Point nextPoint = move(board, startPos, direction); + if (nextPoint == null || route.contains(nextPoint)) continue; + List newRoute = new ArrayList<>(route); + newRoute.add(nextPoint); + if (nextPoint.equals(endPos) && isComplete(board, newRoute)) return newRoute; + List solution = findSolution(board, nextPoint, endPos, newRoute); + if (solution == null) continue; + return solution; + } + return null; + } + + public static Point move(char[][] board, Point pos, Direction direction) { + switch (direction) { + case UP: + if (pos.row != 0 && board[pos.row - 1][pos.column] != 'X') { + return new Point(pos.row - 1, pos.column); + } + break; + case DOWN: + if (pos.row != board.length - 1 && board[pos.row + 1][pos.column] != 'X') { + return new Point(pos.row + 1, pos.column); + } + break; + case LEFT: + if (pos.column != 0 && board[pos.row][pos.column - 1] != 'X') { + return new Point(pos.row, pos.column - 1); + } + break; + case RIGHT: + if (pos.column != board[0].length - 1 && board[pos.row][pos.column + 1] != 'X') { + return new Point(pos.row, pos.column + 1); + } + break; + } + return null; + } + + public static boolean isComplete(char[][] board, List route) { + for (int row = 0; row < board.length; row++) { + for (int column = 0; column < board[0].length; column++) { + if (board[row][column] != 'X' && !route.contains(new Point(row, column))) return false; + } + } + return true; + } + + 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 + } + +} -- cgit From e1fd25b6841e94e0b1861528f3f05378fc23a04f Mon Sep 17 00:00:00 2001 From: bowser0000 Date: Sun, 14 Mar 2021 22:34:12 -0400 Subject: Add support for rev 5 and auto slayer --- README.md | 2 +- .../me/Danker/commands/BlockSlayerCommand.java | 7 ++++-- src/main/java/me/Danker/commands/DHelpCommand.java | 2 +- src/main/java/me/Danker/commands/LootCommand.java | 4 ++++ .../java/me/Danker/features/loot/LootDisplay.java | 8 +++++++ .../java/me/Danker/features/loot/LootTracker.java | 22 ++++++++++++++++--- src/main/java/me/Danker/gui/OnlySlayerGui.java | 25 +++++++++++++++++----- .../java/me/Danker/handlers/ConfigHandler.java | 2 ++ 8 files changed, 60 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/README.md b/README.md index 0207b42..b9abb21 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Discord Server: https://discord.gg/QsEkNQS - /dungeons [player] - Uses API to get dungeon levels of a person. If no name is provided, it checks yours. - /importfishing - Imports your fishing stats from your latest profile to your fishing tracker using the API. - /sbplayers - Uses API to find how many players are on each Skyblock island. -- /onlyslayer <1/2/3/4> - Stops you from starting a slayer quest other than the one specified. +- /onlyslayer <1/2/3/4/5> - Stops you from starting a slayer quest other than the one specified. - /skilltracker - Text display for skill xp/hour. - /reparty - Disbands and reparties all members in the party diff --git a/src/main/java/me/Danker/commands/BlockSlayerCommand.java b/src/main/java/me/Danker/commands/BlockSlayerCommand.java index c0beb42..09da5d6 100644 --- a/src/main/java/me/Danker/commands/BlockSlayerCommand.java +++ b/src/main/java/me/Danker/commands/BlockSlayerCommand.java @@ -21,7 +21,7 @@ public class BlockSlayerCommand extends CommandBase { @Override public String getCommandUsage(ICommandSender arg0) { - return "/" + getCommandName() + " <1/2/3/4>"; + return "/" + getCommandName() + " <1/2/3/4/5>"; } @Override @@ -34,7 +34,7 @@ public class BlockSlayerCommand extends CommandBase { if (args.length == 1) { return getListOfStringsMatchingLastWord(args, "zombie", "spider", "wolf"); } else if (args.length == 2) { - return getListOfStringsMatchingLastWord(args, "1", "2", "3", "4"); + return getListOfStringsMatchingLastWord(args, "1", "2", "3", "4", "5"); } return null; } @@ -84,6 +84,9 @@ public class BlockSlayerCommand extends CommandBase { case 4: BlockWrongSlayer.onlySlayerNumber = "IV"; break; + case 5: + BlockWrongSlayer.onlySlayerNumber = "V"; + break; default: BlockWrongSlayer.onlySlayerName = ""; BlockWrongSlayer.onlySlayerNumber = ""; diff --git a/src/main/java/me/Danker/commands/DHelpCommand.java b/src/main/java/me/Danker/commands/DHelpCommand.java index 841d0b5..c431123 100644 --- a/src/main/java/me/Danker/commands/DHelpCommand.java +++ b/src/main/java/me/Danker/commands/DHelpCommand.java @@ -52,7 +52,7 @@ public class DHelpCommand extends CommandBase { EnumChatFormatting.GOLD + " /dungeons [player] " + EnumChatFormatting.AQUA + " - Uses API to get dungeon levels of a person. If no name is provided, it checks yours.\n" + EnumChatFormatting.GOLD + " /importfishing" + EnumChatFormatting.AQUA + " - Imports your fishing stats from your latest profile to your fishing tracker using the API.\n" + EnumChatFormatting.GOLD + " /sbplayers" + EnumChatFormatting.AQUA + " - Uses API to find how many players are on each Skyblock island.\n" + - EnumChatFormatting.GOLD + " /onlyslayer <1/2/3/4>" + EnumChatFormatting.AQUA + " - Stops you from starting a slayer quest other than the one specified.\n" + + EnumChatFormatting.GOLD + " /onlyslayer <1/2/3/4/5>" + EnumChatFormatting.AQUA + " - Stops you from starting a slayer quest other than the one specified.\n" + EnumChatFormatting.GOLD + " /skilltracker " + EnumChatFormatting.AQUA + " - Text display for skill xp/hour.\n" + EnumChatFormatting.GOLD + " /reparty " + EnumChatFormatting.AQUA + " - Disbands and reparties all members in the party.\n" + EnumChatFormatting.GREEN + " Open Maddox Menu" + EnumChatFormatting.AQUA + " - M by default.\n" + diff --git a/src/main/java/me/Danker/commands/LootCommand.java b/src/main/java/me/Danker/commands/LootCommand.java index 3dba27d..5502068 100644 --- a/src/main/java/me/Danker/commands/LootCommand.java +++ b/src/main/java/me/Danker/commands/LootCommand.java @@ -227,6 +227,8 @@ public class LootCommand extends CommandBase { EnumChatFormatting.RED + " Revenant Catalysts: " + LootTracker.zombieRevCatasSession + "\n" + EnumChatFormatting.DARK_GREEN + " Snake Runes: " + LootTracker.zombieSnakesSession + "\n" + EnumChatFormatting.GOLD + " Scythe Blades: " + LootTracker.zombieScythesSession + "\n" + + EnumChatFormatting.RED + " Shard of the Shreddeds: " + LootTracker.zombieShardsSession + "\n" + + EnumChatFormatting.RED + " Warden Hearts: " + LootTracker.zombieWardenHeartsSession + "\n" + EnumChatFormatting.AQUA + " Time Since RNG: " + timeBetween + "\n" + EnumChatFormatting.AQUA + " Bosses Since RNG: " + bossesBetween + "\n" + EnumChatFormatting.GREEN + EnumChatFormatting.BOLD + " -------------------")); @@ -261,6 +263,8 @@ public class LootCommand extends CommandBase { EnumChatFormatting.RED + " Revenant Catalysts: " + LootTracker.zombieRevCatas + "\n" + EnumChatFormatting.DARK_GREEN + " Snake Runes: " + LootTracker.zombieSnakes + "\n" + EnumChatFormatting.GOLD + " Scythe Blades: " + LootTracker.zombieScythes + "\n" + + EnumChatFormatting.RED + " Shard of the Shreddeds: " + LootTracker.zombieShards + "\n" + + EnumChatFormatting.RED + " Warden Hearts: " + LootTracker.zombieWardenHearts + "\n" + EnumChatFormatting.AQUA + " Time Since RNG: " + timeBetween + "\n" + EnumChatFormatting.AQUA + " Bosses Since RNG: " + bossesBetween + "\n" + EnumChatFormatting.GREEN + EnumChatFormatting.BOLD + " -------------------")); diff --git a/src/main/java/me/Danker/features/loot/LootDisplay.java b/src/main/java/me/Danker/features/loot/LootDisplay.java index 363b70c..f51157b 100644 --- a/src/main/java/me/Danker/features/loot/LootDisplay.java +++ b/src/main/java/me/Danker/features/loot/LootDisplay.java @@ -221,6 +221,8 @@ public class LootDisplay { EnumChatFormatting.RED + "Revenant Catalysts:\n" + EnumChatFormatting.DARK_GREEN + "Snake Runes:\n" + EnumChatFormatting.GOLD + "Scythe Blades:\n" + + EnumChatFormatting.RED + "Shard of Shreddeds:\n" + + EnumChatFormatting.RED + "Warden Hearts:\n" + EnumChatFormatting.AQUA + "Time Since RNG:\n" + EnumChatFormatting.AQUA + "Bosses Since RNG:"; countText = EnumChatFormatting.GOLD + nf.format(LootTracker.zombieRevs) + "\n" + @@ -233,6 +235,8 @@ public class LootDisplay { EnumChatFormatting.RED + LootTracker.zombieRevCatas + "\n" + EnumChatFormatting.DARK_GREEN + LootTracker.zombieSnakes + "\n" + EnumChatFormatting.GOLD + LootTracker.zombieScythes + "\n" + + EnumChatFormatting.RED + LootTracker.zombieShards + "\n" + + EnumChatFormatting.RED + LootTracker.zombieWardenHearts + "\n" + EnumChatFormatting.AQUA + timeBetween + "\n" + EnumChatFormatting.AQUA + bossesBetween; break; @@ -263,6 +267,8 @@ public class LootDisplay { EnumChatFormatting.RED + "Revenant Catalysts:\n" + EnumChatFormatting.DARK_GREEN + "Snake Runes:\n" + EnumChatFormatting.GOLD + "Scythe Blades:\n" + + EnumChatFormatting.RED + "Shard of Shreddeds:\n" + + EnumChatFormatting.RED + "Warden Hearts:\n" + EnumChatFormatting.AQUA + "Time Since RNG:\n" + EnumChatFormatting.AQUA + "Bosses Since RNG:"; countText = EnumChatFormatting.GOLD + nf.format(LootTracker.zombieRevsSession) + "\n" + @@ -275,6 +281,8 @@ public class LootDisplay { EnumChatFormatting.RED + LootTracker.zombieRevCatasSession + "\n" + EnumChatFormatting.DARK_GREEN + LootTracker.zombieSnakesSession + "\n" + EnumChatFormatting.GOLD + LootTracker.zombieScythes + "\n" + + EnumChatFormatting.RED + LootTracker.zombieShardsSession + "\n" + + EnumChatFormatting.RED + LootTracker.zombieWardenHeartsSession + "\n" + EnumChatFormatting.AQUA + timeBetween + "\n" + EnumChatFormatting.AQUA + bossesBetween; break; diff --git a/src/main/java/me/Danker/features/loot/LootTracker.java b/src/main/java/me/Danker/features/loot/LootTracker.java index f7f7044..68cd8b0 100644 --- a/src/main/java/me/Danker/features/loot/LootTracker.java +++ b/src/main/java/me/Danker/features/loot/LootTracker.java @@ -56,6 +56,8 @@ public class LootTracker { public static int zombieRevCatas; public static int zombieSnakes; public static int zombieScythes; + public static int zombieShards; + public static int zombieWardenHearts; public static double zombieTime; public static int zombieBosses; @@ -216,6 +218,8 @@ public class LootTracker { public static int zombieRevCatasSession = 0; public static int zombieSnakesSession = 0; public static int zombieScythesSession = 0; + public static int zombieShardsSession = 0; + public static int zombieWardenHeartsSession = 0; public static double zombieTimeSession = -1; public static int zombieBossesSession = -1; @@ -373,7 +377,7 @@ public class LootTracker { } // Wolf - if (message.contains("Talk to Maddox to claim your Wolf Slayer XP!")) { + if (message.contains(" Wolf Slayer LVL ")) { wolfSvens++; wolfSvensSession++; if (wolfBosses != -1) { @@ -416,7 +420,7 @@ public class LootTracker { wolfFluxesSession++; ConfigHandler.writeIntConfig("wolf", "flux", wolfFluxes); if (ToggleCommand.rngesusAlerts) Utils.createTitle(EnumChatFormatting.DARK_PURPLE + "OVERFLUX CAPACITOR!", 5); - } else if (message.contains("Talk to Maddox to claim your Spider Slayer XP!")) { // Spider + } else if (message.contains(" Spider Slayer LVL ")) { // Spider spiderTarantulas++; spiderTarantulasSession++; if (spiderBosses != -1) { @@ -457,7 +461,7 @@ public class LootTracker { spiderMosquitosSession++; ConfigHandler.writeIntConfig("spider", "mosquito", spiderMosquitos); if (ToggleCommand.rngesusAlerts) Utils.createTitle(EnumChatFormatting.GOLD + "DIGESTED MOSQUITO!", 5); - } else if (message.contains("Talk to Maddox to claim your Zombie Slayer XP!")) { // Zombie + } else if (message.contains(" Zombie Slayer LVL ")) { // Zombie zombieRevs++; zombieRevsSession++; if (zombieBosses != -1) { @@ -502,6 +506,18 @@ public class LootTracker { zombieScythesSession++; ConfigHandler.writeIntConfig("zombie", "scythe", zombieScythes); if (ToggleCommand.rngesusAlerts) Utils.createTitle(EnumChatFormatting.GOLD + "SCYTHE BLADE!", 5); + } else if (message.contains("INSANE DROP! (Shard of the Shredded)")) { + zombieRNG = true; + zombieShards++; + zombieShardsSession++; + ConfigHandler.writeIntConfig("zombie", "shard", zombieShards); + if (ToggleCommand.rngesusAlerts) Utils.createTitle(EnumChatFormatting.RED + "SHARD OF THE SHREDDED!", 5); + } else if (message.contains("INSANE DROP! (Warden Heart)")) { + zombieRNG = true; + zombieWardenHearts++; + zombieWardenHeartsSession++; + ConfigHandler.writeIntConfig("zombie", "heart", zombieWardenHearts); + if (ToggleCommand.rngesusAlerts) Utils.createTitle(EnumChatFormatting.RED + "WARDEN HEART!", 5); } if (wolfRNG) { diff --git a/src/main/java/me/Danker/gui/OnlySlayerGui.java b/src/main/java/me/Danker/gui/OnlySlayerGui.java index 552a354..6ae1490 100644 --- a/src/main/java/me/Danker/gui/OnlySlayerGui.java +++ b/src/main/java/me/Danker/gui/OnlySlayerGui.java @@ -23,6 +23,7 @@ public class OnlySlayerGui extends GuiScreen { private GuiButton two; private GuiButton three; private GuiButton four; + private GuiButton five; @Override public boolean doesGuiPauseGame() { @@ -48,9 +49,14 @@ public class OnlySlayerGui extends GuiScreen { case "III": onlyNumberInt = 3; break; - default: + case "IV": onlyNumberInt = 4; break; + case "V": + onlyNumberInt = 5; + break; + default: + return; } goBack = new GuiButton(0, 2, height - 30, 100, 20, "Go Back"); @@ -58,10 +64,11 @@ public class OnlySlayerGui extends GuiScreen { zombie = new GuiButton(0, width / 2 - 200, (int) (height * 0.4), 120, 20, "Zombie"); spider = new GuiButton(0, width / 2 - 60, (int) (height * 0.4), 120, 20, "Spider"); wolf = new GuiButton(0, width / 2 + 80, (int) (height * 0.4), 120, 20, "Wolf"); - one = new GuiButton(0, width / 2 - 190, (int) (height * 0.6), 85, 20, "I"); - two = new GuiButton(0, width / 2 - 95, (int) (height * 0.6), 85, 20, "II"); - three = new GuiButton(0, width / 2 + 10, (int) (height * 0.6), 85, 20, "III"); - four = new GuiButton(0, width / 2 + 115, (int) (height * 0.6), 85, 20, "IV"); + one = new GuiButton(0, width / 2 - 190, (int) (height * 0.6), 60, 20, "I"); + two = new GuiButton(0, width / 2 - 110, (int) (height * 0.6), 60, 20, "II"); + three = new GuiButton(0, width / 2 - 30, (int) (height * 0.6), 60, 20, "III"); + four = new GuiButton(0, width / 2 + 50, (int) (height * 0.6), 60, 20, "IV"); + five = new GuiButton(0, width / 2 + 130, (int) (height * 0.6), 60, 20, "V"); this.buttonList.add(off); this.buttonList.add(zombie); @@ -71,6 +78,7 @@ public class OnlySlayerGui extends GuiScreen { this.buttonList.add(two); this.buttonList.add(three); this.buttonList.add(four); + this.buttonList.add(five); this.buttonList.add(goBack); } @@ -115,6 +123,8 @@ public class OnlySlayerGui extends GuiScreen { onlyNumberInt = 3; } else if (button == four) { onlyNumberInt = 4; + } else if (button == five) { + onlyNumberInt = 5; } String onlyNumber; @@ -129,6 +139,11 @@ public class OnlySlayerGui extends GuiScreen { onlyNumber = "III"; break; case 4: + onlyNumber = "IV"; + break; + case 5: + onlyNumber = "V"; + break; default: onlyNumber = "IV"; } diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index 19edeff..cb04daa 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -315,6 +315,8 @@ public class ConfigHandler { LootTracker.zombieRevCatas = initInt("zombie", "revCatalyst", 0); LootTracker.zombieSnakes = initInt("zombie", "snake", 0); LootTracker.zombieScythes = initInt("zombie", "scythe", 0); + LootTracker.zombieShards = initInt("zombie", "shard", 0); + LootTracker.zombieWardenHearts = initInt("zombie", "heart", 0); LootTracker.zombieTime = initDouble("zombie", "timeRNG", -1); LootTracker.zombieBosses = initInt("zombie", "bossRNG", -1); -- cgit From 42449d4110853d43b40c50f96c2814b865d24f8d Mon Sep 17 00:00:00 2001 From: bowser0000 Date: Thu, 18 Mar 2021 18:24:48 -0400 Subject: Add custom dungeon boss music --- README.md | 15 ++- src/main/java/me/Danker/DankersSkyblockMod.java | 59 ++++++----- .../me/Danker/commands/CustomMusicCommand.java | 70 ++++++++++++ src/main/java/me/Danker/commands/DHelpCommand.java | 5 +- .../java/me/Danker/commands/DankerGuiCommand.java | 3 +- .../java/me/Danker/commands/ToggleCommand.java | 25 ++++- src/main/java/me/Danker/features/CustomMusic.java | 117 +++++++++++++++++++++ src/main/java/me/Danker/gui/DankerGui.java | 17 ++- .../java/me/Danker/handlers/ConfigHandler.java | 2 + 9 files changed, 279 insertions(+), 34 deletions(-) create mode 100644 src/main/java/me/Danker/commands/CustomMusicCommand.java create mode 100644 src/main/java/me/Danker/features/CustomMusic.java (limited to 'src') diff --git a/README.md b/README.md index b9abb21..dfc8ce4 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Discord Server: https://discord.gg/QsEkNQS - Watcher ready message - Catacombs F7 Stage 3 solvers (Starts with letter, select all colour, ignore arrows on sea lanterns) - Find correct Livid (with graphic display of HP) +- Use custom music in dungeon boss room - Experimentation solvers (Ultrasequencer, Chronomatron, Superpairs) - Hide tooltips in experiment addons - Pet background colors based on level @@ -54,7 +55,7 @@ Discord Server: https://discord.gg/QsEkNQS ## Commands - /dhelp - Returns this message in-game. - /dsm - Opens the GUI for Danker's Skyblock Mod. -- /toggle - Toggles features. /toggle list returns values of every toggle. +- /toggle - Toggles features. /toggle list returns values of every toggle. - /setkey - Sets API key. - /getkey - Returns key set with /setkey and copies it to your clipboard. - /loot [winter/festival/spooky/f(1-7)/session] - Returns loot received from slayer quests or fishing stats. /loot fishing winter returns winter sea creatures instead. @@ -75,11 +76,23 @@ Discord Server: https://discord.gg/QsEkNQS - /onlyslayer <1/2/3/4/5> - Stops you from starting a slayer quest other than the one specified. - /skilltracker - Text display for skill xp/hour. - /reparty - Disbands and reparties all members in the party +- /dsmmusic - Stops or reloads the custom music. ## Keybinds - Open Maddox menu - M by default. +- Regular Ability - Numpad 4 by default. - Start/Stop Skill Tracker - Numpad 5 by default. +## Custom Music +- Supported audio formats: + - .wav + - .mid + - .aiff + - .au + - .rmf +- For the following custom music, place a supported music file with the given name in the `.minecraft/config/dsmmusic` folder. + - Dungeon boss music: `dungeonboss` + ### Notes - Slayer tracker for token drops and 20% chance drops uses a 12x12x12 bounding box centered on the player to detect the drops. If you are out of the range of the item drop, it will not count on the tracker. - API commands may take a while depending on your internet connection. The API may also go down. diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index ab042d6..4a40a61 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -53,6 +53,9 @@ import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToSe import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; +import java.io.IOException; import java.util.List; import java.util.Map; @@ -70,6 +73,7 @@ public class DankersSkyblockMod { static boolean OAMWarning = false; public static String guiToOpen = null; public static boolean firstLaunch = false; + public static String configDirectory; public static String MAIN_COLOUR; public static String SECONDARY_COLOUR; @@ -97,6 +101,7 @@ public class DankersSkyblockMod { MinecraftForge.EVENT_BUS.register(new ChronomatronSolver()); MinecraftForge.EVENT_BUS.register(new ClickInOrderSolver()); MinecraftForge.EVENT_BUS.register(new CreeperSolver()); + MinecraftForge.EVENT_BUS.register(new CustomMusic()); MinecraftForge.EVENT_BUS.register(new DungeonTimer()); MinecraftForge.EVENT_BUS.register(new ExpertiseLore()); MinecraftForge.EVENT_BUS.register(new FasterMaddoxCalling()); @@ -145,31 +150,35 @@ public class DankersSkyblockMod { } @EventHandler - public void preInit(final FMLPreInitializationEvent event) { - ClientCommandHandler.instance.registerCommand(new ToggleCommand()); - ClientCommandHandler.instance.registerCommand(new SetkeyCommand()); - ClientCommandHandler.instance.registerCommand(new GetkeyCommand()); - ClientCommandHandler.instance.registerCommand(new LootCommand()); - ClientCommandHandler.instance.registerCommand(new ReloadConfigCommand()); - ClientCommandHandler.instance.registerCommand(new DisplayCommand()); - ClientCommandHandler.instance.registerCommand(new MoveCommand()); - ClientCommandHandler.instance.registerCommand(new SlayerCommand()); - ClientCommandHandler.instance.registerCommand(new SkillsCommand()); - ClientCommandHandler.instance.registerCommand(new GuildOfCommand()); - ClientCommandHandler.instance.registerCommand(new DHelpCommand()); - ClientCommandHandler.instance.registerCommand(new PetsCommand()); - ClientCommandHandler.instance.registerCommand(new BankCommand()); - ClientCommandHandler.instance.registerCommand(new ArmourCommand()); - ClientCommandHandler.instance.registerCommand(new ImportFishingCommand()); - ClientCommandHandler.instance.registerCommand(new ResetLootCommand()); - ClientCommandHandler.instance.registerCommand(new ScaleCommand()); - ClientCommandHandler.instance.registerCommand(new SkyblockPlayersCommand()); - ClientCommandHandler.instance.registerCommand(new BlockSlayerCommand()); - ClientCommandHandler.instance.registerCommand(new DungeonsCommand()); - ClientCommandHandler.instance.registerCommand(new LobbySkillsCommand()); - ClientCommandHandler.instance.registerCommand(new DankerGuiCommand()); - ClientCommandHandler.instance.registerCommand(new SkillTrackerCommand()); - ClientCommandHandler.instance.registerCommand(new FairySoulsCommand()); + public void preInit(final FMLPreInitializationEvent event) throws UnsupportedAudioFileException, IOException, LineUnavailableException { + ClientCommandHandler.instance.registerCommand(new ArmourCommand()); + ClientCommandHandler.instance.registerCommand(new BankCommand()); + ClientCommandHandler.instance.registerCommand(new BlockSlayerCommand()); + ClientCommandHandler.instance.registerCommand(new CustomMusicCommand()); + ClientCommandHandler.instance.registerCommand(new DHelpCommand()); + ClientCommandHandler.instance.registerCommand(new DankerGuiCommand()); + ClientCommandHandler.instance.registerCommand(new DisplayCommand()); + ClientCommandHandler.instance.registerCommand(new DungeonsCommand()); + ClientCommandHandler.instance.registerCommand(new FairySoulsCommand()); + ClientCommandHandler.instance.registerCommand(new GetkeyCommand()); + ClientCommandHandler.instance.registerCommand(new GuildOfCommand()); + ClientCommandHandler.instance.registerCommand(new ImportFishingCommand()); + ClientCommandHandler.instance.registerCommand(new LobbySkillsCommand()); + ClientCommandHandler.instance.registerCommand(new LootCommand()); + ClientCommandHandler.instance.registerCommand(new MoveCommand()); + ClientCommandHandler.instance.registerCommand(new PetsCommand()); + ClientCommandHandler.instance.registerCommand(new ReloadConfigCommand()); + ClientCommandHandler.instance.registerCommand(new ResetLootCommand()); + ClientCommandHandler.instance.registerCommand(new ScaleCommand()); + ClientCommandHandler.instance.registerCommand(new SetkeyCommand()); + ClientCommandHandler.instance.registerCommand(new SkillTrackerCommand()); + ClientCommandHandler.instance.registerCommand(new SkillsCommand()); + ClientCommandHandler.instance.registerCommand(new SkyblockPlayersCommand()); + ClientCommandHandler.instance.registerCommand(new SlayerCommand()); + ClientCommandHandler.instance.registerCommand(new ToggleCommand()); + + configDirectory = event.getModConfigurationDirectory().toString(); + CustomMusic.init(configDirectory); } @EventHandler diff --git a/src/main/java/me/Danker/commands/CustomMusicCommand.java b/src/main/java/me/Danker/commands/CustomMusicCommand.java new file mode 100644 index 0000000..5364930 --- /dev/null +++ b/src/main/java/me/Danker/commands/CustomMusicCommand.java @@ -0,0 +1,70 @@ +package me.Danker.commands; + +import me.Danker.DankersSkyblockMod; +import me.Danker.features.CustomMusic; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ChatComponentText; + +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; +import java.io.IOException; +import java.util.List; + +public class CustomMusicCommand extends CommandBase { + + @Override + public String getCommandName() { + return "dsmmusic"; + } + + @Override + public String getCommandUsage(ICommandSender arg0) { + return "/" + getCommandName() + " "; + } + + @Override + public int getRequiredPermissionLevel() { + return 0; + } + + @Override + public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + if (args.length == 1) { + return getListOfStringsMatchingLastWord(args, "stop", "reload"); + } + return null; + } + + @Override + public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { + final EntityPlayer player = (EntityPlayer)arg0; + + if (arg1.length == 0) { + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Usage: " + getCommandUsage(arg0))); + return; + } + + switch (arg1[0].toLowerCase()) { + case "stop": + if (CustomMusic.dungeonboss != null) CustomMusic.dungeonboss.stop(); + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Stopped custom music.")); + break; + case "reload": + try { + CustomMusic.init(DankersSkyblockMod.configDirectory); + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Reloaded custom music.")); + } catch (IOException | LineUnavailableException | UnsupportedAudioFileException e) { + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "An error occurred while trying to reload music.")); + e.printStackTrace(); + } + break; + default: + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Usage: " + getCommandUsage(arg0))); + } + } + +} diff --git a/src/main/java/me/Danker/commands/DHelpCommand.java b/src/main/java/me/Danker/commands/DHelpCommand.java index c431123..0348574 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-7)/session]" + EnumChatFormatting.AQUA + " - Returns loot received from slayer quests or fishing stats. /loot fishing winter returns winter sea creatures instead.\n" + @@ -54,7 +54,8 @@ public class DHelpCommand extends CommandBase { EnumChatFormatting.GOLD + " /sbplayers" + EnumChatFormatting.AQUA + " - Uses API to find how many players are on each Skyblock island.\n" + EnumChatFormatting.GOLD + " /onlyslayer <1/2/3/4/5>" + EnumChatFormatting.AQUA + " - Stops you from starting a slayer quest other than the one specified.\n" + EnumChatFormatting.GOLD + " /skilltracker " + EnumChatFormatting.AQUA + " - Text display for skill xp/hour.\n" + - EnumChatFormatting.GOLD + " /reparty " + EnumChatFormatting.AQUA + " - Disbands and reparties all members in the party.\n" + + EnumChatFormatting.GOLD + " /reparty" + EnumChatFormatting.AQUA + " - Disbands and reparties all members in the party.\n" + + EnumChatFormatting.GOLD + " /dsmmusic " + EnumChatFormatting.AQUA + " - Stops or reloads the custom music.\n" + EnumChatFormatting.GREEN + " Open Maddox Menu" + EnumChatFormatting.AQUA + " - M by default.\n" + EnumChatFormatting.GREEN + " Start/Stop Skill Tracker" + EnumChatFormatting.AQUA + " - Numpad 5 by default.\n")); } diff --git a/src/main/java/me/Danker/commands/DankerGuiCommand.java b/src/main/java/me/Danker/commands/DankerGuiCommand.java index bd92b3e..6774d5a 100644 --- a/src/main/java/me/Danker/commands/DankerGuiCommand.java +++ b/src/main/java/me/Danker/commands/DankerGuiCommand.java @@ -89,6 +89,7 @@ public class DankerGuiCommand extends CommandBase { debug.append("[superpairs][").append(ToggleCommand.superpairsToggled).append("]\n"); debug.append("[hidetooltipsinaddons][").append(ToggleCommand.hideTooltipsInExperimentAddonsToggled).append("]\n"); debug.append("[pickblock][").append(ToggleCommand.swapToPickBlockToggled).append("]\n"); + debug.append("[dungeonbossmusic][").append(ToggleCommand.dungeonBossMusic).append("]\n"); debug.append("# Locations\n"); debug.append("[coords][").append(MoveCommand.coordsXY[0]).append(", ").append(MoveCommand.coordsXY[1]).append("]\n"); debug.append("[display][").append(MoveCommand.displayXY[0]).append(", ").append(MoveCommand.displayXY[1]).append("]\n"); @@ -110,7 +111,7 @@ public class DankerGuiCommand extends CommandBase { debug.append("\n"); } else { for (ResourcePackRepository.Entry resource : Minecraft.getMinecraft().getResourcePackRepository().getRepositoryEntries()) { - debug.append("< ").append(StringUtils.stripControlCodes(resource.getResourcePackName())).append(" >\n"); + debug.append("<").append(StringUtils.stripControlCodes(resource.getResourcePackName())).append(">\n"); } } debug.append("```"); diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java index 06619ac..2cc4745 100644 --- a/src/main/java/me/Danker/commands/ToggleCommand.java +++ b/src/main/java/me/Danker/commands/ToggleCommand.java @@ -1,6 +1,7 @@ package me.Danker.commands; import me.Danker.DankersSkyblockMod; +import me.Danker.features.CustomMusic; import me.Danker.handlers.ConfigHandler; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; @@ -70,7 +71,9 @@ public class ToggleCommand extends CommandBase implements ICommand { public static boolean chronomatronToggled; public static boolean superpairsToggled; public static boolean hideTooltipsInExperimentAddonsToggled; - + // Custom Music + public static boolean dungeonBossMusic; + @Override public String getCommandName() { return "toggle"; @@ -86,7 +89,8 @@ public class ToggleCommand extends CommandBase implements ICommand { "notifyslayerslain/necronnotifications/bonzotimer/threemanpuzzle/oruopuzzle/blazepuzzle/" + "creeperpuzzle/waterpuzzle/tictactoepuzzle/boulderpuzzle/silverfishpuzzle/icewalkpuzzle/watchermessage/" + "startswithterminal/selectallterminal/clickinorderterminal/blockwrongterminalclicks/" + - "itemframeonsealanterns/ultrasequencer/chronomatron/superpairs/hidetooltipsinaddons/pickblock/list>"; + "itemframeonsealanterns/ultrasequencer/chronomatron/superpairs/hidetooltipsinaddons/" + + "pickblock/dungeonbossmusic/list>"; } @Override @@ -109,7 +113,7 @@ public class ToggleCommand extends CommandBase implements ICommand { "silverfishpuzzle", "icewalkpuzzle", "watchermessage", "startswithterminal", "selectallterminal", "clickinorderterminal", "blockwrongterminalclicks", "itemframeonsealanterns", "ultrasequencer", "chronomatron", "superpairs", - "hidetooltipsinaddons", "pickblock", "list"); + "hidetooltipsinaddons", "pickblock", "dungeonbossmusic", "list"); } return null; } @@ -385,6 +389,18 @@ public class ToggleCommand extends CommandBase implements ICommand { ConfigHandler.writeBooleanConfig("toggles", "PickBlock", swapToPickBlockToggled); player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Auto-swap to pick block has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + swapToPickBlockToggled + DankersSkyblockMod.MAIN_COLOUR + ".")); break; + case "dungeonbossmusic": + dungeonBossMusic = !dungeonBossMusic; + if (CustomMusic.dungeonboss != null) { + if (dungeonBossMusic) { + CustomMusic.start(); + } else { + CustomMusic.dungeonboss.stop(); + } + } + ConfigHandler.writeBooleanConfig("toggles", "DungeonBossMusic", dungeonBossMusic); + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Custom dungeon boss music has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + dungeonBossMusic + DankersSkyblockMod.MAIN_COLOUR + ".")); + break; case "list": player.addChatMessage(new ChatComponentText(DankersSkyblockMod.TYPE_COLOUR + "Guild party notifications: " + DankersSkyblockMod.VALUE_COLOUR + gpartyToggled + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Coord/Angle display: " + DankersSkyblockMod.VALUE_COLOUR + coordsToggled + "\n" + @@ -431,7 +447,8 @@ public class ToggleCommand extends CommandBase implements ICommand { DankersSkyblockMod.TYPE_COLOUR + " Chronomatron solver: " + DankersSkyblockMod.VALUE_COLOUR + chronomatronToggled + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Superpairs solver: " + DankersSkyblockMod.VALUE_COLOUR + superpairsToggled + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Hide tooltips in experiment addons: " + DankersSkyblockMod.VALUE_COLOUR + hideTooltipsInExperimentAddonsToggled + "\n" + - DankersSkyblockMod.TYPE_COLOUR + " Auto-swap to pick block " + DankersSkyblockMod.VALUE_COLOUR + swapToPickBlockToggled + DankersSkyblockMod.TYPE_COLOUR + " Auto-swap to pick block: " + DankersSkyblockMod.VALUE_COLOUR + swapToPickBlockToggled + "\n" + + DankersSkyblockMod.TYPE_COLOUR + " Custom dungeon boss music: " + DankersSkyblockMod.VALUE_COLOUR + dungeonBossMusic )); break; default: diff --git a/src/main/java/me/Danker/features/CustomMusic.java b/src/main/java/me/Danker/features/CustomMusic.java new file mode 100644 index 0000000..8617e7b --- /dev/null +++ b/src/main/java/me/Danker/features/CustomMusic.java @@ -0,0 +1,117 @@ +package me.Danker.features; + +import me.Danker.DankersSkyblockMod; +import me.Danker.commands.ToggleCommand; +import me.Danker.handlers.ScoreboardHandler; +import me.Danker.utils.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.util.StringUtils; +import net.minecraft.world.World; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.client.event.sound.PlaySoundEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import javax.sound.sampled.*; +import java.io.File; +import java.io.IOException; +import java.util.List; + +public class CustomMusic { + + static boolean prevInDungeonBossRoom = false; + static boolean inDungeonBossRoom = false; + public static Clip dungeonboss; + + @SubscribeEvent + public void onWorldChange(WorldEvent.Load event) { + reset(); + } + + @SubscribeEvent(priority = EventPriority.LOW) + public void onTick(TickEvent.ClientTickEvent event) { + if (event.phase != TickEvent.Phase.START) return; + + Minecraft mc = Minecraft.getMinecraft(); + EntityPlayerSP player = mc.thePlayer; + World world = mc.theWorld; + if (DankersSkyblockMod.tickAmount % 10 == 0) { + if (ToggleCommand.dungeonBossMusic && Utils.inDungeons && world != null && player != null) { + prevInDungeonBossRoom = inDungeonBossRoom; + List scoreboard = ScoreboardHandler.getSidebarLines(); + if (scoreboard.size() > 2) { + String firstLine = ScoreboardHandler.cleanSB(scoreboard.get(scoreboard.size() - 1)); + String secondLine = ScoreboardHandler.cleanSB(scoreboard.get(scoreboard.size() - 2)); + if (firstLine.contains("30,30") || // F1 + firstLine.contains("30,125") || // F2 + firstLine.contains("30,225") || // F3 + secondLine.contains("- Healthy") || // F3 + firstLine.contains("30,344") || // F4 + firstLine.contains("livid") || // F5 + firstLine.contains("sadan") || // F6 + firstLine.contains("necron")) { // F7 + + inDungeonBossRoom = true; + if (!prevInDungeonBossRoom && dungeonboss != null) { + start(); + } + } else { + reset(); + } + } + } + } + } + + @SubscribeEvent + public void onChat(ClientChatReceivedEvent event) { + if (!Utils.inDungeons) return; + String message = StringUtils.stripControlCodes(event.message.getUnformattedText()); + + if (message.contains("EXTRA STATS ")) { + if (dungeonboss != null) dungeonboss.stop(); + } + } + + @SubscribeEvent + public void onSound(PlaySoundEvent event) { + if (ToggleCommand.dungeonBossMusic && Utils.inDungeons && inDungeonBossRoom) { + if (event.name.startsWith("note.")) event.setCanceled(true); + } + } + + public static void init(String configDirectory) throws IOException, LineUnavailableException, UnsupportedAudioFileException { + if (configDirectory == null) return; + File directory = new File(configDirectory + "\\dsmmusic"); + if (!directory.exists()) directory.mkdir(); + + reset(); + + dungeonboss = AudioSystem.getClip(); + File dungeonBossFile = new File(configDirectory + "\\dsmmusic\\dungeonboss.wav"); + if (dungeonBossFile.exists()) { + AudioInputStream ais = AudioSystem.getAudioInputStream(dungeonBossFile); + dungeonboss.open(ais); + + FloatControl volume = (FloatControl) dungeonboss.getControl(FloatControl.Type.MASTER_GAIN); + volume.setValue(-20F); + } + } + + static void reset() { + inDungeonBossRoom = false; + if (dungeonboss != null) dungeonboss.stop(); + } + + public static void start() { + if (dungeonboss != null && inDungeonBossRoom) { + dungeonboss.setMicrosecondPosition(0); + dungeonboss.start(); + dungeonboss.loop(Clip.LOOP_CONTINUOUSLY); + } + } + +} diff --git a/src/main/java/me/Danker/gui/DankerGui.java b/src/main/java/me/Danker/gui/DankerGui.java index a6d2bb1..2d07f27 100644 --- a/src/main/java/me/Danker/gui/DankerGui.java +++ b/src/main/java/me/Danker/gui/DankerGui.java @@ -2,6 +2,7 @@ package me.Danker.gui; import me.Danker.DankersSkyblockMod; import me.Danker.commands.ToggleCommand; +import me.Danker.features.CustomMusic; import me.Danker.handlers.ConfigHandler; import me.Danker.handlers.TextRenderer; import me.Danker.utils.Utils; @@ -46,6 +47,7 @@ public class DankerGui extends GuiScreen { private GuiButton skill50Display; private GuiButton outlineText; private GuiButton cakeTimer; + private GuiButton dungeonBossMusic; // Chat Messages private GuiButton lividDagger; private GuiButton sceptreMessages; @@ -55,7 +57,7 @@ public class DankerGui extends GuiScreen { private GuiButton cooldownMessages; private GuiButton manaMessages; private GuiButton killComboMessages; - //Dungeons + // Dungeons private GuiButton dungeonTimer; private GuiButton lowHealthNotify; private GuiButton lividSolver; @@ -138,6 +140,7 @@ public class DankerGui extends GuiScreen { necronNotifications = new GuiButton(0, width / 2 - 100, (int) (height * 0.2), "Necron Phase Notifications: " + Utils.getColouredBoolean(ToggleCommand.necronNotificationsToggled)); bonzoTimer = new GuiButton(0, width / 2 - 100, (int) (height * 0.3), "Bonzo's Mask Timer: " + Utils.getColouredBoolean(ToggleCommand.bonzoTimerToggled)); autoSkillTracker = new GuiButton(0, width / 2 - 100, (int) (height * 0.4), "Auto Start/Stop Skill Tracker: " + Utils.getColouredBoolean(ToggleCommand.autoSkillTrackerToggled)); + dungeonBossMusic = new GuiButton(0, width / 2 - 100, (int) (height * 0.5), "Custom Dungeon Boss Music: " + Utils.getColouredBoolean(ToggleCommand.dungeonBossMusic)); switch (page) { case 1: @@ -199,6 +202,7 @@ public class DankerGui extends GuiScreen { this.buttonList.add(necronNotifications); this.buttonList.add(bonzoTimer); this.buttonList.add(autoSkillTracker); + this.buttonList.add(dungeonBossMusic); this.buttonList.add(backPage); break; } @@ -386,6 +390,17 @@ public class DankerGui extends GuiScreen { ToggleCommand.killComboMessages = !ToggleCommand.killComboMessages; ConfigHandler.writeBooleanConfig("toggles", "KillComboMessages", ToggleCommand.killComboMessages); killComboMessages.displayString = "Kill Combo Messages: " + Utils.getColouredBoolean(ToggleCommand.killComboMessages); + } else if (button == dungeonBossMusic) { + ToggleCommand.dungeonBossMusic = !ToggleCommand.dungeonBossMusic; + if (CustomMusic.dungeonboss != null) { + if (ToggleCommand.dungeonBossMusic) { + CustomMusic.start(); + } else { + CustomMusic.dungeonboss.stop(); + } + } + ConfigHandler.writeBooleanConfig("toggles", "DungeonBossMusic", ToggleCommand.dungeonBossMusic); + dungeonBossMusic.displayString = "Custom Dungeon Boss Music: " + Utils.getColouredBoolean(ToggleCommand.dungeonBossMusic); } } diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index cb04daa..6b17b3c 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -265,6 +265,8 @@ public class ConfigHandler { ToggleCommand.chronomatronToggled = initBoolean("toggles", "Chronomatron", false); ToggleCommand.superpairsToggled = initBoolean("toggles", "Superpairs", false); ToggleCommand.hideTooltipsInExperimentAddonsToggled = initBoolean("toggles", "HideTooltipsInExperimentAddons", false); + // Custom Music + ToggleCommand.dungeonBossMusic = initBoolean("toggles", "DungeonBossMusic", false); // API if (!hasKey("api", "APIKey")) writeStringConfig("api", "APIKey", ""); -- cgit