FabricMC / fabric-example-mod

Example Fabric mod
Creative Commons Zero v1.0 Universal
1.66k stars 940 forks source link

Can't import net.minecraft.util.registry #260

Closed Soulsender closed 1 year ago

Soulsender commented 1 year ago

I'm unable to import net.minecraft.util.registry. I can import net.minecraft.registry but not with the utils part.

I tried regenerating the gradle sources, but that didn't fix it.

There is an error of Cannot resolve symbol 'registry'

I'm using minecraft 1.20.1.

My code:

package net.soul.testmod1.item;

import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.util.registry.Registry; // <- this is the issue
import net.minecraft.util.Identifier;
import net.soul.testmod1.TestMod1;

public class ModItems {

    public static final Item TESTITEM = registerItem("testitem", new Item(new FabricItemSettings().group(ItemGroup.MISC)));

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

    public static void registerModItems() {
        TestMod1.LOGGER.debug("Registering Mod Items for " + TestMod1.MOD_ID);
    }
}
Cabbasca commented 1 year ago

you need fabric api

modmuss50 commented 1 year ago

👋 We use the issue tracker exclusively for final bug reports and feature requests. However, this issue appears to be better suited for either a discussion thread, or a message on our discord server. Please post your request on one of these, and the conversation can continue there.

Soulsender commented 1 year ago

you need fabric api

I have fabricAPI