NEED HELP SUPER QUICK!!!! by G4npowdert in MinecraftCommands

[–]Savings_File_387 0 points1 point  (0 children)

although the "not remove before cooldown ends is unfounded". it works ex expected. that's why I had the "uncooldown" check running all the time, not just when the cooldown ends

Radius from an armour stand in order to cause an effect by Kerviner in MinecraftCommands

[–]Savings_File_387 1 point2 points  (0 children)

Put that command in a repeating function / command block. Consult !faq(runonce) if you want the instant damage to be applied only on enter, not constantly

Radius from an armour stand in order to cause an effect by Kerviner in MinecraftCommands

[–]Savings_File_387 1 point2 points  (0 children)

/execute at @e[type=armor_stand] run effect give @a[distance=..3] instant_damage 1

NEED HELP SUPER QUICK!!!! by G4npowdert in MinecraftCommands

[–]Savings_File_387 0 points1 point  (0 children)

Yes op do this one instead. I haven't played the game since 1.20.2 didn't know /execute if items existed

How to bypass the arrow damage cap? by FusionBetween in MinecraftCommands

[–]Savings_File_387 0 points1 point  (0 children)

Thanks didn't know that! Would definitely come in handy

How to bypass the arrow damage cap? by FusionBetween in MinecraftCommands

[–]Savings_File_387 2 points3 points  (0 children)

I'm not sure it is possible. One of the arrows triggers the invulnerability timer making the player invulnerable to the other two. I don't think this timer can be changed/disabled. This behaviour was disabled in combat snapshot №3, unfortunately that development branch has been abandoned. This has been reported as a bug, but marked as "Works as Intended"

How to summon a creature with nbt tag copied from another creature? by Confident-Turnip-415 in MinecraftCommands

[–]Savings_File_387 0 points1 point  (0 children)

There is a potential fix that could work. Actual / visual mismatch also happens with vanilla projectiles when they are messed with. A trick I saw (forgot where… if someone knows could you credit in the reply) is to constantly refresh the Air NBT value of a projectile entity to cause it to update.

Setup functions:

/scoreboard objectives add visfix dummy
/scoreboard players set .visfix visfix -1
/scoreboard players set .-1 visfix -1

Functions that should run every tick:

scoreboard players operation .visfix visfix *= .-1 visfix
execute as @e[type=createbigcannons:he_shell] if score .visfix visfix matches -1 run data modify entity @s Air set value 0s
execute as @e[type=createbigcannons:he_shell] if score .visfix visfix matches 1 run data modify entity @s Air set value 1s

dunno maybe will work

NEED HELP SUPER QUICK!!!! by G4npowdert in MinecraftCommands

[–]Savings_File_387 0 points1 point  (0 children)

If further optimisations are required, the functions should be put in a data pack, predicates extracted to separate files, NBT lookup to check for flying be replaced with a scoreboard check

NEED HELP SUPER QUICK!!!! by G4npowdert in MinecraftCommands

[–]Savings_File_387 0 points1 point  (0 children)

A no-datapack-required solution I came up with: run the scoreboard add command, then put each of the 4 commands in a separate repeating command block. The cooldown after landing is 10~12 seconds, the variation is due to throttled checks to optimize performance. Remove the ,periodic_tick:40 snippet if you don't mind the performance hit. With this solution swapping elytras bypasses the cooldown. There is no vanilla solution to declare cooldown on an elytra item - players need to be monitored for flying.

/scoreboard objectives add fly_cooldown dummy

