Skip to content

Commit 7f90c8e

Browse files
authored
cfgで変更可能な項目の追加 (#7)
1 parent e7b07b5 commit 7f90c8e

11 files changed

Lines changed: 150 additions & 211 deletions

File tree

src/main/java/com/github/gtexpert/gtbm/api/util/ModUtility.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.github.gtexpert.gtbm.api.util;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
35
import java.util.Objects;
46
import java.util.Random;
57

@@ -25,6 +27,8 @@
2527

2628
public class ModUtility {
2729

30+
public static List<ItemStack> disabledItems = new ArrayList<>();
31+
2832
public static @NotNull ItemStack getModItem(String modID, String itemName) {
2933
return GameRegistry.makeItemStack(modID + ":" + itemName, 0, 1, null);
3034
}

src/main/java/com/github/gtexpert/gtbm/client/ClientProxy.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package com.github.gtexpert.gtbm.client;
22

3+
import static com.github.gtexpert.gtbm.api.util.ModUtility.disabledItems;
4+
5+
import net.minecraft.client.resources.I18n;
6+
import net.minecraft.item.ItemStack;
37
import net.minecraftforge.client.event.ModelRegistryEvent;
8+
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
49
import net.minecraftforge.fml.common.Mod;
510
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
611
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -18,4 +23,17 @@ public void preInit(FMLPreInitializationEvent event) {
1823

1924
@SubscribeEvent
2025
public static void registerModels(ModelRegistryEvent event) {}
26+
27+
@SubscribeEvent
28+
public static void onItemTooltip(ItemTooltipEvent event) {
29+
ItemStack stack = event.getItemStack();
30+
if (disabledItems.size() > 1) {
31+
for (ItemStack disabled : disabledItems) {
32+
if (stack.isItemEqual(disabled)) {
33+
event.getToolTip().add(I18n.format("gtbm.tooltip.warn.disabled_item"));
34+
}
35+
}
36+
37+
}
38+
}
2139
}

src/main/java/com/github/gtexpert/gtbm/integration/forestry/ForestryConfigHolder.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,16 @@ public class ForestryConfigHolder {
1515
"default: NORMAL",
1616
"valid: [NORMAL, HARD]" })
1717
public static String gameMode = "NORMAL";
18+
19+
@Config.Comment({ "If true, each will be uncraftable.", "default: false" })
20+
public static boolean Still = false,
21+
Fabricator = false,
22+
Centrifuge = false,
23+
Bottler = false,
24+
Fermenter = false,
25+
Rainmaker = false,
26+
Carpenter = false,
27+
Moistener = false,
28+
Raintank = false,
29+
Squeezer = false;
1830
}

