#Fluid bucket item in 1.21.3

4 messages · Page 1 of 1 (latest)

drowsy smelt
#

Hi im trying to create a fluid in the latest version but im having issues because of outdated documentation
This is the code i have for making the fluid bucket but im getting the error:

    at java.base/java.util.Objects.requireNonNull(Objects.java:259)
    at knot//net.minecraft.item.Item$Settings.getTranslationKey(Item.java:738)
    at knot//net.minecraft.item.Item.<init>(Item.java:144)
    at knot//net.minecraft.item.BucketItem.<init>(BucketItem.java:35)
    at knot//com.searooter.liquid.ModLiquids.<clinit>(ModLiquids.java:25)```
drowsy smelt
#

I'm a noob but also trying to register a liquid doesn't require a registry key like how the blocks and items need them for the registry in the latest version?

ocean rampart
#

To solve your first problem, you have to include the registryKey in the item.settings before you register it.

#

public static final Item X = registerItem("x", new Item(new Item.Settings()
.registryKey(RegistryKey.of(RegistryKeys.ITEM, Identifier.of(MOD_ID, "x")))));

private static Item registerItem(String name, Item item) {
return Registry.register(Registries.ITEM, Identifier.of(MOD_ID, name), item);
}