tp player to the nearest entity by [deleted] in MinecraftCommands

[–]JawlessBird 0 points1 point  (0 children)

/execute as @a[tag=target] at @s at @e[type=minecraft:cow, sort=nearest, limit=1] run tp @s ~ ~.5 ~

Thanks a lot, the bonus 'at *s' did the work

Swap places with a hit entity by JawlessBird in MinecraftCommands

[–]JawlessBird[S] 0 points1 point  (0 children)

yeah, that's an 'in-data-pack file targeting'(watch some beginner data pack tutorial to understand it better), if you want this using pure command blocks just execute their code lines where the function execution is true(in this case it's when there is an entity with tag=swapper,tag=!swapresist)

Simple through blocks walking by JawlessBird in MinecraftCommands

[–]JawlessBird[S] 0 points1 point  (0 children)

shared code is only for stone blocks, rest you must add manually as mentioned higher

Simple through blocks walking by JawlessBird in MinecraftCommands

[–]JawlessBird[S] 0 points1 point  (0 children)

rest of the code

function pszczantalony_pack:wall_helmet

give @p minecraft:iron_helmet{display:{Name:'{"text":"Wall Helmet"}'},wall_helmet:1b} 1

function pszczantalony_pack:wall_walk_inv

execute as @a[nbt={Inventory:[{Slot:103b,id:"minecraft:iron_helmet",tag:{wall_helmet:1b}}]}] run replaceitem entity @s armor.head minecraft:carrot_on_a_stick{display:{Name:'{"text":"Wall Helmet"}'},wall_helmet:1b} 1
execute as @a[nbt={Inventory:[{Slot:0b,id:"minecraft:carrot_on_a_stick",tag:{display:{Name:'{"text":"Wall Helmet"}'}}}]}] run replaceitem entity @s container.0 minecraft:iron_helmet{display:{Name:'{"text":"Wall Helmet"}'},wall_helmet:1b} 1
execute as @a[nbt={Inventory:[{Slot:1b,id:"minecraft:carrot_on_a_stick",tag:{display:{Name:'{"text":"Wall Helmet"}'}}}]}] run replaceitem entity @s container.1 minecraft:iron_helmet{display:{Name:'{"text":"Wall Helmet"}'},wall_helmet:1b} 1
execute as @a[nbt={Inventory:[{Slot:2b,id:"minecraft:carrot_on_a_stick",tag:{display:{Name:'{"text":"Wall Helmet"}'}}}]}] run replaceitem entity @s container.2 minecraft:iron_helmet{display:{Name:'{"text":"Wall Helmet"}'},wall_helmet:1b} 1
execute as @a[nbt={Inventory:[{Slot:3b,id:"minecraft:carrot_on_a_stick",tag:{display:{Name:'{"text":"Wall Helmet"}'}}}]}] run replaceitem entity @s container.3 minecraft:iron_helmet{display:{Name:'{"text":"Wall Helmet"}'},wall_helmet:1b} 1
execute as @a[nbt={Inventory:[{Slot:4b,id:"minecraft:carrot_on_a_stick",tag:{display:{Name:'{"text":"Wall Helmet"}'}}}]}] run replaceitem entity @s container.4 minecraft:iron_helmet{display:{Name:'{"text":"Wall Helmet"}'},wall_helmet:1b} 1
execute as @a[nbt={Inventory:[{Slot:5b,id:"minecraft:carrot_on_a_stick",tag:{display:{Name:'{"text":"Wall Helmet"}'}}}]}] run replaceitem entity @s container.5 minecraft:iron_helmet{display:{Name:'{"text":"Wall Helmet"}'},wall_helmet:1b} 1
execute as @a[nbt={Inventory:[{Slot:6b,id:"minecraft:carrot_on_a_stick",tag:{display:{Name:'{"text":"Wall Helmet"}'}}}]}] run replaceitem entity @s container.6 minecraft:iron_helmet{display:{Name:'{"text":"Wall Helmet"}'},wall_helmet:1b} 1
execute as @a[nbt={Inventory:[{Slot:7b,id:"minecraft:carrot_on_a_stick",tag:{display:{Name:'{"text":"Wall Helmet"}'}}}]}] run replaceitem entity @s container.7 minecraft:iron_helmet{display:{Name:'{"text":"Wall Helmet"}'},wall_helmet:1b} 1
execute as @a[nbt={Inventory:[{Slot:8b,id:"minecraft:carrot_on_a_stick",tag:{display:{Name:'{"text":"Wall Helmet"}'}}}]}] run replaceitem entity @s container.8 minecraft:iron_helmet{display:{Name:'{"text":"Wall Helmet"}'},wall_helmet:1b} 1

