ways to store an entity or it's UUID as a variable

Started by Linkdeous on

Topic category: Help with MCreator software

Last seen on 17:03, 26. Jul 2024
Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ways to store an entity or it's UUID as a variable

Hello ! I wanted to ask how could one store an entity as a variable : for example for storing a target to make custom AI , or for long distance targets interactions , as there is no "Entity NBT" in mcreator!

More in depth : im trying to store a UUID (i  think it's called like this?) of an entity (namely any mob/creature or the player found in a "For each entity as Entity iterator" block), for it to be called on each frame for the AI to pathfind to it, and have to only run one check for entity around the creature ! 

i can also code a little in Java, so if it's possible to do by modifying a few things in the generated code, i'm ok with it ! thank you very much for reading , and i hope you'll be able to help me !

Last seen on 20:18, 12. Mar 2024
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I was looking into this, and…
Tue, 07/11/2023 - 00:18

I was looking into this, and I think you can do this using the getUUID() function or something like that. I don't know how to retrieve the entity later.

Last seen on 17:03, 26. Jul 2024
Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
yeah, it's what i tried so…
Tue, 07/11/2023 - 06:07

yeah, it's what i tried so far, but there seems to be no real way to retrieve the entity out of that, unless doing a big loop through all of minecraft's current entities and doing a check to check if the uuid are mathcing, and if yes, storing the entity , but it seems a bit much ..
i would gladly have some help if someone know how to do it !  , i've also tried to do this : 

world.getEntityFromUuid(UUID.fromString(entity.getPersistentData().getString("tagTargetUUID")));

as a custom code snippet, but it doesnt work, getting a cannot find symbol error with this function
 

Last seen on 20:18, 12. Mar 2024
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
What "cannot find symbol"…
Tue, 07/11/2023 - 22:06

What "cannot find symbol" error is it? You can p Roxanne import it.

Last seen on 20:18, 12. Mar 2024
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It looks like ServerLevel …
Sat, 07/15/2023 - 21:29

It looks like ServerLevel (which implements LevelAccessor) has a method getEntity. It takes one argument of type UUID and returns an Entity. A UUID object can be created in a number of ways, including from a string. You could try that.

Last seen on 00:07, 8. Apr 2024
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Late, but answering for the…
Fri, 09/01/2023 - 19:54

Late, but answering for the benefit of anyone else with the same problem.

Ther are plugins and custom code for getting the UUID from a mob. If you have either, then you can use the following to get an entity from the UUID:

 

Make a command. It should have a sole input of "single entity."

Then make its procedure. Make it do whatever you would like to do with the entity you have the UUID of, which will be provided as a command argument.

Wherever you would like to invoke this, use "create text with" and "run command" procedure blocks (or custom code) to make it run that command using the UUID you want as the target entity.

I've used this for one of my mods and it has worked out pretty well, although I have to create commands quite often.