#trying to take damage in day time

1 messages · Page 1 of 1 (latest)

solemn gardenBOT
winter agate
dense flumeBOT
half gyro
# winter agate

you can use a # in front of text to make it a comment (meaning that it will not register toward code and crash your function)

winter agate
#

where would i go about coding it myself im really bad

half gyro
#

the best way to tackle a bigger problem is to split into smaller easier to fix problems. You can split your problem into 3 parts:

  1. You'll need a way to check whether it is day or not. This can be easily done using a predicate. There is even a handy generator for it https://misode.github.io/predicate/
  2. At night, you want to double the hearts, this can be done using an attribute modifier called max_health which can be applied using the command /attribute
  3. When it's day you want to apply damage with a slight delay in between the hits, this can be done using a scoreboard timer to time when to apply damage and the /damage command to apply damage
#

If you need more help with the seporate parts feel free to ask. Since you've never made a datapack before I recommend first checking out our beginner's guide to get a little more familiar with datapacking

winter agate
#

im on the website now

dense flumeBOT
winter agate
#

what code should i delete

#

im ngl ai made it 😭

half gyro
winter agate
#

i fortunately know that now 😭

#

ive got it to raining : true

half gyro
#

you'll get through it dw even if it feels really oververwelming

half gyro
winter agate
#

im watching a tut on predicates

half gyro
#

hmm ok if it works for you then that's fine

winter agate
#

i dont get what i add after raining : true

#

i would imagine its a string of commands to take damage

#

but im really bad at coding

half gyro
half gyro
# winter agate i would imagine its a string of commands to take damage

you won't code the commands directly inside the predicate, instead you'll have to make a ticking function (a function that runs every tick so 20 times a second) to check whether your predicate is true or not which would look like this execute if predicate <your_namespace>:<your_predicate> run ...

winter agate
#

so i put the predicate in the tick function?

half gyro
#

no you put the predicate in a .json file located at/data/<your_namespace>/predicate/

dense flumeBOT
#
# Minecraft Datapack folder structure
# Last updated: Jul 1, 2024

.
├── pack.mcmeta
├── pack.png
└── data
    └── <namespace>
        ├── advancement
        ├── enchantment
        ├── enchantment_provider
        ├── function
        ├── item_modifier
        ├── loot_table
        ├── predicate
        ├── recipe
        ├── structure
        ├── chat_type
        ├── damage_type
        ├── trim_material
        ├── trim_pattern
        ├── jukebox_song
        ├── painting_variant
        ├── wolf_variant
        ├── tags
        |   ├── banner_pattern
        │   ├── block
        │   ├── cat_variant
        │   ├── damage_type
        │   ├── entity_type
        │   ├── fluid
        │   ├── function
        │   ├── game_event
        │   ├── instrument
        │   ├── item
        │   ├── painting_variant
        │   ├── point_of_interest_type
        │   └── worldgen
        ├── dimension
        ├── dimension_type
        └── worldgen
            ├── biome
            ├── configured_carver
            ├── configured_feature
            ├── density_function
            ├── noise
            ├── noise_settings
            ├── placed_feature
            ├── processor_list
            ├── structure
            ├── structure_set
            ├── template_pool
            ├── world_preset
            └── flat_level_generator_preset
half gyro
#

here is the overall folder structure of a datapakc

#

you only need the folders that will actually contain a file

#

the namespace is a folder with a custom lowercase name to differenciate datapacks from eachother

winter agate
#

i downloaded a similar data pack

#

to compare

#

i still dont know what im looking at 😭

#

also it wont let me change my namespadew

#

namespace

#

it just loads then errors

half gyro
#

for what minecraft version?

winter agate
#

nvm ive done it

#

1.21.8

#

mine is

winter agate
half gyro
winter agate
#

i think it is

#

i think theres an easier way to go about it

#

from what i know i need something to tell the pack the time and one to execute the damage

half gyro
#

nope this is the easiest way. The predicate is used for the datapack to tell the time and the ticking function is used to execute the damage

#

I'll make some steps for you to follow:
-# you'll have to wait a bit because I'm not the fastest typer xD

winter agate
#

your very helpfu

half gyro
#
  1. Make a basic datapack structure with a valid pack.mcmeta (you can look if you've done it correctly by running /reload and then do /datapack list to see if your datapack is loaded correclty)

Let's start by making the ticking function
2. make the following folder structure: data/minecraft/tags/function/tick.json
3. in tick.json you'll add your function (which we haven't made yet) to the minecraft tick tree and tell minecraft to run it every tick. This can be done by adding your function to the values in the tag. It will look something like this

{
  "values": [
    "<your_namespace>:<your_function_name_it's_best_to_call_this_tick>"
  ]
}```
4. now create a file in ``data/<your_namespace>/function/<your_function_name_it's_best_to_call_this_tick>.mcfunction``
5. in that file you can temporarly put a ``/say Hello World!`` command to check if you did everything correctly
6. run ``/reload`` ingame and see if you get ``Hello World`` spammed in your chat
twin canyonBOT
#

Now we can create the predicate
7. use the website I've sent earlier to generate a file that checks whether it is day
8. create a file in data/<your_namespace>/predicate/<your_predicate_name>.json and put the output of the website in there
9. now you can add your time check condition to your say command in your tick function to test your predicate this would look something like ```ansi
execute if predicate <your_namespace>:<your_predicate_name> run say hello_world

