Posted October 26, 2024Oct 26 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?
October 27, 2024Oct 27 I have the excact same problem. I think there might have been some changes there, and I can't seem to find a solution anywhere at all.
October 28, 2024Oct 28 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 October 28, 2024Oct 28 by xndir
October 28, 2024Oct 28 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 October 28, 2024Oct 28 by CasAl make the background clear
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.