Skip to content

Commit

Permalink
Changed to include metadata (optionally) in the blacklist.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderChenhall committed Jul 30, 2024
1 parent 3d0fcb1 commit 891ab49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main/java/tconstruct/library/tools/AOEHarvestTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla
if (xPos == x && yPos == y && zPos == z) continue;

Block targetBlock = player.worldObj.getBlock(xPos, yPos, zPos);
int targetMeta = player.worldObj.getBlockMetadata(xPos, yPos, zPos);

if (!AoEExclusionList.isBlockExcluded(toolName, targetBlock)) {
if (!AoEExclusionList.isBlockExcluded(toolName, targetBlock, targetMeta)) {
if (!super.onBlockStartBreak(stack, xPos, yPos, zPos, player))
breakExtraBlock(player.worldObj, xPos, yPos, zPos, sideHit, player, x, y, z);
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/tconstruct/library/util/AoEExclusionList.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ private static void loadConfig() {
String[] exclusionArray = config.getStringList(
tool + "Exclusions",
"AOE_Exclusions",
new String[] { "examplemod:exampleblock" },
"Block IDs that should not be broken by " + tool + "'s AOE effect");
new String[] { "examplemod:exampleblock", "examplemod:exampleblock:1" },
"Block IDs (with optional metadata) that should not be broken by " + tool + "'s AOE effect");
Set<String> exclusionSet = new HashSet<>(Arrays.asList(exclusionArray));
toolExclusionLists.put(tool, exclusionSet);
}
Expand All @@ -35,7 +35,7 @@ private static void loadConfig() {
}
}

public static boolean isBlockExcluded(String tool, Block block) {
public static boolean isBlockExcluded(String tool, Block block, int metadata) {
Set<String> exclusions = toolExclusionLists.get(tool);
if (exclusions == null) {
exclusions = toolExclusionLists.get("tool." + tool);
Expand All @@ -46,6 +46,6 @@ public static boolean isBlockExcluded(String tool, Block block) {
}

String blockId = Block.blockRegistry.getNameForObject(block);
return exclusions.contains(blockId);
return exclusions.contains(blockId) || exclusions.contains(blockId + ":" + metadata);
}
}

0 comments on commit 891ab49

Please sign in to comment.