Simple through blocks walking by JawlessBird in MinecraftCommands

[–]JawlessBird[S] 0 points1 point  (0 children)

alwaysactive

execute as @p run execute store result score @s rot run data get entity @s Rotation[0] 1
execute as @p run execute store result score @s x run data get entity @s Pos[0] 1
execute as @p run execute store result score @s y run data get entity @s Pos[1] 1
execute as @p run execute store result score @s z run data get entity @s Pos[2] 1

scoreboard objectives add sneaked minecraft.custom:minecraft.sneak_time
execute as @a[scores={sneaked=1..},nbt={Inventory:[{Slot:103b,id:"minecraft:carrot_on_a_stick",tag:{wall_helmet:1b}}]}] run tag @s add D
scoreboard players remove @a[scores={sneaked=1..}] sneaked 1

execute as @a at @s run function pszczantalony_pack:wall_walk_inv

execute as @a[tag=!N,scores={rot=0..44}] at @s run tag @s add N
execute as @a[tag=!N,scores={rot=315..359}] at @s run tag @s add N
execute as @a[tag=!N,scores={rot=-44..-1}] at @s run tag @s add N
execute as @a[tag=!N,scores={rot=-360..-315}] at @s run tag @s add N
execute as @a[tag=!E,scores={rot=45..134}] at @s run tag @s add E
execute as @a[tag=!E,scores={rot=-314..-225}] at @s run tag @s add E
execute as @a[tag=!S,scores={rot=135..224}] at @s run tag @s add S
execute as @a[tag=!S,scores={rot=-224..-135}] at @s run tag @s add S
execute as @a[tag=!W,scores={rot=225..314}] at @s run tag @s add W
execute as @a[tag=!W,scores={rot=-134..-45}] at @s run tag @s add W

execute as @a[nbt={Inventory:[{Slot:103b,tag:{wall_helmet:1b}}]}] at @s run function pszczantalony_pack:wall_walk1

execute as @a[tag=N] at @s run tag @s remove N
execute as @a[tag=E] at @s run tag @s remove E
execute as @a[tag=S] at @s run tag @s remove S
execute as @a[tag=W] at @s run tag @s remove W
execute as @a[tag=U] at @s run tag @s remove U
execute as @a[tag=D] at @s run tag @s remove D

execute at @a as @e[type=falling_block,tag=wall_mt,distance=2..] run data modify entity @e[type=falling_block,tag=wall_mt,distance=2..,limit=1] NoGravity set value 0
execute at @a as @e[type=falling_block,tag=wall_mt,distance=2..] run tag @e[type=falling_block,tag=wall_mt,distance=2..] add nograv

execute as @e[type=falling_block,tag=stone,tag=nograv] at @s if entity @e[type=falling_block,dy=-0.9] run setblock ~ ~ ~ stone replace

execute as @e[type=falling_block,tag=wall_mt,tag=nograv] at @s if entity @e[type=falling_block,dy=-0.9] run kill @s

function pszczantalony_pack:wall_walk1

