#Need help translating command block logic into datapacks

1 messages · Page 1 of 1 (latest)

shrewd wharf
#

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.

raven cargoBOT
#

<@&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

shrewd wharf
#

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

sly moth
#

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?

plush thorn
sly moth
#

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

shrewd wharf
#

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

plush thorn
sly moth
#

The way I'm thinking of will be even easier for tweaking

sly moth
# plush thorn tick function ```hs execute as @e[type=skeleton,tag=!modified] run function modi...

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

shrewd wharf
#

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

rare vortex
#

life is roblox

shrewd wharf
sly moth
#

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

shrewd wharf
#

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

tidal musk
#

what exacly is in the predicate file?

sly moth
#

And where is it?

shrewd wharf
#

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.

sly moth
#

It looks like it's missing a file extension

#

Should be a .json

shrewd wharf
sly moth
#

Oh wait

#

No need

#

Your predicates folder is not in a namespace

#

It's its own namespace 😅

shrewd wharf
#

Was I supposed to move it into my namespace? make a new one? can I even have multiple?

sly moth
#

Into your own, and yes you can have multiple

sly moth
shrewd wharf
#

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

raven cargoBOT
# raven cargo <@&1201956957406109788>
Question Closed

Your question, #1255028197947474022 (Need help translating command block logic into datapacks), was resolved!

Original Message

#1255028197947474022 message

Duration open

10h15m