#Creating a simple ability

1 messages · Page 1 of 1 (latest)

wheat dagger
#

My goal is to create a simple ability that summons spikes from the ground that move up, does damage to hit enemies and then "dies".
My issue is, when I try to summon the block_display, it spawns not where I want at all, I want it to be a few blocks in front of the player at feet level, but it's spawning at various Y level
I tried that

$execute at @s anchored eyes align xyz run summon minecraft:block_display ^ ^-0.18 ^1 {block_state:{Name:"minecraft:pointed_dripstone"},transformation:{translation:[-0.5f,-0.5f,-0.5f],scale:[2.0f,4.0f,2.0f],left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f]},Tags:["spike$(ID)"]}

and that

$execute at @s anchored feet run summon marker ^ ^ ^2 {Tags:["spike_a","spike$(ID)"]}
$execute at @e[tag=spike_a,tag=spike$(ID)] align xyz run summon minecraft:block_display ~ ~ ~ {block_state:{Name:"minecraft:pointed_dripstone"},transformation:{translation:[-0.5f,-0.5f,-0.5f],scale:[2.0f,4.0f,2.0f],left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f]},Tags:["spike$(ID)"]}
supple mangoBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 If nobody has answered you by <t:1750213243:t>, feel free to use the Summon Helpers button to ping our helper team.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

#
⚠️ You already have a question open!

Don't forget to close or resolve your old questions once you're done with them. It makes our lives much easier! :D

Open question: #1384201760369016954

opal moat
#

The issue is that you are using ^ ^ ^ coordinates instead of ~ ~ ~ ones. The tildes are relative xyz position while the carrots are based on your facing angle

wheat dagger
#

yeah but if I use ~ ~ ~, how can i make it spawn 1 or 2 blocks in front of the player ?

opal moat
#

You could do execute positioned ^ ^ ^2 run summon ... ~~~

wheat dagger
#

Oh I didn't know

#

I'll try that tomorrow it's 4am

#

Tysm !

wheat dagger
#
$execute at @s positioned ^ ^ ^2 align xyz run summon minecraft:block_display ~ ~ ~ {block_state:{Name:"minecraft:pointed_dripstone"},transformation:{translation:[-0.5f,-0.5f,-0.5f],scale:[2.0f,4.0f,2.0f],left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f]},Tags:["spike$(ID)"]}

that still doesn't work, if I look at the sky, it will spawn them over the ground, and if I look at the ground, it will spawn them underground ?

#
$execute at @s positioned ^ ^ ^2 anchored feet run summon marker ~ ~ ~ {Tags:["spike_a","spike$(ID)"]}
$execute at @e[tag=spike_a,tag=spike$(ID)] align xyz run summon minecraft:block_display ~ ~ ~ {block_state:{Name:"minecraft:pointed_dripstone"},transformation:{translation:[-0.5f,-0.5f,-0.5f],scale:[2.0f,4.0f,2.0f],left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f]},Tags:["spike$(ID)"]}

same thing when I use markers

royal remnant
#

do you want them to not spawn, or to spawn on your nearest valid location?

#

because the latter is rather complicated, the former is something you can do.

wheat dagger
#

I want them to spawn in front of the player's feet, no matter if I look at the sky or at the ground

#

and even if there are blocks

royal remnant
#

Alright, I would advice against the current macro tag, tags are not meant for what you are doing here (we have custom_data)

#

as for summoning in front of the player... yeah that might be rough.

wheat dagger
#

because it seemed to work fine for me

#

and what are tags meant for then ?

royal remnant
#

grouping entities for scoreboard and team related things

#

it is not that you can't use tags with macro contents, I just don't think it is what I would do. using custom_data could very well allow you to not need a macro.

But first the summon part

#

you want it anchored at their feet, rotated ~ 0

#

then positioned

#

then align

#

rotated ~ 0 means keep the north/south/west/east rotation but remove vertical component.

wheat dagger
#

oh ok I get it

#

you impose a rotation of a 0 degree angle right ?

royal remnant
#

0 degree pitch, yaw must remains else we always look north (default yaw of 0)

wheat dagger
#

ok I get it !

#

tysm !

wheat dagger
#

because my goal was to assign an ID to every player

#

