Fabric - 加载游戏时 EntrypointException 崩溃

Fabric - EntrypointException crash upon loading game

我目前正在探索 mod使用 Fabric。大约一个月前,我制作了一个 mod,它工作得很好,无论是在 VSCode 中的调试器 运行 还是在编译时 运行 在真正的 Minecraft 安装中。编译后我添加了一些东西,但现在新编译的版本在加载时游戏崩溃了。但是,奇怪的是,当 VSCode.

中的调试器 运行 时没有崩溃

这里是ExampleMod.Java:

package net.fabricmc.example;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.Rarity;
import net.minecraft.util.registry.Registry;

public class ExampleMod implements ModInitializer {

    public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build(
        new Identifier("testmod", "group"),
        () -> new ItemStack(ExampleMod.FAT_EMERALD));
 
    public static final FatEmeraldItem FAT_EMERALD = new FatEmeraldItem(new Item.Settings().group(ExampleMod.ITEM_GROUP).rarity(Rarity.UNCOMMON));
    
    public static final Block WHITESTONE = new Block(FabricBlockSettings.of(Material.STONE).hardness(1.5f));
    public static final Block POLISHED_WHITESTONE = new Block(FabricBlockSettings.of(Material.STONE).hardness(1.5f));
 
    @Override
    public void onInitialize() {
        Registry.register(Registry.ITEM, new Identifier("testmod", "fat_emerald"), FAT_EMERALD);
        Registry.register(Registry.BLOCK, new Identifier("testmod", "whitestone"), WHITESTONE);
        Registry.register(Registry.ITEM, new Identifier("testmod", "whitestone"), 
            new BlockItem(WHITESTONE, new Item.Settings().group(ExampleMod.ITEM_GROUP)));
        Registry.register(Registry.BLOCK, new Identifier("testmod", "polished_whitestone"), POLISHED_WHITESTONE);
        Registry.register(Registry.ITEM, new Identifier("testmod", "polished_whitestone"), 
            new BlockItem(POLISHED_WHITESTONE, new Item.Settings().group(ExampleMod.ITEM_GROUP)));
    } 
}

这里是 FatEmeraldItem.Java(不要问):

package net.fabricmc.example;

import java.util.List;

import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;

public class FatEmeraldItem extends Item{
    public FatEmeraldItem(Settings settings) {
        super(settings);
    }
    
    @Override
    public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
        if (playerEntity.getHealth() < playerEntity.getMaxHealth()){
            playerEntity.playSound(SoundEvents.BLOCK_GLASS_BREAK, 1.0F, 1.0F);
            playerEntity.heal(2);
            ItemStack stack = playerEntity.getStackInHand(hand);
            stack.decrement(1);
            for (int i = 0; i < 10; i++) {
                world.addParticle(ParticleTypes.HAPPY_VILLAGER, 
                (playerEntity.getX() + Math.random() -0.5), 
                (playerEntity.getEyeY() + Math.random() -0.5), 
                (playerEntity.getZ() + Math.random() -0.5), 
                1, 1, 1);
            }
            return new TypedActionResult<>(ActionResult.SUCCESS, playerEntity.getStackInHand(hand));
        }
        else {
            return new TypedActionResult<>(ActionResult.FAIL, playerEntity.getStackInHand(hand));
        }
    }

    @Override
    public void appendTooltip(ItemStack itemStack, World world, List<Text> tooltip, TooltipContext tooltipContext) {
        tooltip.add(new TranslatableText("item.testmod.fat_emerald_item.tooltip"));
    }
}

这里是崩溃报告:

---- Minecraft Crash Report ----
// Hey, that tickles! Hehehe!

Time: 9/27/20 6:21 PM
Description: Initializing game

