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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hey there! I removed Bobby as Pyralis suggested and found that I still had that and a another closely related bug (or same bug, different presentation) wherein a torch only illuminates its own block and gets smoothed 1 block out, then gone.   After comparing your modlist to mine (I'm on fabric, also 1.20.1) I found we had 2 mods with the same versions. Mine || Yours Bobby-5.0.1.jar ||bobby-1.20.1_v5.0.1.jar ImmediatelyFast-Fabric-1.2.17+1.20.4.jar || ImmediatelyFast-Forge-1.2.17+1.20.4.jar Removing ImmediatelyFast.. immediately (😉) seems to have fixed the issue. Since it's client only- no new world needed either! To note, I also removed all mods related to or containing direct requirements for Sodium, Indium and Iris which may have played a role, I did not test with re-adding.
    • For anyone still looking for the equivalent for 1.19.2+, the render type should be set for the model. In datagen, this can be done by using ModelBuilder::renderType, otherwise just add the line directly to the json file. As for the validity of this question, the idiomatic solution is presented nowhere online; ModelBuilder::renderType is never addressed when discussing block render types meaning that the solution I have provided is the first mentioned usage. Furthermore, there are no external references to this function meaning that to discover its existence requires a deep search through Forge's code. Therefore it is not only understandable but expected that most beginner modders would struggle to find this function given the already poor documentation of Forge's API.
    • Same issue without voicechat?
    • Start by following the docs to get a workspace setup: https://docs.minecraftforge.net/en/latest/gettingstarted/ Then poke around some of the tutorials, https://www.mcjty.eu/docs/1.20/ used to be the goto, but not sure if there are any updates for regular forge or not, but if you've brushed up on Java, it will be enough to get you started. Poke around the Minecraft and Forge sources to see how things are done. Read the FAQ for information on how to post code/logs when you run into issues. Share as much info on issues you have as possible. Use github to host projects, chances of someone helping are higher when they can actually see all your code and/or build it themselves. And finally, keep it on the forums, don't direct message people with questions, most people do not provide personal support like that. Also keep in mind forums posts are not always immediately answered, if you're looking for a quicker response, you can always try the Minecraft Forge discord server.
    • Hello, I have a Forge Minecraft sever (I host it at g-portal.com) which has always worked fine and I had no problems, but today it doesn't wanna work anymore. Today I started the server and the status said online, but after a few seconds it said this: "Start failed". And then out of nowhere it restarted itself and the same thing happened again and again and now it's in an infinite loop where it just keeps failing and then restarts. Here's the download link for the server logs: https://www.mediafire.com/file/sq30dgoonjevib1/2025-07-06-1.log/file Does anyone know how to fix this? If yes I would really appreciate help. Best wishes, Gabs1107
  • Topics

×
×
  • Create New...

Important Information

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