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

During the load() method, BlockEntity.level is always null.. which means I cannot use it to get the MinecraftServer(Level#getServer), which means I cannot get the data I need when loading, causing it so when I rejoin the world(or Ig reload the chunk, never tried), Some data about my block is not saved... How can I get around this?

What I need is:
The MinecraftServer instance, which I thought of getting using BlockEntity.level, but it is null during the BlockEntity#load method

  • Author

The data I use a Location, which is a class I made containing a BlockPos and a Level, the reason I need a level iis because it might not be the same world as the BlockEntity's one.
Basically I am making wireless redstone and I want it to work accross dimensions too and I am trying to load the transmitter's target, but to load a world you need to use MinecraftServer#getLevel which I can only access using Level#getServer

  • Author
3 hours ago, Luis_ST said:

why did you not use lazy loading, means you load the data when you need it the first time

Also, wdym? How do I do that? I just looked at tutorials for BlockEntitiy and all of them used BlockEntity#saveAdditional and BlockEntity#load

  • Author
2 minutes ago, diesieben07 said:

Store the ResourceKey<Level> instead of the Level directly in your Location class.

How will I use it later tho?? When I need to use the Level?
I don't want to always be forced to input a MinecraftServer into my get method

  • Author

Well yeah but if my Location class only contains the ResourceKey<Level> then how is it gonna use the Level internally?
There are short methods such as getBlockState(), getBlockEntity() etc.

Are they all gonna demand a MinecraftServer instance?

  • Author

What I have so far, is a way to store the "world name"(the String I can use the get the ResourceKey<Level> from), and a method called initAndGetWorld(MinecraftServer) that checks if the world is null and if not gives it a value, as well as a method to load the world without the server just by filling in that String, but the problem with that is: I don't know whether I init the world at any point of the code.... so I'm just gonna have to use it anywhere(?)

  • Author
4 minutes ago, diesieben07 said:

Or you need two Location classes, one for storage (using ResourceKey) and one for runtime use (using Level).

I guess this can work, I'll give that a try

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.