Posted July 16, 20223 yr 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 July 16, 20223 yr by FantaLaTone
July 16, 20223 yr 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
July 16, 20223 yr 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
July 16, 20223 yr 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); }
July 16, 20223 yr 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
July 16, 20223 yr 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); }
July 16, 20223 yr 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
July 16, 20223 yr 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) { ^
July 16, 20223 yr - 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.
July 16, 20223 yr - 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.
July 16, 20223 yr 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) {
July 16, 20223 yr 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.
July 16, 20223 yr 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.
July 16, 20223 yr 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
July 16, 20223 yr 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); }
July 16, 20223 yr 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.
July 16, 20223 yr 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.
July 16, 20223 yr 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
July 16, 20223 yr 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 July 16, 20223 yr 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.
July 16, 20223 yr 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 July 16, 20223 yr 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.
July 16, 20223 yr 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
July 16, 20223 yr 10 minutes ago, FantaLaTone said: Crate_BloodOakGUIMenu please show the constructors of this class null is in this case not the solution
July 16, 20223 yr 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 July 16, 20223 yr 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.
July 16, 20223 yr it work yes, but it's not the way to go if there is a Forge replacement you should always use it
July 16, 20223 yr 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.