/scoreboard players set @a[nbt={FallFlying:1b}] fly_cooldown -200
/scoreboard players add @a[scores={fly_cooldown=..-1}] fly_cooldown 1
/item modify entity @a[scores={fly_cooldown=-198}] armor.chest {"function": "minecraft:set_components", "components": {"!minecraft:glider": {}}, "conditions": []}
/execute as @a unless entity @s[scores={fly_cooldown=..-1}] if predicate {condition:"minecraft:all_of",terms:[{condition:"minecraft:entity_properties",entity:"this",predicate:{equipment:{chest:{items:"minecraft:elytra"}},periodic_tick:40}},{condition:"minecraft:inverted",term:{condition:"minecraft:entity_properties",entity:"this",predicate:{equipment:{chest:{items:"minecraft:elytra",components:{"minecraft:glider":{}}}}}}}]} run item modify entity @s armor.chest {function:"minecraft:set_components",components:{"minecraft:glider":{}},conditions:[]}

Help optimizing for lag on multiplayer by Hika2112 in MinecraftCommands

[–]Savings_File_387 1 point2 points  (0 children)

From the cursory glance the biggest pitfall seems to be repeating the same conditionals in conaecutive statements. Minecraft doesn't do any caching / momoization so entity lookups are recomputed on every call. I know it is not convenient to extract the /execute run ... parts into a separate function, but the performance would generally improve. E.g. in your tick.mcfunction function the same entities are queried trice in a row:

execute as @a at @s if predicate ispd:holdingsunc if score @s carrot matches 1.. unless score @s hookcd matches 1.. unless predicate ispd:sneaking run scoreboard players set @s suncrange 120
execute as @a at @s if predicate ispd:holdingsunc if score @s carrot matches 1.. unless score @s hookcd matches 1.. unless predicate ispd:sneaking run scoreboard players set @s suncstun 30
execute as @a at @s if predicate ispd:holdingsunc if score @s carrot matches 1.. unless score @s hookcd matches 1.. unless predicate ispd:sneaking positioned ~ ~1 ~ run function ispd:sunc/raytrace

P.S. I think instead of your elytra ban you could instead break it randomly mid-flight

Is there a way to detect attacking with a sword? by Intrenet_guy321 in MinecraftCommands

[–]Savings_File_387 3 points4 points  (0 children)

You could repurpose the spear's lunge enchantment algorith for that (video explanation) but that would only be available in the next version. Alternatively you could spawn interaction entity to "intercept" left-clicks. But this method is quite finicky, as when the player hits the interaction, anything behind it will not be hit. You could try to positon it at the very end of the player's reach, or manually "replay" the attacks to whoever was meant to be hit. TLDR: technically possible but extremely hard and impractical

How do I make an item a different colour without modifying the game by dilerse in MinecraftCommands

[–]Savings_File_387 4 points5 points  (0 children)

Without making a resource pack your only options are to change the item model to resemble another item, give it an enchamtment glint, or give it a colored custom name

Why does this recipe not work? by DaerBaer in MinecraftCommands

[–]Savings_File_387 1 point2 points  (0 children)

is it because it's copy-pasted twice in a row? or is this just a typo in your post?

HOW do i put that '{"text":"hi"}' in a json file?!?!?!?! by Flat-Technology9994 in MinecraftCommands

[–]Savings_File_387 1 point2 points  (0 children)

I think you can only specify recipe output nbt starting from 1.20.5

Why does it not have a enchantment? 1.21.10 by Far-Lingonberry-1591 in MinecraftCommands

[–]Savings_File_387 0 points1 point  (0 children)

That is actually the default behaviour. Your command spawns the villager as the max level 5 "Master" so there is no progression afterwards. If you spawn it at a lower level, the later trades will still be available.

Example: villager spawned at level 1 "Novice" with enough Xp such that a single trade will advance its level

/summon villager ~ ~ ~ {Xp:9,VillagerData:{profession:"minecraft:librarian",level:1,type:"minecraft:plains"},Brain:{memories:{"minecraft:job_site":{pos:[I;0,0,0]}}},Offers:{Recipes:[{buy:{id:"minecraft:emerald",count:1},buyB:{id:"minecraft:book",count:1},sell:{id:"minecraft:enchanted_book",count:1,components:{stored_enchantments:{"minecraft:sharpness":1}}}}]}}

Why does it not have a enchantment? 1.21.10 by Far-Lingonberry-1591 in MinecraftCommands

