Skip to content

Instantly share code, notes, and snippets.

@Longor1996
Last active August 22, 2017 17:09
Show Gist options
  • Save Longor1996/c404c4c99775d445a151dc401be5c5e2 to your computer and use it in GitHub Desktop.
Save Longor1996/c404c4c99775d445a151dc401be5c5e2 to your computer and use it in GitHub Desktop.

Here are four command suggestions, changed to be distinct from each other and reasonably simple to implement.

The commands are specialized towards the view-direction and field-of-view of entities.


raycast

/raycast <distance> <accuracy> <chained command>

Given the current entity @s, shoot a ray out of its eyes, with the given accuracy, and execute the chained command at the position of whatever was hit (block or entity). If no block or entity has been hit, or we reached the maximum distance, return a result of 0.

  • The accuracy argument is a value between 0 (ray goes anywhere within the FoV) and 1 (maximum accuracy).

  • Optional: A face argument that can be one of forward, backward, left, right, up or down, that changes in which direction the ray is fired, instead of always firing out of the entities eyes.

  • Optional: Add a parameter to specify the amount of rays to be shot.

raymarch

/raymarch <face> <distance> [skip_air] <chained command>

Given the current entity @s, march along a ray out of its eyes and execute the chained command for every block that it passes, using @s with a different position, until it hits the distance limit. It returns the number of blocks it executed the command at.

  • The skip_air argument makes the command skip air blocks.

  • Optional: A face argument that can be one of forward, backward, left, right, up or down, that changes in which direction the ray is fired, instead of always firing out of the entities eyes.

raytrace

/raytrace <entity> <chained command>

Given the current entity @s, trace a ray from its head, to every selected entity, and execute the chained command at its position, but only if the ray does not hit any blocks. Returns the count of successfull traces.

in_fov / in-fov

A command that tests if some entity is in the Field-Of-View of another entity.

The are two possible versions of this command.

Version A: /in_fov <entity> <chained command>

With this version, the chained command will only be executed if the selected entity is within the Field-Of-View of the @s.

Version B: /in_fov <entity>

With this version, the command will return a value of 1 if the selected entity is within the Field-Of-View of the @s entity, and 0 if not. If @s does not have a FoV, return 0.


Tell me what you think!

Final Note: These commands are not particularly hard to implement, with most of the groundwork already being in place (judging from the MCP-decompiled Minecraft code). The biggest problem is getting free time to add them (that is: implementing, documenting, unit testing(?) and bug fixing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment