From 6143fa32651bebd85afa46d8f8a4eeaea9fee595 Mon Sep 17 00:00:00 2001 From: My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> Date: Sat, 19 Dec 2020 11:22:32 -0500 Subject: Feat: Prevent Breaking Farms --- src/main/java/me/Danker/DankersSkyblockMod.java | 37 ++++++++++++++++++++-- src/main/java/me/Danker/commands/DHelpCommand.java | 2 +- .../java/me/Danker/commands/DankerGuiCommand.java | 1 + .../java/me/Danker/commands/ToggleCommand.java | 11 +++++-- src/main/java/me/Danker/gui/DankerGui.java | 14 +++++++- .../java/me/Danker/handlers/ConfigHandler.java | 2 ++ 6 files changed, 60 insertions(+), 7 deletions(-) (limited to 'src/main/java/me/Danker') diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index 2035784..da82fdb 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -3003,8 +3003,9 @@ public class DankersSkyblockMod if (!Utils.inSkyblock || Minecraft.getMinecraft().thePlayer != event.entityPlayer) return; ItemStack item = event.entityPlayer.getHeldItem(); if (item == null) return; + Block block = Minecraft.getMinecraft().theWorld.getBlockState(event.pos).getBlock(); - if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) { + if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) { if (ToggleCommand.aotdToggled && item.getDisplayName().contains("Aspect of the Dragons")) { event.setCanceled(true); } @@ -3037,8 +3038,7 @@ public class DankersSkyblockMod } } - if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { - Block block = Minecraft.getMinecraft().theWorld.getBlockState(event.pos).getBlock(); + else if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { ArrayList interactables = new ArrayList<>(Arrays.asList( Blocks.acacia_door, Blocks.anvil, @@ -3102,6 +3102,37 @@ public class DankersSkyblockMod } } } + + else if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) { + if (ToggleCommand.blockBreakingFarmsToggled) { + ArrayList tools = new ArrayList(Arrays.asList( + Items.wooden_hoe, + Items.stone_hoe, + Items.iron_hoe, + Items.golden_hoe, + Items.diamond_hoe, + Items.wooden_axe, + Items.stone_axe, + Items.iron_axe, + Items.golden_axe, + Items.diamond_axe + )); + + ArrayList farmBlocks = new ArrayList(Arrays.asList( + Blocks.dirt, + Blocks.farmland, + Blocks.carpet, + Blocks.glowstone, + Blocks.sea_lantern + )); + + if (tools.contains(item) && farmBlocks.contains(block)) { + event.setCanceled(true); + } + + } + } + } @SubscribeEvent diff --git a/src/main/java/me/Danker/commands/DHelpCommand.java b/src/main/java/me/Danker/commands/DHelpCommand.java index a9632b9..699374d 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 3e599f5..dea6859 100644 --- a/src/main/java/me/Danker/commands/DankerGuiCommand.java +++ b/src/main/java/me/Danker/commands/DankerGuiCommand.java @@ -62,6 +62,7 @@ public class DankerGuiCommand extends CommandBase { debug.append("[notifyslayerslain][").append(ToggleCommand.notifySlayerSlainToggled).append("]\n"); debug.append("[necronnotifications][").append(ToggleCommand.necronNotificationsToggled).append("]\n"); debug.append("[bonzotimer][").append(ToggleCommand.bonzoTimerToggled).append("]\n"); + debug.append("[blockbreakingfarms][").append(ToggleCommand.blockBreakingFarmsToggled).append("]\n"); debug.append("[threemanpuzzle][").append(ToggleCommand.threeManToggled).append("]\n"); debug.append("[oruopuzzle][").append(ToggleCommand.oruoToggled).append("]\n"); debug.append("[blazepuzzle][").append(ToggleCommand.blazeToggled).append("]\n"); diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java index 2b9bbd7..81e3f9c 100644 --- a/src/main/java/me/Danker/commands/ToggleCommand.java +++ b/src/main/java/me/Danker/commands/ToggleCommand.java @@ -43,6 +43,8 @@ public class ToggleCommand extends CommandBase implements ICommand { public static boolean notifySlayerSlainToggled; public static boolean necronNotificationsToggled; public static boolean bonzoTimerToggled; + public static boolean blockBreakingFarmsToggled; + // Puzzle Solvers public static boolean threeManToggled; public static boolean oruoToggled; @@ -72,7 +74,7 @@ public class ToggleCommand extends CommandBase implements ICommand { return "/" + getCommandName() + " "; } @@ -90,7 +92,7 @@ public class ToggleCommand extends CommandBase implements ICommand { "flowerweapons", "sceptremessages", "petcolors", "dungeontimer", "golemalerts", "expertiselore", "skill50display", "outlinetext", "midasstaffmessages", "implosionmessages", "healmessages", "caketimer", "lowhealthnotify", - "lividsolver", "stopsalvagestarred", "notifyslayerslain", "necronnotifications", "bonzotimer", "threemanpuzzle", "oruopuzzle", "blazepuzzle", + "lividsolver", "stopsalvagestarred", "notifyslayerslain", "necronnotifications", "bonzotimer", "blockbreakingfarms", "threemanpuzzle", "oruopuzzle", "blazepuzzle", "creeperpuzzle", "waterpuzzle", "tictactoepuzzle", "watchermessage", "startswithterminal", "selectallterminal", "clickinorderterminal", "blockwrongterminalclicks", "itemframeonsealanterns", "ultrasequencer", "chronomatron", "superpairs", "hidetooltipsinaddons", "pickblock", "list"); @@ -249,6 +251,11 @@ public class ToggleCommand extends CommandBase implements ICommand { ConfigHandler.writeBooleanConfig("toggles", "BonzoTimer", bonzoTimerToggled); player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Bonzo's Mask timer has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + necronNotificationsToggled + DankersSkyblockMod.MAIN_COLOUR + ".")); break; + case "blockbreakingfarms": + blockBreakingFarmsToggled = !blockBreakingFarmsToggled; + ConfigHandler.writeBooleanConfig("toggles", "BlockBreakingFarms", blockBreakingFarmsToggled); + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Prevent breaking farms has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + necronNotificationsToggled + DankersSkyblockMod.MAIN_COLOUR + ".")); + break; case "threemanpuzzle": threeManToggled = !threeManToggled; ConfigHandler.writeBooleanConfig("toggles", "ThreeManPuzzle", threeManToggled); diff --git a/src/main/java/me/Danker/gui/DankerGui.java b/src/main/java/me/Danker/gui/DankerGui.java index 03937a8..2860997 100644 --- a/src/main/java/me/Danker/gui/DankerGui.java +++ b/src/main/java/me/Danker/gui/DankerGui.java @@ -60,6 +60,7 @@ public class DankerGui extends GuiScreen { private GuiButton notifySlayerSlain; private GuiButton necronNotifications; private GuiButton bonzoTimer; + private GuiButton blockBreakingFarms; public DankerGui(int page) { this.page = page; @@ -125,6 +126,8 @@ public class DankerGui extends GuiScreen { flowerWeapons = new GuiButton(0, width / 2 - 100, (int) (height * 0.5), "Prevent Placing FoT/Spirit Sceptre: " + Utils.getColouredBoolean(ToggleCommand.flowerWeaponsToggled)); necronNotifications = new GuiButton(0, width / 2 - 100, (int) (height * 0.6), "Necron Phase Notifications: " + Utils.getColouredBoolean(ToggleCommand.necronNotificationsToggled)); bonzoTimer = new GuiButton(0, width / 2 - 100, (int) (height * 0.7), "Bonzo's Mask Timer: " + Utils.getColouredBoolean(ToggleCommand.bonzoTimerToggled)); + //Page 6 + blockBreakingFarms = new GuiButton(0, width / 2 - 100, (int) (height * 0.1), "Prevent Breaking Farms: " + Utils.getColouredBoolean(ToggleCommand.blockBreakingFarmsToggled)); switch (page) { case 1: @@ -178,6 +181,11 @@ public class DankerGui extends GuiScreen { this.buttonList.add(flowerWeapons); this.buttonList.add(necronNotifications); this.buttonList.add(bonzoTimer); + this.buttonList.add(nextPage); + this.buttonList.add(backPage); + break; + case 6: + this.buttonList.add(blockBreakingFarms); this.buttonList.add(backPage); break; } @@ -190,7 +198,7 @@ public class DankerGui extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); - String pageText = "Page: " + page + "/5"; + String pageText = "Page: " + page + "/6"; int pageWidth = mc.fontRendererObj.getStringWidth(pageText); new TextRenderer(mc, pageText, width / 2 - pageWidth / 2, 10, 1D); super.drawScreen(mouseX, mouseY, partialTicks); @@ -338,6 +346,10 @@ public class DankerGui extends GuiScreen { ToggleCommand.bonzoTimerToggled = !ToggleCommand.bonzoTimerToggled; ConfigHandler.writeBooleanConfig("toggles", "BonzoTimer", ToggleCommand.bonzoTimerToggled); bonzoTimer.displayString = "Bonzo's Mask Timer: " + Utils.getColouredBoolean(ToggleCommand.bonzoTimerToggled); + } else if (button == blockBreakingFarms) { + ToggleCommand.blockBreakingFarmsToggled = !ToggleCommand.blockBreakingFarmsToggled; + ConfigHandler.writeBooleanConfig("toggles", "BlockBreakingFarms", ToggleCommand.blockBreakingFarmsToggled); + blockBreakingFarms.displayString = "Prevent Breaking Farms: " + Utils.getColouredBoolean(ToggleCommand.blockBreakingFarmsToggled); } else if (button == pickBlock) { ToggleCommand.swapToPickBlockToggled = !ToggleCommand.swapToPickBlockToggled; ConfigHandler.writeBooleanConfig("toggles", "PickBlock", ToggleCommand.swapToPickBlockToggled); diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index 2822738..3d1855e 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -198,6 +198,7 @@ public class ConfigHandler { if (!hasKey("toggles", "NotifySlayerSlain")) writeBooleanConfig("toggles", "NotifySlayerSlain", false); if (!hasKey("toggles", "NecronNotifications")) writeBooleanConfig("toggles", "NecronNotifications", false); if (!hasKey("toggles", "BonzoTimer")) writeBooleanConfig("toggles", "BonzoTimer", false); + if (!hasKey("toggles", "BlockBreakingFarms")) writeBooleanConfig("toggles", "BlockBreakingFarms", true); // Puzzle Solvers @@ -475,6 +476,7 @@ public class ConfigHandler { ToggleCommand.notifySlayerSlainToggled = getBoolean("toggles", "NotifySlayerSlain"); ToggleCommand.necronNotificationsToggled = getBoolean("toggles", "NecronNotifications"); ToggleCommand.bonzoTimerToggled = getBoolean("toggles", "BonzoTimer"); + ToggleCommand.blockBreakingFarmsToggled = getBoolean("toggles", "BlockBreakingFarms"); ToggleCommand.swapToPickBlockToggled = getBoolean("toggles", "PickBlock"); ToggleCommand.flowerWeaponsToggled = getBoolean("toggles", "FlowerWeapons"); -- cgit