Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello, I am currently porting my 1.18 mod into 1.19 but while porting ModContainers I got some errors and I tried everything but I couldn't solve those problems.

 private static final DeferredRegister REGISTRY = DeferredRegister.create(ForgeRegistries.CONTAINERS, Hexcraft.MOD_ID);
    public static final MenuType<Crate_WhiteOakGUIMenu> WHITE_OAK_CRATE_GUI = register("white_oak_crate_gui",
            (id, inv, extraData) -> new Crate_WhiteOakGUIMenu(id, inv, extraData));
    public static final MenuType<Crate_HellbarkGUIMenu> HELLBARK_CRATE_GUI = register("hellbark_crate_gui",
            (id, inv, extraData) -> new Crate_HellbarkGUIMenu(id, inv, extraData));
    public static final MenuType<Crate_BloodOakGUIMenu> BLOOD_OAK_CRATE_GUI = register("blood_oak_crate_gui",
            (id, inv, extraData) -> new Crate_BloodOakGUIMenu(id, inv, extraData));
//  public static final MenuType<EbonyCrateGUIMenu> EBONY_CRATE_GUI = register("ebony_crate_gui",
//            (id, inv, extraData) -> new EbonyCrateGUIMenu(id, inv, extraData));
 
    private static <T extends AbstractContainerMenu> MenuType<T> register(String registryname, IContainerFactory<T> containerFactory) {
        MenuType<T> menuType = new MenuType<T>(containerFactory);
        menuType.setRegistryName(registryname); // NO SET REGISTRY NAME
        REGISTRY.register(menuType); // NO REGISTER
        return menuType;
    }
 
    @SubscribeEvent
    public static void registerContainers(RegisterEvent event) {
        event.getRegistry().registerAll(REGISTRY.toArray(new MenuType[0])); // I DON'T HAVE ANY IDEA
    }

 

Edited by FantaLaTone

  • Author
13 minutes ago, Luis_ST said:

you should use DeferredRegister to register all registry entries,
the setRegistryName is no longer necessary since DeferredRegister does this for you
see: https://forge.gemwire.uk/wiki/Registration#DeferredRegister

I am using DeferredRegister right now but I've made some changes but it still don't work can you just tell me replace this with this? I tried everything on documents but no help

 

  • Author

I changed the some of codes and errors has changed but I still get errors

new code:

private static final DeferredRegister<Container> REGISTRY = DeferredRegister.create(ForgeRegistries.CONTAINERS, Hexcraft.MOD_ID);

    public static final MenuType<Crate_WhiteOakGUIMenu> WHITE_OAK_CRATE_GUI = registerMenu("white_oak_crate_gui",
            (id, inv, extraData) -> new Crate_WhiteOakGUIMenu(id, inv, extraData));
    public static final MenuType<Crate_HellbarkGUIMenu> HELLBARK_CRATE_GUI = registerMenu("hellbark_crate_gui",
            (id, inv, extraData) -> new Crate_HellbarkGUIMenu(id, inv, extraData));
    public static final MenuType<Crate_BloodOakGUIMenu> BLOOD_OAK_CRATE_GUI = registerMenu("blood_oak_crate_gui",
            (id, inv, extraData) -> new Crate_BloodOakGUIMenu(id, inv, extraData));
//  public static final MenuType<EbonyCrateGUIMenu> EBONY_CRATE_GUI = register("ebony_crate_gui",
//            (id, inv, extraData) -> new EbonyCrateGUIMenu(id, inv, extraData));

    private static RegistryObject<<T extends AbstractContainerMenu> MenuType<T>> registerMenu(String registryname, IContainerFactory<T> containerFactory) {
        return REGISTRY.register(registryname, () -> new MenuType<T>(containerFactory));
    }

    public static void register(IEventBus eventBus) {
        event.register(eventBus);
    }

 

1 hour ago, FantaLaTone said:
        menuType.setRegistryName(registryname); // NO SET REGISTRY NAME

this is no longer necessary since DeferredRegister does this for you

1 hour ago, FantaLaTone said:
        REGISTRY.register(menuType); // NO REGISTER

what did you mean by that?

1 hour ago, FantaLaTone said:
    @SubscribeEvent
    public static void registerContainers(RegisterEvent event) {
        event.getRegistry().registerAll(REGISTRY.toArray(new MenuType[0])); // I DON'T HAVE ANY IDEA
    }

why did you use that? if you use DeferredRegister you only need to register the DeferredRegister in the constructor of you main mod class

  • Author
Just now, Luis_ST said:

this is no longer necessary since DeferredRegister does this for you

what did you mean by that?

why did you use that? if you use DeferredRegister you only need to register the DeferredRegister in the constructor of you main mod class

Can you check out this

1 minute ago, FantaLaTone said:

I changed the some of codes and errors has changed but I still get errors

new code:

private static final DeferredRegister<Container> REGISTRY = DeferredRegister.create(ForgeRegistries.CONTAINERS, Hexcraft.MOD_ID);

    public static final MenuType<Crate_WhiteOakGUIMenu> WHITE_OAK_CRATE_GUI = registerMenu("white_oak_crate_gui",
            (id, inv, extraData) -> new Crate_WhiteOakGUIMenu(id, inv, extraData));
    public static final MenuType<Crate_HellbarkGUIMenu> HELLBARK_CRATE_GUI = registerMenu("hellbark_crate_gui",
            (id, inv, extraData) -> new Crate_HellbarkGUIMenu(id, inv, extraData));
    public static final MenuType<Crate_BloodOakGUIMenu> BLOOD_OAK_CRATE_GUI = registerMenu("blood_oak_crate_gui",
            (id, inv, extraData) -> new Crate_BloodOakGUIMenu(id, inv, extraData));
//  public static final MenuType<EbonyCrateGUIMenu> EBONY_CRATE_GUI = register("ebony_crate_gui",
//            (id, inv, extraData) -> new EbonyCrateGUIMenu(id, inv, extraData));

    private static RegistryObject<<T extends AbstractContainerMenu> MenuType<T>> registerMenu(String registryname, IContainerFactory<T> containerFactory) {
        return REGISTRY.register(registryname, () -> new MenuType<T>(containerFactory));
    }

    public static void register(IEventBus eventBus) {
        event.register(eventBus);
    }

 

 

Just now, FantaLaTone said:

I changed the some of codes and errors has changed but I still get errors

please post the error you get

  • Author
3 minutes ago, Luis_ST said:

please post the error you get

