Arqade Asked by SoupMoth _ on July 26, 2021
I’m making something that effects a person with the amplifier accordingly to what amount the score is.
(So if the score is 5 you get poison 5)
Is it possible to contain all of this in one command block without the use of redstone/comparators or functions
You would have to have to create a function or command block chain for this. Something like:
effect give @a[scores={<objective_name>=1}] minecraft:poison <duration> 0 true
effect give @a[scores={<objective_name>=2}] minecraft:poison <duration> 1 true
effect give @a[scores={<objective_name>=3}] minecraft:poison <duration> 2 true
(Effect amplifiers start at 0 in commands, an amplifier of 0 shows up as 1 in the status effect list on the side of your inventory screen, an amplifier of 1 shows up as 2, and so on...)
You might have been able to do this with only one command if /data
allowed modifying player data, but that might not ever be a feature...
Answered by savtoxgsc on July 26, 2021
If you don't need too many levels of poison, the previously posted answer is the best way to approach this. However, should you need upwards of 10 or so levels of poison, you could do something dynamic.
You'll need a second scoreboard objective for tracking the player's actual poison amplifier, which I've called poison_real
In a repeating chain, here's what you could do:
execute as @a store result score @s poison_real run data get entity @s ActiveEffects[{Id:19b}].Amplifier
effect give @a[scores={poison_level=1}] minecraft:poison 999999 0
(only applies when setting someone's score from 0 to 1)scoreboard players remove @a poison_level 1
execute as @a at @s unless entity @e[type=minecraft:area_effect_cloud,name="poison_cloud",distance=..0.1] unless score @s poison_level = @s poison_real run effect clear @s minecraft:poison
execute as @a[scores={poison_level=0..}] at @s unless score @s poison_level = @s poison_real run summon minecraft:area_effect_cloud ~ ~ ~ {Radius:0.1f,CustomName:'"poison_cloud"',Duration:7b,Effects:[{Id:19b,Amplifier:0,Duration:999999}]}
execute as @e[type=minecraft:area_effect_cloud,name="poison_cloud"] at @s store result entity @s Effects[{Id:19b}].Amplifier int 1 run scoreboard players get @p poison_level
scoreboard players add @a poison_level 1
This chain detects a change in the poison_level
score, and if there is a change, it summons an area effect cloud with an Amplifier of the player's poison_level
.
Answered by bubster20 on July 26, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP