Skip to content

Commit d1a5619

Browse files
committed
clean up tool classes impl
1 parent 41ff7ce commit d1a5619

15 files changed

+23
-41
lines changed

src/main/java/gregtech/common/tools/ToolAxe.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public float getAttackSpeed(ItemStack stack) {
5353
@Override
5454
public boolean canMineBlock(IBlockState block, ItemStack stack) {
5555
String tool = block.getBlock().getHarvestTool(block);
56-
return (tool != null && tool.equals("axe")) ||
56+
return (tool != null && AXE_TOOL_CLASSES.contains(tool)) ||
5757
block.getMaterial() == Material.WOOD;
5858
}
5959

src/main/java/gregtech/common/tools/ToolCrowbar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void onStatsAddedToTool(MetaValueItem item) {
4141
@Override
4242
public boolean canMineBlock(IBlockState block, ItemStack stack) {
4343
String tool = block.getBlock().getHarvestTool(block);
44-
return (tool != null && tool.equals("crowbar")) ||
44+
return (tool != null && CROWBAR_TOOL_CLASSES.contains(tool)) ||
4545
block.getMaterial() == Material.CIRCUITS;
4646
}
4747

src/main/java/gregtech/common/tools/ToolFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public float getBaseDamage(ItemStack stack) {
2929
@Override
3030
public boolean canMineBlock(IBlockState block, ItemStack stack) {
3131
String tool = block.getBlock().getHarvestTool(block);
32-
return (tool != null && tool.equals("file")) ||
32+
return (tool != null && FILE_TOOL_CLASSES.contains(tool)) ||
3333
block.getMaterial() == Material.CIRCUITS;
3434
}
3535

src/main/java/gregtech/common/tools/ToolHardHammer.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package gregtech.common.tools;
22

3+
import com.google.common.collect.ImmutableSet;
34
import gregtech.api.recipes.MatchingMode;
45
import gregtech.api.recipes.RecipeMaps;
56
import net.minecraft.block.material.Material;
@@ -16,16 +17,12 @@
1617
import net.minecraft.world.World;
1718

1819
import java.util.Collections;
19-
import java.util.HashSet;
2020
import java.util.List;
2121
import java.util.Set;
2222

2323
public class ToolHardHammer extends ToolBase {
2424

25-
private static final Set<String> HAMMER_TOOL_CLASSES = new HashSet<String>() {{
26-
add("hammer");
27-
add("pickaxe");
28-
}};
25+
private static final Set<String> HAMMER_TOOL_CLASSES = ImmutableSet.of("hammer", "pickaxe");
2926

3027
@Override
3128
public boolean canApplyEnchantment(ItemStack stack, Enchantment enchantment) {
@@ -78,7 +75,7 @@ public float getAttackSpeed(ItemStack stack) {
7875
public boolean canMineBlock(IBlockState block, ItemStack stack) {
7976
String tool = block.getBlock().getHarvestTool(block);
8077
ItemStack itemStack = new ItemStack(block.getBlock(), 1, block.getBlock().getMetaFromState(block));
81-
return (tool != null && (tool.equals("hammer") || tool.equals("pickaxe"))) ||
78+
return (tool != null && HAMMER_TOOL_CLASSES.contains(tool)) ||
8279
block.getMaterial() == Material.ROCK ||
8380
block.getMaterial() == Material.GLASS ||
8481
block.getMaterial() == Material.ICE ||

src/main/java/gregtech/common/tools/ToolHoe.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public float getBaseDamage(ItemStack stack) {
2626
@Override
2727
public boolean canMineBlock(IBlockState block, ItemStack stack) {
2828
String tool = block.getBlock().getHarvestTool(block);
29-
return (tool != null && tool.equals("hoe")) ||
29+
return (tool != null && HOE_TOOL_CLASSES.contains(tool)) ||
3030
block.getMaterial() == Material.GROUND;
3131
}
3232

src/main/java/gregtech/common/tools/ToolMiningHammer.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package gregtech.common.tools;
22

3+
import com.google.common.collect.ImmutableSet;
34
import gregtech.api.items.toolitem.ToolMetaItem;
45
import gregtech.api.util.GTUtility;
56
import gregtech.common.items.behaviors.ModeSwitchBehavior;
@@ -20,10 +21,7 @@
2021

2122
public class ToolMiningHammer extends ToolBase {
2223

23-
private static final Set<String> HAMMER_TOOL_CLASSES = new HashSet<String>() {{
24-
add("pickaxe");
25-
add("hammer");
26-
}};
24+
private static final Set<String> HAMMER_TOOL_CLASSES = ImmutableSet.of("pickaxe", "hammer");
2725

2826
public enum MiningHammerMode implements ModeSwitchBehavior.ILocalizationKey {
2927
THREE_BY_THREE("metaitem.drill.mode.three_by_three", 3, 3, 0.75f),
@@ -89,7 +87,7 @@ public float getMaxDurabilityMultiplier(ItemStack stack) {
8987
@Override
9088
public boolean canMineBlock(IBlockState block, ItemStack stack) {
9189
String tool = block.getBlock().getHarvestTool(block);
92-
return (tool != null && (tool.equals("hammer") || tool.equals("pickaxe"))) ||
90+
return (tool != null && HAMMER_TOOL_CLASSES.contains(tool)) ||
9391
block.getMaterial() == Material.ROCK ||
9492
block.getMaterial() == Material.GLASS ||
9593
block.getMaterial() == Material.ICE ||

src/main/java/gregtech/common/tools/ToolPickaxe.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public float getDigSpeedMultiplier(ItemStack stack) {
3636
@Override
3737
public boolean canMineBlock(IBlockState block, ItemStack stack) {
3838
String tool = block.getBlock().getHarvestTool(block);
39-
return (tool != null && tool.equals("pickaxe")) ||
39+
return (tool != null && PICK_TOOL_CLASSES.contains(tool)) ||
4040
block.getMaterial() == Material.ROCK ||
4141
block.getMaterial() == Material.IRON ||
4242
block.getMaterial() == Material.ANVIL ||

src/main/java/gregtech/common/tools/ToolSaw.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package gregtech.common.tools;
22

3+
import com.google.common.collect.ImmutableSet;
34
import gregtech.api.items.toolitem.ToolMetaItem;
45
import net.minecraft.block.material.Material;
56
import net.minecraft.block.state.IBlockState;
@@ -18,16 +19,12 @@
1819

1920
import javax.annotation.Nullable;
2021
import javax.annotation.ParametersAreNonnullByDefault;
21-
import java.util.HashSet;
2222
import java.util.List;
2323
import java.util.Set;
2424

2525
public class ToolSaw extends ToolBase {
2626

27-
private static final Set<String> SAW_TOOL_CLASSES = new HashSet<String>() {{
28-
add("axe");
29-
add("saw");
30-
}};
27+
private static final Set<String> SAW_TOOL_CLASSES = ImmutableSet.of("axe", "saw");
3128

3229
@Override
3330
public boolean canApplyEnchantment(ItemStack stack, Enchantment enchantment) {
@@ -52,7 +49,7 @@ public float getBaseDamage(ItemStack stack) {
5249
@Override
5350
public boolean canMineBlock(IBlockState block, ItemStack stack) {
5451
String tool = block.getBlock().getHarvestTool(block);
55-
return (tool != null && (tool.equals("axe") || tool.equals("saw"))) ||
52+
return (tool != null && SAW_TOOL_CLASSES.contains(tool)) ||
5653
block.getMaterial() == Material.LEAVES ||
5754
block.getMaterial() == Material.VINE ||
5855
block.getMaterial() == Material.WOOD ||

src/main/java/gregtech/common/tools/ToolScoop.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public int getToolDamagePerBlockBreak(ItemStack stack) {
2020
@Override
2121
public boolean canMineBlock(IBlockState block, ItemStack stack) {
2222
String tool = block.getBlock().getHarvestTool(block);
23-
return tool != null && tool.equals("scoop");
23+
return tool != null && SCOOP_TOOL_CLASSES.contains(tool);
2424
}
2525

2626
@Override

src/main/java/gregtech/common/tools/ToolScrewdriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public float getBaseDamage(ItemStack stack) {
3737
@Override
3838
public boolean canMineBlock(IBlockState block, ItemStack stack) {
3939
String tool = block.getBlock().getHarvestTool(block);
40-
return (tool != null && tool.equals("screwdriver")) ||
40+
return (tool != null && DRIVER_TOOL_CLASSES.contains(tool)) ||
4141
block.getMaterial() == Material.CIRCUITS;
4242
}
4343

0 commit comments

Comments
 (0)