👀 视线(View)#

#bs.view:help

根据实体看到的内容执行命令。

../../_images/view.png

“愿景是看到事物可能的样子,而不是现在的样子。”

—格雷琴·鲁宾(Gretchen Rubin)


🔧 函数#

你可以在下方找到此模块中的所有可用函数。


Aimed block#

#bs.view:at_aimed_block {run:<command>,with:{}}

在实体瞄准的方块处执行命令,并自动对齐坐标(align xyz)。

输入:

Execution as <entities>: entity whose eyes determine the vision origin

函数宏

  • arguments

    • run: command to run at the targeted block position

    • with: optional settings (see advanced usage below)

Example: change the block you are looking at

# Once (will run if you are targeting a block)
function #bs.view:at_aimed_block {run:"setblock ~ ~ ~ minecraft:sponge",with:{}}
Advanced usage

该系统是 #bs.raycast:run 函数的简化特定用例。它内部依赖于该函数,允许你读取其输出,并通过修改其输入来灵活地改变其行为。详见此处

Avoid advancements

此函数可以placed_block 进度一起使用来检测方块放置,但由于与 Minecraft 原生检测相比可能存在精度差异,不推荐这样做。此外,同一游戏刻内快速移动鼠标可能导致瞄准错误的方块。

制作人员:Aksiome


Aimed entity#

#bs.view:as_aimed_entity {run:<command>,with:{}}

以当前实体瞄准的实体为执行者执行指令。

输入:

Execution as <entities>: entity whose eyes determine the vision origin

函数宏

  • arguments

    • run: command to run as the targeted entity

    • with: optional settings (see advanced usage below)

Example: run a command as the entity you are looking at

# Once (will run if you are targeting an entity)
function #bs.view:as_aimed_entity {run:"say I am sorry, are you hitting on me?",with:{}}
#bs.view:at_aimed_entity {run:<command>,with:{}}

以当前实体瞄准的实体为执行位置执行指令。

输入:

Execution as <entities>: entity whose eyes determine the vision origin

函数宏

  • arguments

    • run: command to run at the targeted entity

    • with: optional settings (see advanced usage below)

Example: run a command at the entity you are looking at

# Once (will run if you are targeting an entity)
function #bs.view:at_aimed_entity {run:"particle minecraft:heart ~ ~2 ~ 0 0 0 0 1",with:{}}
Advanced usage

该系统是 #bs.raycast:run 函数的简化特定用例。它内部依赖于该函数,允许你读取其输出,并通过修改其输入来灵活地改变其行为。详见此处

Performance tip

In Minecraft, predicates can check if a player is looking at an entity. If you only need a simple player-specific check, you should consider using the looked entity functions.

制作人员:Aksiome


Aimed point#

#bs.view:at_aimed_point {run:<command>,with:{}}

在射线命中的终点处执行命令。

输入:

Execution as <entities>: entity whose eyes determine the vision origin

函数宏

  • arguments

    • run: command to run at the hit point

    • with: optional settings (see advanced usage below)

Example: run a command at the point you are looking at

# Once (will run if you are aiming at a solid block or entity)
function #bs.view:at_aimed_point {run:"particle minecraft:flame ~ ~ ~ 0 0 0 0 1 force",with:{}}
Advanced usage

该系统是 #bs.raycast:run 函数的简化特定用例。它内部依赖于该函数,允许你读取其输出,并通过修改其输入来灵活地改变其行为。详见此处

制作人员:Aksiome


Block placement#

#bs.view:at_block_placement {run:<command>,with:{}}

根据方块的碰撞箱和其法线方向,精确地得到放置方块的位置,并对齐坐标(align xyz),执行命令。

输入:

Execution as <entities>: entity whose eyes determine the vision origin

函数宏

  • arguments

    • run: command to run at the block placement position

    • with: optional settings (see advanced usage below)

Example: set a block as if the player was placing it

# Once (will run if you are targeting a block)
function #bs.view:at_block_placement {run:"setblock ~ ~ ~ minecraft:sponge",with:{}}
Advanced usage

该系统是 #bs.raycast:run 函数的简化特定用例。它内部依赖于该函数,允许你读取其输出,并通过修改其输入来灵活地改变其行为。详见此处

制作人员:Aksiome


Can see “as to at”#

#bs.view:can_see_ata {with:{}}

验证从实体当前位置到执行位置之间能否被视线穿过。

输入:

Execution as <entities>: entities to check

Execution at <entity> or positioned <x> <y> <z>: position to check for visibility

函数宏

  • arguments

    • with: optional settings (see advanced usage below)

输出:

Return: whether the check is successful (1 or 0)

Example: see if the nearest entity is able to see you

# Once

execute at @s as @e[distance=0.1..,sort=nearest,limit=1] store result score #result bs.data run function #bs.view:can_see_ata {with:{}}
execute if score #result bs.data matches 1 run say You're not hiding very well...
Advanced usage

该系统是 #bs.raycast:run 函数的简化特定用例。它内部依赖于该函数,允许你读取其输出,并通过修改其输入来灵活地改变其行为。详见此处

制作人员:Aksiome、Leirof


In view “as to at”#

#bs.view:in_view_ata {angle:<value>}

判断某个位置是否在实体的视野范围(从实体眼睛发出的锥体)内。

输入:

Execution as <entities>: entities whose field of view is being checked

Execution at <entity> or positioned <x> <y> <z>: position to check if within the field of view cone

函数宏

  • arguments

    • angle: angle of the field of view cone, based on world coordinates (not the fov option)

输出:

Return: whether the check is successful (1 or 0)

Example: check whether the position 0 5 0 is in your field of view

# Once
execute as @s positioned 0 5 0 run function #bs.view:in_view_ata {angle:90}

制作人员:Aksiome、Leirof


Looked entity#

#bs.view:as_looked_entity {run:<command>}

以玩家正在看着的实体为执行者执行命令。

输入:

Execution as <players>: player whose eyes determine the vision origin

函数宏

  • arguments

    • run: command to run as the looked at entity

Tag bs.view.is_lookable: tag that must be added to entities that can be looked at

Example: make the armor stand the player is looking at glow

# Once
tag @e[type=minecraft:armor_stand] add bs.view.is_lookable
function #bs.view:as_looked_entity {run:"effect give @s minecraft:glowing 1 0 true"}
#bs.view:at_looked_entity {run:<command>}

在玩家正在看着的实体处执行命令。

输入:

Execution as <players>: player whose eyes determine the vision origin

函数宏

  • arguments

    • run: command to run at the looked at entity

Tag bs.view.is_lookable: tag that must be added to entities that can be looked at

Example: summon particles at the armor stand the player is looking at

# Once
tag @e[type=minecraft:armor_stand] add bs.view.is_lookable
function #bs.view:at_looked_entity {run:"particle minecraft:crit ~ ~2 ~ 0 0 0 0 1"}

Technical limitations

由于此函数依赖于特定于玩家的谓词,它专门为玩家设计。此外,为了优化性能,同时只允许最多255个实体拥有 bs.view.is_lookable 标签。

制作人员:Aksiome


🏷️ 标签#

You can find below all tags available in this module.


Can see through#

#bs.view:can_see_through

确定方块能否被视线穿透。

制作人员:Aksiome


💬 这对你有帮助吗?

欢迎在下方留下你的问题和反馈!