From 93d99cdfce890c18a7d16db5c1336d6b0de8c7d5 Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Thu, 17 Oct 2024 10:19:59 +0200 Subject: [PATCH] Extend Swing Through Grass tweak Item blacklist for items with special interactions Fixes #571 --- .../universaltweaks/config/UTConfigTweaks.java | 11 +++++++++++ .../misc/swingthroughgrass/UTSwingThroughGrass.java | 4 ++-- .../swingthroughgrass/UTSwingThroughGrassLists.java | 8 ++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java index 37b2acb7..abac7499 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java @@ -1951,6 +1951,17 @@ public static class SwingThroughGrassCategory "Syntax: modid:block" }) public String[] utSwingThroughGrassWhitelist = new String[] {}; + + @Config.Name("[4] Item Blacklist") + @Config.Comment + ({ + "Excludes items from the swing through grass tweak", + "Syntax: modid:item" + }) + public String[] utSwingThroughGrassItemBlacklist = new String[] + { + "erebus:wand_of_animation" + }; } public static class TimeoutsCategory diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/swingthroughgrass/UTSwingThroughGrass.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/swingthroughgrass/UTSwingThroughGrass.java index 16defc00..2ec86799 100644 --- a/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/swingthroughgrass/UTSwingThroughGrass.java +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/swingthroughgrass/UTSwingThroughGrass.java @@ -23,7 +23,7 @@ public class UTSwingThroughGrass @SubscribeEvent(priority = EventPriority.HIGHEST) public static void utSwingThroughGrass(PlayerInteractEvent.LeftClickBlock event) { - if (!UTConfigTweaks.MISC.SWING_THROUGH_GRASS.utSwingThroughGrassToggle) return; + if (!UTConfigTweaks.MISC.SWING_THROUGH_GRASS.utSwingThroughGrassToggle || UTSwingThroughGrassLists.blacklistedItems.contains(event.getEntityPlayer().getHeldItemMainhand().getItem())) return; if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTSwingThroughGrass ::: Left click block event"); Entity entity = getEntityBehindGrass(event.getWorld(), event.getPos(), event.getEntityPlayer()); if (entity != null) @@ -36,7 +36,7 @@ public static void utSwingThroughGrass(PlayerInteractEvent.LeftClickBlock event) @SubscribeEvent(priority = EventPriority.HIGHEST) public static void utInteractThroughGrass(PlayerInteractEvent.RightClickBlock event) { - if (!UTConfigTweaks.MISC.SWING_THROUGH_GRASS.utSwingThroughGrassToggle) return; + if (!UTConfigTweaks.MISC.SWING_THROUGH_GRASS.utSwingThroughGrassToggle || UTSwingThroughGrassLists.blacklistedItems.contains(event.getEntityPlayer().getHeldItemMainhand().getItem())) return; if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTSwingThroughGrass ::: Right click block event"); Entity entity = getEntityBehindGrass(event.getWorld(), event.getPos(), event.getEntityPlayer()); if (entity != null) diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/swingthroughgrass/UTSwingThroughGrassLists.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/swingthroughgrass/UTSwingThroughGrassLists.java index 831248f8..99de1163 100644 --- a/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/swingthroughgrass/UTSwingThroughGrassLists.java +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/misc/swingthroughgrass/UTSwingThroughGrassLists.java @@ -4,6 +4,7 @@ import java.util.List; import net.minecraft.block.Block; +import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.registry.ForgeRegistries; @@ -14,11 +15,13 @@ public class UTSwingThroughGrassLists { protected static List blacklistedBlocks = new ArrayList<>(); protected static List whitelistedBlocks = new ArrayList<>(); + protected static List blacklistedItems = new ArrayList<>(); public static void initLists() { blacklistedBlocks.clear(); whitelistedBlocks.clear(); + blacklistedItems.clear(); try { for (String entry : UTConfigTweaks.MISC.SWING_THROUGH_GRASS.utSwingThroughGrassBlacklist) @@ -31,6 +34,11 @@ public static void initLists() ResourceLocation resLoc = new ResourceLocation(entry); if (ForgeRegistries.BLOCKS.containsKey(resLoc)) whitelistedBlocks.add(ForgeRegistries.BLOCKS.getValue(resLoc)); } + for (String entry : UTConfigTweaks.MISC.SWING_THROUGH_GRASS.utSwingThroughGrassItemBlacklist) + { + ResourceLocation resLoc = new ResourceLocation(entry); + if (ForgeRegistries.ITEMS.containsKey(resLoc)) blacklistedItems.add(ForgeRegistries.ITEMS.getValue(resLoc)); + } } catch (Exception e) {