Jump to content

Multithreading question


NolValue

Recommended Posts

This isn't really an outright request for help or support, more asking a question on what you guys would recommend in terms of this idea.

 

I've been working on a mod as of late, if you guys know what CustomNPCs is, I'm working on my own type of mod in that sort of genre.

 

So, right now, I'm working on a custom AI system based off Behaviour Trees. I chose this over using Minecraft's built in one because theirs feels kind of limited, plus it's easier to visualize what decisions my AI would make this way.

 

After getting closer to completion, I've been thinking about how this system is a lot of overhead to add to Minecrafts already relatively bloated stack.

 

Do you guys think it would be justifiable to move all my NPC entities AI onto their own thread? 

 

As in, have a singleton AI Handler class in which it has it's own thread where it processes its children (at a fixed tickrate of course) on loop?

 

(Accidentally posted in wrong section before. Reposting here and editing old thread)

Link to comment
Share on other sites

If you already know how to handle multithreading properly, then go ahead.

If you don't, then I highly recommend not doing it.

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

4 minutes ago, diesieben07 said:

The thing to be careful about in Minecraft is that almost all data structures in Minecraft are not threadsafe.

If you offload your AI to a separate thread, it cannot directly interact with the world, at all. You need to copy all data that the other thread needs to work on the main thread, before passing that copy on to the other thread to work on.

Yeah, Minecraft really isn't inherently threadsafe. Thankfully, at least right now, the AI is going to only read data from other threads. It shouldn't be able to directly alter it. The most it'll do is maybe spawn an Entity like a projectile.

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.