Jump to content

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


Recommended Posts

Posted

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?

 

Posted
  On 9/25/2018 at 1:49 AM, MrChoke said:

seen the 1.13 code yet.

Expand  

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

  On 9/25/2018 at 1:49 AM, MrChoke said:

If not, can we change this in Forge? 

Expand  

No. This is too bug of a change.

  On 9/25/2018 at 1:49 AM, MrChoke said:

What if I need to define my own path nodes types

Expand  

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.

Posted
  On 9/25/2018 at 1:53 AM, Animefan8888 said:

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

Expand  

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?

Posted (edited)

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

  On 9/25/2018 at 1:59 AM, MrChoke said:

I will see if I can copy part of it.

Expand  
Edited by Cadiboo

About Me

  Reveal hidden contents

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)

Posted (edited)
  On 9/25/2018 at 2:00 AM, 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.

Expand  

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
Posted

About Me

  Reveal hidden contents

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)

Posted
  On 9/25/2018 at 2:00 AM, 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!!!

Expand  

 

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

Posted

Go ahead, but it’s not exactly required

About Me

  Reveal hidden contents

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)

Posted
  On 9/25/2018 at 2:08 AM, Cadiboo said:

Go ahead, but it’s not exactly required

Expand  

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.

 

Posted
  On 9/25/2018 at 2:06 AM, Cadiboo said:
Expand  

 

About Me

  Reveal hidden contents

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)

Posted

In pseudo code

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

About Me

  Reveal hidden contents

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)

Posted (edited)
  On 9/25/2018 at 2:14 AM, Cadiboo said:

In pseudo code

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

Expand  

 

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
Posted
  On 9/25/2018 at 2:18 AM, 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.

 

 

Expand  

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

About Me

  Reveal hidden contents

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)

Posted (edited)
  On 9/25/2018 at 2:20 AM, Cadiboo said:

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

Expand  

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

Edited by MrChoke
Posted (edited)
  On 9/25/2018 at 2:29 AM, MrChoke said:

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

Expand  

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

Edited by Cadiboo

About Me

  Reveal hidden contents

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)

Posted

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!!");
}

 

Posted (edited)

Problematic code issue #10

Edited by Cadiboo

About Me

  Reveal hidden contents

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)

Posted (edited)
  On 9/25/2018 at 3:00 AM, MrChoke said:

 

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

Expand  

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

  Reveal hidden contents

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)

Posted
  On 9/25/2018 at 4:33 AM, 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

Expand  

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

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.