Skip to content

Commit

Permalink
⚡️ Optimize #bs.view:can_see_ata (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
aksiome authored Nov 13, 2024
1 parent 40451cd commit 10c1f40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,11 @@
# Documentation of the feature: https://bookshelf.docs.gunivers.net/en/latest/modules/view.html#can-see-as-to-at
# ------------------------------------------------------------------------------------------------------------

data modify storage bs:ctx _ set value {sx:"",sy:"",sz:""}
data modify storage bs:ctx _.pos set from entity @s Pos

data modify storage bs:ctx _.s set string storage bs:ctx _.pos[0] 0 1
execute if data storage bs:ctx _{s:"-"} run data modify storage bs:ctx _.x set string storage bs:ctx _.pos[0] 1 -1
execute unless data storage bs:ctx _{s:"-"} run data modify storage bs:ctx _.x set from storage bs:ctx _.pos[0]
execute unless data storage bs:ctx _{s:"-"} run data modify storage bs:ctx _.sx set value "-"

data modify storage bs:ctx _.s set string storage bs:ctx _.pos[1] 0 1
execute if data storage bs:ctx _{s:"-"} run data modify storage bs:ctx _.y set string storage bs:ctx _.pos[1] 1 -1
execute unless data storage bs:ctx _{s:"-"} run data modify storage bs:ctx _.y set from storage bs:ctx _.pos[1]
execute unless data storage bs:ctx _{s:"-"} run data modify storage bs:ctx _.sy set value "-"

data modify storage bs:ctx _.s set string storage bs:ctx _.pos[2] 0 1
execute if data storage bs:ctx _{s:"-"} run data modify storage bs:ctx _.z set string storage bs:ctx _.pos[2] 1 -1
execute unless data storage bs:ctx _{s:"-"} run data modify storage bs:ctx _.z set from storage bs:ctx _.pos[2]
execute unless data storage bs:ctx _{s:"-"} run data modify storage bs:ctx _.sz set value "-"

execute summon minecraft:marker run function bs.view:can_see_ata/max_distance/get_rpos with storage bs:ctx _
data modify storage bs:ctx _ set from entity @s Pos
data modify storage bs:ctx x set from storage bs:ctx _[0]
data modify storage bs:ctx y set from storage bs:ctx _[1]
data modify storage bs:ctx z set from storage bs:ctx _[2]
execute summon minecraft:marker run function bs.view:can_see_ata/max_distance/get_rpos with storage bs:ctx
function bs.view:can_see_ata/max_distance/compute with storage bs:ctx

execute facing entity @s eyes run function bs.raycast:run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
# For more details, refer to the MPL v2.0.
# ------------------------------------------------------------------------------------------------------------

$tp @s ~$(sx)$(x) ~$(sy)$(y) ~$(sz)$(z)
# Compute relative position
# Thanks to SilicatYT for sharing this trick on the Minecraft Commands discord
$execute rotated 180 90 run tp @s ^$(x) ^$(z) ^$(y)
data modify storage bs:ctx _ set from entity @s Pos
data modify storage bs:ctx x set from storage bs:ctx _[0]
data modify storage bs:ctx y set from storage bs:ctx _[1]
Expand Down

0 comments on commit 10c1f40

Please sign in to comment.