#I need help in making my first datapack(Crown Datapack)

1 messages · Page 1 of 1 (latest)

outer wasp
#

Just a tip. If you're using plugins too, I would rather use them to make the crowns instead of just the recipes.

vague vector
#

as i heard recipes is a nightmare in datapacks

outer wasp
#

not really

wooden stratus
#

I can agree they aren't that bad to deal with

outer wasp
vague vector
#

but i am a complete newbie into this

pliant parcel
#

Continuing from #💬┃general

#
{
  "criteria": {
    "requirement": {
      "trigger": "minecraft:tick"
    }
  },
  "rewards": {
    "function": "<your namespace>:give_crown"
  }
}
```This is your advancement
#

It will run the function once per player

vague vector
#

thnx nice community guys. you all are very helpfull

outer wasp
#

just use this file and change the pattern and materials

vague vector
pliant parcel
#

first_join.json can be whatever ig but this makes it easier to understand

#

then replace <your namespace> with your actual namespace

vague vector
pliant parcel
#

data/<your namespace>/advancements

vague vector
#

ohk

pliant parcel
#

<@&935561184806060073> help this guy plz i must leave

wooden stratus
#

after all that all you have to do is if they die then you reset that advancement you just made, it will run again once, and give them the item (crown 5)

vague vector
#

give me 15 mins imma finish my hw then imma hop on coding my super cool idea

vague vector
#

i wanted to ask if i have to put anything else in first_join.json

pliant parcel
#

Just that

#

Make sure to change where it says <your namespace>

vague vector
#

ok

#

@pliant parcel my namespace name is crown this is correct right

pliant parcel
#

Tip - File > Open Folder > select the datapack folder

#

That way everything works together

#

You also should install the datapack helper visual studio code extension

vague vector
#

now this is the advancement made. what is the next thing i have to do. nothing else is made except this advancement

vague vector
pliant parcel
vague vector
#

and a specific custom id to every tier crown

vague vector
#

@outer wasp can u help man?

#

anyone

pliant parcel
#

please dont ping random people

vague vector
pliant parcel
#

idk you can give them a crown or something

vague vector
#

so can u tell me the command for the tier 5 crown

pliant parcel
#

datapacks can't directly add custom items

#

you have to use an item that already exists

#

and do stuff with it

vague vector
#

it should be a gold crown which gives permanent resistance

#

using this crown base ill make other crowns

vague vector
#

and unbreakable

#

permanent resistance, prot x and unbreakable

pliant parcel
#

will you eventually want the custom helmet to have a different model/texture?

pliant parcel
#

if not (you can use a gold crown) then its easier

vague vector
#

but yeah if a custom texture would be there then

#

its going to be cool

#

ill use the normal crown texture

#

which i hv no worries

pliant parcel
#

then you can give the player a golden helmet with the Unbreakable NBT tag and a enchantment

vague vector
#

just can u tell what command i should give in give_Crown

pliant parcel
vague vector
vague vector
pliant parcel
vague vector
pliant parcel
vague vector
#

or tag or whatever

pliant parcel
#

no you just have to give a gold helmet

#

you can generate a /give command here

vague vector
#

ohk thnx

pliant parcel
vague vector
#

whom should i target?

pliant parcel
#

leave it as it is, just change the dropdown

vague vector
#

but if i have to add potione effects, i need to give it a custom id also right because then anyone wearing a gold helmet will get these effects

pliant parcel
#

so for that

#

give it a custom tag here

#

then you can get any item that has the Crown:5b tag

vague vector
#

ok

#

also one last thing what is NBT?

#

u kinda free right, like I am not annoying u right?

#

ig not

pliant parcel
#

NBT is basically data that the item (or mobs, blocks) can hold. you can add your own NBT (in this case Crown:5b), or you can use built-in tags (such as Unbreakable:1b will make it unbreakable)

pliant parcel
vague vector
#

i can add 2 NBT?

pliant parcel
#

add as many as you want

#

make sure it follows the format tag:value, tag:value, tag:value

vague vector
#

ohk

pliant parcel
#

you can do some other stuff with it but thats a bit more advanced

vague vector
#

ohk

vague vector
#

can i add changes to max health?

pliant parcel
#

yes

vague vector
#

like if we wear the tier 5 crown i wanna give 12 hearts

#

what i hv to do

pliant parcel
vague vector
#

ok

pliant parcel
#

multiply the amount of hearts by 2

#

because 1 would be half a heart

vague vector
#

ohk thnx man

#

ok i checked and i am getting extra hearts so yeah

#

now @pliant parcel how should i add custom potion effects

#

you are an angel from heaven @pliant parcel . and u have godlike skills

pliant parcel
#

in your tick mcfunction, just do this: hs execute as @a[nbt={Inventory:[{Slot:103b, id:"minecraft:golden_helmet",Count:1b,tag:{Crown:5b}}]}] run effect give @s resistance 1 1
basically: tell all players who have a helmet with a tag of Crown:5b in slot 103 (the head slot) to give the resistance effect

vague vector
#

ohk

#

and can i do something to uk schedule this after every 60 ticks?

#

so that it reduces lag

#

as many players gon play on the server

#

or will the perfomance impact will be negligible?

pliant parcel
#

it won't be very visible - but if you want to schedule it every 3 seconds then thats definitely possible

vague vector
#

now i got how to make other 4 crowns

#

and i will add the recipes from a plugin which i have called custom crafting

pliant parcel
#

load mcfunction: hs schedule function crown:3s 3s
data/crown/functions/3s.mcfunction:hs execute as @a[nbt={Inventory:[{Slot:103b, id:"minecraft:golden_helmet",Count:1b,tag:{Crown:5b}}]}] run effect give @s resistance 4 1 schedule function crown:3s 3s

vague vector
#

so man i kinda finished my very own datapack thnx @pliant parcel

pliant parcel
#

epic

#

gg

vague vector
pliant parcel
vague vector
#

and i kinda don't have to put anything in tick.mcfunction

pliant parcel
#

for another crown just add one more command in 3s function:```hs
execute as @a[nbt={Inventory:[{Slot:103b, id:"minecraft:golden_helmet",Count:1b,tag:{Crown:5b}}]}] run effect give @s resistance 4 1

