自动伐木 woodcutting

英文名称 woodcutting
中文名称
作者 bell07 - ContentDB
语言 英语
版本 Minetest Minetest Version: 5.5.0
依赖Mode或插件
Mode类型
开源协议
视频 https://www.bilibili.com/video/BV1Za411X7GA/
代码仓库 https://github.com/minetest-mods/woodcutting
下载地址 Woodcutting - ContentDB
简历 在按下潜行键开始伐木过程时,从树中挖掘第一个树节点。

这个 mod 是一个用于 minetest 的异步砍树机。按下潜行键时从树中挖掘第一个树节点,然后等到整个树被分解并进入您的库存。

截屏

亮点/特点

  • 没有滞后,因为工作不是立即完成的。可以观察木刻。
  • 您可以通过第二次潜行键停止木刻
  • 适用于所有树木。切割只是跟随每个切割节点的所有方向的连接树(树干)块并将它们添加到处理队列中
  • 您可以通过手动挖掘其他树节点来添加其他树进行处理(无需潜行键)
  • 到玩家的距离用于偏好下一个节点,因此玩家可以部分影响大区域的工作方向
  • 自动采矿速度取决于使用的工具,因此金刚石斧头仍然比空手有利
  • 处理所有检查和功能(如饥饿伤害和工具磨损),就像玩家手动进行采矿一样
  • 结合 item_drop mod 效果真的很好
  • 是否适用于项目组“tree”和“leafdecay”叶子和果实中的所有树木
  • 有关木刻过程状态的简单 HUD 消息(如果处于活动状态)
  • 对于开发人员 - 增强 API

开发者笔记

该模组确实有一些设置、挂钩和对象样式 API,用于游戏或其他模组相关的增强功能。

(默认设置

woodcutting.settings = {
	tree_distance = 1,    -- Apply tree nodes with this distance to the queue. 1 means touching tree nodes only
	leaves_distance = 2,  -- do not touch leaves around the not removed trees with this distance
	player_distance = 80, -- Allow cutting tree nodes with this maximum distance away from player
	dig_leaves = true,    -- Dig dacayable leaves after tree node is digged - can be changed trough woodcutting_dig_leaves in minetest.conf
	wear_limit = 65535,   -- Maximum tool wear that allows cutting
}

挂钩

woodcutting.settings = {
	on_new_process_hook = function(process) return true end, -- do not start the process if set to nil or return false
	on_step_hook = function(process) return true end,        -- if false is returned finish the process
	on_before_dig_hook = function(process, pos) return true end, -- if false is returned the node is not digged
	on_after_dig_hook = function(process, pos, oldnode) return true end, -- if false is returned do nothing after digging node

过程对象

这些钩子在接口中获取一个 lua 对象,这意味着一个具有函数和设置属性的 lua 表。这些方法可以在 on_new_process_hook() 函数中重新定义。这意味着不同用户可以同时使用不同的实现。

属性

请参阅(默认)设置

  • process.tree_distance - 在 process:add_tree_neighbors(pos) 中使用 - 可以在 on_after_dig_hook() 中调整每个步骤
  • process.leaves_distance - 在 process:process_leaves(pos) 中使用 - 可以在 on_after_dig_hook() 中调整每个步骤
  • process.player_distance - 在 process:check_processing_allowed(pos) 中使用 - 可以在 on_step_hook() 中调整每个步骤
  • process.dig_leaves - 在 on_dignode 函数结束时使用 - 可以在 on_after_dig_hook() 中调整每个步骤
  • process.wear_limit - 在 process:check_processing_allowed(pos) 中使用 - 可以在 on_step_hook() 中调整每个步骤

方法

注意:这个方法可以在 on_new_process_hook 中重新定义,对于每个新进程以不同的方式

  • process:stop_process() - 结束进程
  • process:add_tree_neighbors(pos) - 将近树节点添加到处理列表
  • process:get_delay_time(pos) - 获取在 pos 处挖掘节点的延迟时间
  • process:check_processing_allowed(pos) - 检查是否允许在 pos 处砍树
  • process:select_next_tree_node() - 从处理列表中获取下一个节点
  • process:process_woodcut_step() - 处理步骤。不应重新定义 - 改用 on_step_hook
  • process:woodcut_node(pos, delay) - 切割树或叶子节点 - 不应该重新定义 - on_before_dig_hook
  • process:process_leaves(pos) - 处理在挖掘的 pos 周围的叶子
  • process:get_hud_message(pos) - 获取 HUD 消息
  • process:show_hud(pos) - 使用 get_hud_messgae() 方法创建和更新玩家 HUD(在 stop_process 中禁用 HUD)