Minecraft Fabric 1.21.1模组开发:Raw Vibral方块数据生成仅生方块状态,模型无法生成的问题求助
Minecraft Fabric 1.21.1模组开发:Raw Vibral方块数据生成仅生方块状态,模型无法生成的问题求助
各位大佬好,我目前在做一个Fabric 1.21.1的模组,核心是加一种叫Vibral的新材料:
- 这个材料只会在深邃黑暗和远古城市刷新,Raw Vibral是类似幽匿脉络的粘稠方块,和幽匿脉络刷新在同一区域但概率很低,外观和行为都接近幽匿脉络
- 用2个Raw Vibral+2个回响碎片能合成成品Vibral,成品做的盔甲和工具还有隐身相关的特殊效果(比如移动无声、隐藏名牌、隐身时盔甲也跟着隐形)
现在大部分内容都跑通了:配方、盔甲工具(特殊效果还没加)、普通的Vibral方块都正常,唯独Raw Vibral的模型生成卡壳了——我想用数据生成(Data Generation)自动生成模型、方块状态这些JSON文件,但现在只有方块状态文件能生成出来,模型文件死活出不来。
下面是我的ModModelProvider.java代码,里面有我尝试过的各种写法(很多是之前试的ChatGPT方案,都注释掉了但没用):
package net.zadezapper.vibral.datagen; import com.google.gson.JsonElement; import com.mojang.datafixers.util.Either; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider; import net.minecraft.client.render.model.json.JsonUnbakedModel; import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.data.client.*; import net.minecraft.util.Identifier; import net.zadezapper.vibral.Vibral; import net.zadezapper.vibral.block.ModBlocks; import net.zadezapper.vibral.item.ModItems; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.function.Supplier; public class ModModelProvider extends FabricModelProvider { public ModModelProvider(FabricDataOutput output) { super(output); } public static final Model SCULK_VEIN = newModel("sculk_vein", "", TextureKey.TOP, TextureKey.BOTTOM); @Override public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) { blockStateModelGenerator.registerSimpleCubeAll(ModBlocks.VIBRAL_BLOCK); blockStateModelGenerator.registerSimpleCubeAll(ModBlocks.RAW_VIBRAL_BLOCK); // 这里注册后能生成blockstate,但模型文件出不来 blockStateModelGenerator.registerWallPlant(ModBlocks.RAW_VIBRAL); // 下面是我尝试过的各种写法,都没搞定模型生成 Identifier modelId = ModelIds.getBlockModelId(ModBlocks.RAW_VIBRAL); Identifier parent = Identifier.of("minecraft", "block/sculk_vein"); Identifier texture = Identifier.of(Vibral.MOD_ID, "block/raw_vibral"); /* blockStateModelGenerator.modelCollector.accept(modelId, (Supplier<JsonElement>) createCustomModel(texture, parent)); SCULK_VEIN.upload( ModBlocks.RAW_VIBRAL, TextureMap::all, ); blockStateModelGenerator.createSubModel( ModBlocks.RAW_VIBRAL, "vibral:block/raw_vibral", TexturedModel.of(ModBlocks.RAW_VIBRAL).getTextures() ); Function<Identifier, TextureMap> identifierToTextureMap; blockStateModelGenerator.createSubModel( ModBlocks.RAW_VIBRAL, "vibral:block/raw_vibral", SCULK_VEIN, identifierToTextureMap ); blockStateModelGenerator.modelCollector.accept(ModelIds.getBlockModelId(ModBlocks.RAW_VIBRAL), blockStateModelGenerator.modelProvider.models().withExistingParent( ModBlocks.RAW_VIBRAL.getRegistryName().getPath(), new Identifier("block/template_vein")) .texture("vein", new Identifier(Vibral.MOD_ID, "block/raw_vibral")) ); */ } @Override public void generateItemModels(ItemModelGenerator itemModelGenerator) { itemModelGenerator.register(ModItems.VIBRAL, Models.GENERATED); itemModelGenerator.register(ModItems.VIBRAL_SWORD, Models.HANDHELD); itemModelGenerator.register(ModItems.VIBRAL_PICKAXE, Models.HANDHELD); itemModelGenerator.register(ModItems.VIBRAL_AXE, Models.HANDHELD); itemModelGenerator.register(ModItems.VIBRAL_SHOVEL, Models.HANDHELD); itemModelGenerator.register(ModItems.VIBRAL_HOE, Models.HANDHELD); itemModelGenerator.register(ModItems.VIBRAL_HELMET, Models.GENERATED); itemModelGenerator.register(ModItems.VIBRAL_CHESTPLATE, Models.GENERATED); itemModelGenerator.register(ModItems.VIBRAL_LEGGINGS, Models.GENERATED); itemModelGenerator.register(ModItems.VIBRAL_BOOTS, Models.GENERATED); } public static void generateTexturedModels() { TexturedModel.Factory WALL_PLANT = TexturedModel.makeFactory(TextureMap::topBottom, SCULK_VEIN); } private static Model newModel(String parent, String variant, TextureKey... requiredTextureKeys) { return new Model(Optional.of(Identifier.of("minecraft", parent)), Optional.empty(), ModelTransformation.NONE, Optional.empty(), List.of(), Map.of(), Map.of(), Either.left(false), Optional.empty(), List.of(), new HashMap<>(), new HashMap<>()); } }
我想让Raw Vibral的模型和幽匿脉络类似,用数据生成自动生成对应的模型JSON,现在只有blockstate能生成,模型文件完全没影。有没有大佬能帮我看看问题出在哪?或者给个正确的写法参考?谢谢啦!




