Download AutoSwitch — Minecraft Mods — MetaMods

AutoSwitch

Active

Downloads

0

Last update

1 month ago

Versions

20w14a — 1.21.9
Client
Fabric
Neoforge
Utils

AutoSwitch

AutoSwitch is a Minecraft mod (for Fabric/NeoForge) that automatically changes the held item based on your actions — resource gathering, attacking, interaction, or changes in specific stats, as well as available items on the hotbar (for example, if you hit a stone block with your hand, it will switch to a pickaxe).

The mod operates based on rules and offers extensive customization options through a HOCON configuration file autoswitch.conf, located in the config folder next to the resource packs folder. You can quickly navigate there via Options → Resource Packs → go up one level.

The mod can be toggled on and off directly in the game by pressing the R key.


Configuration

This section applies only to AutoSwitch version 12 and above. Earlier versions used a different configuration format.

The configuration file contains four sections — three for defining conditions and targets during various actions and one for general feature settings:

  • attack-action — rules applied during attack (entities or blocks).
  • interact-action — rules used during interaction (right-click-like actions).
  • stat-change-action — rules triggered by stat change events (e.g., using a totem of undying).
  • feature-config — controls the overall behavior of the mod.

Each rule contains:

  • priority — integer; higher values take precedence when multiple targets match.
  • target — what this rule matches (types: BLOCK, ENTITY, STAT, or an EXPRESSION allowing the combination of other targets). Targets can reference tags or specific explicit IDs (minecraft:ender_chest, sugar_cane).
  • tools — ordered array of candidates to switch to. Each must be an ITEM or an EXPRESSION of ITEMs, or be an empty list (to disable switching for that target).

EXPRESSION can have any number of elements or nesting levels, providing a high degree of control. The default configuration covers a wide range of cases and serves as an excellent foundation for expansion.

Tools and targets can have an optional data field to control parameters such as enchantments or block states that should match.

Live Editing

Simply resave the configuration file during gameplay for it to automatically reload.

Implementation Details

Expressions

Expressions can be nested to any depth.

Expressions support the following operations:

  • OR — matches any of its child elements
  • AND — matches all of its child elements
  • NOT — matches none of its child elements
  • XOR — matches only one of its child elements

Data

Currently, the following data types are supported:

  • BlockState — the block state to match
  • Component — currently only supports POTION_CONTENTS on items
  • Enchantment — the enchantments an item has
  • EntityEquipment — the equipment an entity is wearing, such as a pig with a saddle

Selection Priority

Decision order (the first difference determines the choice):

  1. Target Priority — preference is given to rules with higher priority.
  2. Target Rating (multi-level) — comparison of rating levels from 0 to n up to the configured maximum. At each level, comparison in order:
    • isGroup (preference for non-groups)
    • hasData (preference for those with data)
    • typeRating (preference for higher, e.g., weapon DPS or mining level)
    • dataRating (preference for higher, e.g., normalized enchantment level)
  3. Tool Priority — preference for tools with higher intrinsic priority.
  4. Tool Rating (multi-level) — the same multi-level comparison logic as Target Rating (isGroup → hasData → typeRating → dataRating).
  5. Is the slot currently selected? — preference for the current held slot if no differences so far.
  6. Smallest slot index — final tie-breaker: the slot with the smallest index (leftmost) wins.
Text-based Flowchart
START: candidate inventory slots (all slots matching 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? (preference for non-groups)
- compare: hasData? (preference for those with data)
- 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
Project members
dexman545

dexman545

Developer

Created: 14 Dec 2020

ID: 2630