Hey guys Claus here and today I will be covering something real known as uh relational technology or something like that some people call it that but essentially it is kind of a different way to code your data packs to be more flexible using macros and uuids in Combination and you may make them more optimized in the process though not necessarily it depends on the situation so for that I created this little example that uses markers particles and no selectors so essentially what we have here is a command that runs a function that spawns a marker that has a command That it wants to run at that marker and so inside the data pack they’re inside the tick function there’s no selectors and we will look at each of these functions later and there’s no selectors anywhere or mention of this so if I wanted to spawn a new particle like I did there with Bubble I can go here and just type happy villager okay and now boom I have the new particle and I don’t have to do any commands don’t have to do any reload and also I don’t have to do any selectors I don’t have to give it any tags so we’re Going to take a look at how that’s possible and what kind of implications that has so when I actually run that function what’s happening is it’s running this spawn function so the spawn function does spawn a particle with a tag though that tag isn’t really necessary most of the time then it is Using a custom built-in library that we’ll look at at the end of the video that basically just grabs the uuid as a string for the entity so when I have an entity it’s going to have a uuid that is an integer so it’ll be in the form of I Semicolon a b c d where those are just numbers so those three the four values are integers but when you’re actually referring to that entity or wanting to run a command at that entity you have to have to either use a selector or have their typed out string uuid which looks Something like zero zero zero zero-000-00-000 something like that but more or less zeros in different locations in different numbers of course so I am able to refer to an entity with execute as with a selector I can also refer to them with these uuid numbers right and so using those uuid Numbers means that we don’t have to actually use a selector to filter a list to figure out where which entity we want to apply the commands to which can be more efficient so what we’re going to do is add using this is a macro we’re going to add the Command that we had passed in the function and we’re going to add that to the end of a list which will be just an array of values but we’re putting it at the end of the list and we were adding a blank uuid slot at the end of The list which we will then populate with the uuid generated by this function so what this means is that if I do data get storage uid list you will see that it’s a list of things and the first thing has uuid colon with the specific identifier that I could type in the Execute command to reference this entity followed by the command that I want to play at them and so when I add another you will see this list just gets bigger and it gets added to the end okay so now we have a list of uuids and Commands to play at the uuids how do we play them at the actual uh when we want to every tick so in the tick function what we’re going to do is we’re going to cop make a copy of the list which is something that we’re able to delete things from and manipulate without Actually ruining the original list then we are going to store how big that list is and run a function that will Loop itself for each element in the list okay so this is basically looping through the array now the way that we Loop to the array is actually backwards because it’s More efficient to delete something from the end of the array than delete something from the beginning because all the indices change and so what we’re going to do is access things from the end so we are going to play a command using the storage at the end of the list And then we are going to delete the element at the end of the list and then Loop this however many times there I have for however many elements there are and so this will just let us go through the list picking things off from the end One at a time and so since we have two here it will first run the crit and then it will run the flame now play command is our other macro command and this one will run every tick and what it does is it goes to so it runs in a command at a Specific uuid which is this hard-coded thing and then it will run the command at that location which in this case is particle but you could make the command anything you want which is why this is very flexible allows us to change the particle allows us to do whatever we want at this entity So where this kind of comes into the discussion of what’s more efficient well if you have a lot of entities in your world but you need a couple of these very specific use case entities well then this may be more efficient because a selector what it has to do when I say Slash execute at e is it grabs a list of every entity that exists in your world so if that list is very big but the thing you want in that list is very small knowing what the entity is beforehand is actually could be more efficient and so Instead of doing at e type equals marker which will now reduce the list of all entities to only markers and then tag equals particle which will now go to all the markers in the list see what tags they have do they have the tag particle if they do keep them if they don’t Delete them then this finally gives me a list of all the entities to run the command at and so on and continue instead of that we are just going to use our array mixed with our uuids so we had know exactly what that entity is typing in their specific uuid which will then Actually just directly go to that entity with no filtering required Or List required okay so that is really everything now the I have a couple different stress tests I did and it did show that for this really specific case where you have particles and you have a finite number Of particles the uh this method is slower than just a list of tags however if you wanted to support every particle in the game then it may be faster because you don’t have to use one command per particle in the game and as you can see there is wow a lot of Particles in this game so that’s why macros can end up being more efficient in the long run because they allow you to reduce the amount of commands required since you’re doing things dynamically and so that is pretty much it for this uh other important things to note is if You do use this system which you could use this system to replace something like linking to entities via a score but if you want to remove an entity from the list you’re going to have to use a command like this data remove storage uuid list and then you go for anything That has a uuid and then you will have to make a macro that knows what that uuid is and deletes that thing so if you use this specific command but with a dollar sign and inside a macro function you will be able to delete an entity a specific entry in That list of known entities before you kill the entity that you want to kill and so it does require additional uh it is slower and it requires additional overhead when you are spawning and removing entities so this situation or this system may not be ideal if you have A project where you kill and spawn things in that list very frequently and finally the last thing I want to cover is that gu thing um so I will leave a link in the description uh but it was from the Minecraft commands Discord and there is A data pack called Mud which kind of attempts to do this stuff but in a general use case to every entity that you use um though I’m not 100 sure about its performance in certain use cases but inside of it it has this namespace called gu and in this namespace it Basically has a list of functions which are also macros and probably have pretty high performance costs if you plan on running them constantly or often but if you just plan on running them once they’re not too bad and what they do is they generate the uuid that you need From the four integer value that you started with because you will end up with four integers and you need to turn that into a string anyways guys if you like that please leave a like comment let me know what you think about this method what are your thoughts if you want to see Something else let me know in the comments there’s a lot of cool stuff with macros and I will be releasing a couple videos with a couple different concepts in the near future once I get them more polished but for example this which I didn’t use make using macros but This is just one of the concepts that I made which is the vanilla crafter all over again though it’s not 100 finished or polished yet but this actually works for every uh item in the game and uh every recipe in the game so this is just something I Will be showing in upcoming videos once I actually get the UI finished anyways thanks for watching and I’ll see you next time peace Video Information
This video, titled ‘Macro Selectors in Minecraft [Snapshot 23w33a]’, was uploaded by Cloud Wolf on 2023-08-25 16:03:15. It has garnered 3667 views and 266 likes. The duration of the video is 00:09:16 or 556 seconds.
We cover a method of selecting entities using UUID’s and macros to make datapacks more dynamic.
Latest Version (Snapshot 23w33a) 📦 Download: https://www.dropbox.com/scl/fi/jfonww4hrrrrjew9ar0bi/uuid_fun.zip?rlkey=yxpuxdwc80er88fytwrmuwrlw&dl=1
📦 Datapack with UUID generation: https://github.com/gibbsly/mud
🔵 Discord & Other Links: https://linktr.ee/CloudWolfMC 💻 Website: https://cloudwolfyt.github.io