Skip to content

Automation Chain

RunningArmy6 edited this page Nov 18, 2026 · 2 revisions

Colossus v2.8.2 — Ownership-Aware Item Transfer Protection

The Automation Chain is SASL's ownership-aware protection layer for automated inventory transfers.

Introduced in the 2.8.2 codebase, this system evaluates item movement between inventories and checks the ownership of the automation components involved. It is designed to prevent automated transfer paths from crossing ownership boundaries without authorization.

Unlike a simple hopper cancellation system, SASL resolves the owners of the source and destination inventories before deciding whether a transfer should be blocked.


1. Transfer Monitoring

SASL monitors automated inventory movement through Bukkit's InventoryMoveItemEvent.

For each transfer attempt, the system retrieves:

  • Source Inventory: The inventory from which the item is taken.
  • Destination Inventory: The inventory receiving the item.
  • Source Owner: The resolved owner of the source.
  • Destination Owner: The resolved owner of the destination.
  • Automation State: Whether either side belongs to a recognized automation component.

If neither side is recognized as an automation component, the transfer-protection handler exits without applying its ownership rules.

The system then evaluates the ownership relationship between both sides.


2. Ownership Evaluation Rules

SASL applies three main ownership checks.

Condition Result
Both sides have owners, but their UUIDs are different Transfer blocked
Source has an owner, destination is an unowned automation component Transfer blocked
Destination has an owner, source is an unowned automation component Transfer blocked

When none of these conditions is met, this ownership-checking stage does not cancel the transfer.

Same-Owner Automation

When both sides resolve to the same owner UUID, the ownership comparison does not block the transfer.

This allows automation components belonging to the same owner to exchange items without being rejected by the different-owner rule.

Unowned Automation

An unowned automation component is not automatically treated as belonging to the player who placed another component nearby.

When one side is owned and the opposite automation side has no resolved owner, SASL blocks that transfer direction.


3. Unified Ownership Resolution

The transfer handler uses a unified ownership-resolution path through getTransitOwner().

It identifies the inventory holder and retrieves ownership according to its type.

Hopper Blocks

Hopper ownership is resolved through the following sequence:

  1. Check the in-memory hopper ownership cache.
  2. If no cached owner exists, inspect the hopper's Persistent Data Container.
  3. Read and validate the stored UUID.
  4. If a valid UUID is found, place it into the RAM cache.
  5. If PDC does not provide a valid owner, query LockSecurityManager.getOwnerSafe().

This allows SASL to reuse previously resolved ownership data instead of repeatedly performing the same lookup.

Hopper Minecarts

Hopper minecart ownership uses a separate entity-based lookup:

  1. Retrieve the minecart's entity UUID.
  2. Check the minecart ownership cache.
  3. If the cache does not contain an owner, inspect the entity's Persistent Data Container.
  4. Parse the stored owner UUID.
  5. Cache the resolved owner for subsequent lookups.

The minecart cache is keyed by entity UUID rather than block coordinates.

Other Inventory Holders

The unified resolver also handles other inventory holders:

  • Double Chests: Resolves ownership through the chest block and LockSecurityManager.
  • Other BlockState Inventories: Uses LockSecurityManager.getOwnerSafe().

This lets the transfer handler compare automation ownership against the ownership of protected container inventories.


4. Multiworld Hopper Ownership Cache

Hopper ownership is stored in a world-aware cache structure.

The cache separates entries by world UUID:

  • Each world has its own hopper ownership map.
  • Hopper positions are represented using packed block-coordinate keys.
  • Owner UUIDs are stored as map values.
  • The underlying FastUtil map is wrapped with synchronized access.

This structure prevents hopper coordinates from being treated as globally unique across different worlds.

Cache Insertion

When a hopper owner is added:

  1. SASL obtains the map associated with the hopper's world.
  2. If no map exists, a new map is created.
  3. The hopper's packed block key is associated with its owner UUID.
  4. The insertion is performed inside the map's synchronization boundary.

The current implementation also contains a per-world soft-cap eviction path. When the configured internal threshold is reached, an existing map entry is removed before the new owner entry is inserted.

Cache Removal

