Jump to content

[SOLVED] [1.19] I got some errors while porting my 1.18 mod to 1.19


FantaLaTone

Recommended Posts

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
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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);
    }

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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);
    }

 

 

Link to comment
Share on other sites

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) {
                                                                                 ^

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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) {

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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);
    }

 

Link to comment
Share on other sites

 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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • FantaLaTone changed the title to [SOLVED] [1.19] I got some errors while porting my 1.18 mod to 1.19

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.

Link to comment
Share on other sites

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.

Link to comment
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.
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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Losing a significant amount of money to scammers can be a bizarre experience that leaves you feeling helpless and betrayed. This was the situation I found myself in after investing over a hundred thousand dollars in a crypto platform that turned out to be a scam. I was introduced to this platform by a friend of my cousin, and everything seemed legitimate until it was too late for me to realize that I had been duped. The days following the realization of my loss were some of the darkest I have ever experienced. I was consumed by feelings of depression and desperation as I tried everything in my power to retrieve my hard-earned money. I reached out to various authorities and sought advice from friends and family, but it seemed like there was no way to recover what I had lost. It was during this time that a friend mentioned a platform called Wizard Web Recovery that specialized in recovering funds lost to scams. At first, I was skeptical and hesitant to trust another company with my money, but I was running out of options and decided to give them a chance. Looking back, this decision turned out to be the best one I could have made. From the moment I contacted Wizard Web Recovery, I was impressed by their dedication to helping me recover my funds. Their team of experts guided me through the process step by step, explaining each stage clearly and answering all of my questions along the way. They kept me informed of their progress and worked tirelessly to ensure that my case was given the attention it deserved. I was amazed at how quickly Wizard Web Recovery was able to track down the scammers and retrieve my money. Within a relatively short period, I received the news that my funds had been successfully recovered, and I couldn't believe it. It felt like a weight had been lifted off my shoulders, and I was filled with gratitude for the team at Wizard Web Recovery who had made it possible.    
    • my game crashed and I have no idea why here is a link to the pastebin of the crash https://pastebin.com/vv89r9vC
    • ok apparently the issue is even stupider than that. the folder the server was in was called "𝓯𝓻𝓮𝓪𝓴𝔂 server" and apparently the special characters in the folder name break the whole damn thing. this is the stupidest thing in the history of ever
    • Thanks, but now I have the 3d model in hand (and in inventory bcz I won't need that anymore) but now when I try to throw it, it doesnt rotate and its just the end of the trident not the head part. Edit: I removed the 3d custom model. I use the original minecraft files. Json and etc. In minecraft the rendering is made in code. I sent the code in the first message. I have mostly the code. But I don't know how to register the renderers like minecraft do. For example, in minecraft there are 2 jsons: trident_in_hand and trident_throwing , I have both of them. They don't render while I have the item in hand. That's the main problem. I checked the code but I still can't figure out how to register and render the entity basically, in hand
  • Topics

×
×
  • Create New...

Important Information

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