Hello, I'm relatively advanced in datapacks, like load.json and tick.json as well as basic .mcfunction files, but I'm really stuck cos I'm a creating a datapack for my friend, I've done most of it like stonecutters damage, player health indicators and no netherite tools & armor in the smithing table. But there is one thing I'm stuck with, which is limit pearls players can have in their inventory. Can someone help me or explain to me how would i make something that checks for pearls in players inventorys and if their is any more than 16 pearls, clear the rest of them (So X (Total pearls) - Y (Amount of pearls you'd have to clear to get to 16 pearls) = 16 (The amount of pearls your allowed to have). Thx so much for your help guys and I'm glad I've joined what appears to be a really helpful community! :)
#Ender Pearl Limit?
1 messages · Page 1 of 1 (latest)
To check how many pearls Someone has in their inventory, you can execute store result score <scoreboard stuff> run clear @s ender_pearl 0
If that amount is above 16 you can just clear the amount above
Easiest way, is to do it recursively:
remove 1,
if there are still more then 16, repeat this function
Or you do binary decomposition
Ok, so I would make a file like pearlimit.mcfunction and put execute store result score <scoreboard stuff, also what is scoreboard stuff> run clear @s ender pearl 0 but how would i actually make it check and then run that command above, and how would I clear the pearls until the amount is 16? Also thx for the fast response time it means a lot to me. :)
For now it's easiest if you just put that command in a function that is ran every tick, so in a function that is referenced in tick.json
The scoreboard stuff is a score holder and a scoreboard that you want to store the value to
So you can use any fakeplayer on a dummy scoreboard
Ok so run the function above every tick, but then does that do everything or do i need more function files. From wat I'm guessing is the scoreboard irrelevant
Currently you are only getting how many pearls a player has
And that is what you want to store on the scoreboard
That is all that this command is doing
You also probably want to run this function as @a if it should be multiplayer compatible
So what scoreboard command should i run at the loading in of the datapack scoreboard objectives add (what here) (Also what here) limitpearls
Okay
When your data pack loads:
scoreboard objectives add <scoreboard> dummy
On each tick
(this could be improved later but for now each tick)
execute as @a run function <namespace>:check_pearls
Inside of check_pearls.mcfunction
execute store result score .count <scoreboard> run clear @s ender_pearl 0
<…>
Ok, and <scoreoard> is just a name right?
Whats the <...> at the end of check_pearls.mcfunction
So should i use .count or use something different
It doesn’t matter, count is just very descriptive for the count of an item
Ight, done that, so now how would we clear the pearls? Im guessing we use the scoreboard and clear the excess until we get above 16 (which we should probaly make another scoreboard for)?
Yesn't
The solution I proposed first is probably the easiest
So we need another function, something like
remove_pearls.mcfunction
clear @s ender_pearl 1
scoreboard players remove .count <scoreboard> 1
execute if score .count <scoreboard> matches 17.. run function <namespace>:remove_pearls
And we call this function from the check_pearls function if the count score is 17 or above
wait so this is still in the check_pearls.mcfunction or is this remove pearls.mcfunction, if it's the latter then I'm with you
So if it is check_pearls.mcfunction then would the updated one look like execute store result score .count <scoreboard> run clear @s ender_pearl 0 run function <namespace>:remove_pearls
Anyway, gtg now sorry, if you need more help, feel free to ping @ Helper
Ok, I think that should work now right?
Byeee
<@&935561184806060073>
Just in case it's not
NE1 know?
Kk, thx, from ur perspective tho is that a completed datapack or is there more in ur opinion?
that's up to you :P
Err, it doesnt work
What should i do?
<@&935561184806060073>
What do you have now, can you see anything that works, and that doesn’t
(also, I'm back)
If you set your scoreboard to the sidebar, can you see the count
did you /reload
Does it reflect the amount of pearls?
Lemme check
Does the game find all functions in the /function autocompletion?
yeh i fixed it it was the scoreboard thx guys :)
Hey, is there ameant to be two dots after 17 in this code?
yeah
yap
that means 17 or more
so, ..17 would be 17 or less :P
and 5..17 would be everything from 5 to 17
Wait <@&935561184806060073> it doesnt work! I checked and the scoreboard doesnt give me a score when i get a pearl
Any ideas or should i just give up
Put say commands in the functions to see if they run at all
Both the tick and the load one definitly do
cos they spammed m when i joined lol
Yeh the tick spammed me
Does it show up in the /function autocomplete?
Then there is a syntax error in there
You can check each command ingame
In the chat with a / infront
Or use a highlighter for the program you are using to edit the functions
this my check pearls .mcunfction code execute store result score .count pearlscoreboardone run clear @s ender_pearl 0 run function pearlimit:remove_pearls
Is that valid>
Is it valid? Use one of the ways I told you how you can check if it’s valid
I'm not making your data pack
You should be able to do it yourself
Ok i checked it seems to be the run function command at the end, how else could i make teh command run the remove pearls function after the check pearls function
<@&935561184806060073>
There is a lot of text. Can you give me a tldr?
So basically im trying to make a datapack that limits the amount of pearls you can carry in your inventory at one time (the max being 16) and were trying to figure out how to check for more than 16 pearls and if so clear them. Currently I found out the check_pearls.mcunfction we made is invalid so were tryimg to fix it.
Yes but i cant figure it out cos im dumb
What is the thing that's invalid?
because after the word run yo can only add one command
you have to split it into two commands
Ok so how should i do that while maintaing functionality
execute store result score .count pearlscoreboardone run clear @s ender_pearl 0
execute if score .count pearlscoreboardone matches 17.. run function pearlimit:remove_pearls
all in one function or different functions?
in one function
But not in the tick function
Ye
Wait so does this not check every ticK?
Cos this is the file that is run by tick.json
iirc
This should be in an extra function that gets executed as all players in the tick function.
Wait so what, there should be a function that the tick file runs that execute as @a run function pearlimit:check_pearls that runs this function?
this command should be in the tick function 
the one i put or the one u put?
My commands go into the pearls check function and yours in the tick function
Ok thx
I presume this is multi player compatavtavle
I’m guessing so