and use this ID for tags, to differenciate abilities used by different players

royal remnant
#

it is possible, but you could also have your own custom_data component that you can fill and use as you see fit

#

a tag is always a string

#

and it is usually to group entities/players together

wheat dagger
#

and is there a reason why custom_data are used more often than tags for this ?

royal remnant
#

main reason is flexibility

wheat dagger
royal remnant
#

you can put in any json, allowing you to simply copy values from one entity to the new entity (for instance the UUID)

then only once the data is needed will you need a macro if the data type calls for it.

#

but in some cases you don't even need a macro

wheat dagger
#

how could I do what I did with macros without a macro ?

royal remnant
#

not everything would be without a macro

wheat dagger
#

you would assign the custom_data using a macro ?

royal remnant
#

the assigning of data can be done without a macro, that is the beauty of it

#

using it requires a macro in a few cases

wheat dagger
royal remnant
#

just a lot of data modify commands

wheat dagger
#

mmh

royal remnant
#
data modify entity @e[type=marker,tag=lodestone_teleport.TeleportHelper,sort=nearest,limit=1] data.lodestone_teleport:target.playerid set from entity @s UUID
data modify entity @e[type=marker,tag=lodestone_teleport.TeleportHelper,sort=nearest,limit=1] data.lodestone_teleport:target.yaw set from entity @s Rotation[0]
data modify entity @e[type=marker,tag=lodestone_teleport.TeleportHelper,sort=nearest,limit=1] data.lodestone_teleport:target.pitch set from entity @s Rotation[1]
data modify entity @e[type=marker,tag=lodestone_teleport.TeleportHelper,sort=nearest,limit=1] data.lodestone_teleport:target.dimension set from entity @s SelectedItem.components.minecraft:lodestone_tracker.target.dimension
execute store result entity @e[type=marker,tag=lodestone_teleport.TeleportHelper,sort=nearest,limit=1] data.lodestone_teleport:target.x double 1 run data get entity @s SelectedItem.components.minecraft:lodestone_tracker.target.pos[0]
execute store result entity @e[type=marker,tag=lodestone_teleport.TeleportHelper,sort=nearest,limit=1] data.lodestone_teleport:target.y double 1 run data get entity @s SelectedItem.components.minecraft:lodestone_tracker.target.pos[1]
execute store result entity @e[type=marker,tag=lodestone_teleport.TeleportHelper,sort=nearest,limit=1] data.lodestone_teleport:target.z double 1 run data get entity @s SelectedItem.components.minecraft:lodestone_tracker.target.pos[2]```

example, this marker will take the UUID and lodestone compass data in  a custom object that I can then use when calling my macro function that reads this data.
wheat dagger
#

I'll have to look more deeply into the /data command, I saw a youtuber named infernal device use it to be able to create as many custom items, functionnality, etc as he wanted very easily and being able to configure them independently

wheat dagger
#

I genuinely don't understand what's going on there

#

what's target.playerid ?

royal remnant
#

each line boils down to 2 sections:
data modify entity <single_entity_selector> data.<your_object_name> set
and
from entity <single_entity_selector> <nbt_path>
or
value 1b,value 42,value "Hello World"

#

in the above case I have decided the following to be my custom_data object:
name: lodestone_teleport:target

"x": 0,
"y": 0,
"z": 0,
"id": <some_entity_UUID>,
"dimension": "minecraft:overworld",
"pitch": 0.0,
"yaw": 0.0
}```

The above has some default values but it is basically what I fill to pass on into a macro that can resolve these values into commands that do what I want.
wheat dagger
#

oohhhhh I get it

royal remnant
#

then when i called the macro with the function some_macro with entity @n[type=marker] lodestone_teleport:target it will use the customdata of the nearest marker to perform my macro, which can do all sorts of things.

wheat dagger
#

ok I get it

#

couldn't the use of the nearest marker cause some weird edge cases ?

royal remnant
#

in the macro I can then use all the values I put in the custom object

#

in my particular case the marker is summoned at the player it belongs to and I also add a tag to it just in case, the tag is a fixed one however as I am only interested in markers of my own datapack.

wheat dagger
#

that's smart

#

what are you using this for ?

#

(I mean, what kind of datapack are you making with this tech rn ?)

