World & Entities
The world API gives access to the current dimension and its entities. The targeting API reads the player’s crosshair result and fires raycasts.
Guards
Section titled “Guards”Always check world.is_present before reading world state:
return unless world.is_presentworld.is_present # => Booleanworld.get_dimension # => String e.g. "minecraft:overworld"world.get_time # => Integer world tick timeworld.is_raining # => Booleanworld.get_player_count # => Integerworld.get_entity_count # => IntegerFetching entities
Section titled “Fetching entities”world.get_players # => Array of entity objects (players only)world.get_entities # => Array of entity objects (all entities)world.get_entity(id) # => entity object or nilEntity Object
Section titled “Entity Object”Every entity object returned by world.get_players, world.get_entities, world.get_entity, or targeting has the following.
Fields (direct access, no call needed)
Section titled “Fields (direct access, no call needed)”| Field | Type | Description |
|---|---|---|
id | Integer | Entity ID |
name | String | Name string |
display_name | String | Formatted display name |
type | String | Entity type identifier |
x, y, z | Float | Current position |
eye_y | Float | Eye-level Y |
last_x, last_y, last_z | Float | Previous tick position |
yaw, pitch | Float | Rotation |
width, height | Float | Hitbox dimensions |
alive | Boolean | true if not dead |
removed | Boolean | true if removed from world |
invisible | Boolean | |
player | Boolean | true if this is a player entity |
Methods
Section titled “Methods”entity.get_id # => Integerentity.get_uuid # => Stringentity.get_name # => Stringentity.get_display_name # => Stringentity.get_type # => Stringentity.get_x # => Floatentity.get_y # => Floatentity.get_z # => Floatentity.get_eye_y # => Floatentity.get_last_x # => Float (previous tick)entity.get_last_y # => Floatentity.get_last_z # => Floatentity.get_yaw # => Floatentity.get_pitch # => Floatentity.get_width # => Float hitbox widthentity.get_height # => Float hitbox heightentity.get_distance # => Float distance from local player; -1 if no local playerentity.get_health # => Float or nil (nil for non-living entities)entity.get_max_health # => Float or nilentity.get_hurt_time # => Integer or nil frames since last hit
entity.is_player # => Booleanentity.is_living # => Booleanentity.is_hostile # => Booleanentity.is_passive # => Booleanentity.is_alive # => Booleanentity.is_removed # => Booleanentity.is_attackable # => Booleanentity.is_invisible # => Booleanentity.is_friend # => Boolean (Epitaph friends list)entity.is_teammate # => Boolean (Teams feature)entity.is_bot # => Boolean (AntiBot feature)Iterating safely
Section titled “Iterating safely”Always guard for nil, dead, and removed entities:
world.get_players.each do |entity| next if entity.nil? next unless entity.alive next if entity.removed # ...endtargeting
Section titled “targeting”These methods check mc().crosshairTarget directly. None of them take arguments.
targeting.get_type # => "entity", "block", or "miss"targeting.is_entity # => Booleantargeting.is_block # => Booleantargeting.is_miss # => Booleantargeting.get_entity # => entity object or niltargeting.get_block # => block hit object or niltargeting.get returns the full hit result table:
hit = targeting.get# hit.type => "entity", "block", or "miss"# hit.is_entity => Boolean# hit.is_block => Boolean# hit.is_miss => Boolean# hit.x, hit.y, hit.z => Float exact hit position# hit.entity => entity object (when is_entity)# hit.entity_id => Integer (when is_entity)# hit.block => block hit object (when is_block)Block hit object
Section titled “Block hit object”block = targeting.get_block# block.x, block.y, block.z => Integer block position# block.side => String face name: "up", "down", "north", "south", "east", "west"# block.hit_x, block.hit_y, block.hit_z => Float exact cursor position on the faceRaycasts
Section titled “Raycasts”# reach: Float distance# yaw, pitch: optional Float overrides (default: player's current rotation)targeting.raycast(reach) # => hit result or niltargeting.raycast(reach, yaw, pitch) # => hit result or niltargeting.raycast_through_walls(reach) # => hit result or niltargeting.raycast_through_walls(reach, yaw, pitch)Example — entity list HUD
Section titled “Example — entity list HUD”script = { name: "Nearby Players", description: "Lists nearby players on screen.", category: "RENDER",
on_load: lambda do mod.register_double_setting("Max Distance", 32.0, 1.0, 128.0, 1.0) end,
on_render_2d: lambda do |event| return unless player.is_present && world.is_present
max_dist = mod.get_setting_value("Max Distance") || 32.0 self_id = player.get_id white = render.color(255, 255, 255, 255) y = 8
world.get_players.each do |entity| next if entity.nil? || !entity.alive || entity.removed next if entity.id == self_id next if entity.get_distance > max_dist
render.text("#{entity.name} #{entity.get_distance.round(1)}m", 8, y, white, true) y += 10 end end}Example — block targeting
Section titled “Example — block targeting”script = { name: "Block Info", description: "Shows targeted block coords in chat on key press.", category: "MISC",
on_key: lambda do |event| return unless event.pressed return unless targeting.is_block
block = targeting.get_block client.message("Block at #{block.x}, #{block.y}, #{block.z} side: #{block.side}") end}