execute as @a[nbt={Inventory:[{Slot:103b, id:"minecraft:golden_helmet",Count:1b,tag:{Crown:4b}}]}] run effect give @s . . .

schedule function crown:3s 3s```

pliant parcel
#

yea

#

tick function can be empty

#

since you're not using it

vague vector
#

ohk yes man ill kill it

#

ily silabear

#

ly very much

pliant parcel
#

<3 glad you got the datapack working!

vague vector
#

yes

#

🙂

#

one last thing xD
like i wanna make a function which i manually run to get the other tier crowns. so where i have to put other 4 crowns command

#

@pliant parcel

pliant parcel
#

you can just create a function called give_all_crowns.mcfunction and in that function just put all the give commands (for example, the one in give_crown.mcfunction)

vague vector
pliant parcel
#

not at all

pliant parcel
#

as long as it has Crown:5b

#

and is a golden helmet

vague vector
#

i am not getting resistance

#

@pliant parcel

#

less leave this optimization. imma do it normally in tick.mcfunction

pliant parcel
#

sure

#

its not that big of a difference anyway

vague vector
#

i aint getting the effect still

pliant parcel
#

hmm

#

whats the give command for the helmet?

vague vector
#

wait

vague vector
# pliant parcel whats the give command for the helmet?

give @p[limit=1] golden_helmet{display:{Name:'{"text":"Tier 5 Crown","bold":true,"italic":true}',Lore:['{"text":"You get permanent Resistance from this","italic":true}']},Unbreakable:1b,Crown:5b,Enchantments:[{id:"minecraft:protection",lvl:10s}],AttributeModifiers:[{AttributeName:"generic.max_health",Name:"generic.max_health",Amount:15,Operation:0,UUID:[I;-676575865,-1053276835,-1923275262,-472214491],Slot:"head"}]} 1

pliant parcel
#

ok can you wear the helmet and run /data get entity @s Inventory[{Slot:103b}] to see if its in the wrong place

#

then like

#

screenshot the result

vague vector
#

ok

pliant parcel
#

oh

#

did you save the files

vague vector
#

can you give me a give command

pliant parcel
#

and run /reload

vague vector
#

yes

pliant parcel
vague vector
#

everything saved and reloaded 3-4 times

pliant parcel
#

execute as @a[nbt={Inventory:[{Slot:103b, id:"minecraft:golden_helmet",Count:1b,tag:{Crown:5b}}]}] run effect give @s resistance 4 1 run this in chat manually and see if it works

vague vector
#

i can remove these attributes though

pliant parcel
#

they dont cause a problem

vague vector
#

i am getting now

#

the effect

pliant parcel
#

okay okay

#

so the problem is in tick.json and load.json (because the command works, but its not getting run by the datapack)

#

could you send whats in those files plz

vague vector
#

ok sure

#

{
"values": [
"crown:load"
]
}

thhis is load.json

pliant parcel
#

and thats saved where

vague vector
#

{
"values": [
"crown:loop"
]
}

this is tick.json

vague vector
#

inside functions

pliant parcel
vague vector
#

its tick.mcfunction only

pliant parcel
#

change it to loop.mcfunction

vague vector
#

ig very deep issue happened lol

pliant parcel
#

because the tick.json is looking for loop.mcfunction

vague vector
pliant parcel
#

waht

#

can you zip and send your datapack

#

lemme see

vague vector
#

yes

pliant parcel
#

i see

#

these two functions should be in the functions folder

vague vector
#

ohhk

pliant parcel
#

all functions gotta be in the functions folder :P

vague vector
#

just a minor mistake caused so much nuisance xD

pliant parcel
#

it happens

vague vector
pliant parcel
#

remove the second 1

#

i always forget how that works :P

vague vector
#

like?

#

how to remove second 1

pliant parcel
#

execute as @a[nbt={Inventory:[{Slot:103b, id:"minecraft:golden_helmet",Count:1b,tag:{Crown:5b}}]}] run effect give @s resistance 1 1

execute as @a[nbt={Inventory:[{Slot:103b, id:"minecraft:golden_helmet",Count:1b,tag:{Crown:5b}}]}] run effect give @s resistance 1 ```
vague vector
#

