Jump to content

error: package net.minecraft.item does not exist import net.minecraft.item.ItemGroup;


Recommended Posts

Posted (edited)

I am new to modding and I'm sure this is a simple fix but I cannot for the life of me figure out why this error is thrown. 

I am running forge-1.17.1-37.0.90 and all other aspects seem to be working fine

I am following this tutorial https://thebookofmodding.ml/adding-custom-items/

here is my code (sorry its messy rn) [registryhandler class]

https://imgur.com/a/EGC2jyj

package com.example.examplemod;

import net.minecraft.item.ItemGroup;
import net.minecraft.world.item.Item;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fmllegacy.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
/*
public class RegistryHandler {
    // create DeferredRegister object
    public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ExampleMod.MODID);

    public static void init() {
        // attach DeferredRegister to the event bus
        ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
    }

    // register item
   public static final RegistryObject<Item> COPPER = ITEMS.register("copper", () ->
        //    new Item(new Item.Properties().group(ItemGroup.MATERIALS))
       //     );
                new Item(
                    new Item.Properties().group(ItemGroup.MATERIALS)
           )
    );

 */
    public class RegistryHandler {
        public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ExampleMod.MODID);

        public static void init() {
            // attach DeferredRegister to the event bus
            ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
        }

        public static final RegistryObject<Item> TITAN = ITEMS.register("titan",
                ()-> new Item(new Item.Properties().group(ItemGroup.REDSTONE)));
    }

 

Edited by parkat
Posted (edited)

Forge use now Mojang class names and their package names, you can use the Forge bot on discord to convert from mcp to moj mappings 

But I would recommend you to use this scrip it will update your hole project automatically 

Edited by Luis_ST
Posted
12 hours ago, Luis_ST said:

Forge use now Mojang class names and their package names, you can use the Forge bot on discord to convert from mcp to moj mappings 

But I would recommend you to use this scrip it will update your hole project automatically 

thank you! this works!!

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.