refactor: random fixes and usage improvements

This commit is contained in:
2025-02-17 17:01:23 -05:00
parent 8f2fbf11da
commit dde489a8ed
15 changed files with 203 additions and 90 deletions

View File

@@ -1,5 +1,5 @@
local center = { x = 0, z = 0 }
local radius = 50
local radius = 100
function on_tick()
local entities = client:find_entities(function(e)
@@ -15,6 +15,10 @@ function on_tick()
end
function on_init()
info("client initialized, setting client information")
info("client initialized, setting information...")
client:set_client_information({ view_distance = 16 })
end
function on_login()
info("player successfully logged in!")
end

38
lib/inventory.lua Normal file
View File

@@ -0,0 +1,38 @@
function steal(item_name)
for _, chest_pos in client:find_blocks(client.position, get_block_states({ "chest" })) do
client:chat(dump(chest_pos))
client:goto({ position = chest_pos, radius = 3 }, { type = RADIUS_GOAL })
while client.pathfinder.is_calculating or client.pathfinder.is_executing do
sleep(50)
end
client:look_at(chest_pos)
local container = client:open_container_at(chest_pos)
for index, item in container.contents do
if item.kind == item_name then
container:click({slot = index - 1}, THROW_ALL)
sleep(50)
end
end
container = nil
while client.open_container do
sleep(50)
end
end
end
function drop_all_hotbar()
local inventory = client:open_inventory()
for i = 0, 9 do
inventory:click({slot = 36 + i}, THROW_ALL)
end
end
function drop_all_inventory()
local inventory = client:open_inventory()
for i = 0, 45 do
inventory:click({slot = i}, THROW_ALL)
end
end

18
lib/movement.lua Normal file
View File

@@ -0,0 +1,18 @@
function look_at_player(name)
local player = get_player(name)
if player then
player.position.y = player.position.y + 1
client:look_at(player.position)
else
client:chat("player not found!")
end
end
function goto_player(name)
local player = get_player(name)
if player then
client:goto(player.position)
else
client:chat("player not found!")
end
end

View File

@@ -1,3 +1,17 @@
function get_player(name)
local target_uuid = nil
for uuid, player in client.tab_list do
if player.name == name then
target_uuid = uuid
break
end
end
return client:find_entities(function(e)
return e.kind == "minecraft:player" and e.uuid == target_uuid
end)[1]
end
function dump(object)
if type(object) == "table" then
local string = "{ "