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

DWyvern

Members
  • Posts

    7
  • Joined

  • Last visited

DWyvern's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Not sure if you were able to solve, but I believe you need to also add the Behavior MoveToTargetSink to actually move. The other I believe just sets the Path.
  2. I guess what I did was more along the lines of casting, but it allowed gradle to build, so I'm content now.
  3. 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
  4. 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.
  5. @SubscribeEvent public static void onMemoryModuleRegistry(final RegistryEvent.Register<MemoryModuleType<?>> { //Are you referring to some sort of event like this? } Moving ModMemoryModuleType.register(); From Main to My Subscribe event class in the above method seems to work as well. Thank you.
  6. Please tell which event would that be then? I've spent several days trying to figure out how to get this to work as the normal deferred registration didn't work, so this is what I had come up with.
  7. I'm not sure if you were able to figure this out. But I came across the same problem with Deferred Registration. You cannot use Deferred Registration with Those, as I believe there are parts of the program that requires immediate access to the objects, and with deferred registration, they are not registered to the registry till after theses methods run. So this is how I implemented it: public class ModMemoryModuleType<U> extends MemoryModuleType<U> { public static MemoryModuleType<Boolean> PICKUP_ITEM = registerWithCodec("pickup_item_memory_type", Codec.BOOL); public ModMemoryModuleType(Optional<Codec<U>> optionalCodec) { super(optionalCodec); } public String toString() { return this.getRegistryName().toString(); } private static <U> MemoryModuleType<U> registerWithCodec(String identifier, Codec<U> codec) { @SuppressWarnings("unchecked") ModMemoryModuleType<U> mod = (ModMemoryModuleType<U>) new ModMemoryModuleType<>(Optional.of(codec)).setRegistryName(new ResourceLocation(Reference.MOD_ID, identifier)); ForgeRegistries.MEMORY_MODULE_TYPES.register(mod); return mod; } private static <U> ModMemoryModuleType<U> register(String identifier) { @SuppressWarnings("unchecked") ModMemoryModuleType<U> mod = (ModMemoryModuleType<U>) new ModMemoryModuleType<>(Optional.empty()).setRegistryName(new ResourceLocation(Reference.MOD_ID, identifier)); ForgeRegistries.MEMORY_MODULE_TYPES.register(mod); return mod; } } Then In my Main.java I added the line in Main() to instantiate the statics. ModMemoryModuleType.register(); and in my entities I added the following: protected static ImmutableList<MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of( MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.VISIBLE_MOBS, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.ADMIRING_ITEM, ModMemoryModuleType.PICKUP_ITEM); and Finally, my tasks I use it like this: public class ModPickupItemTask extends Task<MobEntity> { int PercentChanceToExecute; public ModPickupItemTask(int percentChanceToExecute) { super(ImmutableMap.of( MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleStatus.VALUE_PRESENT, MemoryModuleType.ADMIRING_ITEM, MemoryModuleStatus.VALUE_ABSENT, ModMemoryModuleType.PICKUP_ITEM, MemoryModuleStatus.VALUE_PRESENT )); this.PercentChanceToExecute = percentChanceToExecute; } If you solved the problem, maybe this will help others who come across this thread.
×
×
  • Create New...

Important Information

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