While trying to create a simple mob count I encountered a roadblock in the form of datapacks lacking command block logic like conditions, single running commands, etc. Could I have an explanation of how datapacks circumnavigate/recreate these features? I have watched some tutorials that mention storing the success of a function but they were confusing.
#Need help translating command block logic into datapacks
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
Someone will come and help soon!
💬 While you wait, take this time to provide more context and details.
🙇 After a while, hit the Summon Helpers button to ping the helper team. They'll be happy to help you
✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve
I want to count each new skeleton, modify the nbt of one, then reset the scoreboard that had the count to restart the process
For tool diversity among skeletons
I can do this just fine with command blocks. However, I want to learn as much as I can about datapacks for the project I'm currently working on
Well there are a few ways to do conditional commands like that, storing the success is one, but if you just want tool diversity among skeletons, why do you want to base it on count?
tick function
execute as @e[type=skeleton,tag=!modified] run function modify_skeleton
function modify_skeleton
tag @s add modified
data modify entity @s ...
Because if it doesn't need to be based on the number of skeletons, then there's a much better way to do this that will also teach you a lot more about data packs
Well I have a xyz dxyz area set up on a custom island, I assumed it would be easiest to tweak if I can just edit when the score resets
if you've watched the guides on datapacks, you should know that tag tick is on the path:
data/minecraft/tags/function/tick.json
The way I'm thinking of will be even easier for tweaking
Start with this example Antoha provided, then in the modify_skeleton function, you have a couple options. For most straightforward configurability, before/instead of the data modify command, do this:
execute store result score @s <scoreboard> run random value 1..5
execute if score @s <scoreboard> matches 1..2 run item replace entity @s weapon.mainhand bow
execute if score @s <scoreboard> matches 3..5 run item replace entity @s weapon.mainhand iron_sword```
Then you can simply adjust the random range, and the numbers that each item is given, and/or even add more entries for different items.
What Antoha's example combined with this is doing, is simply for each skeleton, assigning them a random tool and marking them as already having been assigned, so that they don't get assigned again the next tick
No counting required
I've never seen a compact value range, I always did it with multiple commands. Not only did you provide a new and more capable method, I also learned more about the syntax, thank you! I'll try it now
life is roblox
I see the logic but what is in place of "random" it says it should be a command but it doesn't exist in 1.20.1
Ah, because it doesn't exist in 1.20.1
So you can either use a different method of generating a random number (probably storing the number of items dropped by a loot table), or you can forgo the random number generation and just use chance predicates for each of the item commands
Unfortunately I'm going to go to bed, but hopefully those two phrases will give you some things to look up and you can try to apply it yourself, and ask for assistance if you run into any confusion
Alright, after a break and some more tutorials I have made a predicate workaround, issue, minecraft doesn't think it exists. I put an if predicate command in a command block and it said "unknown predicate <namespace>:random"
The predicate folder isn't giving any issues which is strange considering the situation
what exacly is in the predicate file?
And where is it?
in this instance I would believe my predicate to be "caero:random" and it's a rng predicate
Something has changed from when I was testing yesterday, my namespace/functions and data folders said they had highlighted elements and presented as red, but that magically resolved itself when I booted up my computer again.
Changed it, but when I reloaded my datapack the command block still didn't recognize it
Let's see this again
Oh wait
No need
Your predicates folder is not in a namespace
It's its own namespace 😅
Was I supposed to move it into my namespace? make a new one? can I even have multiple?
Into your own, and yes you can have multiple
Like you said, you want and expect to to be called "caero:random", that means it needs to be inside the caero namespace
I thought so and tried it before, I was sure it gave me issues then but it looks like it's fine
Everything is working! thanks for the insight
Question Closed
Your question, #1255028197947474022 (Need help translating command block logic into datapacks), was resolved!
Original Message
#1255028197947474022 message
Duration open
10h15m