Skip to content

Commit

Permalink
Move model datagen to common
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Oct 4, 2023
1 parent db710a6 commit acaf7f6
Show file tree
Hide file tree
Showing 11 changed files with 563 additions and 770 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.function.Consumer;

import org.jetbrains.annotations.NotNull;

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.FinishedRecipe;
Expand Down Expand Up @@ -35,7 +37,6 @@
import gripe._90.megacells.definition.MEGAItems;
import gripe._90.megacells.definition.MEGATags;
import gripe._90.megacells.integration.appbot.AppBotItems;
import org.jetbrains.annotations.NotNull;

public class CommonRecipeProvider extends RecipeProvider {
public CommonRecipeProvider(PackOutput output) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package gripe._90.megacells.mixin.data;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

import net.minecraft.data.models.model.TextureSlot;

@Mixin(TextureSlot.class)
public interface TextureSlotAccessor {
@Invoker
static TextureSlot invokeCreate(String string) {
throw new AssertionError();
}
}
2 changes: 1 addition & 1 deletion fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ loom {
property("fabric-api.datagen")
property("fabric-api.datagen.modid", rootProject.property("modId").toString())
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 @@ -15,6 +15,6 @@ public void onInitializeDataGenerator(FabricDataGenerator generator) {
pack.addProvider((FabricDataOutput output) -> new CommonLanguageProvider(output));
pack.addProvider((FabricDataOutput output) -> new CommonLootTableProvider(output));
pack.addProvider((FabricDataOutput output) -> new CommonRecipeProvider(output));
pack.addProvider(ModelProvider::new);
pack.addProvider((FabricDataOutput output) -> new CommonModelProvider(output));
}
}
429 changes: 0 additions & 429 deletions fabric/src/data/java/gripe/_90/megacells/datagen/ModelProvider.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package gripe._90.megacells.datagen;

import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.client.model.generators.ItemModelProvider;
import net.minecraftforge.common.data.ExistingFileHelper;

import appeng.core.AppEng;
import appeng.core.definitions.ItemDefinition;

import gripe._90.megacells.MEGACells;
import gripe._90.megacells.core.Addons;
import gripe._90.megacells.integration.appmek.AppMekItems;

class ForgeModelProvider extends ItemModelProvider {
private static final ResourceLocation STORAGE_CELL_LED = AppEng.makeId("item/storage_cell_led");
private static final ResourceLocation PORTABLE_CELL_LED = AppEng.makeId("item/portable_cell_led");

private static final ResourceLocation DRIVE_CELL = AppEng.makeId("block/drive/drive_cell");

public ForgeModelProvider(PackOutput output, ExistingFileHelper existing) {
super(output, MEGACells.MODID, existing);
existing.trackGenerated(STORAGE_CELL_LED, TEXTURE);
existing.trackGenerated(PORTABLE_CELL_LED, TEXTURE);
existing.trackGenerated(DRIVE_CELL, MODEL);
}

@Override
protected void registerModels() {
if (MEGACells.PLATFORM.isAddonLoaded(Addons.APPMEK)) {
basicItem(AppMekItems.MEGA_CHEMICAL_CELL_HOUSING.asItem());

AppMekItems.getCells().forEach(c -> cell(c, "standard", STORAGE_CELL_LED));
AppMekItems.getPortables().forEach(c -> cell(c, "portable", PORTABLE_CELL_LED));

basicItem(AppMekItems.RADIOACTIVE_CELL_COMPONENT.asItem());
cell(AppMekItems.RADIOACTIVE_CHEMICAL_CELL, "standard", STORAGE_CELL_LED);

driveCell("mega_chemical_cell");
driveCell("radioactive_chemical_cell");
}
}

private void cell(ItemDefinition<?> cell, String type, ResourceLocation led) {
var path = cell.id().getPath();
singleTexture(path, mcLoc("item/generated"), "layer0", MEGACells.makeId("item/cell/" + type + "/" + path))
.texture("layer1", led);
}

private void driveCell(String texture) {
var path = "block/drive/cells/" + texture;
withExistingParent(path, DRIVE_CELL).texture("cell", path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ public static void onGatherData(GatherDataEvent event) {
var generator = event.getGenerator();
var output = generator.getPackOutput();

var existing = event.getExistingFileHelper();
generator.addProvider(event.includeClient(), new ModelProvider.Items(output, existing));
generator.addProvider(event.includeClient(), new ModelProvider.Blocks(output, existing));
generator.addProvider(event.includeClient(), new ModelProvider.Parts(output, existing));

var registries = event.getLookupProvider();
generator.addProvider(event.includeServer(), new CommonTagProvider.BlockTags(output, registries));
generator.addProvider(event.includeServer(), new CommonTagProvider.ItemTags(output, registries));

generator.addProvider(event.includeClient(), new CommonModelProvider(output));
generator.addProvider(event.includeClient(), new CommonLanguageProvider(output));
generator.addProvider(event.includeServer(), new CommonLootTableProvider(output));
generator.addProvider(event.includeServer(), new CommonRecipeProvider(output));

generator.addProvider(event.includeServer(), new ForgeRecipeProvider(output));
generator.addProvider(event.includeClient(), new ForgeModelProvider(output, event.getExistingFileHelper()));
}
}
Loading

0 comments on commit acaf7f6

Please sign in to comment.