Skip to content

Commit 31a0da3

Browse files
Requested changes.
1 parent 0722e39 commit 31a0da3

File tree

4 files changed

+59
-46
lines changed

4 files changed

+59
-46
lines changed

src/main/java/net/neganote/gtutilities/common/tools/UtilToolConnection.java

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,108 +17,117 @@ public static void modifyMaterials() {
1717
for (Material material : GTCEuAPI.materialManager.getRegisteredMaterials()) {
1818
ToolProperty toolProperty = material.getProperty(PropertyKey.TOOL);
1919

20+
if (toolProperty == null) {
21+
continue;
22+
}
23+
24+
// Custom MV Tools
2025
if (UtilConfig.INSTANCE.features.customMVToolsEnabled) {
21-
if (toolProperty != null && toolProperty.hasType(GTToolType.SCREWDRIVER_LV)) {
26+
if (toolProperty.hasType(GTToolType.SCREWDRIVER_LV)) {
2227
toolProperty.addTypes(UtilToolType.SCREWDRIVER_MV);
2328
}
24-
if (toolProperty != null && toolProperty.hasType(GTToolType.BUZZSAW)) {
29+
if (toolProperty.hasType(GTToolType.BUZZSAW)) {
2530
toolProperty.addTypes(UtilToolType.BUZZSAW_MV);
2631
}
27-
if (toolProperty != null && toolProperty.hasType(GTToolType.CHAINSAW_LV)) {
32+
if (toolProperty.hasType(GTToolType.CHAINSAW_LV)) {
2833
toolProperty.addTypes(UtilToolType.CHAINSAW_MV);
2934
}
30-
if (toolProperty != null && toolProperty.hasType(GTToolType.WIRE_CUTTER_LV)) {
35+
if (toolProperty.hasType(GTToolType.WIRE_CUTTER_LV)) {
3136
toolProperty.addTypes(UtilToolType.WIRE_CUTTER_MV);
3237
}
33-
if (toolProperty != null && toolProperty.hasType(GTToolType.WRENCH_LV)) {
38+
if (toolProperty.hasType(GTToolType.WRENCH_LV)) {
3439
toolProperty.addTypes(UtilToolType.WRENCH_MV);
3540
}
3641
}
3742

43+
// Custom HV Tools
3844
if (UtilConfig.INSTANCE.features.customHVToolsEnabled) {
39-
if (toolProperty != null && toolProperty.hasType(GTToolType.SCREWDRIVER_LV)) {
45+
if (toolProperty.hasType(GTToolType.SCREWDRIVER_LV)) {
4046
toolProperty.addTypes(UtilToolType.SCREWDRIVER_HV);
4147
}
42-
if (toolProperty != null && toolProperty.hasType(GTToolType.BUZZSAW)) {
48+
if (toolProperty.hasType(GTToolType.BUZZSAW)) {
4349
toolProperty.addTypes(UtilToolType.BUZZSAW_HV);
4450
}
45-
if (toolProperty != null && toolProperty.hasType(GTToolType.CHAINSAW_LV)) {
51+
if (toolProperty.hasType(GTToolType.CHAINSAW_LV)) {
4652
toolProperty.addTypes(UtilToolType.CHAINSAW_HV);
4753
}
4854
}
4955

56+
// Custom EV Tools
5057
if (UtilConfig.INSTANCE.features.customEVToolsEnabled) {
51-
if (toolProperty != null && toolProperty.hasType(GTToolType.SCREWDRIVER_LV)) {
58+
if (toolProperty.hasType(GTToolType.SCREWDRIVER_LV)) {
5259
toolProperty.addTypes(UtilToolType.SCREWDRIVER_EV);
5360
}
54-
if (toolProperty != null && toolProperty.hasType(GTToolType.BUZZSAW)) {
61+
if (toolProperty.hasType(GTToolType.BUZZSAW)) {
5562
toolProperty.addTypes(UtilToolType.BUZZSAW_EV);
5663
}
57-
if (toolProperty != null && toolProperty.hasType(GTToolType.CHAINSAW_LV)) {
64+
if (toolProperty.hasType(GTToolType.CHAINSAW_LV)) {
5865
toolProperty.addTypes(UtilToolType.CHAINSAW_EV);
5966
}
60-
if (toolProperty != null && toolProperty.hasType(GTToolType.WIRE_CUTTER_LV)) {
67+
if (toolProperty.hasType(GTToolType.WIRE_CUTTER_LV)) {
6168
toolProperty.addTypes(UtilToolType.WIRE_CUTTER_EV);
6269
}
63-
if (toolProperty != null && toolProperty.hasType(GTToolType.WRENCH_LV)) {
70+
if (toolProperty.hasType(GTToolType.WRENCH_LV)) {
6471
toolProperty.addTypes(UtilToolType.WRENCH_EV);
6572
}
6673
}
6774

75+
// Custom IV Tools
6876
if (UtilConfig.INSTANCE.features.customIVToolsEnabled) {
69-
if (toolProperty != null && toolProperty.hasType(GTToolType.SCREWDRIVER_LV)) {
77+
if (toolProperty.hasType(GTToolType.SCREWDRIVER_LV)) {
7078
toolProperty.addTypes(UtilToolType.SCREWDRIVER_IV);
7179
}
72-
if (toolProperty != null && toolProperty.hasType(GTToolType.BUZZSAW)) {
80+
if (toolProperty.hasType(GTToolType.BUZZSAW)) {
7381
toolProperty.addTypes(UtilToolType.BUZZSAW_IV);
7482
}
75-
if (toolProperty != null && toolProperty.hasType(GTToolType.CHAINSAW_LV)) {
83+
if (toolProperty.hasType(GTToolType.CHAINSAW_LV)) {
7684
toolProperty.addTypes(UtilToolType.CHAINSAW_IV);
7785
}
7886
}
7987

88+
// Custom LuV Tools
8089
if (UtilConfig.INSTANCE.features.customLuVToolsEnabled) {
81-
if (toolProperty != null && toolProperty.hasType(GTToolType.SCREWDRIVER_LV)) {
90+
if (toolProperty.hasType(GTToolType.SCREWDRIVER_LV)) {
8291
toolProperty.addTypes(UtilToolType.SCREWDRIVER_LuV);
8392
}
84-
if (toolProperty != null && toolProperty.hasType(GTToolType.BUZZSAW)) {
93+
if (toolProperty.hasType(GTToolType.BUZZSAW)) {
8594
toolProperty.addTypes(UtilToolType.BUZZSAW_LuV);
8695
}
87-
if (toolProperty != null && toolProperty.hasType(GTToolType.CHAINSAW_LV)) {
96+
if (toolProperty.hasType(GTToolType.CHAINSAW_LV)) {
8897
toolProperty.addTypes(UtilToolType.CHAINSAW_LuV);
8998
}
90-
if (toolProperty != null && toolProperty.hasType(GTToolType.WIRE_CUTTER_LV)) {
99+
if (toolProperty.hasType(GTToolType.WIRE_CUTTER_LV)) {
91100
toolProperty.addTypes(UtilToolType.WIRE_CUTTER_LuV);
92101
}
93-
if (toolProperty != null && toolProperty.hasType(GTToolType.WRENCH_LV)) {
102+
if (toolProperty.hasType(GTToolType.WRENCH_LV)) {
94103
toolProperty.addTypes(UtilToolType.WRENCH_LuV);
95104
}
96-
if (toolProperty != null && toolProperty.hasType(GTToolType.DRILL_LV)) {
105+
if (toolProperty.hasType(GTToolType.DRILL_LV)) {
97106
toolProperty.addTypes(UtilToolType.DRILL_LUV);
98107
}
99108
}
100109

110+
// Custom ZPM Tools
101111
if (UtilConfig.INSTANCE.features.customZPMToolsEnabled) {
102-
if (toolProperty != null && toolProperty.hasType(GTToolType.SCREWDRIVER_LV)) {
112+
if (toolProperty.hasType(GTToolType.SCREWDRIVER_LV)) {
103113
toolProperty.addTypes(UtilToolType.SCREWDRIVER_ZPM);
104114
}
105-
if (toolProperty != null && toolProperty.hasType(GTToolType.BUZZSAW)) {
115+
if (toolProperty.hasType(GTToolType.BUZZSAW)) {
106116
toolProperty.addTypes(UtilToolType.BUZZSAW_ZPM);
107117
}
108-
if (toolProperty != null && toolProperty.hasType(GTToolType.CHAINSAW_LV)) {
118+
if (toolProperty.hasType(GTToolType.CHAINSAW_LV)) {
109119
toolProperty.addTypes(UtilToolType.CHAINSAW_ZPM);
110120
}
111-
if (toolProperty != null && toolProperty.hasType(GTToolType.WIRE_CUTTER_LV)) {
121+
if (toolProperty.hasType(GTToolType.WIRE_CUTTER_LV)) {
112122
toolProperty.addTypes(UtilToolType.WIRE_CUTTER_ZPM);
113123
}
114-
if (toolProperty != null && toolProperty.hasType(GTToolType.WRENCH_LV)) {
124+
if (toolProperty.hasType(GTToolType.WRENCH_LV)) {
115125
toolProperty.addTypes(UtilToolType.WRENCH_ZPM);
116126
}
117-
if (toolProperty != null && toolProperty.hasType(GTToolType.DRILL_LV)) {
127+
if (toolProperty.hasType(GTToolType.DRILL_LV)) {
118128
toolProperty.addTypes(UtilToolType.DRILL_ZPM);
119129
}
120130
}
121-
122131
}
123132
}
124-
}
133+
}

src/main/java/net/neganote/gtutilities/common/tools/UtilToolHelper.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@ public class UtilToolHelper {
1616

1717
static {
1818
if (UtilConfig.INSTANCE.features.customLuVToolsEnabled) {
19-
SUPPLY_POWER_UNIT_LUV = () -> UtilToolItems.POWER_UNIT_LUV != null ?
20-
UtilToolItems.POWER_UNIT_LUV.get().getDefaultInstance() : ItemStack.EMPTY;
19+
SUPPLY_POWER_UNIT_LUV = () -> UtilToolItems.POWER_UNIT_LUV.get().getDefaultInstance();
2120
} else {
2221
SUPPLY_POWER_UNIT_LUV = () -> ItemStack.EMPTY;
2322
}
2423

2524
if (UtilConfig.INSTANCE.features.customZPMToolsEnabled) {
26-
SUPPLY_POWER_UNIT_ZPM = () -> UtilToolItems.POWER_UNIT_ZPM != null ?
27-
UtilToolItems.POWER_UNIT_ZPM.get().getDefaultInstance() : ItemStack.EMPTY;
25+
SUPPLY_POWER_UNIT_ZPM = () -> UtilToolItems.POWER_UNIT_ZPM.get().getDefaultInstance();
2826
} else {
2927
SUPPLY_POWER_UNIT_ZPM = () -> ItemStack.EMPTY;
3028
}
3129
}
32-
}
30+
}

src/main/java/net/neganote/gtutilities/common/tools/recipe/UtilToolRecipeHelper.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.gregtechceu.gtceu.common.data.GTMaterials;
1616
import com.gregtechceu.gtceu.data.recipe.VanillaRecipeHelper;
1717

18+
import net.minecraft.MethodsReturnNonnullByDefault;
1819
import net.minecraft.data.recipes.FinishedRecipe;
1920
import net.minecraft.world.item.Item;
2021
import net.minecraft.world.item.ItemStack;
@@ -25,8 +26,8 @@
2526
import com.tterrag.registrate.util.entry.ItemEntry;
2627
import it.unimi.dsi.fastutil.ints.Int2ReferenceArrayMap;
2728
import it.unimi.dsi.fastutil.ints.Int2ReferenceMap;
28-
import org.jetbrains.annotations.NotNull;
2929

30+
import javax.annotation.ParametersAreNonnullByDefault;
3031
import java.util.function.Consumer;
3132

3233
import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlags.*;
@@ -35,6 +36,8 @@
3536
/**
3637
* Recipes for custom tools.
3738
*/
39+
@MethodsReturnNonnullByDefault
40+
@ParametersAreNonnullByDefault
3841
public class UtilToolRecipeHelper {
3942

4043
public static final Int2ReferenceMap<ItemEntry<? extends Item>> powerUnitItems = new Int2ReferenceArrayMap<>(
@@ -45,7 +48,7 @@ public class UtilToolRecipeHelper {
4548

4649
private UtilToolRecipeHelper() {}
4750

48-
public static void run(@NotNull Consumer<FinishedRecipe> provider, @NotNull Material material) {
51+
public static void run( Consumer<FinishedRecipe> provider, Material material) {
4952
ToolProperty property = material.getProperty(PropertyKey.TOOL);
5053
if (property == null) {
5154
return;
@@ -54,8 +57,8 @@ public static void run(@NotNull Consumer<FinishedRecipe> provider, @NotNull Mate
5457
processElectricTool(provider, property, material);
5558
}
5659

57-
private static void processElectricTool(@NotNull Consumer<FinishedRecipe> provider, @NotNull ToolProperty property,
58-
@NotNull Material material) {
60+
private static void processElectricTool( Consumer<FinishedRecipe> provider, ToolProperty property,
61+
Material material) {
5962
if (!material.shouldGenerateRecipesFor(plate)) {
6063
return;
6164
}
@@ -167,9 +170,9 @@ private static void processElectricTool(@NotNull Consumer<FinishedRecipe> provid
167170
}
168171
}
169172

170-
private static void addElectricToolRecipe(@NotNull Consumer<FinishedRecipe> provider, @NotNull TagPrefix toolHead,
171-
@NotNull GTToolType @NotNull [] toolItems,
172-
@NotNull Material material) {
173+
private static void addElectricToolRecipe( Consumer<FinishedRecipe> provider, TagPrefix toolHead,
174+
GTToolType [] toolItems,
175+
Material material) {
173176
for (GTToolType toolType : toolItems) {
174177
if (!material.getProperty(PropertyKey.TOOL).hasType(toolType)) continue;
175178

src/main/java/net/neganote/gtutilities/common/tools/recipe/UtilToolRecipes.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.gregtechceu.gtceu.data.recipe.VanillaRecipeHelper;
1111
import com.gregtechceu.gtceu.utils.ToolItemHelper;
1212

13+
import net.minecraft.MethodsReturnNonnullByDefault;
1314
import net.minecraft.core.registries.BuiltInRegistries;
1415
import net.minecraft.data.recipes.FinishedRecipe;
1516
import net.minecraft.world.item.Item;
@@ -21,8 +22,8 @@
2122
import com.tterrag.registrate.util.entry.ItemEntry;
2223
import it.unimi.dsi.fastutil.ints.Int2ReferenceArrayMap;
2324
import it.unimi.dsi.fastutil.ints.Int2ReferenceMap;
24-
import org.jetbrains.annotations.NotNull;
2525

26+
import javax.annotation.ParametersAreNonnullByDefault;
2627
import java.util.List;
2728
import java.util.function.Consumer;
2829

@@ -32,6 +33,8 @@
3233
/**
3334
* Handles Custom tool & power unit recipes.
3435
*/
36+
@ParametersAreNonnullByDefault
37+
@MethodsReturnNonnullByDefault
3538
public final class UtilToolRecipes {
3639

3740
private UtilToolRecipes() {}
@@ -41,12 +44,12 @@ private UtilToolRecipes() {}
4144
private static final Int2ReferenceMap<Material> baseMaterials = new Int2ReferenceArrayMap<>();
4245
private static final Int2ReferenceMap<List<ItemEntry<? extends Item>>> batteryItems = new Int2ReferenceArrayMap<>();
4346

44-
public static void init(@NotNull Consumer<FinishedRecipe> provider) {
47+
public static void init( Consumer<FinishedRecipe> provider) {
4548
initTierMaps();
4649
registerPowerUnitRecipes(provider);
4750

4851
for (Material material : GTCEuAPI.materialManager.getRegisteredMaterials()) {
49-
net.neganote.gtutilities.common.tools.recipe.UtilToolRecipeHelper.run(provider, material);
52+
UtilToolRecipeHelper.run(provider, material);
5053
}
5154
}
5255

@@ -71,7 +74,7 @@ private static void initTierMaps() {
7174
/**
7275
* Registers shaped recipes for the LuV and ZPM tool power units.
7376
*/
74-
private static void registerPowerUnitRecipes(@NotNull Consumer<FinishedRecipe> provider) {
77+
private static void registerPowerUnitRecipes( Consumer<FinishedRecipe> provider) {
7578
for (int tier : powerUnitItems.keySet()) {
7679
var powerUnitEntry = powerUnitItems.get(tier);
7780
var motorEntry = motorItems.get(tier);

0 commit comments

Comments
 (0)