Skip to content

Instantly share code, notes, and snippets.

@appgurueu
Created June 6, 2022 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save appgurueu/2a4c800efffe6c0bc63bed98b46995d5 to your computer and use it in GitHub Desktop.
Save appgurueu/2a4c800efffe6c0bc63bed98b46995d5 to your computer and use it in GitHub Desktop.
Minetest: Redo tool raycast
local eye_pos = player:get_pos()
eye_pos.y = eye_pos.y + player:get_properties().eye_height
local first, third = player:get_eye_offset()
if not vector.equals(first, third) then minetest.log("warning", "First & third person eye offsets don't match, assuming first person") end
eye_pos = vector.add(eye_pos, vector.divide(first, 10))
local def = player:get_wielded_item():get_definition()
for pointed_thing in minetest.raycast(eye_pos, vector.add(eye_pos, vector.multiply(player:get_look_dir(), def.range or 4)), true, def.liquids_pointable) do if pointed_thing.ref ~= player then --[[do something]] end end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment