Jump to content

PathNodeType being an enum is a big problem for custom path finding


MrChoke

Recommended Posts

I am writing my own custom PathNavigator and NodeProcessor.  And I am finding I can't extend anything from existing code because Mojang decided to make PathNodeType an enum.  This enum is used all over the place in path finding and even in some other entity code.  What if I need to define my own path nodes types?  For example, I want to be able to break fences.  Well, too bad trying to use any of the existing code because with an enum I can't add anything to it nor can I extend it.

 

I don't know how many people have seen the 1.13 code yet.  Did Mojang change this?  If not, can we change this in Forge?  I'll write the code if I need to.  Thoughts?

 

Link to comment
Share on other sites

1 minute ago, MrChoke said:

seen the 1.13 code yet.

I have not seen this, however you could probably look for the mcp(minecraft coder pack for 1.13 and check.

2 minutes ago, MrChoke said:

If not, can we change this in Forge? 

No. This is too bug of a change.

2 minutes ago, MrChoke said:

What if I need to define my own path nodes types

Use reflection and add another entry to the enum. Look at how the EnumHelper class does it if you need an example.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

4 minutes ago, Animefan8888 said:

Use reflection and add another entry to the enum. Look at how the EnumHelper class does it if you need an example.

WOW, that code is deep.  I read enums are read-only, PERIOD.  That is some serious hack-like code.  It is using "sun" objects for example.  Oh well.  If it works great.  I will see if I can copy part of it.  Too bad PathNodeType is not handled already.  Can that be a Forge change?

Link to comment
Share on other sites

It’s very deep code, which is why it breaks on everything except java 8. However it is the “proper” way of adding enum a in forge and is used by all Modders.

 

See an example of adding an enum in the AddHorseArmor method.

Don’t copy the forge method if that’s what you meant by this!!!

3 minutes ago, MrChoke said:

I will see if I can copy part of it.

Edited by Cadiboo

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

5 minutes ago, Cadiboo said:

It’s very deep code, which is why it breaks on everything except java 8. However it is the “proper” way of adding enum a in forge and is used by all Modders.

Ok.  Of course it still won't let me do something like this:

 

PathNodeType.NEW_TYPE

 

Since the compiler will fail that.  But perhaps it will allow me to keep a lot of existing code at least.  But how do I reference one of these new runtime enum values then???

 

So any chance of PathNodeType being added to EnumHelper?

Edited by MrChoke
Link to comment
Share on other sites

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

6 minutes ago, Cadiboo said:

It’s very deep code, which is why it breaks on everything except java 8. However it is the “proper” way of adding enum a in forge and is used by all Modders.

 

See an example of adding an enum in the AddHorseArmor method.

Don’t copy the forge method if that’s what you meant by this!!!

 

A method like "addPathNodeType" would be great.  It doesn't exist!  We need one.  I smell a forge pull request coming....

Link to comment
Share on other sites

Go ahead, but it’s not exactly required

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

1 minute ago, Cadiboo said:

Go ahead, but it’s not exactly required

Explain how its not required unless I start lifting EnumHelper code which I agree is a very bad idea.  

 

Though, please help me with my other question.  How do you reference one of these new enums in code??  PathNodeType.NEW_TYPE sure won't work.

 

Link to comment
Share on other sites

5 minutes ago, Cadiboo said:

 

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

In pseudo code

public static final EnumType NEW_ENUM = reflectionHelper.addEnum(EnumType.class, new Class[]{enum argument classes}, new enum argument values...);

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

4 minutes ago, Cadiboo said:

In pseudo code

public static final EnumType NEW_ENUM = reflectionHelper.addEnum(EnumType.class, new Class[]{enum argument classes}, new enum argument values...);

 

I will look at the code you sent me.  Seems like I can call addENum() from EnumHelper.  That is fine too.

 

So for my question on referencing it at runtime, would this built-in Enum method work for the runtime entry?

 

static <T extends Enum<T>>
T
valueOf(Class<T> enumType, String name)

 

If so, I think this will work.

 

 

Edited by MrChoke
Link to comment
Share on other sites

1 minute ago, MrChoke said:

 

I will look at the code you sent me.  Seems like I can call addENum() from EnumHelper.  That is fine too.

 

So for my question on referencing it at runtime, would this built-in Enum method work for the runtime entry?

 

static <T extends Enum<T>>
T
valueOf(Class<T> enumType, String name)

 

If so, I think this will work.

 

 

Maybe, but just reference your new enum that you added with enumhelper and stored in a constant field.

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

9 minutes ago, Cadiboo said:

Maybe, but just reference your new enum that you added with enumhelper and stored in a constant field.

Still not seeing how I can reference the new enum value as a constant...   I am looking at the HroseArmor stuff....

Edited by MrChoke
Link to comment
Share on other sites

4 minutes ago, MrChoke said:

Still not seeing how I can reference the new enum value as a constant...   I am looking at the HroseArmor stuff....

Enumhelper.addEnum returns the new enum created. Store it somewhere and reference it

Edited by Cadiboo

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

Just wanted to let you know, that was a piece of cake to add.  And the built-in valueOf() method works too:

 

final Class[] parameterTypes = new Class[] { float.class };
PathNodeType FENCE_OPEN = EnumHelper.addEnum(PathNodeType.class, "FENCE_OPEN", parameterTypes, 0.0F);

PathNodeType test1 = Enum.valueOf(PathNodeType.class, "FENCE_OPEN");
if(test1 == FENCE_OPEN)
{
    System.out.println("PASSED!!");
}

 

Link to comment
Share on other sites

Problematic code issue #10

Edited by Cadiboo

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

On 9/25/2018 at 1:00 PM, MrChoke said:

 

You mean I call the new field something like "MYMOD_FENCE_OPEN"?

I recommend naming your enum a resource location (MODID, EnumName).toString(). What you name it in your field reference is up to you.

 

I don’t know if having a semicolon in the enum name will cause issues though

Edited by Cadiboo

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

10 hours ago, Cadiboo said:

I recommend naming your enum a resource location (MODID, EnumName).toString(). What you name it in your field reference is up to you.

 

I don’t know if having a semicolon in the enum name will cause issues though

: is a colon.

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