royal remnant
#

I have used this only once

#

datapack that allows you to teleport to the target lodestones by sneaking while holding the compass in your mainhand

#

it performs location checks, chunk loads, dimension changes etc.

wheat dagger
#

ok I see

#

also, I have another question

#

about the summon command

#
$execute at @s anchored feet rotated ~ 0 positioned ^ ^-1.8 ^1 align xyz run summon minecraft:block_display ~ ~ ~ {block_state:{Name:"minecraft:pointed_dripstone"},transformation:{translation:[-0.5f,-0.5f,-0.5f],scale:[2.0f,4.0f,2.0f],left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f]},Tags:["spike$(ID)"]}
$execute at @s anchored feet rotated ~ 0 positioned ^ ^-1.8 ^2 align xyz run summon minecraft:block_display ~ ~ ~ {block_state:{Name:"minecraft:pointed_dripstone"},transformation:{translation:[-0.5f,-0.5f,-0.5f],scale:[2.0f,4.0f,2.0f],left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f]},Tags:["spike$(ID)"]}
$execute at @s anchored feet rotated ~ 0 positioned ^ ^-1.8 ^3 align xyz run summon minecraft:block_display ~ ~ ~ {block_state:{Name:"minecraft:pointed_dripstone"},transformation:{translation:[-0.5f,-0.5f,-0.5f],scale:[2.0f,4.0f,2.0f],left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f]},Tags:["spike$(ID)"]}
$execute at @s anchored feet rotated ~ 0 positioned ^ ^-1.8 ^4 align xyz run summon minecraft:block_display ~ ~ ~ {block_state:{Name:"minecraft:pointed_dripstone"},transformation:{translation:[-0.5f,-0.5f,-0.5f],scale:[2.0f,4.0f,2.0f],left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f]},Tags:["spike$(ID)"]}

I do that

#

(it's just 4 times the same command)

#

but I have some weird things happening depending on the direction i'm looking at

#

The one of the left (only summons 3 block display ?) when I'm looking with a 45° angle in the x or y direction

#

the 2nd one works perfectly, it's when I'm looking in the direction of the x or y axis

#

and the last one, when it's a more random angle

royal remnant
#

you want them to stay in a nice line?

wheat dagger
#

yeah

royal remnant
#

or keep to the blocks

wheat dagger
#

a nice line

wheat dagger
royal remnant
#

change it to align y instead of xyz

wheat dagger
#

I don't really understand the align xyz here tbh

#

does it align with the xyz of ~ ~ ~

#

or of ^^^?

royal remnant
#

no

#

it is applied last

#

^ ^ ^2 = go 2 blocks in the direction where I am looking (with rotation fix the pitch is already gone)

then align says: give me the block coordinates of this location

#

which for y-axis is definitely what you want

#

but for x and z axis it is not

#

align xyz changes 0.5,0.3,1.2 to 0,0,1

#

align y changes 0.5,0.3,1.2 to 0.5,0,1.2

#

align xyz changes 0.5,0.3,1.2 to 0,0.3,1

#

if that makes sense?

#

you could also perform the align before the positioned argument

#

that way the ^ ^ ^ is the block you stand on but the other entities simply follow the direction you are looking at

#

although technically align y is all you need

wheat dagger
royal remnant
#

yeah exactly

wheat dagger
#

and when i did align x,y,z, I forced it to be align to a block in the x and z axis, hence, not always making a straight line

#

great explanations, thx you so much !

royal remnant
#

no problem, if you get stuck on anything else feel free to ask.

wheat dagger
#

yeah thx you :)

wheat dagger
#

right after the summoning of the block display, I used that

#
$execute as @e[tag=spike$(ID)] run data merge entity @s {start_interpolation:0,interpolation_duration:10,transformation:{translation:[-0.5f,2f,-0.5f]}}

and for some reasons, it doesn't work half of the time ?

#

any idea of the reasons behind it ?

#

use_spike function

#revoke advancement
advancement revoke @s only abilities:use_spike

#summon dripstones
execute store result storage ability:id ID int 1 run scoreboard players get @s ID
function abilities:spikes/use_spike_macro with storage ability:id
#

use_spike_macro

