#Ender Pearl Limit?

1 messages · Page 1 of 1 (latest)

zenith wasp
#

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! :)

sour mesa
#

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

zenith wasp
#

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. :)

sour mesa
#

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

zenith wasp
sour mesa
#

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

zenith wasp
sour mesa
#

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
<…>
zenith wasp
#

Ok, and <scoreoard> is just a name right?

sour mesa
#

Yeah

#

And .count is also arbitrarily chosen

zenith wasp
#

Whats the <...> at the end of check_pearls.mcfunction

sour mesa
#

The next commands

#

The ones actually taking away the pearls

#

We are not there yet

zenith wasp
sour mesa
#

It doesn’t matter, count is just very descriptive for the count of an item

zenith wasp
#

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)?

sour mesa
#

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

zenith wasp
#

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

sour mesa
#

Anyway, gtg now sorry, if you need more help, feel free to ping @ Helper

zenith wasp
#

Ok, I think that should work now right?

#

Byeee

#

<@&935561184806060073>

#

Just in case it's not

#

NE1 know?

lime maple
#

try it and see

#

if it doesnt work

#

say so

zenith wasp
lime maple
#

that's up to you :P

zenith wasp
#

What should i do?

#

<@&935561184806060073>

sour mesa
#

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

lime maple
#

did you /reload

sour mesa
#

Does it reflect the amount of pearls?

zenith wasp
#

Lemme check

sour mesa
#

Does the game find all functions in the /function autocompletion?

zenith wasp
#

yeh i fixed it it was the scoreboard thx guys :)

zenith wasp
lime maple
#

yeah

hollow mesa
#

yap

lime maple
#

that means 17 or more

hollow mesa
#

that means anything greater than 17

#

including 17

lime maple
#

so, ..17 would be 17 or less :P

hollow mesa
#

and 5..17 would be everything from 5 to 17

zenith wasp
#

Ok

#

Thx y'all

zenith wasp
#

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

sour mesa
#

Put say commands in the functions to see if they run at all

zenith wasp
#

Kk

#

what /say commands

#

Oh wait no i get it hang on

#

Ok yeh they work

zenith wasp
#

cos they spammed m when i joined lol

sour mesa
#

Load should sent it once at most

#

So the check_pearls function doesn’t send anything?

zenith wasp
#

Yeh the tick spammed me

sour mesa
#

Does it show up in the /function autocomplete?

zenith wasp
#

Yes

#

Oh wait

#

hang on

#

the check_peaerls dosnt show up

sour mesa
#

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

zenith wasp
#

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>

sour mesa
#

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

zenith wasp
#

<@&935561184806060073>

crystal turret
#

There is a lot of text. Can you give me a tldr?

zenith wasp
# crystal turret 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.

crystal turret
#

Isn't this just 2 simple functions with 3 commands?

#

If I'm not wrong of coures

zenith wasp
#

Yes but i cant figure it out cos im dumb

crystal turret
#

What is the thing that's invalid?

zenith wasp
#

the thing at the end that runs the function remove pearls

#

after 0 its all invalid

crystal turret
#

because after the word run yo can only add one command

#

you have to split it into two commands

zenith wasp
#

Ok so how should i do that while maintaing functionality

crystal turret
#
execute store result score .count pearlscoreboardone run clear @s ender_pearl 0
execute if score .count pearlscoreboardone matches 17.. run function pearlimit:remove_pearls
zenith wasp
#

all in one function or different functions?

crystal turret
#

in one function

zenith wasp
#

I assume different'

#

Oh Ok

#

Thx ill try it

crystal turret
#

But not in the tick function

zenith wasp
#

Ye

zenith wasp
#

Cos this is the file that is run by tick.json

#

iirc

crystal turret
zenith wasp
#

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?

crystal turret
#

this command should be in the tick function this

zenith wasp
#

the one i put or the one u put?

crystal turret
#

My commands go into the pearls check function and yours in the tick function

zenith wasp
#

Ok thx

zenith wasp
#

I presume this is multi player compatavtavle