Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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

 

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

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)

  • Author

It is, indeed, an IWorldReader, which gives me everything I need.

 

Things look sharply less silly now.  Thanks so much.

 

  • 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?

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.