Skip to content

Commit

Permalink
Extend Swing Through Grass tweak
Browse files Browse the repository at this point in the history
Item blacklist for items with special interactions
Fixes #571
  • Loading branch information
ACGaming committed Oct 17, 2024
1 parent 5a39340 commit 93d99cd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -14,11 +15,13 @@ public class UTSwingThroughGrassLists
{
protected static List<Block> blacklistedBlocks = new ArrayList<>();
protected static List<Block> whitelistedBlocks = new ArrayList<>();
protected static List<Item> blacklistedItems = new ArrayList<>();

public static void initLists()
{
blacklistedBlocks.clear();
whitelistedBlocks.clear();
blacklistedItems.clear();
try
{
for (String entry : UTConfigTweaks.MISC.SWING_THROUGH_GRASS.utSwingThroughGrassBlacklist)
Expand All @@ -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)
{
Expand Down

0 comments on commit 93d99cd

Please sign in to comment.