net.fabricmc.loader.api.EntrypointException: Exception while loading entries for entrypoint 'main' provided by 'testmod'
    at net.fabricmc.loader.EntrypointStorage.getEntrypointContainers(EntrypointStorage.java:193)
    at net.fabricmc.loader.FabricLoader.getEntrypointContainers(FabricLoader.java:268)
    at net.fabricmc.loader.entrypoint.minecraft.hooks.EntrypointUtils.invoke0(EntrypointUtils.java:44)
    at net.fabricmc.loader.entrypoint.minecraft.hooks.EntrypointUtils.invoke(EntrypointUtils.java:36)
    at net.fabricmc.loader.entrypoint.minecraft.hooks.EntrypointClient.start(EntrypointClient.java:32)
    at net.minecraft.class_310.<init>(class_310.java:423)
    at net.minecraft.client.main.Main.main(Main.java:177)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:227)
    at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:140)
    at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26)
Caused by: java.lang.NoClassDefFoundError: net/minecraft/block/AbstractBlock$Settings
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at net.fabricmc.loader.util.DefaultLanguageAdapter.create(DefaultLanguageAdapter.java:45)
    at net.fabricmc.loader.EntrypointStorage$NewEntry.create(EntrypointStorage.java:114)
    at net.fabricmc.loader.EntrypointStorage$NewEntry.getOrCreate(EntrypointStorage.java:101)
    at net.fabricmc.loader.EntrypointStorage.getEntrypointContainers(EntrypointStorage.java:186)
    ... 13 more
Caused by: java.lang.ClassNotFoundException: net.minecraft.block.AbstractBlock$Settings
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at net.fabricmc.loader.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:166)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 19 more


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
    at net.fabricmc.loader.EntrypointStorage.getEntrypointContainers(EntrypointStorage.java:193)
    at net.fabricmc.loader.FabricLoader.getEntrypointContainers(FabricLoader.java:268)
    at net.fabricmc.loader.entrypoint.minecraft.hooks.EntrypointUtils.invoke0(EntrypointUtils.java:44)
    at net.fabricmc.loader.entrypoint.minecraft.hooks.EntrypointUtils.invoke(EntrypointUtils.java:36)
    at net.fabricmc.loader.entrypoint.minecraft.hooks.EntrypointClient.start(EntrypointClient.java:32)
    at net.minecraft.class_310.<init>(class_310.java:423)

-- Initialization --
Details:
Stacktrace:
    at net.minecraft.client.main.Main.main(Main.java:177)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:227)
    at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:140)
    at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26)

