AutoSwitch 是一款适用于 Fabric 和 NeoForge 的 Minecraft 模组,可在攻击或与环境中的方块/实体交互时,自动将当前使用的工具切换至正确的工具。例如:当你攻击石头方块时,它会自动切换到镐子;当你挖掘烦人的沙砾层时,它会切换到铲子。具体使用哪种工具以及触发时机均可配置,并且会考虑诸如当前装备附魔、目标方块的方块状态(blockstate)或实体的装备等信息。
AutoSwitch 使用位于 config 文件夹中的 HOCON 配置文件 autoswitch.conf,该文件夹与资源包文件夹相邻。快速进入该目录的方法是:进入 选项 > 资源包 > 向上导航一级文件夹。
在游戏中按下 R 键(默认)即可开启或关闭此模组。
配置说明
本节仅适用于 AutoSwitch 12+ 版本。早期版本使用了不同的配置格式。
配置文件包含四个部分——三个用于定义在不同操作发生时匹配的选择器(selectors)和目标(targets),另一个用于通用功能配置:
attack-action- 攻击(实体或方块)时使用的规则。interact-action- 交互(右键点击实体或方块)时使用的规则。stat-change-action- 由状态变更事件触发的规则(例如不死图腾激活,仅在单人游戏中生效)。feature-config- 控制模组的整体行为。
每条规则包含以下字段:
priority- 整数;当多个目标匹配时,数值越高优先级越高。target- 类型为BLOCK、ENTITY、STAT的IdSelector,或者是允许组合其他目标的EXPRESSION。tools- 按顺序排列的ITEM类型的IdSelectors 或EXPRESSIONs,表示要切换到的工具;也可以为空列表(以针对该目标禁用切换)。
IdSelectors 可以引用标签或特定的显式 ID(如 #minecraft:stone、minecraft:ender_chest)。它们有一个可选的 data 字段,用于匹配特定物品附魔或方块状态等条件。player 数据字段可应用于任何类型的选择器,允许根据玩家的状态进行匹配,例如是否正在潜行或与目标保持特定距离。
EXPRESSIONs 可以拥有任意数量的元素或任意深度的嵌套,从而提供极大的控制力。默认配置涵盖了广泛的情况,可作为扩展配置的绝佳基础。
实时编辑
只需在游戏运行期间重新保存配置文件,模组便会自动重新加载。
配置详情
表达式 (Expressions)
表达式可以嵌套到你想要的任意深度。
表达式支持以下操作:
OR- 匹配其子项中的任意一个AND- 匹配其所有子项NOT- 不匹配其任何子项XOR- 仅匹配其子项中的一个
数据 (Data)
目前支持以下数据类型:
BlockState- 要匹配的方块状态Component- 目前仅支持物品的POTION_CONTENTS(药水效果)Enchantment- 物品拥有的附魔EntityEquipment- 实体穿戴的装备,例如背着鞍的猪Player- 玩家的状态,例如是否正在潜行、持有特定物品、骑乘某物或与目标保持特定距离。
选择优先级
首先,AutoSwitch 会检查目标是否存在匹配项,并优先选择具有匹配工具的最高优先级匹配项。如果存在多个具有相同优先级的匹配项,它将开始考察配置的精确度——例如,如果配置中定义了目标 #minecraft:stone(标签)和 minecraft:stone(方块),且两者都匹配并具有相同的优先级,它将优先选择非标签的 minecraft:stone 目标。如果该目标没有匹配的工具,则会查看由标签目标指定的工具。如果指定了任何可选数据,这也会被视为使匹配更精确的因素。指定的数据越多,匹配被认为越精确。
如果匹配的目标具有相同的优先级和精确度,则将使用基于上下文的类型评级来优先选择。对于方块,它们的评级均相同,但对于附魔,评级将基于附魔等级;或者在攻击生物时使用物品时,评级将基于预估造成的伤害。指定的数据也可以拥有自己的评级(例如工具上的附魔)。类型的评级优先于数据的评级。
一旦选中了目标,工具的选择过程大致与上述过程相同。工具的优先级基于其在给定目标工具列表中出现的顺序,否则其精确度、类型评级和数据评级与目标的选择标准相同。
如果此时没有首选工具,且当前手持物品是这些并列候选工具之一,则优先使用该工具。否则,它将优先选择热键栏中最左侧槽位中的并列候选工具。
基于文本的流程图
开始:候选物品栏槽位(所有匹配选择器的槽位)
|
v
比较目标优先级
|-- 如果不同 --> 选择最高目标优先级 --> 结束
|
v (相同)
比较目标评级(等级 0..N)
对于每个等级:
- 比较:是否分组?(非分组优先)
- 比较:是否有数据?(有数据优先)
- 比较:类型评级(更高者胜)
- 比较:数据评级(更高者胜)
|-- 如果发现差异 --> 选择胜出者 --> 结束
|
v (无差异)
比较工具优先级
|-- 如果不同 --> 选择最高工具优先级 --> 结束
|
v (相同)
比较工具评级(等级 0..N)
(与目标评级相同的逐层规则)
|-- 如果发现差异 --> 选择胜出者 --> 结束
|
v (仍然平局)
偏好当前选中的槽位?
|-- 是 --> 选择当前选中槽位 --> 结束
|-- 否 --> 选择最小(最左侧)槽位 --> 结束
AutoSwitch is a Minecraft mod available on Fabric and NeoForge for automatically switching the active tool to the correct one when attacking or interacting with blocks or entities - you attack a stone block, it switches to a pickaxe, then when you hit an annoying gravel patch it switches to a shovel. Which tool is chosen and when is all configurable, taking into account information such as the current enchantments on the tool, the target's blockstate, or an entity's equipment.
AutoSwitch uses a HOCON config file autoswitch.conf, located in the config folder which is next to the
resource pack folder. A quick way to navigate there is by going to Options > Resource Packs > navigate up one folder.
The mod can be toggled on/off in game by pressing R (default).
Configuration
This section only applies to AutoSwitch 12+. Earlier versions used a different config format.
There are four sections in the config file - three for defining selectors and targets when various actions occur, and one for general feature configuration:
attack-action- rules used when attacking (entities or blocks).interact-action- rules used when interacting (right-clicking entities or blocks).stat-change-action- rules triggered by stat events (e.g., a totem of undying activates, works only in singleplayer).feature-config- Controls the overall behavior of the mod.
Each rule contains:
priority- integer; higher values are given precedence what multiple targets match.target- anIdSelectorof typeBLOCK,ENTITY,STAT, or anEXPRESSIONallowing the combination of other targets).tools- ordered array ofIdSelectors orEXPRESSIONs with theITEMtype to switch to, or be an empty list (to disable switching for that target).
IdSelectors can reference tags or specific explicit IDs (#minecraft:stone, minecraft:ender_chest). They have an
optional data field to allow matching against things like specific item enchantments or blockstates.
The player data field can be applied to any type of selector, allowing matching based on the player's condition such
as if they are crouching or a certain distance away from a target.
EXPRESSIONs can have as many elements or as much depth as you wish, allowing for a great deal of control.
The default config covers a wide range of cases and should serve as a great basis for expanding.
Live edits
Simply resave the config file while the game is running for it to be automatically reloaded.
Configuration Details
Expressions
Expressions can be nested to any depth you desire.
Expressions support the following operations:
OR- Match any one of its childrenAND- Match all of its childrenNOT- Match none of its childrenXOR- Match only one of its children
Data
Currently, the following data types are supported:
BlockState- The block state to matchComponent- Currently only supportsPOTION_CONTENTSon itemsEnchantment- The enchantments an item hasEntityEquipment- The equipment an entity is wearing, such as a pig with a saddlePlayer- The player's condition, such as if they are sneaking, have a certain item, are riding something, or a certain distance away from a target.
Selection Priority
First, AutoSwitch will examine the target for any match, prefering the highest priority match with matching tools.
If there are multiple matches with the same priority, it will begin to look at how specific the configuration is -
for example, if config defines targets #minecraft:stone (a tag) and minecraft:stone (a block), and both match and
have the same priority, it will prefer the non-tag minecraft:stone target. If that target did not have any
matching tools, then it will look at the tools specified by the tag target. If any optional data is specified,
that is also considered to make the match more specific. The more data is specified, the more specific the
match is considered.
If the matched targets have the same priority and specificity, then it will use a context-aware type rating to prioritize the selection. For blocks, they all have the same rating, but enchantments will be based on the enchantment level, or for items when attacking a mob, it will be based on the estimated damage to be dealt. Specified data can also have its own ratings (e.g. enchantments on a tool). The rating of the type takes precedence over the data rating.
Once a target has been selected, tool selection follows roughly the same process as above. A tool's priority is based on how early it appears in the tool list for the given target, otherwise the specificity, type rating, and data rating are the same as with targets.
If there is no preferred tool at this point, and the held item is one of these tying tools, then it will be preferred. Otherwise, it will prefer the tied tool in the leftmost hotbar slot.
Text-based Flowchart
START: candidate inventory slots (all slots that matched a selector)
|
v
Compare Target Priority
|-- if different --> choose highest Target Priority --> END
|
v (same)
Compare Target Rating (levels 0..N)
For each level:
- compare: isGroup? (non-group preferred)
- compare: hasData? (with data preferred)
- compare: typeRating (higher wins)
- compare: dataRating (higher wins)
|-- if difference found --> choose winner --> END
|
v (no difference)
Compare Tool Priority
|-- if different --> choose highest Tool Priority --> END
|
v (same)
Compare Tool Rating (levels 0..N)
(same per-level rules as Target Rating)
|-- if difference found --> choose winner --> END
|
v (still tied)
Prefer currently selected slot?
|-- Yes --> choose currently selected --> END
|-- No --> choose smallest (leftmost) slot --> END
下载 AutoSwitch
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
- 26.3 更新
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
AE2:一款流行的自动化与存储模组
模组
那是什么?一个 Waila/Hwyla 的分支。
评论 0
登录后参与评分
还没有评论,来抢沙发吧