• 0

    posted a message on Can you stop Stackable Dropped items from stacking /grouping?

    If you summon the item with a pickupDelay of 32767 it will never be picked up and will not merge (I tested this myself).

    summon item ~ ~ ~ {PickupDelay:32767,Item:{id:"minecraft:red_wool",Count:1b}}

    Hope this helps and works for you!

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Repeat command until certain event happens

    Run this command in a tick function in your datapack or in a repeating command block:

    execute as @e[type=zombie] at @s unless entity @s[x=0,y=0,z=0] run tp @s ~ ~ ~0.05

    This will keep teleporting every zombie 0.05 blocks on the positive Z-axis until they're at exactly 0 0 0.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on How do you make a command that detects the winner in a certain area?

    First find the corner of your area with the lowest x, y, and z values (this should be in the north-west direction). Write down the coordinates of this location, as we'll be executing a command there to check for players in a cuboid region that always stretches off in the positive X Y Z directions.


    execute positioned 7 11 6 if entity @p[dx=20,dy=20,dz=20] run say A player has been found!

    The '7 11 6' is the lowest corner in your area. The value for 'dx' is the size of your room on the x-axis. 'dy' same thing for y and 'dz' same thing for z. The command that gets run here (so 'say A player has been found!') can be replaced with whatever you want the check to do. This command can then be run every tick in a datapack or through a repeating command block.


    Hope this helps!

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on How to detect an entity that looks at the player?

    You could do this with raycasting, but I just thought of another smart way to go about doing this.

    NOTE: The following commands are run by the armor stand (every tick).


    First, we take the current yaw and pitch (so the rotation values of the player) and store those in a scoreboard:

    scoreboard objectives add originalYaw dummy
    scoreboard objectives add originalPitch dummy
    execute store result score @s originalYaw run data get entity @s Rotation[0]
    execute store result score @s originalPitch run data get entity @s Rotation[1]

    Then we summon another invisible and marker armor stand at the position of the original armor stand like this:

    summon minecraft:armor_stand ~ ~ ~ {Marker:1b,Invisible:1b,Tags:["rotCheck"]}

    We can now force this 'rotCheck' armor stand to face the player. When that is done we can take that armor stand's yaw and pitch, so the yaw and pitch necessary for it to be looking at the player:

    execute as @e[tag=rotCheck] at @s facing entity @p eyes run tp @s ~ ~ ~ ~ ~
    scoreboard objectives add goalYaw
    scoreboard objectives add goalPitch
    execute store result score @s goalYaw run data get entity @e[tag=rotCheck,limit=1] Rotation[0]
    execute store result score @s goalPitch run data get entity @e[tag=rotCheck,limit=1] Rotation[1]

    Finally we can subtract originalYaw from goalYaw and originalPitch from goalPitch. This might give us negative values, however, so we'll account for that and convert negative values to positive ones.

    scoreboard objectives add distanceYaw
    scoreboard objectives add distancePitch
    execute store result score @s distanceYaw run scoreboard players operation @s originalYaw -= @s goalYaw
    execute store result score @s distancePitch run scoreboard players operation @s originalPitch -= @s goalPitch
    scoreboard objectives add Constants
    scoreboard players set -1 Constants -1
    
    execute if score @s distanceYaw matches ..0 run scoreboard players operation @s distanceYaw *= -1 Constants
    execute if score @s distancePitch matches ..0 run scoreboard players operation @s distancePitch *= -1 Constants

    After doing all that you have a positive value that indicates how many degrees of rotation the yaw and pitch of the player is from the degrees they would have when looking directly at the player. You can choose a range yourself and if the offset is within a small range you could assume they're pretty much looking at the player:

    execute if score @s distanceYaw matches ..10 if score @s distancePitch matches ..10 run say I am pretty much looking at the nearest player!

    All together you get this function that gets run by every armor stand every tick:

    #Scoreboard objectives
    scoreboard objectives add originalYaw dummy
    scoreboard objectives add originalPitch dummy
    scoreboard objectives add goalYaw
    scoreboard objectives add goalPitch
    scoreboard objectives add distanceYaw
    scoreboard objectives add distancePitch
    scoreboard objectives add Constants
    scoreboard players set -1 Constants -1
    
    #Store original yaw and pitch
    execute store result score @s originalYaw run data get entity @s Rotation[0]
    execute store result score @s originalPitch run data get entity @s Rotation[1]
    
    #Summon armor stand, face it towards the player and store its yaw and pitch
    summon minecraft:armor_stand ~ ~ ~ {Marker:1b,Invisible:1b,Tags:["rotCheck"]}
    execute as @e[tag=rotCheck] at @s facing entity @p eyes run tp @s ~ ~ ~ ~ ~
    execute store result score @s goalYaw run data get entity @e[tag=rotCheck,limit=1] Rotation[0]
    execute store result score @s goalPitch run data get entity @e[tag=rotCheck,limit=1] Rotation[1]
    
    #Compare the original and goal yaw and pitch and account for negative values
    execute store result score @s distanceYaw run scoreboard players operation @s originalYaw -= @s goalYaw
    execute store result score @s distancePitch run scoreboard players operation @s originalPitch -= @s goalPitch
    execute if score @s distanceYaw matches ..0 run scoreboard players operation @s distanceYaw *= -1 Constants
    execute if score @s distancePitch matches ..0 run scoreboard players operation @s distancePitch *= -1 Constants
    
    #Check if the result is within range offset
    execute if score @s distanceYaw matches ..10 if score @s distancePitch matches ..10 run say I am pretty much looking at the nearest player!
    
    #Kill the armor stand you used to check the rotation
    kill @e[tag=rotCheck]

    Hope this helps!

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Replacing mob sounds?

    Unless you replace an existing Minecraft mob and replace its sounds, I believe you'll indeed have to do this by hand (unless you use mods).


    Your current implementations are great, I don't think they can be optimized much more, but maybe I'm wrong.

    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on Making a stick give the levitation effect

    You can give the player a stick to use for this with a custom tag like so:

    give @p stick{levitation:1} 1

    Then you can add a custom advancement to a datapack (.json) with any name you want, I chose 'hurt_test.json'. The code is this:

    {
        "criteria": {
            "hurt": {
                "trigger": "minecraft:entity_hurt_player",
                "conditions": {
                    "damage": {
                        "type": {
                            "source_entity": {
                                "equipment": {
                                    "mainhand": {
                                        "item": "minecraft:stick",
                                        "tag": "levitation:1"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "rewards": {
            "function": "myepicdatapack:hurt_by_stick"
        }
    }

    The code checks if the player has been hurt by any entity (including other players), and checks if that entity was holding a stick with the 'levitation:1' tag. If this is all true it runs the function 'hurt_by_stick' from your datapack. Now you can add some code in that function:

    effect give @s levitation 5 2
    advancement revoke @s only myepicdatapack:hurt_test

    This function (ran when the advancement checking for damage with the stick is dealt) gives the effect for 5 seconds with an amplifier of 2 (can be changed between 0-255) and it removes the testing advancement from the player so that the method can be used again.


    I didn't have time to test all this myself, but everything should work. The only things that I'm uncertain about are the custom tags and the advancement.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Command where player drops their head...

    This is possible using loot tables, as we can ask those to insert a player's name into a player head's NBT. We first add a datapack to our world and in it add a folder called 'loot_tables', just like the folder 'functions'. In it we add a new loot_table file. You can give it any name you want, I went with drop_player_head.json. The file looks like this:


    {
        "type": "minecraft:chest",
    	"pools": [
    		{
    			"rolls": 1,
    			"entries": [
    				{
    					"type": "item",
    					"name": "minecraft:player_head",
    					"functions": [
    						{
    							"function": "minecraft:fill_player_head",
    							"entity": "this"
    						}
    					]
    				}
    			]
    		}
    	]
    }

    What this will do is it will set the loot to a player head and then fill the player head's SkullOwner NBT with the name of the entity who ran the loot function. We can then use this command to drop the head of any player at their position:

    /execute as JohnDoe54 at @s run loot spawn ~ ~ ~ loot MyEpicDatapack:drop_player_head

    Now for the part about doing this when a player is killed. It's quite difficult (without plugins or mods) to run a function accurately when a player is killed specifically by another player, but it is easy to do this when they die to anything, which could include another player. You could simply toggle this function on or off when the player is in or out of PVP to make it work properly.


    We first add a scoreboard that tracks the deathCount for every player:

    /scoreboard objectives add Deaths deathcount

    Then we detect if this value goes up for a player, in which case we run the loot command to drop the head and reset the counter. This following code has to be ran every tick, so use the datapack's built-in tick function to do this.

    execute as @a at @s if score @s Deaths matches 1.. run loot spawn ~ ~ ~ loot MyEpicDatapack:drop_player_head
    scoreboard players reset @a Deaths

    This should make a player drop their own head when they die.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Need help with a command (1.19)

    There were a lot of syntax issues in your command, I recommend using a command generator such as MCStacker next time, I fixed all the issues for you and it all works.



    give @p wither_skeleton_spawn_egg{EntityTag:{id:"minecraft:wither_skeleton",CustomName:'{"text":"Wither Boss"}',CustomNameVisible:1,Glowing:1,Health:100,Attributes:[{Name:"generic.max_health",Base:100},{Name:"generic.follow_range",Base:500},{Name:"generic.knockback_resistance",Base:0.49d},{Name:"generic.movement_speed",Base:0.4d},{Name:"generic.attack_damage",Base:2}],Fire:20,Silent:1,HandItems:[{id:"minecraft:diamond_sword",tag:{display:{Name:'{"text":"Fake Wither Sword (Trade)"}',Lore:['{"text":"vous devez donner cet item a un"}','{"text":"admin et il vous donnera le"}','{"text":"vrai item"}']},Enchantments:[{id:"knockback",lvl:2},{id:"fire_aspect",lvl:2}]},Count:1},{id:"minecraft:shield",tag:{display:{Name:'{"text":"Wither Shield"}',Lore:['{"text":"le bouclier maudit du wither..."}']},Enchantments:[{id:"unbreaking",lvl:3}]},Count:1}],HandDropChances:[2F,2F],ArmorItems:[{tag:{display:{Name:'{"text":"Bottes du Wither Boss"}',Lore:['{"text":"vous devez donner cet item a un"}','{"text":"admin et il vous donnera le"}','{"text":"vrai item"}']},Enchantments:[{id:"protection",lvl:4},{id:"unbreaking",lvl:3}]},Count:1,id:"minecraft:diamond_boots"},{tag:{display:{Name:'{"text":"Jambi\\\\u00e8re du Wither Boss"}',Lore:['{"text":"vous devez donner cet item a un"}','{"text":"admin et il vous donnera le"}','{"text":"vrai item"}']},Enchantments:[{id:"protection",lvl:4},{id:"unbreaking",lvl:3}]},Count:1,id:"minecraft:diamond_leggings"},{tag:{display:{Name:'{"text":"plastron du Wither Boss"}',Lore:['{"text":"vous devez donner cet item a un"}','{"text":"admin et il vous donnera le"}','{"text":"vrai item"}']},Enchantments:[{id:"protection",lvl:4},{id:"unbreaking",lvl:3}]},Count:1,id:"minecraft:diamond_chestplate"},{id:"minecraft:diamond_helmet",Count:1,tag:{display:{Name:'{"text":"Casque du Wither Boss"}',Lore:['{"text":"vous devez donner cet item a un"}','{"text":"admin et il vous donnera le"}','{"text":"vrai item"}']},Enchantments:[{id:"protection",lvl:4},{id:"unbreaking",lvl:3}]}}],ArmorDropChances:[2F,2F,2F,2F],ActiveEffects:[{Id:8,Amplifier:0,Duration:2147483647},{Id:24,Amplifier:0,Duration:2147483647}]}}

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on wall facing?

    You could make the command face a player like this and then use directional parameters (^) to place the wall in that direction.


    execute at @e[type=clumps:xp_orb_big] facing as @p[tag=thrower] run fill ^1 ^ ^ ^-1 ^2 ^ minecraft:gray_stained_glass

    This will copy the direction the player is looking at to the experience orb and make the experience orb place a wall in front of it in that direction.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Trying to program villager trades with custom written books 1.18-1.19

    If you use MCStacker with proper parameters (it also has a nice way to insert NBT into the selling field) it should all work perfectly, at least it did for me.

    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on 1.16.5, trying to make a command involving tags, yet removing a tag is not working?

    Hello! To me everything seems perfect, I even tried it myself and it works flawlessly. So you have these commands in a ticked function or repeating command blocks:


    /execute as @e[tag=NexusTestWaystone,tag=!inZone] at @s if entity @p[distance=..1] run tag @s add inZone
    /execute as @e[tag=NexusTestWaystone,tag=inZone] at @s unless entity @p[distance=..1] run tag @s remove inZone

    This works without problems, maybe you just made a small mistake when using the commands?

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on {command block} How do I make a rabbit, spawn every x amount of seconds.

    The first can be accomplished using repeaters and a command block to summon the rabbit, you can use the internet to calculate how many repeaters = how many seconds :)


    As for the second, Java Edition is just way better for this sort of stuff.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on fill mutiple dispensers with one command block

    You can use the /fill command for this, it's much more convenient.


    /fill x1 y1 z1 x2 y2 z2 dispenser{Items:[{Slot:0b,id:"minecraft:zombie_spawn_egg",Count:64b},{Slot:1b,id:"minecraft:zombie_spawn_egg",Count:64b},{Slot:2b,id:"minecraft:zombie_spawn_egg",Count:64b},{Slot:3b,id:"minecraft:zombie_spawn_egg",Count:64b},{Slot:4b,id:"minecraft:zombie_spawn_egg",Count:64b},{Slot:5b,id:"minecraft:zombie_spawn_egg",Count:64b},{Slot:6b,id:"minecraft:zombie_spawn_egg",Count:64b},{Slot:7b,id:"minecraft:zombie_spawn_egg",Count:64b},{Slot:8b,id:"minecraft:zombie_spawn_egg",Count:64b}]}
    Posted in: Creative Mode
  • 0

    posted a message on Changing Warden's Detection Range

    I believe this might work:


    /execute as @e[type=warden] run data merge entity @s {listener:{range:1}}

    Simply change the 1 to anything else and run this every tick using your datapack, this should then modify every warden in the world.

    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on Draining Item Durability Over Time

    You can store the player's starting armor damage in a score like this:

    /execute store result score @p durability run data get entity @p Inventory[{Slot:102b}].tag.Damage


    Of course, this is damage, not the durability value, but that does not matter for our use. You cannot directly modify the player's NBT (so their inventory), but you can other entities'. We will summon an armor stand holding an iron chestplate like so:

    /summon armor_stand ~ ~ ~ {Tags:["chestplate"],HandItems:[{id:"minecraft:iron_chestplate",Count:1b,tag:{Damage:1}},{}]}


    I gave it a damage value of 1 because then we can modify it (if there is no damage, we can't modify the value). We will now copy the scoreboard value to the damage of the armor stand's iron chestplate like this:

    /execute store result entity @e[tag=chestplate,limit=1] HandItems[0].tag.Damage int 1 run scoreboard players get @p durability


    Finally, we can copy the item from the armor stand to the player like so:

    /item replace entity @s armor.chest from entity @e[tag=chestplate,limit=1] weapon.mainhand


    Using all these commands and a simple command to decrease the durability value, you can do exactly that!

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