diff --git a/data/beeutility/functions/load.mcfunction b/data/beeutility/functions/load.mcfunction index b7e0f29..0903e75 100644 --- a/data/beeutility/functions/load.mcfunction +++ b/data/beeutility/functions/load.mcfunction @@ -1,3 +1,6 @@ +#region Initialize scoreboards scoreboard objectives add beeadult dummy scoreboard objectives add beebaby dummy -scoreboard objectives add beeamount dummy \ No newline at end of file +scoreboard objectives add beeamount dummy +scoreboard objectives add beeage dummy +#endregion \ No newline at end of file diff --git a/data/beeutility/functions/query.mcfunction b/data/beeutility/functions/query.mcfunction index 5c6abd1..febeb8d 100644 --- a/data/beeutility/functions/query.mcfunction +++ b/data/beeutility/functions/query.mcfunction @@ -1,8 +1,24 @@ execute store result score @s beeamount run data get block ~ ~ ~ Bees -execute store result score @s beeadult if data block ~ ~ ~ Bees[{EntityData:{Age:0}}] -scoreboard players operation @s beebaby = @s beeamount -scoreboard players operation @s beebaby -= @s beeadult +#region query "Bee 1"'s age +execute store result score @s beeage if data block ~ ~ ~ Bees[0].EntityData.Age run data get block ~ ~ ~ Bees[0].EntityData.Age +execute if data block ~ ~ ~ Bees[0].EntityData.Age if score @s beeage matches 0.. run scoreboard players add @s beeadult 1 +execute if data block ~ ~ ~ Bees[0].EntityData.Age if score @s beeage matches ..-1 run scoreboard players add @s beebaby 1 +#endregion +#region query "Bee 2"'s age +execute store result score @s beeage if data block ~ ~ ~ Bees[1].EntityData.Age run data get block ~ ~ ~ Bees[1].EntityData.Age +execute if data block ~ ~ ~ Bees[1].EntityData.Age if score @s beeage matches 0.. run scoreboard players add @s beeadult 1 +execute if data block ~ ~ ~ Bees[1].EntityData.Age if score @s beeage matches ..-1 run scoreboard players add @s beebaby 1 +#endregion +#region query "Bee 3"'s age +execute store result score @s beeage if data block ~ ~ ~ Bees[2].EntityData.Age run data get block ~ ~ ~ Bees[2].EntityData.Age +execute if data block ~ ~ ~ Bees[2].EntityData.Age if score @s beeage matches 0.. run scoreboard players add @s beeadult 1 +execute if data block ~ ~ ~ Bees[2].EntityData.Age if score @s beeage matches ..-1 run scoreboard players add @s beebaby 1 +#endregion title @s actionbar ["",{"text":"[蜜蜂助手] ","color":"gold"},{"score":{"name":"*","objective":"beeamount"}},"只蜜蜂,成年的",{"score":{"name":"*","objective":"beeadult"}},"只,幼年的",{"score":{"name":"*","objective":"beebaby"}},"只"] -scoreboard players set @a beeamount 0 +#region reset scoreboards +#shouldn't use "reset" operation, which may cause a null result +scoreboard players set @s beeamount 0 scoreboard players set @s beeadult 0 -scoreboard players set @s beebaby 0 \ No newline at end of file +scoreboard players set @s beebaby 0 +scoreboard players set @s beeage 0 +#endregion \ No newline at end of file diff --git a/data/beeutility/functions/tick.mcfunction b/data/beeutility/functions/tick.mcfunction index 6844168..ab63521 100644 --- a/data/beeutility/functions/tick.mcfunction +++ b/data/beeutility/functions/tick.mcfunction @@ -1 +1 @@ -execute as @a[predicate=beeutility:hold_glass_bottle] at @s anchored eyes positioned ^ ^ ^ anchored feet run function beeutility:ray +execute as @a[predicate=beeutility:hold_glass_bottle] at @s anchored eyes positioned ^ ^ ^ anchored feet run function beeutility:ray \ No newline at end of file