From 0fad92f9a890f74f2a1c7b0a792325a641f5d322 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 20:19:31 -0500 Subject: Fixed prevent breaking farms Could be improved with a mixin --- src/main/java/me/Danker/DankersSkyblockMod.java | 69 +++++++++++++------------ 1 file changed, 36 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index 325696e..84a181d 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -3003,7 +3003,39 @@ 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.LEFT_CLICK_BLOCK) { + + Block block = Minecraft.getMinecraft().theWorld.getBlockState(event.pos).getBlock(); + + 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.getItem()) && farmBlocks.contains(block)) { + event.setCanceled(true); + } + + } + } if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) { if (ToggleCommand.aotdToggled && item.getDisplayName().contains("Aspect of the Dragons")) { @@ -3038,7 +3070,9 @@ public class DankersSkyblockMod } } - else if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { + if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { + Block block = Minecraft.getMinecraft().theWorld.getBlockState(event.pos).getBlock(); + ArrayList interactables = new ArrayList<>(Arrays.asList( Blocks.acacia_door, Blocks.anvil, @@ -3102,37 +3136,6 @@ 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 -- cgit