Jump to content

[1.15.2] How to get Registry ids?


Axspeo

Recommended Posts

Why do you need the integer id? Integer ids are unreliable and should almost never be used.

In any case, Registry is only really meant for vanilla's use. ForgeRegistries is what you would use to access registries.

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Link to comment
Share on other sites

1 hour ago, imacatlolol said:

Why do you need the integer id? Integer ids are unreliable and should almost never be used.

In any case, Registry is only really meant for vanilla's use. ForgeRegistries is what you would use to access registries.

Was checking Twilight Forest Source code and found it here.

That's why I was asking

Link to comment
Share on other sites

1 hour ago, imacatlolol said:

Why do you need the integer id? Integer ids are unreliable and should almost never be used.

In any case, Registry is only really meant for vanilla's use. ForgeRegistries is what you would use to access registries.

In my custom BiomeProvider I have to use a custom layer which looks like this:

public class CustomLayer implements IC0Transformer
{
    @Override
    public int apply(INoiseRandom context, int value)
    {
     	 return Registry.BIOME.getId(BiomeInit.CUSTOM_BIOME)
    }
}

How can I do without using Minecraft Registry IDs ?

Link to comment
Share on other sites

11 minutes ago, QuantumSoul said:

In my custom BiomeProvider I have to use a custom layer which looks like this:


public class CustomLayer implements IC0Transformer
{
    @Override
    public int apply(INoiseRandom context, int value)
    {
     	 return Registry.BIOME.getId(BiomeInit.CUSTOM_BIOME)
    }
}

How can I do without using Minecraft Registry IDs ?

bruh that was my question already

Link to comment
Share on other sites

16 minutes ago, QuantumSoul said:

How can I do without using Minecraft Registry IDs ?

27 minutes ago, Axspeo said:

Was checking Twilight Forest Source code and found it here.

That's why I was asking

Ah, I see. I'm not super familiar with world gen, but I think this is one of those rare cases where using the numerical IDs is actually necessary, you both were right in the first place.

I looked at a couple other major world-gen mods (Betweenlands and Midnight) and they seem to do the same thing, so I don't believe there's any issues with using the vanilla registry here.

As for the deprecation warning itself, you can use the SupressWarnings annotation; though you may want to add a comment about why the suppression is needed for your own future reference.

Edited by imacatlolol
Typo

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Link to comment
Share on other sites

4 minutes ago, imacatlolol said:

Ah, I see. I'm not super familiar with world gen, but I think this is one of those rare cases where using the numerical IDs is actually necessary, you both were right in the first place.

I looked at a couple other major world-gen mods (Betweenlands and Midnight) and they seem to do the same thing, so I don't believe there's any issues with using the vanilla registry here.

As for the deprecation warning itself, you can use the SupressWarnings annotation; though you may want to add a comment about why the suppression is needed for your own future reference.

I think if we want to use ForgeRegistries, we have to create a LOT of new classes just to solve that one layer problem

Link to comment
Share on other sites

1 minute ago, QuantumSoul said:

I think if we want to use ForgeRegistries, we have to create a LOT of new classes just to solve that one layer problem

I don't think you would. You'd probably just have to cast the IForgeRegistry to ForgeRegistry and use its getID method, but I'm just assuming that it would return the same result.

It certainly wouldn't be any more difficult to work with, I'm sure.

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Link to comment
Share on other sites

1 minute ago, imacatlolol said:

I don't think you would. You'd probably just have to cast the IForgeRegistry to ForgeRegistry and use its getID method, but I'm just assuming that it would return the same result.

It certainly wouldn't be any more difficult to work with, I'm sure.

Isn't it another ID ?

Link to comment
Share on other sites

6 minutes ago, QuantumSoul said:

Isn't it another ID ?

Ran a quick test, both registries seem to return the same IDs, which makes sense all things considered.

So, both the vanilla and forge registries would work for this purpose, unless I'm missing something. In the end I believe it would just be personal preference; most modders seem to use the vanilla registry, but using the forge registry may be preferred by the forge team.

  • Thanks 1

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Link to comment
Share on other sites

6 hours ago, imacatlolol said:

So, both the vanilla and forge registries would work for this purpose, unless I'm missing something. In the end I believe it would just be personal preference; most modders seem to use the vanilla registry, but using the forge registry may be preferred by the forge team.

Using the Forge method would indeed be preferred.

My thought on the matter is:

Vanilla methods that are marked deprecated means they should not be called by outside methods. Due to this, the method can be removed at any time by Mojang or Forge without undergoing the "oh look I'm deprecated, that means I will get removed in the next version; your IDE should be shouting at you to use the newly introduced approach instead!" Therefore the Forge provided method is often considered a better approach and often more future-proof.

  • Like 1

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

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

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

Announcements



×
×
  • Create New...

Important Information

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