为什么我得到 "Unidentified mapping from registry minecraft:block"?

Why do I get "Unidentified mapping from registry minecraft:block"?

我正在学习如何编写 Minecraft 模组(版本 1.14.4)并且能够制作物品。现在我正在尝试制作一个块。我正在关注实际上涵盖 1.14.3 的 this tutorial video,但我认为它已经足够接近了。

我目前收到此错误:

[20Mar2020 14:09:10.522] [服务器 thread/INFO] [net.minecraftforge.registries.ForgeRegistry/REGISTRIES]:注册表块:从世界中找到一个丢失的 ID examplemod:examplemod [20Mar2020 14:09:10.613] [服务器 thread/ERROR] [net.minecraftforge.registries.GameData/REGISTRIES]:来自注册表的未识别映射 minecraft:block examplemod:examplemod: 676

我在运行时也看到了这个:

我试过弄乱我如何命名注册表,但我似乎无法确定问题所在。也许我没有正确格式化我的 json 文件?

请注意,ItemList 和 BlockList 只是 类,其中包含我创建的每个 Block/Item 的静态实例。

ExampleMod.java:

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

public static final String MOD_ID = "examplemod";

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

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

private void setup(final FMLCommonSetupEvent event)
{
    // some preinit code
    LOGGER.info("HELLO FROM PREINIT");
    LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
}

private void doClientStuff(final FMLClientSetupEvent event) {
    // do something that can only be done on the client
    LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings);
}

private void enqueueIMC(final InterModEnqueueEvent event)
{
    // some example code to dispatch IMC to another mod
    InterModComms.sendTo(ExampleMod.MOD_ID, "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
}

private void processIMC(final InterModProcessEvent event)
{
    // some example code to receive and process InterModComms from other mods
    LOGGER.info("Got IMC {}", event.getIMCStream().
            map(m->m.getMessageSupplier().get()).
            collect(Collectors.toList()));
}
// You can use SubscribeEvent and let the Event Bus discover methods to call
@SubscribeEvent
public void onServerStarting(FMLServerStartingEvent event) {
    // do something when the server starts
    LOGGER.info("HELLO from server starting");
}

// You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
// Event bus for receiving Registry Events)
@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
public static class RegistryEvents {

    @SubscribeEvent
    public static void onItemsRegistry(final RegistryEvent.Register<Item> blockItemEvent)
    {
        ItemList.bomb_item = new Item(new Item.Properties().group(ItemGroup.COMBAT));
        ItemList.bomb_item.setRegistryName(new ResourceLocation(ExampleMod.MOD_ID, "bomb_item"));

        ItemList.mystery_block = new BlockItem(BlockList.mystery_block, new Item.Properties().group(ItemGroup.MISC));
        ItemList.mystery_block.setRegistryName(new ResourceLocation(ExampleMod.MOD_ID, "mystery_block"));

        blockItemEvent.getRegistry().registerAll(ItemList.bomb_item, ItemList.mystery_block);

        LOGGER.info("Items registered.");
    }

    @SubscribeEvent
    public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
        BlockList.mystery_block = new Block(Block.Properties.create(Material.CAKE)
                                            .hardnessAndResistance(2.0f, 2.0f)
                                            .sound(SoundType.GLASS));

        BlockList.mystery_block.setRegistryName(new ResourceLocation(MOD_ID, "mystery_block"));

        blockRegistryEvent.getRegistry().registerAll(BlockList.mystery_block);

        LOGGER.info("Blocks registered.");
    }
}

}

blockstates/mystery_block.json:

{ "variants":{ “”:{ "model": "examplemod:block/mystery_block" } } }

models/block/mystery_block.json:

{ "parent": "block/cube_all", "textures":{ "all": "examplemod:block/mystery_block" } }

models/item/mystery_block.json:

{ "parent": "examplemod:block/mystery_block" }

这意味着在某个时候你有一个块注册为 "examplemod:examplemod",而现在你没有。您可以安全地忽略该消息。如果您开始一个新世界而不是打开一个旧世界,您将不会收到该消息。

顺便说一句,不推荐使用 HarryTalks 学习 mod(在 Minecraft Forge forums 上)。显然他使用了几种不良做法(我实际上没有使用过)。 备选建议是 Cadiboo's example mod, or McJty's tutorials.