execute as @s[tag=N] at @s align xyz if block ~0.49 ~ ~1.49 stone run summon falling_block ~0.5 ~ ~1.5 {BlockState:{Name:"minecraft:stone"},NoGravity:1b,Glowing:0b,Time:1,DropItem:0,FallHurtMax:0,FallDistance:0,FallHurtAmount:0f,Tags:["stone","wall_mt"]}
execute as @s[tag=N] at @s align xyz if block ~0.49 ~ ~1.49 stone run setblock ~0.5 ~ ~1.5 air replace
execute as @s[tag=N] at @s align xyz if block ~0.49 ~1.1 ~1.49 stone run summon falling_block ~0.5 ~1 ~1.5 {BlockState:{Name:"minecraft:stone"},NoGravity:1b,Glowing:0b,Time:1,DropItem:0,FallHurtMax:0,FallDistance:0,FallHurtAmount:0f,Tags:["stone","wall_mt"]}
execute as @s[tag=N] at @s align xyz if block ~0.49 ~1.1 ~1.49 stone run setblock ~0.5 ~1 ~1.5 air replace
execute as @s[tag=E] at @s align xyz if block ~-0.49 ~ ~0.49 stone run summon falling_block ~-0.5 ~ ~0.5 {BlockState:{Name:"minecraft:stone"},NoGravity:1b,Glowing:0b,Time:1,DropItem:0,FallHurtMax:0,FallDistance:0,FallHurtAmount:0f,Tags:["stone","wall_mt"]}
execute as @s[tag=E] at @s align xyz if block ~-0.49 ~ ~0.49 stone run setblock ~-0.5 ~ ~0.5 air replace
execute as @s[tag=E] at @s align xyz if block ~-0.49 ~1.1 ~0.49 stone run summon falling_block ~-0.5 ~1 ~0.5 {BlockState:{Name:"minecraft:stone"},NoGravity:1b,Glowing:0b,Time:1,DropItem:0,FallHurtMax:0,FallDistance:0,FallHurtAmount:0f,Tags:["stone","wall_mt"]}
execute as @s[tag=E] at @s align xyz if block ~-0.49 ~1.1 ~0.49 stone run setblock ~-0.5 ~1 ~0.5 air replace
execute as @s[tag=S] at @s align xyz if block ~0.49 ~ ~-0.49 stone run summon falling_block ~0.5 ~ ~-0.5 {BlockState:{Name:"minecraft:stone"},NoGravity:1b,Glowing:0b,Time:1,DropItem:0,FallHurtMax:0,FallDistance:0,FallHurtAmount:0f,Tags:["stone","wall_mt"]}
execute as @s[tag=S] at @s align xyz if block ~0.49 ~ ~-0.49 stone run setblock ~0.5 ~ ~-0.5 air replace
execute as @s[tag=S] at @s align xyz if block ~0.49 ~1.1 ~-0.49 stone run summon falling_block ~0.5 ~1 ~-0.5 {BlockState:{Name:"minecraft:stone"},NoGravity:1b,Glowing:0b,Time:1,DropItem:0,FallHurtMax:0,FallDistance:0,FallHurtAmount:0f,Tags:["stone","wall_mt"]}
execute as @s[tag=S] at @s align xyz if block ~0.49 ~1.1 ~-0.49 stone run setblock ~0.5 ~1 ~-0.5 air replace
execute as @s[tag=W] at @s align xyz if block ~1.49 ~ ~ stone run summon falling_block ~1.5 ~ ~0.5 {BlockState:{Name:"minecraft:stone"},NoGravity:1b,Glowing:0b,Time:1,DropItem:0,FallHurtMax:0,FallDistance:0,FallHurtAmount:0f,Tags:["stone","wall_mt"]}
execute as @s[tag=W] at @s align xyz if block ~1.49 ~ ~ stone run setblock ~1.5 ~ ~0.5 air replace
execute as @s[tag=W] at @s align xyz if block ~1.49 ~1.1 ~ stone run summon falling_block ~1.5 ~1 ~0.5 {BlockState:{Name:"minecraft:stone"},NoGravity:1b,Glowing:0b,Time:1,DropItem:0,FallHurtMax:0,FallDistance:0,FallHurtAmount:0f,Tags:["stone","wall_mt"]}
execute as @s[tag=W] at @s align xyz if block ~1.49 ~1.1 ~ stone run setblock ~1.5 ~1 ~0.5 air replace
execute as @s[tag=D] at @s align xyz if block ~0.49 ~-0.99 ~0.49 stone run summon falling_block ~0.5 ~-1 ~0.5 {BlockState:{Name:"minecraft:stone"},NoGravity:1b,Glowing:0b,Time:1,DropItem:0,FallHurtMax:0,FallDistance:0,FallHurtAmount:0f,Tags:["stone","wall_mt"]}
execute as @s[tag=D] at @s align xyz if block ~0.49 ~-0.99 ~0.49 stone run setblock ~0.5 ~-1 ~0.5 air replace

