Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Missing registry object


Recommended Posts

I'm trying to register an object that uses other items in the class but I'm not sure how to make it register properly

 

Blueprints.java: (creating new blueprint)
 

public class Blueprints {

    private static final List<Blueprint.Resource> SKANA_RESOURCES =
            Arrays.asList(
                    new Blueprint.Resource(Items.STICK, 1),
                    new Blueprint.Resource(Resources.MORPHICS.get(), 1)
            );
    public static final RegistryObject<Item> SKANA_BLUEPRINT =
            Registration.ITEMS.register("skana_blueprint",
                    () -> new Blueprint(new Item.Properties().tab(TennoMC.TAB_TENNO), 
                            SKANA_RESOURCES,
                            Swords.SKANA.get())
            );
    
    public static void register() {}
}

Blueprint.java: (my new class)

public class Blueprint extends Item {

    public List<Resource> resources;
    public Item outputItem;

    public Blueprint(Properties properties, List<Resource> resources, Item outputItem) {
        super(properties);
        this.resources = resources;
        this.outputItem = outputItem;
    }


    public static class Resource {
        public final Item item;
        public final int amount;

        public Resource(Item item, int amount) {
            this.item = item;
            this.amount = amount;
        }
    }
}

Registration.java:

public class Registration {

    public static final DeferredRegister<Item> ITEMS =
            DeferredRegister.create(ForgeRegistries.ITEMS, TennoMC.MOD_ID);

    public static void init() {
        IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
        ITEMS.register(eventBus);
    }
}

TennoMC.java:

public TennoMC {
  registerModAdditions();
}

private void registerModAdditions() {

        // Inits additions
        Registration.init();

        // Inits in game items
        Resources.register();
        Blueprints.register();
}

 

Link to post
Share on other sites

Fixed the issue by referring to the ResourceLocation instead of Item.

Like so:

public class Blueprint extends Item {

    public List<Resource> resources;
    public ResourceLocation outputItem;

    public Blueprint(Properties properties, List<Resource> resources, ResourceLocation outputItem) {
        super(properties);
        this.resources = resources;
        this.outputItem = outputItem;
    }


    public static class Resource {
        public final ResourceLocation resourceLocation;
        public final int amount;

        public Resource(ResourceLocation resourceLocation, int amount) {
            this.resourceLocation = resourceLocation;
            this.amount = amount;
        }
    }
}

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.