src/main/java/com/github/gtexpert/gtbm/integration/forestry/ForestryModule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public void postInit(FMLPostInitializationEvent event) {
2727
FFMItemRecipe.init();
2828
FFMMaterialsRecipe.init();
2929
FFMToolRecipe.init();
30+
FFMCraftingRecipe.init();
3031

3132
CarpenterLoader.initBase();
3233
CarpenterLoader.initMode();
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.github.gtexpert.gtbm.integration.forestry.recipes;
2+
3+
import static com.github.gtexpert.gtbm.api.util.ModUtility.*;
4+
5+
import java.util.HashMap;
6+
import java.util.Map;
7+
import java.util.function.Supplier;
8+
9+
import net.minecraft.item.ItemStack;
10+
11+
import gregtech.api.recipes.ModHandler;
12+
13+
import com.github.gtexpert.gtbm.api.util.Mods;
14+
import com.github.gtexpert.gtbm.integration.forestry.ForestryConfigHolder;
15+
16+
public class FFMCraftingRecipe {
17+
18+
private static String id = Mods.Names.FORESTRY;
19+
20+
public static void init() {
21+
recipeRemoval();
22+
}
23+
24+
public static void recipeRemoval() {
25+
Map<Supplier<Boolean>, String> recipes = new HashMap<>();
26+
recipes.put(() -> ForestryConfigHolder.Still, "still");
27+
recipes.put(() -> ForestryConfigHolder.Fabricator, "fabricator");
28+
recipes.put(() -> ForestryConfigHolder.Centrifuge, "centrifuge");
29+
recipes.put(() -> ForestryConfigHolder.Bottler, "bottler");
30+
recipes.put(() -> ForestryConfigHolder.Fermenter, "fermenter");
31+
recipes.put(() -> ForestryConfigHolder.Rainmaker, "Rainmaker");
32+
recipes.put(() -> ForestryConfigHolder.Carpenter, "carpenter");
33+
recipes.put(() -> ForestryConfigHolder.Moistener, "moistener");
34+
recipes.put(() -> ForestryConfigHolder.Raintank, "raintank");
35+
recipes.put(() -> ForestryConfigHolder.Squeezer, "squeezer");
36+
recipes.put(() -> ForestryConfigHolder.Fermenter, "fermenter");
37+
38+
recipes.forEach((config, name) -> {
39+
if (config.get()) {
40+
removeRecipeWithTooltip(getModItem(id, name));
41+
}
42+
});
43+
}
44+
45+
private static void removeRecipeWithTooltip(ItemStack stack) {
46+
disabledItems.add(stack);
47+
ModHandler.removeRecipeByOutput(stack);
48+
}
49+
}

src/main/java/com/github/gtexpert/gtbm/integration/forestry/recipes/machines/CentrifugeLoader.java

Lines changed: 0 additions & 210 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,20 @@
22

33
import static gregtech.api.unification.ore.OrePrefix.*;
44

5-
import net.minecraft.init.Blocks;
6-
import net.minecraft.init.Items;
75
import net.minecraft.item.ItemStack;
86

97
import gregtech.api.recipes.RecipeBuilder;
108
import gregtech.api.recipes.RecipeMaps;
11-
import gregtech.api.unification.OreDictUnifier;
12-
import gregtech.api.unification.material.Materials;
139

1410
import com.github.gtexpert.gtbm.api.util.Mods;
1511

16-
import forestry.factory.MachineUIDs;
17-
import forestry.factory.ModuleFactory;
18-
1912
public class CentrifugeLoader {
2013

2114
public static void init() {
2215
if (!Mods.ForestryApiculture.isModLoaded()) return;
2316

2417
ItemStack wax = Mods.Forestry.getItem("beeswax");
2518
ItemStack drop = Mods.Forestry.getItem("honey_drop");
26-
// Recipe was not added by GTCEu
2719
// GenDustry Section
2820
if (Mods.Gendustry.isModLoaded()) {
2921
for (int i = 10; i < 26; i++) {
@@ -32,204 +24,6 @@ public static void init() {
3224
new int[] { 10000, 5000, 3000 });
3325
}
3426
}
35-
// If Forestry's Centrifuge is enabled, recipes will be added by GTCEu
36-
if (ModuleFactory.machineEnabled(MachineUIDs.CENTRIFUGE)) return;
37-
// Forestry Section
38-
RecipeMaps.CENTRIFUGE_RECIPES.recipeBuilder()
39-
.inputs(Mods.Forestry.getItem("propolis", 1, 3))
40-
.chancedOutput(Mods.Forestry.getItem("crafting_material", 1, 2), 6000, 0)
41-
.chancedOutput(Mods.Forestry.getItem("propolis"), 1000, 0)
42-
.EUt(5).duration(128).buildAndRegister();
43-
44-
registerCombRecipe(Mods.Forestry.getItem("bee_combs", 1),
45-
new ItemStack[] { wax, drop },
46-
new int[] { 10000, 9000 });
47-
registerCombRecipe(Mods.Forestry.getItem("bee_combs", 1, 2),
48-
new ItemStack[] { Mods.Forestry.getItem("refractory_wax"), Mods.Forestry.getItem("phosphor", 2) },
49-
new int[] { 10000, 7000 });
50-
registerCombRecipe(Mods.Forestry.getItem("bee_combs", 1, 3),
51-
new ItemStack[] { Mods.Forestry.getItem("propolis"), drop },
52-
new int[] { 10000, 4000 });
53-
registerCombRecipe(Mods.Forestry.getItem("bee_combs", 1, 4),
54-
new ItemStack[] { wax, drop, new ItemStack(Items.SNOWBALL), Mods.Forestry.getItem("pollen", 1, 1) },
55-
new int[] { 8000, 7000, 4000, 2000 });
56-
registerCombRecipe(Mods.Forestry.getItem("bee_combs", 1, 5),
57-
new ItemStack[] { Mods.Forestry.getItem("honeydew"), drop },
58-
new int[] { 10000, 4000 });
59-
registerCombRecipe(Mods.Forestry.getItem("bee_combs", 1, 6),
60-
new ItemStack[] { drop, Mods.Forestry.getItem("propolis", 1, 3) },
61-
new int[] { 10000, 8000 });
62-
registerCombRecipe(Mods.Forestry.getItem("bee_combs", 1, 7),
63-
new ItemStack[] { wax, drop },
64-
new int[] { 10000, 9000 });
65-
registerCombRecipe(Mods.Forestry.getItem("bee_combs", 1, 15),
66-
new ItemStack[] { wax, drop },
67-
new int[] { 10000, 9000 });
68-
registerCombRecipe(Mods.Forestry.getItem("bee_combs", 1, 16),
69-
new ItemStack[] { Mods.Forestry.getItem("honeydew"), new ItemStack(Items.QUARTZ), drop },
70-
new int[] { 6000, 3000, 2000 });
71-
// ExtraBee Section
72-
if (Mods.ExtraBees.isModLoaded()) {
73-
registerCombRecipe(combExtraBee(0),
74-
new ItemStack[] { wax, drop },
75-
new int[] { 10000, 5000 });
76-
registerCombRecipe(combExtraBee(1),
77-
new ItemStack[] { new ItemStack(Items.ROTTEN_FLESH), wax, drop },
78-
new int[] { 8000, 2000, 2000 });
79-
registerCombRecipe(combExtraBee(2),
80-
new ItemStack[] { new ItemStack(Items.DYE, 1, 15), wax, drop },
81-
new int[] { 8000, 2000, 2000 });
82-
registerCombRecipe(combExtraBee(3),
83-
new ItemStack[] { drop, Mods.ExtraBees.getItem("propolis", 1, 1) },
84-
new int[] { 7500, 600 });
85-
registerCombRecipe(combExtraBee(4),
86-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Coal), wax, drop },
87-
new int[] { 10000, 8000, 7500 });
88-
registerCombRecipe(combExtraBee(6),
89-
new ItemStack[] { Mods.ExtraBees.getItem("propolis"), drop },
90-
new int[] { 10000, 9000 });
91-
registerCombRecipe(combExtraBee(7),
92-
new ItemStack[] { Mods.ExtraBees.getItem("honey_drop", 1, 6), drop },
93-
new int[] { 10000, 9000 });
94-
registerCombRecipe(combExtraBee(8),
95-
new ItemStack[] { Mods.ExtraBees.getItem("honey_drop", 1, 3), drop },
96-
new int[] { 10000, 9000 });
97-
registerCombRecipe(combExtraBee(9),
98-
new ItemStack[] { Mods.ExtraBees.getItem("honey_drop", 1, 7), drop },
99-
new int[] { 10000, 9000 });
100-
registerCombRecipe(combExtraBee(10),
101-
new ItemStack[] { Mods.ExtraBees.getItem("honey_drop", 1, 8), drop },
102-
new int[] { 10000, 9000 });
103-
registerCombRecipe(combExtraBee(11),
104-
new ItemStack[] { wax, drop },
105-
new int[] { 5000, 2500 });
106-
registerCombRecipe(combExtraBee(12),
107-
new ItemStack[] { OreDictUnifier.get(dust, Materials.Redstone), wax, drop },
108-
new int[] { 10000, 8000, 5000 });
109-
registerCombRecipe(combExtraBee(14),
110-
new ItemStack[] { Mods.ExtraBees.getItem("honey_drop"), wax,
111-
OreDictUnifier.get(dust, Materials.Redstone) },
112-
new int[] { 10000, 8000, 7500 });
113-
registerCombRecipe(combExtraBee(15),
114-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Iron), wax, drop },
115-
new int[] { 10000, 5000, 2500 });
116-
registerCombRecipe(combExtraBee(16),
117-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Gold), wax, drop },
118-
new int[] { 10000, 5000, 2500 });
119-
registerCombRecipe(combExtraBee(17),
120-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Copper), wax, drop },
121-
new int[] { 10000, 5000, 2500 });
122-
registerCombRecipe(combExtraBee(18),
123-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Tin), wax, drop },
124-
new int[] { 10000, 5000, 2500 });
125-
registerCombRecipe(combExtraBee(19),
126-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Silver), wax, drop },
127-
new int[] { 10000, 5000, 2500 });
128-
registerCombRecipe(combExtraBee(21),
129-
new ItemStack[] { wax, drop },
130-
new int[] { 5000, 2500 });
131-
registerCombRecipe(combExtraBee(22),
132-
new ItemStack[] { drop, new ItemStack(Items.CLAY_BALL), wax },
133-
new int[] { 8000, 8000, 2500 });
134-
registerCombRecipe(combExtraBee(23),
135-
new ItemStack[] { wax, drop },
136-
new int[] { 1000, 9000 });
137-
registerCombRecipe(combExtraBee(24),
138-
new ItemStack[] { new ItemStack(Blocks.BROWN_MUSHROOM_BLOCK), wax,
139-
new ItemStack(Blocks.RED_MUSHROOM_BLOCK) },
140-
new int[] { 10000, 9000, 7500 });
141-
registerCombRecipe(combExtraBee(25),
142-
new ItemStack[] { Mods.ExtraBees.getItem("propolis", 1, 7), drop },
143-
new int[] { 7000, 5000 });
144-
registerCombRecipe(combExtraBee(27),
145-
new ItemStack[] { wax, OreDictUnifier.get(dust, Materials.Sulfur),
146-
Mods.ExtraBees.getItem("honey_drop", 1, 1) },
147-
new int[] { 8000, 7500, 5000 });
148-
registerCombRecipe(combExtraBee(28),
149-
new ItemStack[] { wax, Mods.ExtraBees.getItem("honey_drop", 1, 2) },
150-
new int[] { 8000, 8000 });
151-
registerCombRecipe(combExtraBee(29),
152-
new ItemStack[] { wax, new ItemStack(Items.SLIME_BALL), drop },
153-
new int[] { 10000, 7500, 7500 });
154-
registerCombRecipe(combExtraBee(30),
155-
new ItemStack[] { new ItemStack(Items.BLAZE_POWDER), wax },
156-
new int[] { 10000, 7500 });
157-
registerCombRecipe(combExtraBee(32),
158-
new ItemStack[] { Mods.ExtraBees.getItem("honey_drop", 1, 5), drop },
159-
new int[] { 8000, 7500 });
160-
registerCombRecipe(combExtraBee(36),
161-
new ItemStack[] { OreDictUnifier.get(dust, Materials.Obsidian), drop },
162-
new int[] { 7500, 5000 });
163-
registerCombRecipe(combExtraBee(37),
164-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Lead), wax, drop },
165-
new int[] { 10000, 5000, 2500 });
166-
registerCombRecipe(combExtraBee(40),
167-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Zinc), wax, drop },
168-
new int[] { 10000, 5000, 2500 });
169-
registerCombRecipe(combExtraBee(41),
170-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Titanium), wax, drop },
171-
new int[] { 10000, 5000, 2500 });
172-
registerCombRecipe(combExtraBee(42),
173-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Tungsten), wax, drop },
174-
new int[] { 10000, 5000, 2500 });
175-
registerCombRecipe(combExtraBee(45),
176-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Platinum), wax, drop },
177-
new int[] { 10000, 5000, 2500 });
178-
registerCombRecipe(combExtraBee(46),
179-
new ItemStack[] { new ItemStack(Items.DYE, 6, 4), wax, drop },
180-
new int[] { 10000, 5000, 2500 });
181-
registerCombRecipe(combExtraBee(48),
182-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Pyrite),
183-
OreDictUnifier.get(dustSmall, Materials.Iron), wax, drop },
184-
new int[] { 10000, 10000, 5000, 2500 });
185-
registerCombRecipe(combExtraBee(50),
186-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Cinnabar), wax, drop,
187-
OreDictUnifier.get(dust, Materials.Redstone) },
188-
new int[] { 10000, 5000, 2500, 500 });
189-
registerCombRecipe(combExtraBee(51),
190-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Sphalerite),
191-
OreDictUnifier.get(dustSmall, Materials.Zinc), wax, drop },
192-
new int[] { 10000, 10000, 5000, 2500 });
193-
registerCombRecipe(combExtraBee(52),
194-
new ItemStack[] { Mods.ExtraBees.getItem("misc", 1, 2), wax, drop },
195-
new int[] { 10000, 5000, 2500 });
196-
registerCombRecipe(combExtraBee(53),
197-
new ItemStack[] { Mods.ExtraBees.getItem("misc", 1, 3), wax, drop },
198-
new int[] { 10000, 5000, 2500 });
199-
registerCombRecipe(combExtraBee(54),
200-
new ItemStack[] { Mods.ExtraBees.getItem("misc", 1, 4), wax, drop },
201-
new int[] { 10000, 5000, 2500 });
202-
registerCombRecipe(combExtraBee(56),
203-
new ItemStack[] { Mods.ExtraBees.getItem("misc", 1, 1), wax, drop },
204-
new int[] { 10000, 5000, 2500 });
205-
206-
int meta = 13;
207-
for (int i = 57; i < 73; i++) {
208-
registerCombRecipe(combExtraBee(i),
209-
new ItemStack[] { Mods.ExtraBees.getItem("honey_drop", 1, meta), drop, wax },
210-
new int[] { 10000, 8000, 8000 });
211-
meta++;
212-
}
213-
registerCombRecipe(combExtraBee(73),
214-
new ItemStack[] { OreDictUnifier.get(dustSmall, Materials.Nickel), wax, drop },
215-
new int[] { 10000, 5000, 2500 });
216-
registerCombRecipe(combExtraBee(75),
217-
new ItemStack[] { OreDictUnifier.get(dust, Materials.Glowstone), drop },
218-
new int[] { 10000, 2500 });
219-
registerCombRecipe(combExtraBee(76),
220-
new ItemStack[] { OreDictUnifier.get(dust, Materials.Saltpeter), drop },
221-
new int[] { 10000, 2500 });
222-
registerCombRecipe(combExtraBee(79),
223-
new ItemStack[] { Mods.Forestry.getItem("fertilizer_bio"), drop },
224-
new int[] { 10000, 2500 });
225-
registerCombRecipe(combExtraBee(81),
226-
new ItemStack[] { drop, new ItemStack(Items.QUARTZ),
227-
OreDictUnifier.get(dust, Materials.CertusQuartz) },
228-
new int[] { 2500, 2500, 2000 });
229-
registerCombRecipe(combExtraBee(82),
230-
new ItemStack[] { drop, OreDictUnifier.get(dust, Materials.EnderPearl) },
231-
new int[] { 2500, 2500 });
232-
}
23327
}
23428

