如何在 minecraft forge 中修复 "loading model for blockstate variant '#normal' exception"?

How to fix "loading model for blockstate variant '#normal' exception" in minecraft forge?

在成功地使一个项目具有纹理之后,在过去的几个小时里,我一直在努力使块的纹理加载工作(解释我的错误消息,这是我挣扎的模型加载)

到目前为止,我遵循了 cubicoders 教程 ( https://cubicoder.wordpress.com/2018/06/20/basic-block/ )。因为他创建块的解决方案抛出了一个错误,所以我检查了其他教程。虽然我的错误日志坚持认为问题出在模型加载中(特别是变量#normal 的变量加载),但这部分与我能找到的每个教程中的完全相同。
还有什么可能触发这种异常?

我的完整项目代码可以在这里找到:https://github.com/harlekintiger/modding
这实际上只是基本设置、一个项目和这个损坏的块。


最重要的部分如下:

"basic_block.json" 位于 "resources/assets/MODID/blockstate":

{
   "forge_marker": 1,
   "defaults": {
      "model": "firstforgemod:basic_block"
   },
      "variants": {
         "normal": [{}],
         "inventory": [{}]
   }
}

"basic_block.json" 位于 "resources/assets/MODID/models/block":

{
   "parent": "block/cube_all",
   "textures": {
      "all": "firstforgemod:blocks/basic_block"
   }
}
实际块的

Class:

public class BlockBasic extends Block{

    public BlockBasic(Material material, String unlocalizedName, String registryName){
        this(material, SoundType.STONE, unlocalizedName, registryName);
    }

    public BlockBasic(Material material, SoundType sound, String unlocalizedName, String registryName){
        super(material);
        setUnlocalizedName(FirstForgeMod.MODID + "." + unlocalizedName);
        setRegistryName(registryName);
        setCreativeTab(FirstForgeMod.TUTORIAL_TAB);
        setSoundType(sound);
    }
}

Class 收集方块:

@ObjectHolder(FirstForgeMod.MODID)
public class TutorialBlocks {

    public static final Block BASIC_BLOCK = null;
}

ModelRegistryHandler class:(我猜这里少了什么)

@EventBusSubscriber(Side.CLIENT)
public class ModelRegistryHandler {

    @SubscribeEvent
    public static void registerModels(ModelRegistryEvent event){
        registerModel(TutorialItems.BASIC_ITEM);
        registerModel(Item.getItemFromBlock(TutorialBlocks.BASIC_BLOCK));
    }

    private static void registerModel(Item item) {
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    }
}

注册表处理程序class:

@EventBusSubscriber
public class RegistryHandler {

    @SubscribeEvent
    public static void registerBlocks(Register<Block> event){
        final Block[] blocks ={
            new BlockBasic(Material.ROCK, "blockBasic", "basic_block")
        };

        event.getRegistry().registerAll(blocks);
    }

    @SubscribeEvent
    public  static  void registerItems(Register<Item> event){
        final Item[] items = {
                new ItemBasic("itemBasic", "basic_item")
        };

        final Item[] itemBlocks = {
                new ItemBlock(TutorialBlocks.BASIC_BLOCK).setRegistryName(TutorialBlocks.BASIC_BLOCK.getRegistryName())
        };

        event.getRegistry().registerAll(items);
        event.getRegistry().registerAll(itemBlocks);
    }
}

我的世界启动(带有错误消息)和关闭的日志文件:
https://pastebin.com/Ff7NuFSk


我得到的是: 游戏开始,可以在游戏中放置方块,但在世界和库存中完全没有纹理(缺少纹理 texutre)。

Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 14 column 2 path $

这是你的潜在错误。

https://github.com/harlekintiger/modding/blob/master/src/main/resources/assets/firstforgemod/blockstates/basic_block.json#L14

JSON 是一种数据格式,它不允许在文件的任何位置添加注释(任何类型)。