D:\Fiverr Tasks\adree411\src\main\java\com\masterquentus\hexcraft\world\HexcraftMenus.java:37: error: <identifier> expected
    private static RegistryObject<<T extends AbstractContainerMenu> MenuType<T>> registerMenu(String registryname, IContainerFactory<T> containerFactory) {
                                 ^
D:\Fiverr Tasks\adree411\src\main\java\com\masterquentus\hexcraft\world\HexcraftMenus.java:37: error: <identifier> expected
    private static RegistryObject<<T extends AbstractContainerMenu> MenuType<T>> registerMenu(String registryname, IContainerFactory<T> containerFactory) {
                                    ^
D:\Fiverr Tasks\adree411\src\main\java\com\masterquentus\hexcraft\world\HexcraftMenus.java:37: error: <identifier> expected
    private static RegistryObject<<T extends AbstractContainerMenu> MenuType<T>> registerMenu(String registryname, IContainerFactory<T> containerFactory) {
                                                                  ^
D:\Fiverr Tasks\adree411\src\main\java\com\masterquentus\hexcraft\world\HexcraftMenus.java:37: error: <identifier> expected
    private static RegistryObject<<T extends AbstractContainerMenu> MenuType<T>> registerMenu(String registryname, IContainerFactory<T> containerFactory) {
                                                                               ^
D:\Fiverr Tasks\adree411\src\main\java\com\masterquentus\hexcraft\world\HexcraftMenus.java:37: error: invalid method declaration; return type required
    private static RegistryObject<<T extends AbstractContainerMenu> MenuType<T>> registerMenu(String registryname, IContainerFactory<T> containerFactory) {
                                                                                 ^

 

- public static final MenuType<Crate_WhiteOakGUIMenu> WHITE_OAK_CRATE_GUI = registerMenu("white_oak_crate_gui",
            (id, inv, extraData) -> new Crate_WhiteOakGUIMenu(id, inv, extraData));

+ public static final RegistryObject<MenuType<Crate_WhiteOakGUIMenu>> WHITE_OAK_CRATE_GUI = registerMenu("white_oak_crate_gui",
            (id, inv, extraData) -> new Crate_WhiteOakGUIMenu(id, inv, extraData));

You hold the RegistryObject, then use WHITE_OAK_CRATE_GUI.get() to access it later.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

- RegistryObject<<T extends AbstractContainerMenu> MenuType<T>>
  
+ RegistryObject<T extends AbstractContainerMenu> MenuType<T>

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author

I got new problems
 

private static RegistryObject<T extends AbstractContainerMenu> MenuType<T> registerMenu(String registryname, IContainerFactory<?> containerFactory) { return REGISTRY.register(registryname, () -> new MenuType<T>(containerFactory)); }

 

this is the error message i get:

D:\Fiverr Tasks\adree411\src\main\java\com\masterquentus\hexcraft\world\HexcraftMenus.java:37: error: <identifier> expected
    private static RegistryObject<T extends AbstractContainerMenu> MenuType<T> registerMenu(String registryname, IContainerFactory<?> containerFactory) {

 

Its more like

<T extends AbstractContainerMenu> RegistryObject<MenuType<T>>

Your return type is the RegistryObject, the T is a generic parameter definition.

I was too hung up on the weird double brackets. 🙂

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

I think you need to take a step back and understand what you are doing. You can't just keep posting compiler errors from random code you write here.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author
2 minutes ago, warjort said:

Its more like

<T extends AbstractContainerMenu> RegistryObject<MenuType<T>>

Your return type is the RegistryObject, the T is a generic parameter definition.

I was too hung up on the weird double brackets. 🙂

Are you sure about this cause it messed so many things now

  • Author

currently this is the errors i get

D:\Fiverr Tasks\adree411\src\main\java\com\masterquentus\hexcraft\world\HexcraftMenus.java:26: error: incompatible types: inference variable B has incompatible equality constraints Container,MenuType<?>
    private static final DeferredRegister<Container> REGISTRY = DeferredRegister.create(ForgeRegistries.CONTAINERS, Hexcraft.MOD_ID);
                                                                                       ^
  where B is a type-variable:
    B extends Object declared in method <B>create(IForgeRegistry<B>,String)
D:\Fiverr Tasks\adree411\src\main\java\com\masterquentus\hexcraft\world\HexcraftMenus.java:29: error: incompatible types: incompatible parameter types in lambda expression
            (id, inv, extraData) -> new Crate_WhiteOakGUIMenu(id, inv, extraData));
            ^
D:\Fiverr Tasks\adree411\src\main\java\com\masterquentus\hexcraft\world\HexcraftMenus.java:31: error: incompatible types: incompatible parameter types in lambda expression
            (id, inv, extraData) -> new Crate_HellbarkGUIMenu(id, inv, extraData));
            ^
D:\Fiverr Tasks\adree411\src\main\java\com\masterquentus\hexcraft\world\HexcraftMenus.java:33: error: incompatible types: incompatible parameter types in lambda expression
            (id, inv, extraData) -> new Crate_BloodOakGUIMenu(id, inv, extraData));
            ^

and this is my current code :

private static final DeferredRegister<Container> REGISTRY = DeferredRegister.create(ForgeRegistries.CONTAINERS, Hexcraft.MOD_ID);

    public static final RegistryObject<MenuType<Crate_WhiteOakGUIMenu>> WHITE_OAK_CRATE_GUI = REGISTRY.register("white_oak_crate_gui",
            (id, inv, extraData) -> new Crate_WhiteOakGUIMenu(id, inv, extraData));
    public static final RegistryObject<MenuType<Crate_HellbarkGUIMenu>> HELLBARK_CRATE_GUI = REGISTRY.register("hellbark_crate_gui",
            (id, inv, extraData) -> new Crate_HellbarkGUIMenu(id, inv, extraData));
    public static final RegistryObject<MenuType<Crate_BloodOakGUIMenu>> BLOOD_OAK_CRATE_GUI = REGISTRY.register("blood_oak_crate_gui",
            (id, inv, extraData) -> new Crate_BloodOakGUIMenu(id, inv, extraData));
//  public static final MenuType<EbonyCrateGUIMenu> EBONY_CRATE_GUI = register("ebony_crate_gui",
//            (id, inv, extraData) -> new EbonyCrateGUIMenu(id, inv, extraData));

    public static void register(IEventBus eventBus) {
        REGISTRY.register(eventBus);
    }

 

 That is probably because you are trying to register MenuTypes in a

DeferredRegister<Container>

 

Like I said above, try to figure this out for yourself.

That means spending time on it to understand what the compiler is telling you, not dumping the compiler errors here for us to fix without you engaging your brain. 🙂

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

You will probably find it easier to get rid of the registerMenu() method and just write the register directly in the static initializer(s).

That way the compiler will have more opportunity to infer the correct generic parameters.
 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author
6 minutes ago, warjort said:

You will probably find it easier to get rid of the registerMenu() method and just write the register directly in the static initializer(s).

That way the compiler will have more opportunity to infer the correct generic parameters.
 

Yeah I get rid off the registerMenu method but now those lambda functions in registers giving some errors

Look at the MenuType constructor. It takes a MenuType.MenuSupplier. 

That functional interface's method takes 2 parameters while you have 3 in your lambda.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

public static final RegistryObject<MenuType<Crate_WhiteOakGUIMenu>> WHITE_OAK_CRATE_GUI =

         REGISTRY.register("white_oak_crate_gui", () -> new MenuType<>((id, inv) -> new Crate_WhiteOakGUIMenu(id, inv)));

You are also not even using the MenuType constructor, or using a supplier for the object. It should be more like the above.

 

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author

Ok I fixed it i just simply changed 

new Crate_BloodOakGUIMenu(id, inv, extraData)

with

new Crate_BloodOakGUIMenu(id, inv, null)

thanks for your helps

  • FantaLaTone changed the title to [SOLVED] [1.19] I got some errors while porting my 1.18 mod to 1.19
10 minutes ago, FantaLaTone said:
Crate_BloodOakGUIMenu

please show the constructors of this class null is in this case not the solution

The null is the "extraData".

It's from forge's IContainerFactory, which you can pass to the MenuType constructor instead. It's a subclass of MenuType.MenuSupplier.

Using a lambda means it won't be an IContainerFactory, so the parameter is redundant.

Using that IContainerFactory means you can pass extra data to the client when you open the screen. See the NetworkHooks.openScreen() methods and MenuType.create()

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

But you only need it if you have extra data to pass.

For future reference using IContainerFactory would look something like this

() -> new MenuType<>((IContainerFactory<Crate_WhiteOakGuiInv>) Crate_WhiteOakGuiInv::new)

where the constructor has signature

(int, Inventory, FriendlyByteBuf)

 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.