#summon spikes block display
$execute at @s anchored feet rotated ~ 0 positioned ^ ^-1.8 ^1 align y run summon minecraft:block_display ~ ~ ~ {block_state:{Name:"minecraft:pointed_dripstone"},transformation:{translation:[-0.5f,-0.5f,-0.5f],scale:[2.0f,4.0f,2.0f],left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f]},Tags:["spike$(ID)"]}
$execute at @s anchored feet rotated ~ 0 positioned ^ ^-1.8 ^2 align y run summon minecraft:block_display ~ ~ ~ {block_state:{Name:"minecraft:pointed_dripstone"},transformation:{translation:[-0.5f,-0.5f,-0.5f],scale:[2.0f,4.0f,2.0f],left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f]},Tags:["spike$(ID)"]}
$execute at @s anchored feet rotated ~ 0 positioned ^ ^-1.8 ^3 align y run summon minecraft:block_display ~ ~ ~ {block_state:{Name:"minecraft:pointed_dripstone"},transformation:{translation:[-0.5f,-0.5f,-0.5f],scale:[2.0f,4.0f,2.0f],left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f]},Tags:["spike$(ID)"]}
$execute at @s anchored feet rotated ~ 0 positioned ^ ^-1.8 ^4 align y run summon minecraft:block_display ~ ~ ~ {block_state:{Name:"minecraft:pointed_dripstone"},transformation:{translation:[-0.5f,-0.5f,-0.5f],scale:[2.0f,4.0f,2.0f],left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f]},Tags:["spike$(ID)"]}

#move the block display 1 block vertically
$execute as @e[tag=spike$(ID)] run data merge entity @s {start_interpolation:0,interpolation_duration:10,transformation:{translation:[-0.5f,2f,-0.5f]}}

schedule function abilities:spikes/kill_spike 0.5s append
#

and the kill spike is just a /kill for the spikes with this tag

royal remnant
#

uhhhh I am not an expert with how data merge works, I forgot about the exact nuances of it

wheat dagger
#

it's fine x)

#

I'm confused tho, why does it work half of the time

flat mulch
#

From the video it seems like it only doesn't work if you spawn to spikes too fast in succession but not if you wait until they are fully gone.

#

How does the kill function work?

wheat dagger
#

sorry for the ping, it's bad habits

flat mulch
#

it doesn't bother me

wheat dagger
#

good thing, it bothers some people x)

flat mulch
#

another question, why do you use macro generated tags instead of scores?

wheat dagger
#

wdym ?

flat mulch
#

you build the tag names at runtime

wheat dagger
#

what I do, is I have a "tick" advancement that adds 1 to a fake player then gives this value to the player

#

then use it in a macro

wheat dagger
flat mulch
#

that seems like using scores but with extra unneccesary steps

wheat dagger
flat mulch
#

you can just give every spike the spike tag and set their id score to the current global id counter when you spawn them.

#

with macros this can cause some serious lag if you use it too frequently

wheat dagger
#

I'll change that

#

and see if it fix the problem

#

even if it's not related

#

you never know x)

flat mulch
#

¯_(ツ)_/¯

#

maybe the macro does cause this

wheat dagger
#

yeah, and you are right, if I wait long enough, the issue doesn't happen

#

but I have no idea why it happens in the first place tbh

wheat dagger
#

if I use the spell and right after someone else uses it

#

wouldn't the spikse and everything get the score of the 2nd player ?

flat mulch
#

no, even if two players trigger the ability in the same tick, they get processed sequentially

wheat dagger
#

and be treated as the 2nd player's spell

flat mulch
#

if you do it right there is no interference

wheat dagger
#

I know, but like, if I do
scoreboard players operation @e[tag=spike] ID = @s ID

#

they will all get my tag, but if right after that, the 2nd player use the ability, it will run the same command again

flat mulch
#

don't do that

wheat dagger
#

and they will all get his ID ?

flat mulch
#

when spawning new entities, always add an additional new tag that gets immediately removed at the end of the setup function. In your setup function you can then always target the entities with the new tag without worrying about accidentially targeting the wrong entities.

#

(and use type arguments to reduce the amount of entities the command has to search through)

wheat dagger
#

so I summon the entity with a spike tag and a temp tag
give it the score to entities with the temp tag
remove the tag