23529
public static void registerCombRecipe(ItemStack comb, ItemStack[] output, int[] chance) {
@@ -253,8 +47,4 @@ public static void registerCombRecipe(ItemStack comb, ItemStack[] output, int[]
25347

25448
builder.buildAndRegister();
25549
}
256-
257-
public static ItemStack combExtraBee(int meta) {
258-
return Mods.ExtraBees.getItem("honey_comb", 1, meta);
259-
}
26050
}

src/main/java/com/github/gtexpert/gtbm/integration/gendustry/GendustryConfigHolder.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,17 @@
99
@Config(modid = ModValues.MODID,
1010
name = ModValues.MODID + "/integration/" + Modules.MODULE_GENDUSTRY,
1111
category = "Gendustry")
12-
public class GendustryConfigHolder {}
12+
public class GendustryConfigHolder {
13+
14+
@Config.Comment({ "If true, each will be uncraftable.", "default: false" })
15+
public static boolean MutagenProducer = false,
16+
Mutatron = false,
17+
IndustrialApiary = false,
18+
GeneticImprinter = false,
19+
GeneticSampler = false,
20+
AdvancedMutagen = false,
21+
ProteinLiquifier = false,
22+
DNAExtractor = false,
23+
GeneticTransposer = false,
24+
GeneticReplicator = false;
25+
}

src/main/java/com/github/gtexpert/gtbm/integration/gendustry/GendustryModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.gtexpert.gtbm.integration.gendustry;
22

3+
import com.github.gtexpert.gtbm.integration.gendustry.recipes.GendustryCraftingRecipe;
34
import net.minecraft.block.Block;
45
import net.minecraftforge.event.RegistryEvent;
56
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
@@ -30,5 +31,6 @@ public void registerBlocks(RegistryEvent.Register<Block> event) {
3031
public void postInit(FMLPostInitializationEvent event) {
3132
GendustryItemsRecipe.init();
3233
GendustryBlocksRecipe.init();
34+
GendustryCraftingRecipe.init();
3335
}
3436
}

0 commit comments

Comments
 (0)