BLOCK纹理加载成功,但BlockItem纹理不在Main World Forge 1.15.2中

2022-04-18 00:00:00 json minecraft java minecraft-forge

我尝试了许多教程并查找了文档,但仍未成功。 我将向您展示我的代码文件目录和问题的图像。

Testmod/Testmod.java:

package com.SkySibe.testmod;


import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

// The value here should match an entry in the META-INF/mods.toml file
@Mod("testmod")
public class TestMod
{
    // Directly reference a log4j logger.
    private static final Logger LOGGER = LogManager.getLogger();
    public static final String MOD_ID = "testmod";
    public static TestMod instance;

    public TestMod() {
        // Register the setup method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        // Register the doClientStuff method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);

        instance = this;

        // Register ourselves for server and other game events we are interested in
        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event)
    {

    }

    private void doClientStuff(final FMLClientSetupEvent event) {

    }

}

testmod/init/BlockInit.java:

package com.SkySibe.testmod.init;

import com.SkySibe.testmod.TestMod;

import net.minecraft.block.Block;
import net.minecraft.block.OreBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.registries.ObjectHolder;

@ObjectHolder(TestMod.MOD_ID)
@Mod.EventBusSubscriber(modid = TestMod.MOD_ID, bus = Bus.MOD)
public class BlockInit {
    public static final Block ruby_ore = null;

    @SubscribeEvent
    public static void registerBlocks(final RegistryEvent.Register<Block> event) {
        event.getRegistry().register(new OreBlock(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 3.0F).sound(SoundType.STONE).harvestTool(ToolType.PICKAXE)).setRegistryName("ruby_ore"));
    }

    @SubscribeEvent
    public static void registerBlockItems(final RegistryEvent.Register<Item> event) {
        event.getRegistry().register(new BlockItem(ruby_ore,new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)).setRegistryName("ruby_ore"));
    }
}

Assets/testmod/lockStates/ruby_ore.json:

{
    "variants": {
        "": { "model": "testmod:block/ruby_ore"}
    }
}

Assets/Testmod/Models/Block/ruby_ore.json:

{
    "parent": "block/cube_all",
    "textures": {
        "all": "testmod:blocks/ruby_ore"
    }
}

Assets/testmod/Models/Item/ruby_ore.json:

{
    "parent": "testmod:block/ruby_block"
}


解决方案

(来自评论)

您没有在文件assets/testmod/models/item/ruby_ore.json中写入好的项目。应该是:

{
    "parent": "testmod:block/ruby_ore"
}

相关文章