ohk niceee

pliant parcel
#

its the backspace button

vague vector
#

thnx baby love you @pliant parcel

pliant parcel
#

:P

vague vector
#

everything is ggs now

pliant parcel
#

epic

vague vector
#

imma sleep for now and finish my project tommorow

pliant parcel
#

gn

vague vector
#

gn

#

i was coding this at 1:54 a.m. my place

pliant parcel
#

oh wow

#

thats late

vague vector
#

but finally its done

#

like i learnt a lot

pliant parcel
#

yeah

#

as coding stuff goes, this is pretty simple

#

but it teaches you a lot

vague vector
#

imma do some more projects like this and soon be the master of coding

pliant parcel
#

epic

vague vector
#

and beat you also and one day teach u lmao

#

but that day is kinda far

#

for now

pliant parcel
#

that would be great to see

#

with enough practise

#

you'll get there ;)

vague vector
#

you do coding as a job or you are a student?

pliant parcel
#

I'm a student but I taught myself everything I know about coding

vague vector
#

also one more thing

#

should i make a different namespace for the other crowns

pliant parcel
#

Nah

vague vector
#

that will look kinda organized

#

or will it affect the datapack

pliant parcel
#

It won't affect the datapack that much but there isn't really a need. Plus, you have give_all_crowns function and that would not make as much sense if there were multiple namespaces

#

99% of datapacks use one namespace (and minecraft namespace)

vague vector
#

yeh true

pliant parcel
#

But if you want, go ahead

#

I gtg now too

vague vector
#

also one more thing

pliant parcel
#

sure

vague vector
#

ok sure

#

we gon talk tommorow

pliant parcel
#

okie

#

adios

vague vector
#

gn

vague vector
vague vector
#

@pliant parcel I made everything

#

all crowns

#

and also i took help from my friend and made a mechanism in which whenever a player dies, no matter what tier his crown is at, he recieves Tier 5 crown

vague vector
#

@here I finished the datapack @pliant parcel

low trench
vague vector
#

@pliant parcel

#

thnx man

pliant parcel
#

I subbed

vague vector
#

i subbed u