Jump to content

Recommended Posts

Posted

After upgrade from 1.21.1 to 1.21.3, when I do gradlew runData, I get really strange error that I cannot understand:

Caused by: java.lang.NullPointerException: Item id not set
		at java.base/java.util.Objects.requireNonNull(Objects.java:259)
		at TRANSFORMER/minecraft@1.21.3/net.minecraft.world.item.Item$Properties.effectiveDescriptionId(Item.java:461)
		at TRANSFORMER/minecraft@1.21.3/net.minecraft.world.item.Item.<init>(Item.java:111)
		at TRANSFORMER/uniqueweaponry@1.21.3-0.4.1/ba.minecraft.uniqueweaponry.common.item.grenade.base.BaseGrenadeItem.<init>(BaseGrenadeItem.java:22)
		at TRANSFORMER/uniqueweaponry@1.21.3-0.4.1/ba.minecraft.uniqueweaponry.common.item.grenade.FlashGrenadeItem.<init>(FlashGrenadeItem.java:9)
		at TRANSFORMER/uniqueweaponry@1.21.3-0.4.1/ba.minecraft.uniqueweaponry.common.item.GrenadeItems.lambda$0(GrenadeItems.java:22)
		at TRANSFORMER/forge@53.0.0/net.minecraftforge.registries.DeferredRegister$EventDispatcher.lambda$handleEvent$0(DeferredRegister.java:366)
		at TRANSFORMER/forge@53.0.0/net.minecraftforge.registries.RegisterEvent.register(RegisterEvent.java:59)
		at TRANSFORMER/forge@53.0.0/net.minecraftforge.registries.DeferredRegister$EventDispatcher.handleEvent(DeferredRegister.java:366)
		at TRANSFORMER/forge@53.0.0/net.minecraftforge.registries.__EventDispatcher_handleEvent_RegisterEvent.invoke(.dynamic)
		at SECURE-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:48)
		at SECURE-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:304)
		at SECURE-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:290)

Have there been changes related on how items should be registered now?

Posted (edited)

Fabric explains it a bit here, Forge needs to provide a guide for 1.21.3 since the examples are Fabric specific: https://fabricmc.net/2024/10/14/1212.html

EDIT: This seems to work but I don't know if this is the proper way to do it. Truly an annoying change especially if you have lots of items and blocks:

Old:

public static final RegistryObject<Item> ITEM_EGG = ITEMS.register("egg", () -> new Item(new Item.Properties()));

New:

ITEM_EGG = ITEMS.register("egg", () -> new Item(new Item.Properties().useItemDescriptionPrefix().setId(ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modid:egg")))));

Neo also has more on the topic: https://neoforged.net/news/21.2release/

Edited by xndir
  • Like 1
Posted (edited)

The information from xndir worked for me. Alsp in my case, similar errors appear for fluid blocks in the new version, indicating that adjustments are also necessary. Without these changes, an error message stating “block id not set” will appear.

The following code example demonstrates how to correctly configure the fluid block:

public static final RegistryObject<LiquidBlock> EXAMPLE_FLUID_BLOCK =
    BlocksRegister.BLOCKS.register(
        "example_fluid_block",
        () ->
            new ExampleFluidBlock(
                EXAMPLE_FLUID,
                Block.Properties.ofFullCopy(Blocks.WATER)
                    .noCollission()
                    .strength(1000.0F)
                    .noOcclusion()
                    .setId(
                        ResourceKey.create(
                            ForgeRegistries.BLOCKS.getRegistryKey(),
                            ResourceLocation.parse(
                                String.format("%s:%s", ExampleMod.MOD_ID, "example_fluid_block")
                            )
                        )
                    )
            )
    );

 

Edited by CasAl
make the background clear
  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.