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

How can I convert a resource key to a string(or other serializable type) and then back to a resource key? I need this for storing dimensions for /homes and /warps! Is this even possible?

I read the docs on resource location but I can’t seem to find anything on resource key!

  • Author
5 hours ago, diesieben07 said:

A ResourceKey is just two ResourceLocations. One for the type of registry and one for the element within that registry. For example:


ResourceKey.create(new ResourceLocation("minecraft", "block"), new ResourceLocation("minecraft", "stone"))

This describes the ResourceKey for the registry entry "minecraft:stone" within the "minecraft:block" registry.

You can serialize a ResourceKey by serializing both ResourceLocations. Or, if you know that it will always be a certain registry, you only need to serialize the 2nd ResourceLocation and fill the other one in when deserializing.

Thanks for the help, I just have one more question. ResourceKey.location only returns one resource location(I believe the registry). How would I get both?(entry and registry)

  • Author
On 9/6/2021 at 4:43 AM, diesieben07 said:

A ResourceKey is just two ResourceLocations. One for the type of registry and one for the element within that registry. For example:


ResourceKey.create(new ResourceLocation("minecraft", "block"), new ResourceLocation("minecraft", "stone"))

This describes the ResourceKey for the registry entry "minecraft:stone" within the "minecraft:block" registry.

You can serialize a ResourceKey by serializing both ResourceLocations. Or, if you know that it will always be a certain registry, you only need to serialize the 2nd ResourceLocation and fill the other one in when deserializing.

ResourceKey.create(ResourceLocation, ResourceLocation) is not visible. So I am using this!

ResourceKey<Level> dimension = ResourceKey.create(ResourceKey.createRegistryKey(new ResourceLocation(worldRegistry)), new ResourceLocation(worldEntry));

 

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.