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

[1.14.4] My Kingdom for a World


Ommina
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

More and more methods are already and will be converted to use the interfaces like IBlockReader (there are more, like IEntityReader, etc.). World is not the only implementation of these. You should rely on the interfaces as much as possible.

So, again: Why do you need a World specifically? Which methods from World do you need that are not exposed by IBlockReader already? Why do you need isBlockLoaded?

Link to comment
Share on other sites

(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.

Link to comment
Share on other sites

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 WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.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)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

2 minutes ago, Ommina said:

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?

The method is public and IBlockReader is an interface. Anyone can call it with whatever implementation of IBlockReader they want and your method should behave properly.

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.