This is what a non working file looks like { "credit": "Made with Blockbench",…
- User
This is what a non working file looks like
{ "credit": "Made with Blockbench", "display": { "firstperson_lefthand": { "scale": [ 0.5, 0.5, 0.5 ], "translation": [ -3.75, 2.25, 4.75 ] }, "firstperson_righthand": { "scale": [ 0.5, 0.5, 0.5 ], "translation": [ -3.75, 2.25, 4.75 ] }, "fixed": { "translation": [ 0, 0, 1.5 ] }, "ground": { "scale": [ 0.75, 0.75, 0.75 ], "translation": [ 0, 4.25, 0 ] }, "gui": { "rotation": [ 0, 30.75, 0 ], "scale": [ 0.75, 0.75, 0.75 ] }, "head": { "translation": [ 0, 14.25, 0 ] }, "thirdperson_lefthand": { "scale": [ 0.25, 0.3, 0.25 ], "translation": [ 0, 2.25, 0 ] }, "thirdperson_righthand": { "scale": [ 0.25, 0.3, 0.25 ], "translation": [ 0, 2.25, 1 ] } }, "elements": [ { "faces": { "down": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "east": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "north": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "south": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "up": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "west": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] } }, "from": [ 2, 0, 2 ], "name": "Base", "to": [ 14, 14, 14 ] }, { "faces": { "down": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "east": { "texture": "#0", "uv": [ 0, 0, 16, 2 ] }, "north": { "texture": "#0", "uv": [ 0, 0, 16, 2 ] }, "south": { "texture": "#0", "uv": [ 0, 0, 16, 2 ] }, "up": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "west": { "texture": "#0", "uv": [ 0, 0, 16, 2 ] } }, "from": [ 1, 14, 1 ], "name": "Top", "to": [ 15, 16, 15 ] } ], "groups": [ { "children": [ 0, 1 ], "color": 0, "name": "Stone Pedestal", "origin": [ 0, 0, 0 ] } ], "textures": { "0": "minecraft:block/cobblemon:black_tumblestone_bricks", "particle": "minecraft:block/cobblemon:black_tumblestone_bricks" } }
This one is working
{ "credit": "Made with Blockbench", "display": { "firstperson_lefthand": { "scale": [ 0.5, 0.5, 0.5 ], "translation": [ -3.75, 2.25, 4.75 ] }, "firstperson_righthand": { "scale": [ 0.5, 0.5, 0.5 ], "translation": [ -3.75, 2.25, 4.75 ] }, "fixed": { "translation": [ 0, 0, 1.5 ] }, "ground": { "scale": [ 0.75, 0.75, 0.75 ], "translation": [ 0, 4.25, 0 ] }, "gui": { "rotation": [ 0, 30.75, 0 ], "scale": [ 0.75, 0.75, 0.75 ] }, "head": { "translation": [ 0, 14.25, 0 ] }, "thirdperson_lefthand": { "scale": [ 0.25, 0.3, 0.25 ], "translation": [ 0, 2.25, 0 ] }, "thirdperson_righthand": { "scale": [ 0.25, 0.3, 0.25 ], "translation": [ 0, 2.25, 1 ] } }, "elements": [ { "faces": { "down": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "east": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "north": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "south": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "up": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "west": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] } }, "from": [ 2, 0, 2 ], "name": "Base", "to": [ 14, 14, 14 ] }, { "faces": { "down": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "east": { "texture": "#0", "uv": [ 0, 0, 16, 2 ] }, "north": { "texture": "#0", "uv": [ 0, 0, 16, 2 ] }, "south": { "texture": "#0", "uv": [ 0, 0, 16, 2 ] }, "up": { "texture": "#0", "uv": [ 0, 0, 16, 16 ] }, "west": { "texture": "#0", "uv": [ 0, 0, 16, 2 ] } }, "from": [ 1, 14, 1 ], "name": "Top", "to": [ 15, 16, 15 ] } ], "groups": [ { "children": [ 0, 1 ], "color": 0, "name": "Stone Pedestal", "origin": [ 0, 0, 0 ] } ], "textures": { "0": "cobblemon:block/cobblemon:black_tumblestone_block", "particle": "cobblemon:block/cobblemon:black_tumblestone_block" } }
but I use datagen to generate so how is the output different?
package net.mattias.pedestal.datagen.custom;
import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.mattias.pedestal.Pedestals; import net.mattias.pedestal.util.PedestalVariant; import net.mattias.pedestal.util.PedestalVariants; import net.minecraft.data.DataOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.DataWriter; import net.minecraft.registry.Registries; import net.minecraft.util.Identifier;
import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.file.Files; import java.nio.file.Path; import java.util.concurrent.CompletableFuture;
public class PedestalModelGenerator implements DataProvider { private final FabricDataOutput output; private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
public PedestalModelGenerator(FabricDataOutput fabricDataOutput) { this.output = fabricDataOutput; } @Override public CompletableFuture<?> run(DataWriter writer) { return CompletableFuture.supplyAsync(() -> { try { JsonObject template = loadTemplate(); for (PedestalVariant pedestalVariant : PedestalVariants.VARIANTS) { try { JsonObject model = template.deepCopy(); JsonObject textures = model.getAsJsonObject("textures"); Identifier baseBlockId = Registries.BLOCK.getId(pedestalVariant.baseBlock().get()); textures.addProperty("0", baseBlockId.getNamespace() + ":block/" + pedestalVariant.textureName()); textures.addProperty("particle", baseBlockId.getNamespace() + ":block/" + pedestalVariant.textureName()); if(pedestalVariant.textureName().contains("glass")) { model.addProperty("render_type", "translucent"); } Path modelFile = output.resolvePath(DataOutput.OutputType.RESOURCE_PACK).resolve(Pedestals.MOD_ID + "/models/block/" + pedestalVariant.registryName() + ".json"); Files.createDirectories(modelFile.getParent()); DataProvider.writeToPath(writer, model, modelFile).get(); } catch (Exception e) { Pedestals.LOGGER.warn("Failed to generate model for: " + pedestalVariant.registryName()); e.printStackTrace(); } } } catch (IOException e) { Pedestals.LOGGER.error("Failed to do something"); throw new RuntimeException(e); } return null; }); } private JsonObject loadTemplate() throws IOException { InputStream stream = getClass().getClassLoader().getResourceAsStream("assets/pedestals/template/models/block/pedestal.json"); if (stream == null) throw new FileNotFoundException("Pedestal template model not found"); return gson.fromJson(new InputStreamReader(stream), JsonObject.class); } @Override public String getName() { return "Pedestal Model Generator"; }} package net.mattias.pedestal.blocks.custom;
import net.mattias.pedestal.util.PedestalVariant; import net.mattias.pedestal.util.PedestalVariants; import net.minecraft.registry.Registries; import net.minecraft.util.Identifier;
import java.util.List;
public class CobblemonVariants {
public static void define() { VARIANTS.forEach(PedestalVariants::register); } public static final List<PedestalVariant> VARIANTS = List.of( new PedestalVariant("apricorn_planks_pedestal", "apricorn_planks", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "apricorn_planks"))), new PedestalVariant("apricorn_log_pedestal", "apricorn_log", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "apricorn_planks"))), new PedestalVariant("tumblestone_pedestal", "tumblestone_block", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "tumblestone_block"))), new PedestalVariant("polished_tumblestone_pedestal", "polished_tumblestone", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "polished_tumblestone"))), new PedestalVariant("chiseled_polished_tumblestone_pedestal", "chiseled_polished_tumblestone", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "chiseled_polished_tumblestone"))), new PedestalVariant("tumblestone_bricks_pedestal", "tumblestone_bricks", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "tumblestone_bricks"))), new PedestalVariant("chiseled_tumblestone_bricks_pedestal", "chiseled_tumblestone_bricks", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "chiseled_tumblestone_bricks"))), new PedestalVariant("smooth_tumblestone_pedestal", "smooth_tumblestone", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "smooth_tumblestone"))), new PedestalVariant("black_tumblestone_pedestal", "black_tumblestone_block", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "black_tumblestone_block"))), new PedestalVariant("polished_black_tumblestone_pedestal", "polished_black_tumblestone", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "polished_black_tumblestone"))), new PedestalVariant("chiseled_polished_black_tumblestone_pedestal", "chiseled_polished_black_tumblestone", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "chiseled_polished_black_tumblestone"))), new PedestalVariant("black_tumblestone_bricks_pedestal", "black_tumblestone_bricks", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "black_tumblestone_bricks"))), new PedestalVariant("chiseled_black_tumblestone_bricks_pedestal", "chiseled_black_tumblestone_bricks", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "chiseled_black_tumblestone_bricks"))), new PedestalVariant("smooth_black_tumblestone_pedestal", "smooth_black_tumblestone", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "smooth_black_tumblestone"))), new PedestalVariant("sky_tumblestone_pedestal", "sky_tumblestone_block", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "sky_tumblestone_block"))), new PedestalVariant("polished_sky_tumblestone_pedestal", "polished_sky_tumblestone", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "polished_sky_tumblestone"))), new PedestalVariant("chiseled_polished_sky_tumblestone_pedestal", "chiseled_polished_sky_tumblestone", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "chiseled_polished_sky_tumblestone"))), new PedestalVariant("sky_tumblestone_bricks_pedestal", "sky_tumblestone_bricks", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "sky_tumblestone_bricks"))), new PedestalVariant("chiseled_sky_tumblestone_bricks_pedestal", "chiseled_sky_tumblestone_bricks", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "chiseled_sky_tumblestone_bricks"))), new PedestalVariant("smooth_sky_tumblestone_pedestal", "smooth_sky_tumblestone", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "smooth_sky_tumblestone"))) );}
Assistant
The issue lies in how the texture paths are being generated in your
PedestalModelGeneratorclass. Specifically, the problem is with the way thetexturesobject is being populated in the JSON model files. Let's break this down step by step and identify the discrepancy between the working and non-working models.
Key Differences Between Working and Non-Working Models
Non-Working Model
"textures": { "0": "minecraft:block/cobblemon:black_tumblestone_bricks", "particle": "minecraft:block/cobblemon:black_tumblestone_bricks" }Working Model
"textures": { "0": "cobblemon:block/cobblemon:black_tumblestone_block", "particle": "cobblemon:block/cobblemon:black_tumblestone_block" }The key difference is:
-
Namespace Issue:
- In the non-working model, the namespace is incorrectly prefixed as
minecraft:block/cobblemon:.... - In the working model, the namespace is correctly structured as
cobblemon:block/....
- In the non-working model, the namespace is incorrectly prefixed as
-
Path Formatting:
- The non-working model redundantly includes
cobblemon:afterminecraft:block/, which is invalid. - The working model uses a clean
cobblemon:block/...path without redundancy.
- The non-working model redundantly includes
Root Cause in Your Code
In your
PedestalModelGeneratorclass, the following lines are responsible for generating the texture paths:Identifier baseBlockId = Registries.BLOCK.getId(pedestalVariant.baseBlock().get()); textures.addProperty("0", baseBlockId.getNamespace() + ":block/" + pedestalVariant.textureName()); textures.addProperty("particle", baseBlockId.getNamespace() + ":block/" + pedestalVariant.textureName());Here’s what’s happening:
baseBlockId.getNamespace()retrieves the namespace of the block (e.g.,cobblemon).- The
pedestalVariant.textureName()provides the texture name (e.g.,black_tumblestone_bricks). - The resulting texture path becomes
cobblemon:block/black_tumblestone_bricks.
However, if the
baseBlockIdis not properly registered or if there’s an issue with the namespace resolution, it might default tominecraft, leading to incorrect paths likeminecraft:block/cobblemon:black_tumblestone_bricks.
Solution
To fix this issue, ensure that:
-
Correct Namespace Usage:
- Ensure that all blocks from the
Cobblemonmod are correctly registered under thecobblemonnamespace. - Verify that the
Registries.BLOCK.get(Identifier.of("cobblemon", ...))calls in yourCobblemonVariantsclass are returning valid blocks.
- Ensure that all blocks from the
-
Fix the Texture Path Generation:
- Modify the texture path generation logic to ensure it always uses the correct namespace (
cobblemon) and avoids redundant prefixes.
- Modify the texture path generation logic to ensure it always uses the correct namespace (
Here’s the updated
PedestalModelGeneratorcode:private JsonObject loadTemplate() throws IOException { InputStream stream = getClass().getClassLoader().getResourceAsStream("assets/pedestals/template/models/block/pedestal.json"); if (stream == null) throw new FileNotFoundException("Pedestal template model not found"); return gson.fromJson(new InputStreamReader(stream), JsonObject.class); } @Override public CompletableFuture<?> run(DataWriter writer) { return CompletableFuture.supplyAsync(() -> { try { JsonObject template = loadTemplate(); for (PedestalVariant pedestalVariant : PedestalVariants.VARIANTS) { try { JsonObject model = template.deepCopy(); JsonObject textures = model.getAsJsonObject("textures"); // Ensure the correct namespace is used String namespace = "cobblemon"; // Force the namespace to "cobblemon" String texturePath = namespace + ":block/" + pedestalVariant.textureName(); textures.addProperty("0", texturePath); textures.addProperty("particle", texturePath); if (pedestalVariant.textureName().contains("glass")) { model.addProperty("render_type", "translucent"); } Path modelFile = output.resolvePath(DataOutput.OutputType.RESOURCE_PACK) .resolve(Pedestals.MOD_ID + "/models/block/" + pedestalVariant.registryName() + ".json"); Files.createDirectories(modelFile.getParent()); DataProvider.writeToPath(writer, model, modelFile).get(); } catch (Exception e) { Pedestals.LOGGER.warn("Failed to generate model for: " + pedestalVariant.registryName()); e.printStackTrace(); } } } catch (IOException e) { Pedestals.LOGGER.error("Failed to do something"); throw new RuntimeException(e); } return null; }); }
Explanation of Changes
-
Force Namespace to
cobblemon:- Instead of relying on
baseBlockId.getNamespace(), we explicitly set the namespace to"cobblemon". This ensures that all texture paths use the correct namespace.
- Instead of relying on
-
Simplify Texture Path Construction:
- The texture path is now constructed as
cobblemon:block/<textureName>, which matches the format of the working model.
- The texture path is now constructed as
-
Avoid Redundant Prefixes:
- By directly constructing the path, we avoid issues like
minecraft:block/cobblemon:....
- By directly constructing the path, we avoid issues like
Verify Block Registration
Ensure that all blocks referenced in your
CobblemonVariantsclass are correctly registered in thecobblemonnamespace. For example:new PedestalVariant("black_tumblestone_bricks_pedestal", "black_tumblestone_bricks", () -> Registries.BLOCK.get(Identifier.of("cobblemon", "black_tumblestone_bricks")))If any block is missing or incorrectly registered, it will cause texture lookup failures.
Testing
After making these changes:
- Rebuild your mod and reload the resource pack.
- Check the generated JSON model files to ensure they use the correct texture paths (e.g.,
cobblemon:block/black_tumblestone_bricks). - Launch the game and verify that the textures load correctly.
This should resolve the texture loading issues for all tumblestone variants.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.