Posted April 2, 20196 yr So I have some problems, which is 1. I don't understand what this thing does 2. I want to return LazyOptional in my capability provider, but it gives me the cast error because idk how 3. I want to get the type of the LazyOptional(get T from LazyOptional<T>) Please help me out, if there's a necessity to post my code then I will edit this post
April 2, 20196 yr I think you should post your code About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
July 12, 20196 yr 0 Advanced issues found ▲ On 4/2/2019 at 7:02 AM, Cadiboo said: I think you should post your code ^Why? (Almost think you're stupid. No offense) 1. From what I understand, it keeps from returning null without the dev knowing. 2. LazyOptional.of((NonNullSupplier<T>) Optional.fromNullable("your capability instance here")); 3. Use .orElse in LazyOptional and set null as the argument. If you get null and not a capability then the LazyOptional is empty. Took me literally weeks to find the answer for 2. And take at me mod source for guidance: Github
July 12, 20196 yr Somehow my post doesn't display properly. Here is a redo: On 4/2/2019 at 7:02 AM, Cadiboo said: I think you should post your code ^Why (I Almost think you're stupid. No offense) 1. From what I understand, it keeps from returning null without the dev knowing. 2. LazyOptional.of((NonNullSupplier<T>) Optional.fromNullable("Your capability instance here")); 3. Use .orElse in LazyOptional and set null as the argument. If you get null and not a capability instance then the LazyOptional is empty. Took me literally weeks to find the answer for 2. And take a look at my mod source for guidance: https://github.com/WotblitzMC/FEUniversial Edited July 12, 20196 yr by WOTBLITZ
July 12, 20196 yr You should return LazyOptional.of(() -> yourCapabilityInstance).cast(); in getCapability, or even better, store LazyOptional.of(() -> yourCapabilityInstance) in a field to reduce the number of objects that you create. About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
August 18, 20196 yr Author Thank you guys, turns out I found a better solution, you guys can check it out the code on my Github https://github.com/yuckyh/Equinox P.S. I hope I'm not necroposting, just want to make sure that this can work and everyone can find out how.
August 18, 20196 yr @Cadiboo Quote You should return LazyOptional.of(() -> yourCapabilityInstance).cast(); in getCapability never ever do that it makes it impossible to cache the capability https://github.com/MinecraftForge/MinecraftForge/blob/1.14.x/src/main/java/net/minecraftforge/common/util/LazyOptional.java#L294
August 18, 20196 yr You also need to invalidate them when your TE is removed: https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/entity/SifterTileEntity.java#L174-L179 Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.