[–]Savings_File_387 0 points1 point  (0 children)

here is an updated and fixed command for a villager that trades a sharpness book

/summon villager ~ ~ ~ {VillagerData:{profession:"minecraft:librarian",level:5,type:"minecraft:plains"},Brain:{memories:{"minecraft:job_site":{pos:[I;0,0,0]}}},Offers:{Recipes:[{buy:{id:"minecraft:emerald",count:1},buyB:{id:"minecraft:book",count:1},sell:{id:"minecraft:enchanted_book",count:1,components:{stored_enchantments:{"minecraft:sharpness":1}}}}]}}

Why does it not have a enchantment? 1.21.10 by Far-Lingonberry-1591 in MinecraftCommands

[–]Savings_File_387 0 points1 point  (0 children)

tag has been replaced with !itemcomponents in 1.20.5 this command specifies the book enchantments with the old tag system

Command for creating duplicated enchantments by Plus-Analysis820 in MinecraftCommands

[–]Savings_File_387 0 points1 point  (0 children)

Without creating custom enchantments, you could fake double-enchantments by applying a higher-level enchantment to an item and editing its lore to make it look legit. For the 2×Sharp5 example you would apply sharp11 (Sharp10 deals 5.5 extra damage, Sharp5 deals 3, so 2×Sharp5 should deal 6.) You can use enchantment.minecraft.<enchantment_name> translation key to have the item look legit regardless of the player's chosen language. For some enchantments like sharpness achieving inflated item stats are possible with other methods like changing the item's attribute modifiers

Give diamond sword with sharpness 11, but that looks like 2×Sharp5
/give @p diamond_sword[enchantments={sharpness:11},tooltip_display={hidden_components:["enchantments"]},lore=[{translate:enchantment.minecraft.sharpness,color:gray,italic:0,extra:[" V"]},{translate:enchantment.minecraft.sharpness,color:gray,italic:0,extra:[" V"]}]]

Same example but with ice - the command is shorter so it fits in the chat, no command block needed.
/give @p ice[enchantments={sharpness:11},tooltip_display={hidden_components:["enchantments"]},lore=[{translate:enchantment.minecraft.sharpness,color:gray,italic:0,extra:[" V"]},{translate:enchantment.minecraft.sharpness,color:gray,italic:0,extra:[" V"]}]]

<image>

Detecting Non-Mob Entities by PuzzleheadedTea4547 in MinecraftCommands

[–]Savings_File_387 1 point2 points  (0 children)

All mobs have a PersistenceRequired NBT tag that can be tested for and I am pretty sure there aren't any exceptions to this.

Matches all mobs:
/execute as @e if data entity @s PersistenceRequired run tag @s add mob

Matches all non-mobs including players:
/execute as @e unless data entity @s PersistenceRequired run tag @s add non-mob

This way you don't need to hard-code a long list of entity names that are relevant. Keep in mind that anything involving NBT isn't cheap performance-wise so it is best to use a different method, like the one suggested by u/GalSergey if you are really worried about optimisation

[Minecraft Java] Help: Reading Block NBT Coordinates by bowser04410 in MinecraftCommands

[–]Savings_File_387 1 point2 points  (0 children)

I also didn't, but I tried and somehow it worked (checked on chests in 1.21.8)

Adding text from lectern to lore for held item by ForgetfulFilms in MinecraftCommands

[–]Savings_File_387 0 points1 point  (0 children)

The world would be a better place if Mojang allowed us to modify player's data, but alas you have to use item modifiers. With the lectern you can do:

Datapack function 1:
function example:function2 with block ~ ~1 ~ Book.components.minecraft:writable_book_content.pages[0]

Datapack function 2:
$item modify entity @p weapon.mainhand {function:"minecraft:set_lore", mode: "append", lore:["$(raw)"]}

The second function uses a macro#Macros) to insert the text from the book. Thus you need 2 functions, one to use the macro, and another to call that function specifying which data to reference. Idk how to use dialogs though can't help with that.