Skip to content

👁️ Line of Sight & Obstruction Mechanics (MC 26.2)

📌 Repository Source Disclaimer: The documentation in this Wiki reflects the current source code state in the repository, which may include recent unreleased commits or developmental features ahead of public release builds on CurseForge and Modrinth.

Feature InfoboxTechnical Parameters
Primary Vision Enginenet.dasik.social.api.vision.PlayerVisionTracker
Secondary Vision Enginenet.instantgratification.magnet.SecondaryVisionCheck
Spherical Field of View$360.0^\circ$ (Full omnidirectional perception)
Contact Distance Tolerance$0.3\text{ m}$ target contact threshold
Memory Retention Tagig_magnet$isMagnetized() / ig_magnet$setMagnetized()
Momentum Ruleig:magnet_keep_moving_if_unseen = true
Granular Filter RulesTransparent blocks, Flora, Block Entities

📖 Dual-Pass Vision Architecture

To prevent unearned item collection through cave walls and secure bases while maintaining zero-lag performance, Magnet, Let me get that! employs a high-speed Dual-Pass Vision Pipeline:

                                +---------------------------+
                                |    TARGET ITEM DETECTED   |
                                +-------------+-------------+
                                              |
                                              v
                              +-------------------------------+
                              |    PRIMARY PASS (360° LOS)    |
                              |   PlayerVisionTracker.canSee  |
                              +---------------+---------------+
                                              |
                        +---------------------+---------------------+
                        |                                           |
                   [VISIBLE]                                   [OBSTRUCTED]
                        |                                           |
                        v                                           v
      +-----------------------------------+               +--------------------+
      |     SECONDARY PASS (GRANULAR)     |               |   MOMENTUM CHECK   |
      |     SecondaryVisionCheck.canSee   |               | keepMovingIfUnseen |
      +-----------------+-----------------+               +---------+----------+
                        |                                           |
            +-----------+-----------+                     +---------+---------+
            |                       |                     |                   |
        [PASS]                   [BLOCKED]            [MAGNETIZED]      [UNMAGNETIZED]
            |                       |                     |                   |
            v                       v                     v                   v
    +---------------+       +---------------+     +---------------+   +---------------+
    |  PULL ITEM &  |       | REJECT / STOP |     | CONTINUE PULL |   | REJECT PULL   |
    | SET MAGNETIZED|       +---------------+     +---------------+   +---------------+
    +---------------+

🔍 Pass 1: Primary 360° Spherical Line-of-Sight Check

The primary pass calls DasikLibrary's optimized raycasting engine:

java
boolean canSee = net.dasik.social.api.vision.PlayerVisionTracker.canSee(player, entity, (double) range, 360.0);
  • Omnidirectional FOV: With a $360.0^\circ$ FOV cone, the player can attract items directly behind their head, above them, or below their feet as long as no solid wall intervenes.
  • 0.3m Contact Tolerance: When items are tucked tightly against block corners, sub-voxel raycasting with a $0.3\text{m}$ radius ensures items are not falsely rejected.

🌿 Pass 2: Granular Block State Filtering (SecondaryVisionCheck)

If the primary pass succeeds, the mod evaluates optional granular obstruction rules using BlockGetter.traverseBlocks:

java
public static boolean canSee(Player player, Entity target, boolean blockTransparent, boolean blockFlora, boolean blockEntities)
  1. Flora & Foliage Filtering (ig:magnet_blocked_by_flora):
    • Checks if any traversed block is an instance of BushBlock (tall grass, flowers, crops, saplings) or LeavesBlock (tree leaves).
    • If enabled (true), foliage acts as an opaque barrier to item attraction.
  2. Interactive Block Entities (ig:magnet_blocked_by_block_entities):
    • Checks state.hasBlockEntity() across traversed positions.
    • If enabled (true), Chests, Trapped Chests, Barrels, Shulker Boxes, Beds, and Dispensers block line of sight.
  3. Transparent & Non-Full Blocks (ig:magnet_blocked_by_transparent):
    • Raycasts against state.getVisualShape(...).
    • If enabled (true), Glass, Glass Panes, Iron Bars, Fences, Slabs, and Stairs block item collection.

🚀 Momentum Continuity (keepMovingIfUnseen)

In fast-paced mining or combat, items pulled around a corner often temporarily break line of sight. Rather than freezing or falling into lava:

  1. Magnetization Tag: When an item is seen in line of sight, ((IMagnetEntity) entity).ig_magnet$setMagnetized() sets an in-memory boolean flag.
  2. Momentum Retention: If the item breaks LOS on subsequent ticks:
    • If ig:magnet_keep_moving_if_unseen = true AND ig_magnet$isMagnetized() == true: The item continues being pulled to the player.
    • If ig:magnet_keep_moving_if_unseen = false: Pulling stops immediately upon LOS loss.
    • If the item was never seen (e.g. spawned behind a wall by an explosion or dispenser): Pulling is rejected immediately.

⚙️ Relevant Configuration & GameRules

GameRuleTypeDefaultDescription
ig:magnet_los_onlyBooleantrueRequires line-of-sight visibility to attract items.
ig:magnet_keep_moving_if_unseenBooleantrueContinues pulling magnetized items if LOS is broken mid-flight.
ig:magnet_blocked_by_transparentBooleanfalseIf true, glass and transparent blocks obstruct line of sight.
ig:magnet_blocked_by_floraBooleanfalseIf true, grass, leaves, and flowers obstruct line of sight.
ig:magnet_blocked_by_block_entitiesBooleanfalseIf true, chests, beds, and block entities obstruct line of sight.

Official documentation & web portal for Dasik Igaijinn mods.