-- System Details --
Details:
    Minecraft Version: 1.16.3
    Minecraft Version ID: 1.16.3
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 1.8.0_51, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 558825304 bytes (532 MB) / 1644167168 bytes (1568 MB) up to 2147483648 bytes (2048 MB)
    CPUs: 6
    JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M
    Fabric Mods: 
        cloth-basic-math: Cloth Basic Math 0.5.1
        cloth-config2: Cloth Config v4 4.7.0-unstable
        fabric: Fabric API 0.22.0+build.408-1.16
        fabric-api-base: Fabric API Base 0.1.3+12a8474c95
        fabric-biome-api-v1: Fabric Biome API (v1) 2.0.0+c29459ab95
        fabric-blockrenderlayer-v1: Fabric BlockRenderLayer Registration (v1) 1.1.4+c6a8ea8995
        fabric-command-api-v1: Fabric Command API (v1) 1.0.8+5ce5339895
        fabric-commands-v0: Fabric Commands (v0) 0.2.0+52d3083695
        fabric-containers-v0: Fabric Containers (v0) 0.1.8+045df74f95
        fabric-content-registries-v0: Fabric Content Registries (v0) 0.1.9+059ea86695
        fabric-crash-report-info-v1: Fabric Crash Report Info (v1) 0.1.2+b7f9825d95
        fabric-events-interaction-v0: Fabric Events Interaction (v0) 0.4.1+f8ac1db295
        fabric-events-lifecycle-v0: Fabric Events Lifecycle (v0) 0.2.0+16acbe5b95
        fabric-game-rule-api-v1: Fabric Game Rule API (v1) 1.0.2+f8ac1db295
        fabric-item-api-v1: Fabric Item API (v1) 1.2.0+f8ac1db295
        fabric-item-groups-v0: Fabric Item Groups (v0) 0.2.0+438f963695
        fabric-key-binding-api-v1: Fabric Key Binding API (v1) 1.0.1+730711c695
        fabric-keybindings-v0: Fabric Key Bindings (v0) 0.2.0+3fa9f7c595
        fabric-lifecycle-events-v1: Fabric Lifecycle Events (v1) 1.2.0+74cc3b2095
        fabric-loot-tables-v1: Fabric Loot Tables (v1) 1.0.1+432ea18895
        fabric-mining-levels-v0: Fabric Mining Levels (v0) 0.1.2+b764ce9995
        fabric-models-v0: Fabric Models (v0) 0.1.1+f8ac1db295
        fabric-networking-blockentity-v0: Fabric Networking Block Entity (v0) 0.2.5+b50ffc7b95
        fabric-networking-v0: Fabric Networking (v0) 0.1.10+e00ecb5f95
        fabric-object-builder-api-v1: Fabric Object Builder API (v1) 1.8.1+f8ac1db295
        fabric-object-builders-v0: Fabric Object Builders (v0) 0.7.0+432ea18895
        fabric-particles-v1: fabric-particles-v1 0.2.2+fb0d9b0e95
        fabric-registry-sync-v0: Fabric Registry Sync (v0) 0.5.1+f8ac1db295
        fabric-renderer-api-v1: Fabric Renderer API (v1) 0.3.1+f8ac1db295
        fabric-renderer-indigo: Fabric Renderer - Indigo 0.4.1+f8ac1db295
        fabric-renderer-registries-v1: Fabric Renderer Registries (v1) 2.2.0+f8ac1db295
        fabric-rendering-data-attachment-v1: Fabric Rendering Data Attachment (v1) 0.1.4+f8ac1db295
        fabric-rendering-fluids-v1: Fabric Rendering Fluids (v1) 0.1.12+f8ac1db295
        fabric-rendering-v0: Fabric Rendering (v0) 1.1.1+f8ac1db295
        fabric-rendering-v1: Fabric Rendering (v1) 1.3.1+f8ac1db295
        fabric-resource-loader-v0: Fabric Resource Loader (v0) 0.3.1+facf3bbf95
        fabric-screen-handler-api-v1: Fabric Screen Handler API (v1) 1.1.0+8724984195
        fabric-structure-api-v1: Fabric Structure API (v1) 1.1.0+f8ac1db295
        fabric-tag-extensions-v0: Fabric Tag Extensions (v0) 1.0.3+ac8e8c5995
        fabric-textures-v0: Fabric Textures (v0) 1.0.4+eae12eb895
        fabric-tool-attribute-api-v1: Fabric Tool Attribute API (v1) 1.2.3+f8ac1db295
        fabricloader: Fabric Loader 0.10.0+build.208
        fiber: fiber 0.23.0-2
        minecraft: Minecraft 1.16.3
        modmenu: Mod Menu 1.14.6+build.31
        okzoomer: Ok Zoomer 4.0.1+1.16.2
        sodium: Sodium 0.1.0
        testmod: Test Mod 1.0.0
    Launched Version: fabric-loader-0.10.0+build.208-1.16.3
    Backend library: LWJGL version 3.2.2 build 10
    Backend API: NO CONTEXT
    GL Caps: 
    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'fabric'
    Type: Client (map_client.txt)
    CPU: <unknown>

我已经尝试删除其他 mods 并且发生了同样的崩溃。我尽可能多地尝试完全重置项目(除了我的代码之外的所有内容)并重新运行 相关的 gradle 任务(在这样做的过程中,设法破坏了我的 gradle 安装,但我固定)。我查看了 this Whosebug question,,它有相同的主要错误,但根本问题不同(他们的是 NullPointerException,而我的是 ClassNotFoundException)。我不确定我做错了什么。

Fabric Discord 服务器上的某个人能够帮助我。问题似乎是两件事之一(或两者):

  1. gradle 缓存中可能有损坏的 Minecraft。我用 ./gradlew clean build 来帮助解决这个问题。

  2. 我想我 运行 开发 jar 而不是普通 jar。 dev jar 实际上不应该是 运行.