Skip to content

Commit

Permalink
Fixed a critical bug
Browse files Browse the repository at this point in the history
Age为非负数的都是成年蜜蜂
  • Loading branch information
lakejason0 authored Jan 25, 2020
1 parent 4e41907 commit c648c67
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
5 changes: 4 additions & 1 deletion data/beeutility/functions/load.mcfunction
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#region Initialize scoreboards
scoreboard objectives add beeadult dummy
scoreboard objectives add beebaby dummy
scoreboard objectives add beeamount dummy
scoreboard objectives add beeamount dummy
scoreboard objectives add beeage dummy
#endregion
26 changes: 21 additions & 5 deletions data/beeutility/functions/query.mcfunction
Original file line number Diff line number Diff line change
@@ -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
scoreboard players set @s beebaby 0
scoreboard players set @s beeage 0
#endregion
2 changes: 1 addition & 1 deletion data/beeutility/functions/tick.mcfunction
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c648c67

Please sign in to comment.