half gyro
#

uuugh

#

the bot did weird

#

it sould look like this: execute if predicate <your_namespace>:<your_prediacte_name> run say Hello World

winter agate
#

ive always used the basic tick and load code

half gyro
#

ok so that already works?

winter agate
#

theres nothing in them atm

#

i made the predicate file

#

do i just put the day time

half gyro
#

ok nice put a say command in there to double check that it's working correcly please (this will save a lot of time)

winter agate
#

i have the folder in my data pack folder but will it work if its not zipped?

half gyro
# winter agate

so what basically happens is that the time of the world gets divided by period and then the remainder is checked against values you want to have the period set to 24000 since that's the number of ticks in a minecraft day then you want to check if the value is between 0 and 12000 to check for the first half of the daylight cycle (which is when it's day)

winter agate
#

okay period i understand not so much the value

#

your a phenomal teacher i have watched like 20 vids on data packs but learnt more from you then all of them 😭

winter agate
#

are you proud of me

#

IT WORKS

#

MY FIRST SUCCESFUL DATA PACK

#

im gonna chase this high all day

daring lintel
winter agate
#

same 😭

#

im so fricking happy tho

#

ive never been able to make a data pack work

#

now i have the freedom of learning stuff

#

look i did it myself

#

it took me 30 mins but

#

i did it myself

#

how do i get it to be a colour

daring lintel
#

REALLY useful for datapacking

#

I would recommend learning it

#

(Not that difficult)

winter agate
#

im cooking bro

#

i feel like i invented fire

daring lintel
mild mesa
daring lintel
winter agate
#

can someone help me add the rest of the thing

#

im trying to make it damage me in the sun

daring lintel
#

/damage

winter agate
#

this is as far as i got

#

idk what value does

#

if somoene can explain what value does i can try figure stuff out on my own

daring lintel
winter agate
#

yea but i dont understand what value does

#

and what i need it to be for my data pack

daring lintel
#

Actually i dont understand it too
...
Sry

winter agate
#

lmao dw

#

you helped me anyway with the other thing

daring lintel
#

I looked at the wiki and i think i know now

#
{
  "condition": "minecraft:time_check",
  "value": {
    "min": 0,
    "max": 12000
  },
  "period": 24000
}

checks if its day

winter agate
daring lintel
#

Whats the error?

winter agate
#

got it

#

i had it under other code

#

i shouldve elaborated i dont want to take damage if im under shade and stuff like a zombie

daring lintel
#

Ohh
Then add it to the predicate

winter agate
#

predicates

#

my enemy

#

add it to the predicate file?

#

this is the predicate file

#

ohhhhhhhhhhhhh

#

i get u now

daring lintel
winter agate
#

im going through the minecraft zombies code

daring lintel
#

Oh

#

Don't think this helps
But mb

winter agate
winter agate
daring lintel
#

Nice
Ill have to leave
Have fun

winter agate
#

thx

#

okay so now

#

i need it to damage me if these are not true

#

@half gyro my friend

#

ive made progress

#

very little progress

winter agate
#

i think i did smth wrong

#

scoreboard players tag @e[type=minecraft:zombie,tag=burn] remove burn
scoreboard players tag @e[type=minecraft:zombie] add burn {Fire:0s,IsBaby:1b}
scoreboard players tag @e[type=minecraft:zombie] add burn {Fire:-1s,IsBaby:1b}
scoreboard players set @e[tag=loopHandle] catchFire 0
stats entity @e[tag=loopHandle] set QueryResult @s catchFire
execute @e[tag=loopHandle] ~ ~ ~ time query daytime
execute @e[tag=loopHandle,score_catchFire_min=12541] ~ ~ ~ scoreboard players tag @e[tag=burn] remove burn
scoreboard players set @e[tag=burn] catchFire 0
stats entity @e[tag=burn] set SuccessCount @s catchFire
execute @e[tag=burn] ~ ~ ~ testforblocks ~ ~1.5 ~ ~ 254 ~ -211 ~1.5 211 masked
entitydata @e[tag=burn,score_catchFire_min=1] {Fire:200s}

#

i found that online

half gyro
half gyro
# winter agate scoreboard players tag @e[type=minecraft:zombie,tag=burn] remove burn scoreboard...

please just don't use AI... stats entity @e[tag=loopHandle] set QueryResult @s catchFire just doesn't / didn't exist at all
You won't learn anything if you're using AI to do everything for you. Instead use AI as a pocket teacher while not copying all the code... (tho AI can't even help with being a datapack teacher)
Using AI correctly sure is a skill but once you do you can learn to code A LOT faster

#

Anyways what have you done already? and where are you stuck?

winter agate
#

😢

half gyro
#

it doesn't really matter if it's wrong anyways

winter agate
#

yea mb mb