AutoSwitch 是一款适用于 Fabric 和 NeoForge 的 Minecraft 模组,可在攻击或与环境中的方块/实体交互时,自动将当前手持工具切换为最合适的工具——例如你攻击石头方块时它会切换到镐子,而当你对着一块烦人的 gravel(沙砾)区域进行交互时,它又会切换到铲子。具体切换哪些工具以及在何时切换均可自定义配置,并会参考当前工具附魔、目标方块的 BlockState(方块状态),或实体的装备情况等数据。
AutoSwitch 使用 HOCON 格式的配置文件 autoswitch.conf,该文件位于与资源包文件夹相邻的 config 文件夹中。快速导航至该位置的简便方法是:Options > Resource Packs > navigate up one folder(选项 > 资源包 > 向上返回一级目录)。
在游戏中,按下 R 键(默认)即可开启或关闭此模组。
配置说明
本节内容仅适用于 AutoSwitch 12+ 版本。早期版本使用了不同的配置格式。
配置文件中包含四个部分——其中三个用于定义在不同操作发生时对应的选择器与目标,另一个则用于通用功能配置:
attack-action- 在攻击(实体或方块)时使用的规则。interact-action- 在交互(右键点击实体或方块)时使用的规则。stat-change-action- 由状态变化事件触发的规则(例如不死图腾激活,仅在单人游戏中生效)。feature-config- 控制模组的整体行为。
每条规则包含以下内容:
priority- 整数;当多个目标匹配时,数值越高优先级越高。target- 类型为BLOCK(方块)、ENTITY(实体)、STAT(状态)的IdSelector,或允许组合其他目标的EXPRESSION(表达式)。tools- 按顺序排列的ITEM类型的IdSelector或EXPRESSION列表,表示要切换到的工具;也可以为空列表(表示对该目标禁用切换)。
IdSelector 可以引用标签或具体的显式 ID(如 #minecraft:stone、minecraft:ender_chest)。它还拥有一个可选的 data 字段,用于匹配特定物品附魔或方块状态等条件。player 数据字段可应用于任何类型的选择器,从而基于玩家的状态(如是否蹲伏或与目标的距离)进行匹配。
EXPRESSION(表达式)可以包含任意数量的元素或达到任意嵌套深度,从而实现高度灵活的控制。默认配置已覆盖广泛的使用场景,可作为进一步扩展的良好基础。
实时编辑
只需在游戏运行时重新保存配置文件,即可自动重载。
配置详情
表达式
表达式支持按需嵌套至任意深度。
表达式支持以下运算:
OR- 匹配其任一子项AND- 匹配其所有子项NOT- 不匹配其任何子项XOR- 仅匹配其一个子项
数据
目前支持以下数据类型:
BlockState- 要匹配的方块状态Component- 目前仅支持物品的POTION_CONTENTS(药水效果)Enchantment- 物品拥有的附魔EntityEquipment- 实体穿戴的装备,例如骑乘鞍的猪Player- 玩家的状态,例如是否潜行、持有特定物品、正在骑乘某物,或与目标的距离等。
选择优先级
首先,AutoSwitch 会检查目标是否存在匹配项,优先选择具有最高优先级且工具也匹配的结果。如果存在多个优先级相同的匹配项,系统将进一步考察配置的精确度——例如,若配置中同时定义了 #minecraft:stone(标签)和 minecraft:stone(具体方块),两者均匹配且优先级相同,则系统会优先选择非标签的 minecraft:stone 目标。若该目标未指定匹配的工具,则会回退到标签目标所指定的工具。如果指定了可选数据,也会将其纳入考量以提高匹配的精确度。指定的数据越多,匹配被视为越精确。
如果匹配的目标具有相同的优先级和精确度,系统将使用基于上下文的类型评级来优先选择。对于方块,它们的评级相同;但对于附魔,评级将基于附魔等级;而在攻击怪物时,物品的评级则基于预估造成的伤害。指定的数据也可以拥有各自的评级(例如工具上的附魔)。类型的评级优先级高于数据的评级。
选定目标后,工具的选择过程大致同上。工具的优先级主要取决于其在对应目标工具列表中的出现顺序;否则,其精确度、类型评级和数据评级与目标的选择逻辑一致。
如果此时没有首选工具,且当前手持物品是并列候选工具之一,则该物品将被优先选用。否则,系统将优先选择位于快捷栏最左侧的并列候选工具。
基于文本的流程图
START: 候选物品栏槽位(所有匹配选择器的槽位)
|
v
比较目标优先级(Target Priority)
|-- 若不同 --> 选择最高目标优先级 --> END
|
v (相同)
比较目标评级(等级 0..N)
针对每个等级:
- 比较:是否为组?(优先非组)
- 比较:是否有数据?(优先有数据)
- 比较:类型评级(更高者胜)
- 比较:数据评级(更高者胜)
|-- 若发现差异 --> 选择胜出者 --> END
|
v (无差异)
比较工具优先级(Tool Priority)
|-- 若不同 --> 选择最高工具优先级 --> END
|
v (相同)
比较工具评级(等级 0..N)
(与目标评级相同的逐等级规则)
|-- 若发现差异 --> 选择胜出者 --> END
|
v (仍平局)
偏好当前选中的槽位?
|-- 是 --> 选择当前选中槽位 --> END
|-- 否 --> 选择最小(最左侧)槽位 --> END
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 [Fabric]
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch [Fabric]
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch [Fabric]
下载 AutoSwitch [Fabric]
下载 AutoSwitch [Fabric]
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch [Fabric]
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch [Fabric]
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch [Fabric]
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch [Fabric]
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 AutoSwitch [Fabric]
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
暂无更新日志
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
查看物品与配方
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
AE2:一款流行的自动化与存储模组
模组
那是什么?一个 Waila/Hwyla 的分支。
评论 0
登录后参与评分
还没有评论,来抢沙发吧