Posted January 9, 20205 yr Perhaps not a very good trade, but putting that aside. Overriding Block's getWeakPower(), I have an IBlockReader instance (and a blockstate, blockpos, and side). I need a World instance instead. There are plenty of examples of getting a World instance in wilds of the Internet, but I've been unable to find anything current. Searching for methods that return a World did yield IForgeDimension, but it didn't take me very far. So -- where can I get my World? If I missed something obviously, well, frankly I'll be quite pleased.
January 9, 20205 yr Author Ah. Not the response I was expecting. I have a handful of functions that I'm calling from randomTick(). I would quite like to call the same functions from getWeakPower() without copying and pasting just to change the signature. World also provides isBlockLoaded(), which I would like to take advantage of. Three copy/pasted functions isn't the end of the world (teehee). But I'd sure like to remove the duplication if I can.
January 10, 20205 yr Author (My) getWeakPower() checks the state of the four horizontal blocks surrounding it. I can do that via IBlockReader, but I'd like to avoid loading any chunks to do so, if the block happens to be placed directly on the edge of an unloaded chunk. And that's the only method from World that I need. Everything else I can do with IBlockReader. I just want to call the same functions from randomTick as I do from getWeakPower. It's not so much a matter of missing a method (isBlockLoaded notwithstanding), but wanting to avoid a bunch of duplicated copy/pasted code. If I do without the isBlockLoaded, I can cast randomTick's World to IBlockReader and get on with my life.
January 10, 20205 yr 20 minutes ago, Ommina said: I can cast randomTick's World to IBlockReader But World already is an IBlockReader, you don’t need to cast. 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)
January 10, 20205 yr Author It is, indeed, an IWorldReader, which gives me everything I need. Things look sharply less silly now. Thanks so much.
January 10, 20205 yr Author I've added the check, but it prompts a followup. I was working under the assumption that if the IBlockReader was also an IWorldReader once, it would be each time. Are cases such as "usually it is, but sometimes it might not be" typical?
January 10, 20205 yr What D7 means is that an IBlockReader is not necessarily also an IWorldReader. If the object you get is only one and not the other, just assume that neighboring blocks are loaded. 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.