Posted March 14, 20223 yr I'm struggling to try and figure out why I'm receiving this error when doing a gradlew build D:\Projects\ModAlpha6.0\src\main\java\com\dwyvern\modalpha\init\ModScreens.java:22: error: incompatible types: cannot infer type-variable(s) M,U             MenuScreens.register(ModContainers.ELEPHANT_INVENTORY_CONTAINER.get(), ElephantInventoryScreen::new);                       ^   (argument mismatch; cannot infer functional interface descriptor for ScreenConstructor<ElephantInventoryContainer,U>)  where M,U are type-variables:   M extends AbstractContainerMenu declared in method <M,U>register(MenuType<? extends M>,ScreenConstructor<M,U>)   U extends Screen,MenuAccess<M> declared in method <M,U>register(MenuType<? extends M>,ScreenConstructor<M,U>) When I execute runClient from within Eclipse (2021-12 4.22.0), it compiles, runs, and functions correctly without any issue. but when I run gradlew build from the command prompt to generate the jar file for the mod, I receive the above error. Does anyone know why this is happening and how I should fix it? Here are some of the class Contents:  public class ModContainers {    public static final DeferredRegister<MenuType<?>> CONTAINER = DeferredRegister.create(ForgeRegistries.CONTAINERS, Reference.MOD_ID);      public static final RegistryObject<MenuType<ElephantInventoryContainer>> ELEPHANT_INVENTORY_CONTAINER  = CONTAINER.register("elephant_inventory_container", () -> new MenuType<>(ElephantInventoryContainer::new)); } public class ModScreens {    public static void registerScreens(FMLClientSetupEvent event)    {       event.enqueueWork(() -> {          MenuScreens.register(ModContainers.ELEPHANT_INVENTORY_CONTAINER.get(), ElephantInventoryScreen::new);       });    } public class ElephantInventoryScreen extends AbstractContainerScreen<ElephantInventoryContainer> {      private static final ResourceLocation TEXTURE_BG = new ResourceLocation(Reference.MOD_ID + ":textures/gui/container3x9.png");    public ElephantInventoryScreen(ElephantInventoryContainer container, Inventory playerInventory, Component title)    {       super(container, playerInventory, title);   } ... } public class ElephantInventoryContainer extends AbstractContainerMenu {    public ElephantInventoryContainer(int id, Inventory playerInv)    {       super(ModContainers.ELEPHANT_INVENTORY_CONTAINER.get(), id);   } ... }  Any guidance or suggestions is much appreciated.  Thank you. Edited March 14, 20223 yr by diesieben07 code tag
March 14, 20223 yr Author I should have came to this forum sooner. 🙂 I've been racking my brain over why this was happening for a couple days now. You are correct. Specifying the Parameter Type solved the issue.          MenuScreens.register(ModContainers.ELEPHANT_INVENTORY_CONTAINER.get(), (MenuScreens.ScreenConstructor<ElephantInventoryContainer, ElephantInventoryScreen>) ElephantInventoryScreen::new);   Thank you very much diesieben07
March 14, 20223 yr Author I guess what I did was more along the lines of casting, but it allowed gradle to build, so I'm content now. Â
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.