jiaowoCheung 发表于 2024-2-23 10:58:26

MineCraft 1.12.2 forge2860;可以加载itemblock的模型,但不能加载“Block”

​       我的项目可以在“/assets//models”下加载模型文件,但是当模型文件映射到纹理时,无法加载图像;        我的项目可以加载 itemblock 的模型,但无法加载Block
        以下是 BlockRegister.java:
package com.cheung.cheungmodsite.common.register;

import com.cheung.cheungmodsite.MainGuider;
import com.cheung.cheungmodsite.common.block.SeparationChamber;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@Mod.EventBusSubscriber(modid = MainGuider.MODID)
public class BlockRegister {

    //public static Block SeparationChamber=new Block(Material.ROCK);
    //这可以是一个没有任何功能的方块选择
    public static final Block separationchamber = new SeparationChamber();

    public BlockRegister() {
      MinecraftForge.EVENT_BUS.register(this);
    }

    private static Block[] blocks = {
            separationchamber
    };

    @SubscribeEvent
    public static void registerBlocks(RegistryEvent.Register<Block> event) {
      for (Block block : blocks) {
            event.getRegistry().registerAll(block);
      }
    }

    @SubscribeEvent
    public static void registerItemBlocks(RegistryEvent.Register<Item> event) {
      for (Block block : blocks) {
            Item itemBlock = new ItemBlock(block).setRegistryName(block.getRegistryName());
            ModelLoader.setCustomModelResourceLocation(itemBlock,
                  0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
            event.getRegistry().registerAll(itemBlock);
      }
    }

}


        我使用 Blockbech 的 Json 。        这里是/models/block/a.json:
{
        "credit": "Made with Blockbench",
        "textures": {
                "0": "cheungblocksite:blocks/container",
                "1": "cheungblocksite:blocks/dark",
                "2": "cheungblocksite:blocks/grey",
                "3": "cheungblocksite:blocks/greyflat",
                "4": "cheungblocksite:blocks/white",
                "6": "cheungblocksite:blocks/red",
                "7": "cheungblocksite:blocks/greyportlarge",
                "8": "cheungblocksite:blocks/blueflat",
                "9": "cheungblocksite:blocks/algae",
                "10": "cheungblocksite:blocks/yellow",
                "particle": "cheungblocksite:blocks/white"
        },还有/blockstates/a.json:
{
"forge_marker": 1,
"variants": {
    "normal": {
      "model": "cheungmodsite:separationchamber"
    },
    "inventory": {
      "model": "cheungmodsite:separationchamber"
    }
}
}
​下面是实际效果




页: [1]
查看完整版本: MineCraft 1.12.2 forge2860;可以加载itemblock的模型,但不能加载“Block”