• 0

    posted a message on command block teleporter help

    You can add a cooldown to the teleport so the player has time to leave the teleport area.

    This tutorial shows the idea. The commands are in the description so you can easily copy them from there. It's an old video but I believe all the commands should still work in the newer versions.

    Episode 57: A two way teleporter using a cooldown to stop the player getting caught in an infinite teleporting loop:

    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on Minecraft wont reconize my mcfunctions files

    I believe that in 1.21 the folders have been renamed. Try changing the folder name from "functions" to "function".


    Here is the changelog in case it helps: https://www.minecraft.net/en-us/article/minecraft-java-edition-1-21#:~:text=TAGS-,DIRECTORY RENAMES,-Some registry types

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Help with teleportation trident

    Hello, not sure what version you are in, but here is something in 1.19.4

    First give the player the trident with a custom tag, using the name to target things can often break.

    give @p trident{my:trident, display:{Name:'{"text":"My test trident"}'}}


    Next set up some scores:
    scoreboard objectives add id dummy

    scoreboard objectives add used_trident used:trident


    A repeating command to assign all players an id if they don't already have one
    execute as @a unless score @s id = @s id store result score @s id run scoreboard players add #id_holder id 1


    Lastly a repeating chain to teleport the player to their trident if it is in the ground and more than 5 blocks away:
    1: Copy the players ID to the nearest trident that doesn't have an ID, if that player has just thrown a tagged trident.
    execute as @a[scores={used_trident=1}] at @s as @e[type=trident, sort=nearest, limit=1, nbt={Trident:{tag:{my:trident}}}] unless score @s id = @s id run scoreboard players operation @s id = @a[distance=..0.1] id

    2: Teleport the player to any trident that is in the ground and has the same ID as the player.
    execute as @e[type=trident, nbt={inGround:true, Trident:{tag:{my:trident}}}] at @s as @a[distance=5..] if score @s id = @e[type=trident, distance=..0.1, nbt={Trident:{tag:{my:trident}}}, limit=1] id run tp @s[tag=!dev] @e[type=trident, distance=..0.1, nbt={Trident:{tag:{my:trident}}}, limit=1]

    3: Reset the players score.
    scoreboard players reset @a used_trident


    This may not be exactly what you want, but hopefully it will help a bit. :)

    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on Command block enchantment for God sword error

    Which version are you in?
    What item are you holding when you activate the command block?

    It looks like you are trying to enchant an item that can't have the sharpness enchantment.

    In 1.19.4 if I put the following command into a command block and activate it while holding a sword then it works:

    enchant @p sharpness 1

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Item in Item Frame Detection

    I am guessing you asked this question on Minecraft Commands Reddit as well, since it's almost identical.
    In case it wasn't you, here is the answer from GalSergey that was given there.

    Do not try to check the item name, this check often fails. Use a custom tag for this, here's an example:
    Item example:

    give @s spruce_stairs{Test:true}


    Command block

    execute positioned 22 115 7 as @e[type=item,distance=..1,nbt={Item:{tag:{Test:true}}}] run say Example Command.
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Help with a command block

    Testing using a name can be tricky since Minecraft likes to reorder the data about the name causing the command to fail even though it looks ok.
    Better to give the head a custom tag and check for that.


    Give player head:

    give @p player_head{customTag:true}


    Check for tagged item in head slot:
    effect give @a[nbt={Inventory:[{Slot:103b, tag:{customTag:true}}]}] minecraft:health_boost 1 9 true


    Checking the NBT of the player every tick is not great for performance so you may want to run checks like this every 1 or 2 seconds instead of 20 times a second.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Command that changes Armor when on certain block. (Version 1.20.1)

    Does this work?

    execute as @a at @s unless block ~ ~-1 ~ minecraft:packed_ice run item replace entity @s armor.feet with minecraft:air



    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on 1.20.1 how do you make item frames invincible to blocks?

    Invulnerable won't stop it coming off the wall if it's inside a block, you can use the Fixed property:

    data modify entity @e[type=item_frame,sort=nearest,limit=1] Fixed set value 1b


    This will make the nearest item frame to where the command was ran be Fixed. It won't break even if the block it's on is broken.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Need help with trouble shooting my command

    Tested in: Java 1.20.1 (But should work in some earlier versions as well.)

    There was a few errors in there. This should work:

    summon villager ~ ~ ~ {summon villager ~ ~ ~ { Silent:1b,Invulnerable:1b,CustomName:'{"text":"Sam","color":"gold","bold":true}',Attributes:[{Name:generic.movement_speed,Base:0}], VillagerData:{level:99,profession:"minecraft:cleric",type:"minecraft:savanna"}, Offers:{ Recipes:[ {maxUses:100,buy:{id:"minecraft:emerald",Count:40b},sell:{id:"minecraft:villager_spawn_egg",Count:1b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:60b},sell:{id:"minecraft:villager_spawn_egg",Count:1b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:10b},sell:{id:"minecraft:chicken_spawn_egg",Count:1b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:10b},sell:{id:"minecraft:chicken_spawn_egg",Count:1b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:45b},sell:{id:"minecraft:chicken_spawn_egg",Count:5b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:64b},sell:{id:"minecraft:chicken_spawn_egg",Count:10b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:10b},sell:{id:"minecraft:cow_spawn_egg",Count:1b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:10b},sell:{id:"minecraft:cow_spawn_egg",Count:1b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:45b},sell:{id:"minecraft:cow_spawn_egg",Count:5b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:64b},sell:{id:"minecraft:cow_spawn_egg",Count:10b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:10b},sell:{id:"minecraft:pig_spawn_egg",Count:1b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:45b},sell:{id:"minecraft:pig_spawn_egg",Count:5b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:64b},sell:{id:"minecraft:pig_spawn_egg",Count:10b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:10b},sell:{id:"minecraft:sheep_spawn_egg",Count:1b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:45b},sell:{id:"minecraft:sheep_spawn_egg",Count:5b}}, {maxUses:100,buy:{id:"minecraft:emerald",Count:90b},sell:{id:"minecraft:sheep_spawn_egg",Count:10b}} ] }}


    Also worth noting that when you charge above 64 emeralds for something it will auto discount to 64 since you can't have a larger stack than that. You could probably charge them 64 and 26 emeralds to make 90 like in the recipe below:

    {maxUses:100,buy:{id:"minecraft:emerald",Count:64b},buyB:{id:"minecraft:emerald",Count:26b},sell:{id:"minecraft:villager_spawn_egg",Count:1b}}


    When making commands like this, https://mcstacker.net/ can be quite helpful.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Test for how many players are in a specific gamemode

    Yes, first you will need a dummy objective called "amount".

    scoreboard objectives add amount dummy


    Then you have the three command blocks in a chain:

    Repeat Active: Put the number of players into objective
    Chain Unconditional Active: Check the score and run a command
    Chain Unconditional Active: Reset the fake players score


    Hope that helps :)

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Test for how many players are in a specific gamemode

    You could save the amount of players in survival to a score and then check the score:

    Put number of players in Survival in to a scoreboard objective called amount on a fake player:

    execute as @a[gamemode=survival] run scoreboard players add #fakePlayer amount 1


    Check if the score is 1 and run a command if it is:

    execute if score #fakePlayer amount matches 1 run say Hi


    Reset the fake players score:

    scoreboard players reset #fakePlayer amount
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Motion[0] tag not changing

    The z motion is detected from further away. Is it getting pushed out of range before the x motion can be done?
    Or maybe the:

    execute unless entity @s
    is saying: Run this command unless this entity exists, which it does, so that code doesn't run.

    Things to try:
    Changing the distance for the x check to match the z check, or
    Remove this:
     execute unless entity @s
    from the beginning of line 1 and 3


    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Help my friend make a door that gives a message when trying to open it but doesn't open

    It later versions you could put an interaction entity just in front of the door, so the player is not actually clicking the door, but the interaction entity. Then get that to say or run whatever you want when clicked on. Java 1.19.4 and higher have the interaction entity: https://minecraft.fandom.com/wiki/Interaction

    In earlier versions you could maybe check to see if the door is open, and if it is then shut it with commands and say whatever you want. This may well look a bit janky though. :)

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on (Command) How to count items with specific tags in inventory?

    I'm not sure, but I would guess the more items in there, the more there is to check, so it would be slower. As I said, complete guess. :)

    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on (Command) How to count items with specific tags in inventory?

    If you are using a Datapack I'm pretty sure you could set up a custom item tag called #everything and put the id of every item that can have "the_tag:1" in there. Then use the following in game:


    clear @p #everything{the_tag:1} 0
    Posted in: Commands, Command Blocks and Functions
  • To post a comment, please .