When a hopper ownership entry is removed:

  • SASL locates the corresponding world map.
  • Removes the hopper's packed coordinate key.
  • Removes the world map itself if it becomes empty.

This avoids retaining empty world-level cache containers.


5. Minecart Ownership Cache

Hopper minecarts use a separate cache:

minecartOwnerCache

Its key is the minecart entity UUID, and its value is the owner's UUID.

The cache provides three main operations:

Method Purpose
getMinecartOwner(UUID) Retrieves the cached owner
setMinecartOwner(UUID, UUID) Stores an owner association
removeMinecartOwner(UUID) Removes an entity's owner association

The insertion method checks the configured hard-cap constant before accepting a new entry.

The minecart's PDC remains an additional ownership source, allowing the resolver to repopulate the RAM cache when the entity is inspected again.


6. Transfer Pair Cache

Repeatedly evaluating the same denied transfer pair can create unnecessary work.

SASL therefore maintains a separate deniedTransferCache.

This cache does not store inventory ownership. Instead, it records recently denied source-destination pairs.

Pair Identification

The transfer handler builds a pair key using:

  • The source holder's raw block key.
  • The destination holder's raw block key.
  • The mix64 mixing function.
  • A bit rotation and XOR operation to combine the values.

If a valid pair key is available, SASL checks whether that pair was denied recently.

If the denial timestamp is still inside DENY_COOLDOWN_MS, the transfer is cancelled immediately without repeating the full ownership comparison.

If the pair is not inside the cooldown period, normal ownership resolution continues.

Capacity Protection

The denied-transfer cache also has a hard-cap check.

When its capacity is reached, SASL sets the denyOverCap flag instead of inserting another entry.

This prevents the event handler from continuing to grow the cache beyond its configured internal limit.


7. Maximus Integration

The denied-transfer cache is also maintained by the Maximus runtime maintenance system.

The Rapid Sweeper runs every 100 ticks, approximately every 5 seconds under normal server tick timing.

It performs two maintenance operations:

Expired Entry Cleanup

  • Checks stored denial timestamps.
  • Removes entries older than SecurityListener.DENY_COOLDOWN_MS.

Over-Cap Recovery

  • Checks the denyOverCap flag.
  • Resets the flag when triggered.
  • Clears the denied-transfer cache.

This keeps temporary transfer-denial data from accumulating indefinitely.

The hopper and minecart ownership caches are separate from this temporary denial cache.


8. Configuration

The main configuration switch is:

settings.prevent-hopper-transfer

Default configuration:

settings:
  prevent-hopper-transfer: true
Value Behavior
true Enables the ownership-aware transfer protection handler
false The handler exits without applying its transfer ownership checks

The default value in the inspected configuration is true.

Disabling this setting does not mean that every other SASL protection mechanism is disabled. It specifically disables this transfer-protection handler.


9. What This System Covers

The inspected 2.8.2 implementation contains the following mechanisms:

  • Ownership-aware inventory transfer evaluation.
  • Hopper block ownership lookup.
  • Hopper minecart ownership lookup.
  • PDC-based owner resolution.
  • Multiworld hopper ownership caching.
  • Entity UUID-based minecart ownership caching.
  • Double-chest owner resolution during transfer evaluation.
  • Different-owner transfer rejection.
  • Owned-to-unowned automation boundary protection.
  • Recent denied-transfer pair caching.
  • Hard-cap handling for temporary denial data.
  • Maximus cleanup of expired denial entries.

10. Implementation Boundaries

The Automation Chain should be understood as an ownership-aware transfer protection system, not as a universal automation-management framework.

The current implementation does not establish the following claims:

  • Every possible inventory transfer is blocked.
  • Every unowned inventory is automatically protected.
  • All automation types have persistent owner records.
  • Hopper ownership is stored in a separate database.
  • Minecart ownership is stored in a separate database.
  • The transfer cache guarantees a specific TPS improvement.
  • Every minecart type receives identical player-interaction protection.

The transfer handler operates on the inventory holders and ownership information it can resolve.

Its behavior is determined by the actual ownership checks and configuration state described above.


SASL Colossus v2.8.2 — Automation Chain

Ownership-aware automation transfer protection, backed by dedicated hopper and minecart ownership caches.

Clone this wiki locally