Hello everyone,
I'm currently working on a mod that adds some heads to the game. The code on my ModBlocks.java is as follows:
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MyMod.MOD_ID);
public static final RegistryObject<Block> MOB_HEAD = registerBlock("mob_head",
() -> new SkullBlock(ModTypes.Mob, BlockBehaviour.Properties.of(Material.DECORATION).strength(1.0F)));
public static final RegistryObject<Block> MOB_WALL_HEAD = registeBlock("mob_wall_head",
() -> new WallSkullBlock(ModTypes.Mob, BlockBehaviour.Properties.of(Material.DECORATION).strength(1.0F).lootFrom(MOB_HEAD)));
private static <T extends Block> RegistryObject<T> registerBlock(String name, Supplier<T> block) {
RegistryObject<T> toReturn = BLOCKS.register(name, block);
registerBlockItem(name, toReturn);
return toReturn;
}
private static <T extends Block> void registerBlockItem(String name, RegistryObject<T> block) {
ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS)));
}
public static void register(IEventBus eventBus) {
BLOCKS.register(eventBus);
}
public static enum ModTypes implements SkullBlock.Type {
MOB,
}
Adding the SkullBlock alone is no problem, but when adding the WallSkullBlock I get the following crash:
---- Minecraft Crash Report ----
// Don't do that.
Time: 1/9/22, 8:44 PM
Description: Initializing game
java.lang.StackOverflowError: Initializing game
at net.minecraft.world.level.block.WallSkullBlock.getDescriptionId(WallSkullBlock.java:30) ~[forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.17.1-recomp.jar%2375!:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.world.item.BlockItem.getDescriptionId(BlockItem.java:200) ~[forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.17.1-recomp.jar%2375!:?] {re:classloading}
at net.minecraft.world.level.block.WallSkullBlock.getDescriptionId(WallSkullBlock.java:30) ~[forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.17.1-recomp.jar%2375!:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.world.item.BlockItem.getDescriptionId(BlockItem.java:200) ~[forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.17.1-recomp.jar%2375!:?] {re:classloading}
...
at net.minecraft.world.level.block.WallSkullBlock.getDescriptionId(WallSkullBlock.java:30) ~[forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.17.1-recomp.jar%2375!:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.world.item.BlockItem.getDescriptionId(BlockItem.java:200) ~[forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.17.1-recomp.jar%2375!:?] {re:classloading}
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Thread: Render thread
Stacktrace:
at net.minecraft.world.level.block.WallSkullBlock.getDescriptionId(WallSkullBlock.java:30) ~[forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.17.1-recomp.jar%2375!:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.world.item.BlockItem.getDescriptionId(BlockItem.java:200) ~[forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.17.1-recomp.jar%2375!:?] {re:classloading}
at net.minecraft.world.level.block.WallSkullBlock.getDescriptionId(WallSkullBlock.java:30) ~[forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.17.1-recomp.jar%2375!:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.world.item.BlockItem.getDescriptionId(BlockItem.java:200) ~[forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.17.1-recomp.jar%2375!:?] {re:classloading}
...
at net.minecraft.world.level.block.WallSkullBlock.getDescriptionId(WallSkullBlock.java:30) ~[forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.17.1-recomp.jar%2375!:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.world.item.BlockItem.getDescriptionId(BlockItem.java:200) ~[forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.17.1-recomp.jar%2375!:?] {re:classloading}
-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.main.Main.main(Main.java:158) ~[forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}
at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:38) ~[fmlloader-1.17.1-37.1.1.jar%233!:?] {}
at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.21.jar%238!:?] {}
at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.21.jar%238!:?] {}
at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.21.jar%238!:?] {}
at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.21.jar%238!:?] {}
at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.21.jar%238!:?] {}
at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.21.jar%238!:?] {}
at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.21.jar%238!:?] {}
at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) [bootstraplauncher-0.1.17.jar:?] {}
-- System Details --
Details:
Minecraft Version: 1.17.1
Minecraft Version ID: 1.17.1
Operating System: Windows 10 (amd64) version 10.0
Java Version: 16.0.2, Eclipse Foundation
Java VM Version: OpenJDK 64-Bit Server VM (mixed mode, sharing), Eclipse Foundation
Memory: 710770920 bytes (677 MiB) / 1000341504 bytes (954 MiB) up to 2076180480 bytes (1980 MiB)
CPUs: 8
Processor Vendor: GenuineIntel
Processor Name: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Identifier: Intel64 Family 6 Model 140 Stepping 1
Microarchitecture: Tiger Lake
Frequency (GHz): 1.69
Number of physical packages: 1
Number of physical CPUs: 4
Number of logical CPUs: 8
Graphics card #0 name: NVIDIA GeForce MX350
Graphics card #0 vendor: NVIDIA (0x10de)
Graphics card #0 VRAM (MB): 2048.00
Graphics card #0 deviceId: 0x1c94
Graphics card #0 versionInfo: DriverVersion=27.21.14.6231
Graphics card #1 name: Intel(R) Iris(R) Xe Graphics
Graphics card #1 vendor: Intel Corporation (0x8086)
Graphics card #1 VRAM (MB): 1024.00
Graphics card #1 deviceId: 0x9a49
Graphics card #1 versionInfo: DriverVersion=27.20.100.9749
Memory slot #0 capacity (MB): 4096.00
Memory slot #0 clockSpeed (GHz): 4.27
Memory slot #0 type: LPDDR4
Memory slot #1 capacity (MB): 4096.00
Memory slot #1 clockSpeed (GHz): 4.27
Memory slot #1 type: LPDDR4
Virtual memory max (MB): 19110.91
Virtual memory used (MB): 14648.52
Swap memory total (MB): 11196.12
Swap memory used (MB): 1829.44
JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
Launched Version: MOD_DEV
Backend library: LWJGL version 3.2.2 SNAPSHOT
Backend API: Intel(R) Iris(R) Xe Graphics GL version 3.2.0 - Build 27.20.100.9749, Intel
Window size: <not initialized>
GL Caps: Using framebuffer using OpenGL 3.2
GL debug messages:
Using VBOs: Yes
Is Modded: Definitely; Client brand changed to 'forge'
Type: Client (map_client.txt)
CPU: 8x 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
ModLauncher: 9.0.21+9.0.21+main.6bb4b073
ModLauncher launch target: forgeclientuserdev
ModLauncher naming: mcp
ModLauncher services:
mixin PLUGINSERVICE
eventbus PLUGINSERVICE
object_holder_definalize PLUGINSERVICE
runtime_enum_extender PLUGINSERVICE
capability_token_subclass PLUGINSERVICE
capability_inject_definalize PLUGINSERVICE
accesstransformer PLUGINSERVICE
runtimedistcleaner PLUGINSERVICE
mixin TRANSFORMATIONSERVICE
fml TRANSFORMATIONSERVICE
FML Language Providers:
[email protected]
javafml@null
Mod List:
forge-1.17.1-37.1.1_mapped_parchment_2021.08.15-1.|Minecraft |minecraft |1.17.1 |COMMON_SET|Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f
|Forge |forge |37.1.1 |COMMON_SET|Manifest: NOSIGNATURE
main |Beheading Mod |beheadingmod |0.0.0 |COMMON_SET|Manifest: NOSIGNATURE
Crash Report UUID: 47eb6044-d121-4f55-b85c-35c166d3534c
FML: 37.1
Forge: net.minecraftforge:37.1.1
PS: As is a StackOverFlow I didn't put the 1K lines, but just the 2 lines that loop 500 times.
From the crash report, BlockItem.getDescriptionId() calls WallSkullBlock.getDescriptionId(), whichs calls back again BlockItem.getDescriptionId().
Should this description id be generated automatically?
Or should I add a declaration somewhere?
From WallSkullBlock implementation, it should call Item.getDescriptionId(), not BlockItem's, why is this? Is this a forge bug?