Skip to content

Commit

Permalink
Use separate Fabric mod for datagen
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Oct 4, 2023
1 parent acaf7f6 commit fd926d5
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ subprojects {
silentMojangMappingsLicense()

@Suppress("UnstableApiUsage")
mixin.defaultRefmapName.set("$modId-refmap.json")
mixin.defaultRefmapName.set("$modId.refmap.json")
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
import gripe._90.megacells.mixin.data.TextureSlotAccessor;

public class CommonModelProvider implements DataProvider {
private static final TextureSlot LAYER3 = textureSlot("layer3");
private static final TextureSlot LAYER3 = TextureSlotAccessor.invokeCreate("layer3");
private static final ModelTemplate PORTABLE = new ModelTemplate(
Optional.of(new ResourceLocation("minecraft:item/generated")),
Optional.empty(),
Expand All @@ -67,12 +67,12 @@ public class CommonModelProvider implements DataProvider {
TextureSlot.LAYER2,
LAYER3);

private static final TextureSlot CELL = textureSlot("cell");
private static final TextureSlot CELL = TextureSlotAccessor.invokeCreate("cell");
private static final ModelTemplate DRIVE_CELL =
new ModelTemplate(Optional.of(AppEng.makeId("block/drive/drive_cell")), Optional.empty(), CELL);

private static final TextureSlot SIDES = textureSlot("sides");
private static final TextureSlot SIDES_STATUS = textureSlot("sidesStatus");
private static final TextureSlot SIDES = TextureSlotAccessor.invokeCreate("sides");
private static final TextureSlot SIDES_STATUS = TextureSlotAccessor.invokeCreate("sidesStatus");
private static final ModelTemplate INTERFACE = new ModelTemplate(
Optional.of(AppEng.makeId("part/interface_base")),
Optional.empty(),
Expand All @@ -97,12 +97,6 @@ public CommonModelProvider(PackOutput output) {
this.output = output;
}

private static TextureSlot textureSlot(String key) {
return MEGACells.PLATFORM.getLoader() == Loaders.FABRIC
? TextureSlot.create(key)
: TextureSlotAccessor.invokeCreate(key);
}

@NotNull
@Override
public CompletableFuture<?> run(CachedOutput writer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"minVersion": "0.8",
"package": "gripe._90.megacells.mixin.data",
"compatibilityLevel": "JAVA_17",
"mixins": ["TextureSlotAccessor", "forge.MainMixin"],
"mixins": ["TextureSlotAccessor"],
"injectors": {
"defaultRequire": 1
}
Expand Down
4 changes: 2 additions & 2 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ loom {
source("data")

property("fabric-api.datagen")
property("fabric-api.datagen.modid", rootProject.property("modId").toString())
property("fabric-api.datagen.modid", "${property("modId")}-data")
property("fabric-api.datagen.output-dir", file("src/generated/resources").absolutePath)
// property("fabric-api.datagen.strict-validation")
property("fabric-api.datagen.strict-validation")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;

import gripe._90.megacells.MEGACells;

public class MEGADataGenerators implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator generator) {
Expand All @@ -17,4 +19,9 @@ public void onInitializeDataGenerator(FabricDataGenerator generator) {
pack.addProvider((FabricDataOutput output) -> new CommonRecipeProvider(output));
pack.addProvider((FabricDataOutput output) -> new CommonModelProvider(output));
}

@Override
public String getEffectiveModId() {
return MEGACells.MODID;
}
}
10 changes: 10 additions & 0 deletions fabric/src/data/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"schemaVersion": 1,
"id": "megacells-data",
"version": "1",

"mixins": ["megacells.data.mixins.json"],
"entrypoints": {
"fabric-datagen": ["gripe._90.megacells.datagen.MEGADataGenerators"]
}
}
4 changes: 1 addition & 3 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
"entrypoints": {
"ae2": ["gripe._90.megacells.fabric.MEGACellsFabric"],
"ae2:client": ["gripe._90.megacells.fabric.MEGACellsClient"],
"modmenu": ["gripe._90.megacells.integration.modmenu.ModMenuIntegration"],

"fabric-datagen": ["gripe._90.megacells.datagen.MEGADataGenerators"]
"modmenu": ["gripe._90.megacells.integration.modmenu.ModMenuIntegration"]
},

"depends": {
Expand Down
1 change: 1 addition & 0 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ loom {
programArgs("--existing", project(":common").file("src/main/resources").absolutePath)
programArgs("--existing", file("src/main/resources").absolutePath)
programArgs("--mixin.config", "$modId.data.mixins.json")
programArgs("--mixin.config", "$modId.data.forge.mixins.json")

@Suppress("UnstableApiUsage")
mods {
Expand Down
10 changes: 10 additions & 0 deletions forge/src/data/resources/megacells.data.forge.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"required": true,
"minVersion": "0.8",
"package": "gripe._90.megacells.mixin.data.forge",
"compatibilityLevel": "JAVA_17",
"mixins": ["MainMixin"],
"injectors": {
"defaultRequire": 1
}
}

0 comments on commit fd926d5

Please sign in to comment.