Fabric – 游戏加载时的EntrypointException崩溃

huangapple go评论113阅读模式
英文:

Fabric - EntrypointException crash upon loading game

问题

我目前正在使用 Fabric 进行模组开发。大约一个月前,我制作了一个完全正常运行的模组,在 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 ----
// 嘿,那磕磕绊绊的!嘿嘿嘿!
时间: 9/27/20 6:21 PM
描述: 正在初始化游戏
net.fabricmc.loader.api.EntrypointException: 在为由'testmod'提供的'主要'入口点加载条目时出现异常
at net.fabricmc.loader.EntrypointStorage.getEntrypointContainers(EntrypointStorage.java:193)
//...以下为堆栈跟踪
Caused by: java.lang.NoClassDefFoundError: net/minecraft/block/AbstractBlock$Settings
//...以下为堆栈跟踪

我尝试过移除其他模组,但仍然发生相同的崩溃。我尝试重置项目(除了我的代码之外的所有内容),并重新运行相关的 Gradle 任务(在这个过程中,我成功地破坏了我的 Gradle 安装,但我已经修复了它)。我看了一下 这个 StackOverflow 问题,其中有相同的主要错误,但根本问题不同(他们的问题是 NullPointerException,而我的是 ClassNotFoundException)。我不确定我做错了什么。

英文:

I'm currently exploring modding using Fabric. About a month ago, I made a mod that worked just fine, both when run from the debugger in VSCode and when compiled and run on a real Minecraft installation. I have added a few things since I compiled it, but now the newly compiled version crashes the game upon loading. However, strangely, there is no crash when run from the debugger in VSCode.

Here is 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(&quot;testmod&quot;, &quot;group&quot;),
() -&gt; 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(&quot;testmod&quot;, &quot;fat_emerald&quot;), FAT_EMERALD);
Registry.register(Registry.BLOCK, new Identifier(&quot;testmod&quot;, &quot;whitestone&quot;), WHITESTONE);
Registry.register(Registry.ITEM, new Identifier(&quot;testmod&quot;, &quot;whitestone&quot;), 
new BlockItem(WHITESTONE, new Item.Settings().group(ExampleMod.ITEM_GROUP)));
Registry.register(Registry.BLOCK, new Identifier(&quot;testmod&quot;, &quot;polished_whitestone&quot;), POLISHED_WHITESTONE);
Registry.register(Registry.ITEM, new Identifier(&quot;testmod&quot;, &quot;polished_whitestone&quot;), 
new BlockItem(POLISHED_WHITESTONE, new Item.Settings().group(ExampleMod.ITEM_GROUP)));
} 
}

And here is FatEmeraldItem.Java (don't ask):

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&lt;ItemStack&gt; use(World world, PlayerEntity playerEntity, Hand hand) {
if (playerEntity.getHealth() &lt; 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 &lt; 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&lt;&gt;(ActionResult.SUCCESS, playerEntity.getStackInHand(hand));
}
else {
return new TypedActionResult&lt;&gt;(ActionResult.FAIL, playerEntity.getStackInHand(hand));
}
}
@Override
public void appendTooltip(ItemStack itemStack, World world, List&lt;Text&gt; tooltip, TooltipContext tooltipContext) {
tooltip.add(new TranslatableText(&quot;item.testmod.fat_emerald_item.tooltip&quot;));
}
}

And here is the crash report:

---- 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 &#39;main&#39; provided by &#39;testmod&#39;
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.&lt;init&gt;(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.&lt;init&gt;(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 &#39;fabric&#39;
Type: Client (map_client.txt)
CPU: &lt;unknown&gt;

I have tried removing other mods and the same crash occurred. I tried as much as completely resetting the project (everything except my code) and rerunning the relevant gradle tasks (and in doing so, managed to break my gradle installation, but I fixed that). I looked at this StackOverflow question, which had the same main error, but a different root problem (theirs was a NullPointerException, while mine is a ClassNotFoundException). I'm not sure what I'm doing wrong.

答案1

得分: 0

在 Fabric Discord 服务器上有人能够帮助我。看起来问题可能是以下两种情况之一(或两者皆有):

  1. 可能 gradle 缓存中的 Minecraft 文件损坏了。我使用了 ./gradlew clean build 来处理这个问题。

  2. 我想我当时运行的是开发版的 jar 文件,而不是正常版的。开发版的 jar 文件实际上不应该被运行。

英文:

Someone on the Fabric Discord server was able to help me. It seems like the problem was one of two things (or both):

  1. There may have been a corrupted Minecraft in the gradle cache. I used ./gradlew clean build to help with that.

  2. I think I was running the dev jar as opposed to the normal jar. The dev jar isn't supposed to actually be run.

huangapple
  • 本文由 发表于 2020年9月28日 06:44:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/64093994.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定