#

if so, it makes sense to me

#

else, I didn't understand anything

wheat dagger
flat mulch
#

Example with pseudo code:
some advancement triggering the first function

summon function

summon entity ~ ~ ~1 {Tags:["spike","new"]}
summon entity ~ ~ ~2 {Tags:["spike","new"]}
summon entity ~ ~ ~3 {Tags:["spike","new"]}
function namespace:setup

setup function

scoreboard add %Server gobal_id add 1
execute as @e[type=entity,tag=spike,tag=new] run scoreboard operation @s global_id = %Server global_id

# other setup stuff
...
...
...

tag @e[type=entity,tag=spike,tag=new] remove new
wheat dagger
#

Thx you

#

I understand it perfectly I think

#

great explanations

flat mulch
#

or you can run the setup functiuon as ever new entity and only use @s in there for slight better performance
Example with pseudo code:
some advancement triggering the first function

summon function

summon entity ~ ~ ~1 {Tags:["spike","new"]}
summon entity ~ ~ ~2 {Tags:["spike","new"]}
summon entity ~ ~ ~3 {Tags:["spike","new"]}
scoreboard add %Server gobal_id add 1
execute as @e[type=entity,tag=spike,tag=new] function namespace:setup

setup function

scoreboard operation @s global_id = %Server global_id

# other setup stuff
...
...
...

tag @s remove new
wheat dagger
#

mmh

#

if I run a function as every entity with a certain type and tag

#

I get better perfomance than if I run the function for everyone and put the selectors only in the different commands inside the function ?

flat mulch
#

The thing is If you use @e[...] every time, it hs to search through all existing entities and find the ones you target every time.
If you run one function as all those entities it has to search for them once and and then only needs to reference those found entities (@s doesn't do entitiy searches because it's the same entity that is already targetted)

wheat dagger
#

Yeah that makes sense

#

i'll change the code with the suggestions you made

#

tysm :)

flat mulch
#

np

wheat dagger
#

Is there a way to have cooldowns that are independant from eachothers without using 95555 scoreboards ?

#

without using 500 macros, because the only way I could think of is creating multiple fake players using the player's ID I defined

#

and it would be 1 macro per cooldown

opal moat
#

One scoreboard per item is the usual strategy

#

If you want it to reload only while you hold it you could edit nbt on the item

wheat dagger
#

in term of optimization, which one would be the most performant ?

#

macros or 500 scoreboards ?

opal moat
#

1 hardcoded scoreboard per item is definitely faster

flat mulch
#

you also don't need any macros

flat mulch
wheat dagger
#

Ofc I won't need 95555 different scoreboards x)

flat mulch
#

You could combine the cooldowns so it also blocks other abillities if you use one.

#

but otherwise having one for each si completely normal

wheat dagger
#

I really want them to be independant, I made a system today that is similar to wynncraft's ability system

flat mulch
#

Bigger packs of mine had nearly 100 scoreboards or more

wheat dagger
#

Damn

flat mulch
#

they are like variables in code and you use those for everything.

wheat dagger
#

I really wish macros didn't use that much perf

#

I would use them for everything

#

They are so easy to use

flat mulch
#

the main problem why they cost so much is because the interpreter has to reparse the whole file,

wheat dagger
#

And also, the code is clearer to see for me with macros

flat mulch
#

they don't just pass parameters but are a whole string builder

wheat dagger
flat mulch
#

Just know that it is much more work to parse a file than to pass arguments to a function

wheat dagger
#

Why didn't they just make it so they just pass the parameters ?

flat mulch
#

in that case you wouldn't be able to make stuff like this:

#
function namespace:macro {one:"cute", two:"r", three:"unktio", four:"other_function"}`
$exe$(one) as @a $(two)un f$(three)n namespace:$(four)
#

this is a stupid example but it gives you much more flexibillity

wheat dagger
#

It makes sense

flat mulch
#

you can basically fill in any part with anything instead of pre defined slots that expect specific values

wheat dagger
#

With this example, you made me understand something I couldn't understand too about the function command x)

#

Ty for that

#

It makes sense to me, ty for the explanation !

flat mulch
#

👍

wheat dagger
#

It's 3am, english is becoming increasingly hard to use

#

x)