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



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • So as the title says it seems im the only one with this issue, it was working fine yesturday. basically the server just keeps saying Pinging.... and doesn't load, i added a vanilla server to see if all servers would behave the same but no, my modded server was the only one. i asked some of my friends to try connecting and no problem so it seems on my end. I tried connecting even when it says pinging and it just stuck on Encrypting and then timed out Client log https://gist.github.com/thekingtoonboy/1c53875b856e0563b9313a8cc060a4a0.js latest Server log [19Sep2021 06:06:35.440] [Netty Epoll Server IO #2/INFO] [codechicken.lib.config.ConfigSyncManager/]: Skipping config sync, No mods have registered a syncable config. [19Sep2021 06:06:35.529] [Netty Epoll Server IO #2/WARN] [com.connectivity.Connectivity/]: Login payload for Registry minecraft:item is using 111.6286% of max allowed size and will cause errors during login if connectivity is not present on client side. [19Sep2021 06:06:35.543] [Netty Epoll Server IO #2/WARN] [com.connectivity.Connectivity/]: Login payload for Registry minecraft:block is using 87.6082% of max allowed size [19Sep2021 06:06:37.491] [User Authenticator #1/INFO] [net.minecraft.network.login.ServerLoginNetHandler/]: UUID of player KiingSultan is e69dbe58-dd8d-4d26-9317-a643a0ffde12 [19Sep2021 06:08:37.721] [Server thread/INFO] [net.minecraft.network.login.ServerLoginNetHandler/]: com.mojang.authlib.GameProfile@1b416c43[id=e69dbe58-dd8d-4d26-9317-a643a0ffde12,name=KiingSultan,properties={textures=[com.mojang.authlib.properties.Property@38939441]},legacy=false] (/5.193.109.22:50035) lost connection: Timed out [19Sep2021 06:13:10.808] [Netty Epoll Server IO #0/INFO] [codechicken.lib.config.ConfigSyncManager/]: Skipping config sync, No mods have registered a syncable config. [19Sep2021 06:13:10.867] [Netty Epoll Server IO #0/WARN] [com.connectivity.Connectivity/]: Login payload for Registry minecraft:item is using 111.6286% of max allowed size and will cause errors during login if connectivity is not present on client side. [19Sep2021 06:13:10.880] [Netty Epoll Server IO #0/WARN] [com.connectivity.Connectivity/]: Login payload for Registry minecraft:block is using 87.6082% of max allowed size [19Sep2021 06:13:18.792] [User Authenticator #2/INFO] [net.minecraft.network.login.ServerLoginNetHandler/]: UUID of player KiingSultan is e69dbe58-dd8d-4d26-9317-a643a0ffde12 [19Sep2021 06:15:19.013] [Server thread/INFO] [net.minecraft.network.login.ServerLoginNetHandler/]: com.mojang.authlib.GameProfile@28a892fa[id=e69dbe58-dd8d-4d26-9317-a643a0ffde12,name=KiingSultan,properties={textures=[com.mojang.authlib.properties.Property@53a47b26]},legacy=false] (/5.193.109.22:50239) lost connection: Timed out  
    • Sorry for the very late response, but mixed with what you said + looking at the twilight forest source code I was able to get it working
    • Hello Everyone! I just started learning how to code forge mods and this is my first post. I have been coding spigot plugins for 2 years so I'm not totally clueless. I just want to know how to get all the items from a Inventory/GUI. I have no clue how. I tried something like this. but it got me nowhere @SubscribeEvent public void onOpenInventory(GuiOpenEvent e) { e.getGui().itemsplsssss }  
    • I think that is the problem. I changed to using ResourceKeys instead and haven't seen the log since. 
    • That's how, thanks a lot! (≧ ▽ ≦)
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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