• 0

    posted a message on Help with excluding certain datas while selecting a score

    You could use the "unless" argument and include the value you don't want the target to have:

    /execute as @a unless entity @s[scores={class=7}] run ...
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on how do I detect an un enchanted weapon using /execute

    Since the "ench" tag will not exist unless there are actually enchantments, you'll want to use the "unless" argument instead of "if" and detect the existence of that tag:

    /execute as @a if entity @s[nbt=Inventory:[{id:"minecraft:diamond_sword",tag:{ench:[{}]}}]] run ...

    (using "ench:[{}]" specifically because "ench:[]" would check if the tag exists but has nothing in it, which will not normally be the case)

    EDIT: Actually, this might not be what you want. The above only succeeds if the player has no enchanted swords at all in their inventory. If they have 1 unenchanted sword and 1 enchanted sword, the command will fail.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on How to have a player be struck by lightning when they are in a certain area?

    You will need to add an area limiter such as "distance", which is the radius with the coordinates at the center. For example, the following targets players between 0 and 1 block of those coordinates (the .. indicates "between these two numbers"):

    execute at @a[name=!Lux_o,x=-94,y=121,z=-66,distance=0..1] run summon lightning_bolt ~ ~ ~
    Posted in: Commands, Command Blocks and Functions
  • 2

    posted a message on How do I detect if a player is still or moving??
    Quote from orangejuice137»

    I'm trying to detect if a player is standing still or moving. This command below is attempting to add 1 to a scoreboard "timer" when I'm standing still.

    /execute as @a[nbt={Motion:[0.0,0.0,0.0]}] run scoreboard players add @s timer 1

    As you probably could've guessed, this doesn't work. Even when I'm moving, it will still add 1.

    For some odd reason, however, it stops when I'm sprinting and jumping (weird exception).

    Can you guys help me out?

    One reason the command behaves that way (apart from player motion being messed up as was mentioned) is because when you test for data within a list (values surrounded by square brackets), each element within the list you specify is checked within every element on the target.

    For example, if you checked for "List:[1]" and the target had a list of "List:[3,2,1]", it would match because your specified value of "1" is compared with the target's values of "3", "2", and "1", and it matched the last value. Therefore your test of "Motion:[0.0,0.0,0.0]" is the exact same as testing "Motion:[0.0]".

    But for whatever reason, the player's X and Z motion will be 0 even when moving normally, so the check for Motion:[0.0] will always find at least 1 element. Sprint-jumping causes the values to actually update, and no motion values are 0 at that point, so the check fails.

    As for the objectives, you'd create them like so (prepended with "minecraft.custom:minecraft."):

    /scoreboard objectives add jump minecraft.custom:minecraft.jump
    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on What exactly does sort=arbitrary do?

    It simply means unsorted, such that the order will be whatever it is internally.

    Internally the sorting is based on load order, such as which chunks are accessed first. Each chunk has its own array of entities. For example, when a chunk is loaded, it loads entities in the order that they were saved to chunk files. You can manipulate the ordering by killing and summoning entities in a specific order in the same chunk.

    However, this is not something you'll want to rely on because it could change in the future. The goal of "arbitrary" is to greatly increase performance by not using expensive sorting methods (which was not avoidable pre-1.13, as it would always sort by distance unless @r was used), so that's all you should really be using it for.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on How to Test for an Armor Stand Holding an Item in 1.13

    The NBT structure itself has not changed ("HandItems" is a list of compounds and "id" is a string), but in 1.13 you can use the "nbt" selector parameter to specify NBT for a target:

    /execute as @e[type=armor_stand,nbt={HandItems:[{id:"minecraft:iron_sword"}]}] run say I am an armor stand holding an iron sword
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on [Solved] 1.13 Functions not working

    The "alldata" is the namespace, while "custom" is the name of the pack itself. The namespace is what's used when calling the function:

    /function alldata:tablenchairs
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Issues with commands in Java Edition

    Aye, that's what I mean. But what I'm asking is what you're using the resulting signal for, such as if it's to activate other command blocks (and if so, what the commands might do) or to turn on a set of redstone lamps.

    Lamps would be trickier, but if you're just looking to run more commands, you'd use "/execute store" to grab the number of entities found and place it into a score. The "/execute if entity" subcommand, when placed last in /execute without using "run", will return the number of targets found. You'd then use the resulting score to activate other commands.

    For example, this stores the number of entities in the scoreboard under a fake player called "entity#" in the objective "counters":

    /execute store result score entity# counters if entity @e

    And the following will run a /say command if the "if score" condition succeeds (if there are 3+ loaded entities in the world):

    /execute if score entity# counters matches 3.. run say There are 3 or more entities.
    Posted in: Redstone Discussion and Mechanisms
  • 0

    posted a message on Issues with commands in Java Edition
    Quote from aarno5»

    I know how to use the new /execute command, I've already researched that. But I cannot figure out how to recreate that certain command


    If I need to find some way around this it wouldn't be the hardest thing I've done, I was just asking to see if anyone on here knew the answer already.

    Are you talking about output to comparators? If so, what exactly were you using that output for? Command blocks now only output a signal of 1 or 0 for the success of a command block, and no longer based on the number of targets. But there are ways to get the number itself into, for example, a scoreboard score. Just depends on what you were using it for.

    Posted in: Redstone Discussion and Mechanisms
  • 0

    posted a message on Testing an inventory for >= of an item in 1.13
    Quote from nphhpn»

    That's the point. Original command test if nearest player has isEmeraldCount matches 15.. while your command finds the nearest player with score isEmeraldCount matches 15. Think about a case when a player with 15 emeralds come in, get a score isEmeraldCount of 15, then other player with less than 15 emerald come in, nearer than the first one. The first player drop his emeralds then the second press the button. Because the first command only update the score of the nearest player, your command still recognises the first player has 15 isEmeraldCount score and remove emeralds from him while the original command does not.

    I will break down the commands presented in the thread by OP and myself. This has nothing to do with somebody "coming in" and breaking something. That situation literally cannot happen because I'm talking about one command, not multiple. And even then, unless you're using redstone (which you absolutely should not be doing since 1.9), commands are going to run in the specified order before any player movement is handled. The only way player movement could break that is if you used a command mixed in with your detection commands to teleport players around. But that would be the map-maker purposefully breaking it, which isn't an argument.


    execute if score @p[gamemode=adventure,x=-2104,y=54,z=-2153,distance=..6] isEmeraldCount matches 15.. run clear @p[gamemode=adventure,x=-2104,y=54,z=-2153,distance=..6] minecraft:emerald 15


    /clear @p[gamemode=adventure,x=-2104,y=54,z=-2153,distance=..6,scores={isEmeraldCount=15}] minecraft:emerald 15

    The first command checks if a player with a score exists. Then, a second time, it checks if that same player exists. Then it clears the emeralds.

    The second command checks if a player with a score exists. Then it clears the emeralds.

    The second command is the equivalent of the first, without the unnecessary fluff from /execute. They are logically the same, but the second one is much more efficient.

    To reiterate, look at both of the selectors in the first command. They are exactly the same. It is therefore redundant and, while normally with /execute, you'd use "as [target]" to remove the redundancy and use "@s" for nested selectors (which is highly efficient). But since you don't need /execute for this operation, it can be removed. The reason you don't need it is because the "if score [target] isEmeraldCount matches 15" is literally the same as "scores={isEmeraldCount=15}" and that same exact player was being targeted in the first command anyways.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Testing an inventory for >= of an item in 1.13
    Quote from nphhpn»

    I tested. For the first, the command still execute even when the target is not an op. For the second, it really matter. The command I used was:

    /scoreboard objectives add a dummy

    Then I summoned a villager and type:

    /scoreboard players set @e[type=!player] a 1

    /execute if score @e[sort=nearest,limit=1] a matches 1 run say hi

    The chat still empty.

    It's likely because you're targeting the wrong entity. You specify "type=!player" in the first selector but don't do that in the second, meaning it's going to target you instead.

    And even so, it's irrelevant. I'm specifically talking about the original command in the thread. I'm not about to go through every hypothetical situation when the specific situation in the original topic doesn't need "if score".

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Testing an inventory for >= of an item in 1.13
    Quote from nphhpn»

    For the first, that's just what I think. Minecraft will execute as if the player is the executor, so it might fail il that player is not an op?

    For the second, that's when "if entity" is used, but this is "if score" so that's different.

    For the first it's not the case. "/execute as" marks the player as a 'command sender', which is not reliant on the player being an OP. It primarily means that the target is the one to target with "@s" (though there are some other things, such as who is sent command feedback as controlled by "sendCommandFeedback" gamerule). Prior to 1.13, a 'command sender' also included XYZ location for command execution, though in 1.13 that has been split into "at".

    For the second, it still doesn't matter. The "if score" being used is equivalent to the "scores" selector parameter. While "if score" in general does have some extra options, the command that was being used did not use them, thus it could simply be removed in favor of the "scores" parameter.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Testing an inventory for >= of an item in 1.13
    Quote from nphhpn»

    "/execute as [target]" will fail if that target is not an op.

    Those two commands have different result in multiplayer. The original command will test if the nearest player has a number of a score while your command will find the nearest player who has a number of score.

    For the first, are you sure? I know this was an issue with the old CommandStats system, but this is much different. I cannot test it myself unfortunately. If this is the case, can you provide a link to the bug report?

    For the second, the end result is the same. Using "if entity" followed by performing a command on the exact same target is no different than having a redundant /testfor command pre-1.13.

    EDIT: I've conferred with the /r/MinecraftCommands discord server who can confirm that both "execute as" and "execute store" do not require the target to be an OP. Make sure you're not having permission clashes from something like Spigot.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Help Updating Commands to 1.13
    Quote from YMbrothers»

    Yeah... Making items invulnerable so you don't even need the armor stand. Feel free to use mine.

    Also, the "b" is to specify that the data is a boolean type. You don't rly need it for /give or /summon, but you MUST need it for detecting (like @e[nbt={Item:{Count:1b}}])

    "b" stands for "byte" rather than boolean, which holds a numerical value between -128 and 127. There is no true boolean datatype for NBT as it just uses byte instead. This is also the case for "true/false", which are transformed into bytes as "1b/0b".

    Quote from Flexico»

    Turns out I needed to put the extra quotes in the NBT tags but not the entity specifier. Weird.

    I have a post here explaining the changes made to the NBT parser in 1.11. In particular for strings, any string that contains a value that is not any of the following will require the use of quotes around the value:

    a-z A-Z 0-9 . _ + -

    Since minecraft:diamond contains a colon, which is not in the list of acceptable characters above, it will require quotes around the whole string.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Command Block checking armor slots.
    Quote from PurelyAliyah»

    Thank you so much! I had been stressing about it for days. I really appreciate the help!

    While it will take extra work to modify the items first, you can greatly reduce the complexity of detection by using custom item tags. For example, the following item has lore as well as a custom tag called "blargh" with a value of 1 and datatype of byte:

    /give @p minecraft:stone{blargh:1b,display:{Lore:["Line 1","Line 2"]}}

    And to detect it, you simply look for "blargh:1b":

    say @a[nbt={Inventory:[{tag:{blargh:1b}}]}

    As a quick example using your current command, where each value of "blargh" represents a unique item as a whole:

    effect give @a[nbt={Inventory:[{Slot:103b,tag:{blargh:1b}},{Slot:102b,tag:{blargh:2b}},{Slot:101b,tag:{blargh:3b}},{Slot:100b,tag:{blargh:4b}}]}] minecraft:speed 4 1 true

    Such that you'd only have "blargh:3b" on the item "id:"minecraft:leather_leggings",tag:{blargh:3b,display:{Lore:["Effects with full Draconium set:","+Speed II"]}}", which allows you to detect it based on "blargh:3b" alone.

    Posted in: Commands, Command Blocks and Functions
  • To post a comment, please .