Skip to content

Commit 1b5bf48

Browse files
authored
Add storage drawers integration (#10)
1 parent b386364 commit 1b5bf48

30 files changed

Lines changed: 1091 additions & 5 deletions

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# v1.3.0
2+
## New: Storage Drawers Integration
3+
- GT materials can now be used to craft _Storage Upgrades_.
4+
- Craftable materials, multipliers, and related settings can be configured via cfg.
5+
- Original materials (Obsidian/Iron/Gold/Diamond/Emerald) are always included.
6+
7+
* * *
8+
19
# v1.2.4
210
## Tinkers' Construct Integration
311
- Fixed GT main-hand + TiC off-hand combination dropping items twice

DEVELOPER.md

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
GTMoreTools exposes addon APIs for its mod integrations.
44
The table below shows current coverage:
55

6-
| Integration | API package | Status |
7-
|---|---|---|
8-
| Tinkers' Construct | `integration.tic.api` | Available |
9-
| Better Builder's Wands || No API yet |
10-
| Chisel || No API yet |
6+
| Integration | API package | Status |
7+
|------------------------|----------------------------------|-------------------------------|
8+
| Tinkers' Construct | `integration.tic.api` | Available |
9+
| Better Builder's Wands || No API yet |
10+
| Chisel || No API yet |
11+
| Storage Drawers | `integration.storagedrawers.api` | Available, but for mixin only |
1112

1213
All registration calls must happen during your mod's `preInit` phase,
1314
**before** GTMT's `registerBlocks`, unless stated otherwise.
@@ -160,3 +161,73 @@ Parallel count scales as `4^(tier − EV) / 2` from EV upward.
160161
### Bookshelf variants (Assembler)
161162

162163
6 wood types × 1 recipe each: 6 planks + 3 Books → carved Bookshelf (100 EU, ULV).
164+
165+
---
166+
167+
## Storage Drawers Integration
168+
An addon API currently exists, but it is mixin-based and not usable. The following describes the internal logic for reference.
169+
170+
### What is added
171+
172+
- Storage Upgrades made from GT materials will be registered for the GT materials specified in the cfg.
173+
174+
### Config Options
175+
176+
`removeOriginal`
177+
- Controls whether the default Storage Upgrade recipes are removed.
178+
- true: All original Storage Upgrade recipes are removed. Only recipes defined by this mod (via upgradeMaterials) will be available.
179+
- false: Original recipes remain alongside the newly added ones.
180+
- Use this if you want to fully replace the default progression with GT-based materials.
181+
182+
`upgradeMaterials`
183+
- Defines custom materials used to craft Storage Upgrades.
184+
- Each entry adds a new Storage Upgrade variant based on a GT material.
185+
186+
#### _Format_
187+
`modId:materialName@multiplier%tier`
188+
189+
#### _Parameters_
190+
- `materialName`: Must be a valid GT material with a dust property.
191+
- `multiplier`: Determines the storage capacity multiplier of the upgrade.
192+
- Range: 1 to 2147483647
193+
- Not affected by the StorageDrawers config.
194+
- `tier` (optional): Required Field Generator tier.
195+
- Range: 1 (LV) to 8 (UV)
196+
- If omitted, defaults to -1 (no Field Generator required).
197+
198+
#### _Behavior_
199+
- A Storage Upgrade using the specified material will be registered for each entry.
200+
- If the config is empty, only the original materials are available.
201+
- Original materials (Obsidian / Iron / Gold / Diamond / Emerald):
202+
- Always included automatically.
203+
- Use tier -1.
204+
- Their multipliers are controlled by the StorageDrawers config.
205+
- **Do NOT define them here.**
206+
207+
#### _Example_
208+
`gregtech:steel@4%2`
209+
- Adds a Steel Storage Upgrade
210+
- Multiplier: x4
211+
- Requires MV-tier Field Generator
212+
213+
#### _Logging_
214+
- Registration results can be checked in the log.
215+
- The process starts with `[GT More Tools]: UpgradeMaterialData registration started.` and ends with `[GT More Tools]: UpgradeMaterialData registration finished.`
216+
- On successful registration, the following message is logged: `[GT More Tools]: Registered UpgradeMaterial (Material=..., meta=..., multiplier=x..., requiredTier=...)`
217+
- For example, a successful registration will produce a log like: `[GT More Tools]: Registered UpgradeMaterial (Material=steel, meta=324, multiplier=x4, requiredTier=2 (MV))`
218+
- Entries with an invalid format will be skipped, and the log will indicate the issue.
219+
220+
### Crafting
221+
222+
```
223+
P S P
224+
S U S
225+
P X P
226+
```
227+
228+
- **P** = `plate`
229+
- **S** = `screw`
230+
- **U** = Upgrade Template
231+
- **X** = If _tier_ is -1, a `stickLong`; otherwise, a `Field Generator` of the specified tier
232+
233+
- _Storage Upgrade_ conversion recipes between StorageDrawers and GTMoreTools are always added for Obsidian / Iron / Gold / Diamond / Emerald.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ This mod is an add-on for GregTech CEu that provides integration with various mo
2929
For full details, see [CHANGELOG.md](CHANGELOG.md).
3030

3131

32+
### Storage Drawers Integration
33+
- Add GT material-based Storage Upgrades.
34+
3235
## For Addon Developers
3336

3437
GTMoreTools exposes a public API for extending the Tinkers' Construct integration.

buildscript.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ debug_all = false
3434
debug_chisel = false
3535
debug_bbw = false
3636
debug_tic = false
37+
debug_drawers = false
3738

3839
# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you
3940
# restart Minecraft in development. Choose this dependent on your mod:

dependencies.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,13 @@ dependencies {
6868
runtimeOnly rfg.deobf("curse.maven:mantle-74924:2713386")
6969
runtimeOnly rfg.deobf("curse.maven:tinkers-antique-1242239:7339332")
7070
}
71+
72+
// Debug Storage Drawers: 1.12-5.5.3
73+
compileOnly rfg.deobf("curse.maven:chameleon-230497:2450900") // Chameleon-1.12-4.1.3
74+
compileOnly rfg.deobf("curse.maven:storage-drawers-223852:5981297")
75+
if (project.debug_all.toBoolean() || project.debug_drawers.toBoolean()) {
76+
runtimeOnly rfg.deobf("curse.maven:chameleon-230497:2450900") // Chameleon-1.12-4.1.3
77+
runtimeOnly rfg.deobf("curse.maven:storage-drawers-223852:5981297")
78+
implementation rfg.deobf("curse.maven:topalldependents-1120632:6138503")
79+
}
7180
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.github.gtexpert.gtmt.api.unification.material.info;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
import gregtech.api.GregTechAPI;
7+
import gregtech.api.unification.material.Material;
8+
import gregtech.api.unification.material.Materials;
9+
import gregtech.api.unification.material.info.MaterialFlags;
10+
import gregtech.api.unification.material.properties.PropertyKey;
11+
12+
import com.github.gtexpert.gtmt.api.util.ModLog;
13+
import com.github.gtexpert.gtmt.integration.storagedrawers.StorageDrawersConfigHolder;
14+
15+
public class GTMTMaterialFlags {
16+
17+
public static void integrationStorageDrawers() {
18+
Set<Material> materials = new HashSet<>();
19+
materials.add(Materials.Obsidian);
20+
materials.add(Materials.Iron);
21+
materials.add(Materials.Gold);
22+
materials.add(Materials.Diamond);
23+
materials.add(Materials.Emerald);
24+
25+
for (String str : StorageDrawersConfigHolder.upgradeMaterials) {
26+
if (str.isEmpty()) continue;
27+
28+
String[] split1 = str.split("@", 2);
29+
30+
if (split1.length != 2) {
31+
continue;
32+
33+
}
34+
String materialPart = split1[0];
35+
36+
if (!materialPart.contains(":")) {
37+
continue;
38+
}
39+
40+
Material material = GregTechAPI.materialManager.getMaterial(materialPart);
41+
42+
if (material == null) {
43+
continue;
44+
}
45+
46+
if (!material.hasProperty(PropertyKey.DUST)) {
47+
ModLog.logger.warn("Material must have dust property. Skipping entry.");
48+
continue;
49+
}
50+
materials.add(material);
51+
}
52+
53+
for (Material material : materials) {
54+
if (!material.hasFlag(MaterialFlags.GENERATE_PLATE)) material.addFlags(MaterialFlags.GENERATE_PLATE);
55+
if (!material.hasFlag(MaterialFlags.GENERATE_ROD)) material.addFlags(MaterialFlags.GENERATE_ROD);
56+
if (!material.hasFlag(MaterialFlags.GENERATE_LONG_ROD)) material.addFlags(MaterialFlags.GENERATE_LONG_ROD);
57+
if (!material.hasFlag(MaterialFlags.GENERATE_BOLT_SCREW))
58+
material.addFlags(MaterialFlags.GENERATE_BOLT_SCREW);
59+
}
60+
}
61+
}

src/main/java/com/github/gtexpert/gtmt/api/util/Mods.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public enum Mods {
6868
ProjectRedIllumination(Names.PROJECT_RED_ILLUMINATION),
6969
Railcraft(Names.RAILCRAFT),
7070
RefinedStorage(Names.REFINED_STORAGE),
71+
StorageDrawers(Names.STORAGE_DRAWERS),
7172
Thaumcraft(Names.THAUMCRAFT),
7273
ThaumicEnergistics(Names.THAUMIC_ENERGISTICS),
7374
TheOneProbe(Names.THE_ONE_PROBE),
@@ -143,6 +144,7 @@ public static class Names {
143144
public static final String PROJECT_RED_ILLUMINATION = "projectred-illumination";
144145
public static final String RAILCRAFT = "railcraft";
145146
public static final String REFINED_STORAGE = "refinedstorage";
147+
public static final String STORAGE_DRAWERS = "storagedrawers";
146148
public static final String THAUMCRAFT = "thaumcraft";
147149
public static final String THAUMIC_ENERGISTICS = "thaumicenergistics";
148150
public static final String THE_ONE_PROBE = "theoneprobe";
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.github.gtexpert.gtmt.integration.storagedrawers;
2+
3+
import net.minecraftforge.common.config.Config;
4+
5+
import com.github.gtexpert.gtmt.api.ModValues;
6+
import com.github.gtexpert.gtmt.modules.Modules;
7+
8+
@Config.LangKey(ModValues.MODID + ".config.integration.storage_drawers")
9+
@Config(modid = ModValues.MODID,
10+
name = ModValues.MODID + "/integration/" + Modules.MODULE_DRAWERS,
11+
category = "StorageDrawers")
12+
public class StorageDrawersConfigHolder {
13+
14+
@Config.Comment({ "Remove original storage upgrade recipe", "default: true" })
15+
public static boolean removeOriginal = true;
16+
17+
@Config.Comment({ "Specifies the materials that can be used to craft Storage Upgrades.",
18+
"Format: modId:materialName@multiplier%tier",
19+
"==Notes==",
20+
"--Material--",
21+
"Must have the dust property",
22+
"--Multiplier--",
23+
"The range of \"multiplier\" is 1 to 2147483647",
24+
"The \"multiplier\" value is not affected by StorageDrawers config.",
25+
"--Tier--",
26+
"\"tier\" represents the required field generator tier and can be set from 1 (LV) to 8 (UV).",
27+
"The \"tier\" field is optional and defaults to -1 (no field generator required) if omitted.",
28+
"--Others--",
29+
"Original materials (Obsidian/Iron/Gold/Diamond/Emerald) are automatically added with tier -1.",
30+
"Do not specify them here.",
31+
"The multiplier values for original materials are controlled by the StorageDrawers config.",
32+
"If this entry is left empty, only the original materials will be added." })
33+
public static String[] upgradeMaterials = new String[] {
34+
"gregtech:wrought_iron@4", "gregtech:bronze@8",
35+
"gregtech:steel@16", "gregtech:bismuth_bronze@32%1",
36+
"gregtech:aluminium@64", "gregtech:rose_gold@128%2",
37+
"gregtech:stainless_steel@256", "gregtech:ultimet@512%3",
38+
"gregtech:titanium@1024", "gregtech:ruridit@2048%4",
39+
"gregtech:tungsten_steel@4096", "gregtech:hssg@8192%5",
40+
"gregtech:rhodium_plated_palladium@16384", "gregtech:europium@32768%6",
41+
"gregtech:naquadah_alloy@65536", "gregtech:americium@131072%7",
42+
"gregtech:darmstadtium@262144", "gregtech:neutronium@524288%8"
43+
};
44+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package com.github.gtexpert.gtmt.integration.storagedrawers;
2+
3+
import static com.github.gtexpert.gtmt.integration.storagedrawers.items.StorageDrawersItems.upgradeStorageGT;
4+
5+
import java.util.Collections;
6+
import java.util.List;
7+
8+
import net.minecraft.block.Block;
9+
import net.minecraft.item.Item;
10+
import net.minecraft.item.crafting.IRecipe;
11+
import net.minecraftforge.client.event.ModelRegistryEvent;
12+
import net.minecraftforge.event.RegistryEvent;
13+
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
14+
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
15+
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
16+
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
17+
import net.minecraftforge.fml.relauncher.Side;
18+
import net.minecraftforge.fml.relauncher.SideOnly;
19+
import net.minecraftforge.registries.IForgeRegistry;
20+
21+
import org.jetbrains.annotations.NotNull;
22+
23+
import gregtech.api.unification.material.event.PostMaterialEvent;
24+
25+
import com.github.gtexpert.gtmt.api.ModValues;
26+
import com.github.gtexpert.gtmt.api.modules.TModule;
27+
import com.github.gtexpert.gtmt.api.unification.material.info.GTMTMaterialFlags;
28+
import com.github.gtexpert.gtmt.api.util.Mods;
29+
import com.github.gtexpert.gtmt.integration.IntegrationSubmodule;
30+
import com.github.gtexpert.gtmt.integration.storagedrawers.items.ItemGTMaterialUpgradeStorage;
31+
import com.github.gtexpert.gtmt.integration.storagedrawers.items.StorageDrawersItems;
32+
import com.github.gtexpert.gtmt.integration.storagedrawers.recipes.UpgradesLoader;
33+
import com.github.gtexpert.gtmt.integration.storagedrawers.storageupgrades.StorageUpgradeColors;
34+
import com.github.gtexpert.gtmt.integration.storagedrawers.storageupgrades.UpgradeMaterialData;
35+
import com.github.gtexpert.gtmt.integration.storagedrawers.storageupgrades.UpgradesMaterialRegistry;
36+
import com.github.gtexpert.gtmt.modules.Modules;
37+
38+
@TModule(
39+
moduleID = Modules.MODULE_DRAWERS,
40+
containerID = ModValues.MODID,
41+
modDependencies = Mods.Names.STORAGE_DRAWERS,
42+
name = "GTMoreTools Storage Drawers Integration",
43+
description = "Storage Drawers Module")
44+
public class StorageDrawersModule extends IntegrationSubmodule {
45+
46+
@NotNull
47+
@Override
48+
public List<Class<?>> getEventBusSubscribers() {
49+
return Collections.singletonList(StorageDrawersModule.class);
50+
}
51+
52+
@Override
53+
public void preInit(FMLPreInitializationEvent event) {
54+
StorageDrawersItems.init();
55+
}
56+
57+
@Override
58+
@SideOnly(Side.CLIENT)
59+
public void init(FMLInitializationEvent event) {
60+
StorageUpgradeColors.init();
61+
}
62+
63+
@Override
64+
public void postInit(FMLPostInitializationEvent event) {}
65+
66+
@SubscribeEvent
67+
public static void onRegisterItems(RegistryEvent.Register<Item> event) {
68+
IForgeRegistry<Item> registry = event.getRegistry();
69+
registry.register(upgradeStorageGT);
70+
}
71+
72+
@SubscribeEvent
73+
@SideOnly(Side.CLIENT)
74+
public static void onRegisterModels(ModelRegistryEvent event) {
75+
ItemGTMaterialUpgradeStorage.registerModels();
76+
}
77+
78+
@SubscribeEvent
79+
public static void registerMaterialFlags(PostMaterialEvent event) {
80+
GTMTMaterialFlags.integrationStorageDrawers();
81+
}
82+
83+
@Override
84+
public void registerBlocks(RegistryEvent.Register<Block> event) {}
85+
86+
@Override
87+
public void registerRecipesNormal(RegistryEvent.Register<IRecipe> event) {
88+
StorageDrawersUtil.UPGRADE_MATERIALS = StorageDrawersUtil.parse(StorageDrawersConfigHolder.upgradeMaterials);
89+
for (UpgradeMaterialData data : StorageDrawersUtil.UPGRADE_MATERIALS) {
90+
UpgradesMaterialRegistry.REGISTRY.put(data.getMaterial(), data.getId(), data.getMultiple(),
91+
data.getTier());
92+
}
93+
}
94+
95+
@Override
96+
public void registerRecipesLowest(RegistryEvent.Register<IRecipe> event) {
97+
UpgradesLoader.upgradeStorage();
98+
}
99+
}

0 commit comments

Comments
 (0)