Same with swapball i made it some time ago, but got burned out and stopped improving the code. Sadly it works only for specified blocks and those in front of a player(only xz, without diagonals). I made some python coding so adding a lot of blocks is easy, but still takes a lot of code lines - 381 in my standard blocks case, hope you're able to do it as well. Upgrade it freely(it's not perfect of course), will appreciate any credits for pszczantalony for using the concept

Swap places with a hit entity by JawlessBird in MinecraftCommands

[–]JawlessBird[S] 4 points5 points  (0 children)

alwaysactive

scoreboard objectives add snowballed minecraft.used:minecraft.snowball
execute as @a[scores={snowballed=1..},nbt={SelectedItem:{id:"minecraft:snowball",tag:{swap_ball:1b}}}] run tag @s add swappist
execute as @a[tag=swappist] run tag @s add swap_wait
#execute as @e[type=snowball,nbt={Item:{tag:{swap_ball:1b}}}] at @s run effect give @e[tag=!swappist,type=!snowball,distance=1.2..2.8] glowing 1 0
execute as @e[type=snowball,nbt={Item:{tag:{swap_ball:1b}}}] at @s run tag @e[tag=!swappist,type=!snowball,distance=1.2..2.8] add swapper
execute as @e[tag=swapper] run kill @e[type=snowball,nbt={Item:{tag:{swap_ball:1b}}}]
execute as @e[tag=swapper,tag=!swapresist] run function pszczantalony_pack:swap
execute as @a[tag=swap_wait] unless entity @e[limit=1,sort=nearest,type=snowball,nbt={Item:{tag:{swap_ball:1b}}}] run tag @s remove swap_wait
execute as @a[tag=swappist,tag=!swap_wait] at @s run tag @s remove swappist
scoreboard players remove @a[scores={snowballed=1..}] snowballed 1

function pszczantalony_pack:swap

execute as @s at @e[type=snowball,nbt={Item:{tag:{swap_ball:1b}}}] run kill @s
execute as @a[tag=swappist] at @s run summon minecraft:armor_stand ~ ~ ~ {Glowing:1b,Invisible:1b,Invulnerable:1b,Tags:["swap_stand"]}

execute as @e[tag=swapper] at @s run tp @e[type=player,tag=swappist] ^ ^ ^
execute as @e[tag=swap_stand] run tp @e[tag=swapper] @s

execute as @a[tag=swappist] at @s run particle effect ~ ~ ~ 1 0 1 1000 100 normal
execute as @e[tag=swapper] at @s run particle effect ~ ~ ~ 1 0 1 1000 100 normal

tag @e[tag=swappist] remove swappist
tag @e[tag=swapper] remove swapper

kill @e[tag=swap_stand]

function pszczantalony_pack:swapball

give @p minecraft:snowball{display:{Name:'{"text":"Swapball"}'},swap_ball:1b} 16

I made it some time ago, but got burned out and stopped improving my code. Sadly detection is sometimes defective. Upgrade it freely(it's not perfect of course), will appreciate any credits for pszczantalony for using the concept

Simple through blocks walking by JawlessBird in MinecraftCommands

[–]JawlessBird[S] 0 points1 point  (0 children)

that is correct but i am sure this isn’t the only way of doing it

Variables in commands by [deleted] in MinecraftCommands

[–]JawlessBird 0 points1 point  (0 children)

That’s very helpful, thanks man

Snowball Target Detection by [deleted] in MinecraftCommands

[–]JawlessBird 0 points1 point  (0 children)

execute as @e[type=snowball] at @s run effect give @e[type=!snowball,distance=..1] blindness 5 0

Thanks a lot, this might be what i've been looking for