• 0

    posted a message on Help with a command block setting zombie's health to another value (20w18a)

    You need to increase the base of the maxHealth attribute to 50.0d before increasing the health:

    /execute as @e[type=zombie,nbt={Attributes:[{Name:"generic.maxHealth",Base:20.0d}]}] run data modify entity @s Attributes[0].Base set value 50.0d
    
    /execute as @e[type=zombie,nbt={Attributes:[{Name:"generic.maxHealth",Base:50.0d}]}] run data modify entity @s Health set value 50.0f
    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on Filled Composter/Cauldron on Armor Stand?

    The BlockStateTag only applies to blocks, and the composter on the armor stand is an item. Some items have a 3D model, so that's why it looks like the armor stand is wearing a block.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on How could I make all pickaxes only able to break a certain block?

    This should do:

    /execute as @a[nbt={SelectedItem:{id:"minecraft:diamond_pickaxe"}}] unless data entity @s SelectedItem.tag.CanDestroy run replaceitem entity @s weapon.mainhand diamond_pickaxe{CanDestroy:["someBlock"]}
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on How to execute?

    Create the following scoreboard objectives (you only need to create these once):

    /scoreboard objectives add count dummy
    /scoreboard objectives add count_area dummy

    All commands beyond this point can run on a loop.


    Store the number of players from team green into a scoreboard objective:

    /execute store result score players count run execute if entity @a[team=green]

    I'm using a fake player called players for this example but you can use a real player or armor stand if you want to. The next step is to detect how many players from the green team are in the specified area and store that number into the second scoreboard objective:

    /execute store result score players count_area run execute if entity @e[x=,y=,z=,dx=,dy=,dz=,team=green]

    x, y, and z are the coordinates of a corner of the detection area. The dx, dy, and dz are the width, height, and length of the detection area. The final step is to compare the values of the two objectives. If the values match, that means all players from the green team are in the specified area. Here is how you can compare the two:

    /execute if score players count = players count_area run say hi
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Can You Change Gravity?

    Not really, but jump boost + slow falling works well for simulating low gravity.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Tesla Tower

    Here is the command in the new syntax:

    /execute at @e[name=!your_name,distance=..10] run summon lightning_bolt ~ ~ ~
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Help with coodrinates please

    This should work:

    /execute as @a[x=0,y=0,z=0,distance=..10] unless score @s <objective> matches 1.. run scoreboard players set @s <objective> 0
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Disable CanDestroy in certain locations

    Oh, I think I understand what you are trying to achieve. So you want a specific type of block to be breakable across the entire map but not to be breakable at a list of pre-defined coordinates. I don't know how you can do that without using /setblock. Maybe someone else has a better idea.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on 1.15 - Tag isn't kept from inventory to entity.

    It's tricky to accurately detect when a snowball hits a block because the direction the snowball is facing changes based on its motion. You can see what I mean by enabling the hitboxes (F3+B) and throwing a snowball. The blue line is the direction the snowball is facing.


    Anyway, I came up with a solution. It's easier to just use the snowball's collision detection logic than to invent your own. My solution uses armor stands which teleport to the snowball until it lands and then the armor stand detects that and executes a command. I hope this helps you with your project. Simply paste the following commands into a command block chain (1 repeating and 3 chain command blocks all set to always active).

    /execute as @e[type=minecraft:snowball] at @s unless entity @e[tag=detect,distance=..2] run summon minecraft:armor_stand ~ ~ ~ {Tags:["detect"],NoGravity:1}
    /execute as @e[tag=detect] at @s run tp @s @e[type=snowball,limit=1,sort=nearest,distance=..2]
    /execute as @e[tag=detect] at @s unless entity @e[type=minecraft:snowball,distance=..2] run <command_to_run>
    /execute as @e[tag=detect] at @s unless entity @e[type=minecraft:snowball,distance=..2] run kill @s
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Disable CanDestroy in certain locations

    Then expand the detection area?

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Disable CanDestroy in certain locations

    I would use /replaceitem to swap the player's pickaxe with a regular one when they are in a specific area and switch it back when they exit the area.


    Place down a repeating command block and a chain command block attached to the repeating one. Paste the following commands into the command blocks and set them to always active.

    execute as @a[x=,y=,z=,dx=,dy=,dz=] if data entity @s SelectedItem.tag.CanDestroy run replaceitem entity @s weapon.mainhand minecraft:diamond_pickaxe
    
    execute as @a[nbt={SelectedItem:{id:"minecraft:diamond_pickaxe"}}] unless entity @s[x=,y=,z=,dx=,dy=,dz=] unless data entity @s SelectedItem.tag.CanDestroy run replaceitem entity @s weapon.mainhand minecraft:diamond_pickaxe{CanDestroy:["some_block"]}

    x,y, and z are the coordinates of one corner and dx,day, and dz are the width, height, and length of the area. Here is a world download in case you don't know how to set the system up: https://www.dropbox.com/sh/eo7zkg1y592v9tr/AABhNfz1B5_VV6TitfWNWwBia?dl=0.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on 1.15 - Tag isn't kept from inventory to entity.

    You could tag the snowball using /tag. That method isn't very accurate though.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on 1.15 - Tag isn't kept from inventory to entity.

    I assume you are referring to custom item tags?

    /give @s snowball{someTag:1b}

    ^ these custom tags can only be applied to items and the thrown snowball is an entity.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on 1.13+ testfor commands

    You can use the new if and unless statements to test for things:

    execute if entity @a[x=,y=,z=,dx=,dy=,dz=] run say hi

    or you can specify the condition in the selector directly:

    execute as @a[x=,y=,z=,dx=,dy=,dz=] run say hi
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on How to make dropped items change the weather?

    Here is the base command, run it in a repeating command block:

    /execute if entity @e[type=item,nbt={Item:{id:"minecraft:stick",tag:{display:{Name:'{"text":"clear"}'}}},OnGround:1b}] run weather clear

    I should also mention that the syntax for detecting the item name depends on how you name the item. Anvils use the format specified in the command (Name:'{"text":"clear"}') but if you generate the item using commands and use Name:"\"clear\"", then you have to use the same format in the command.

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