Class BuiltImmersiveInfoImpl<E>

java.lang.Object
com.hammy275.immersivemc.client.immersive.info.BuiltImmersiveInfoImpl<E>
All Implemented Interfaces:
BuiltImmersiveInfo<E>, ImmersiveInfo

public final class BuiltImmersiveInfoImpl<E> extends Object implements BuiltImmersiveInfo<E>
Base class for infos that Immersives constructed with the builder can use.
  • Field Details

    • hitboxes

      public final List<RelativeHitboxInfoImpl> hitboxes
    • hitboxesOut

      public final List<HitboxInfo> hitboxesOut
    • extraData

      public final E extraData
    • immersiveDir

      public net.minecraft.core.Direction immersiveDir
    • airCheckPassed

      public boolean airCheckPassed
    • slotsHovered

      public int[] slotsHovered
    • light

      public int light
    • ticksExisted

      public long ticksExisted
  • Constructor Details

  • Method Details

    • getAllHitboxes

      public List<HitboxInfo> getAllHitboxes()
      Specified by:
      getAllHitboxes in interface ImmersiveInfo
      Returns:
      The list of all hitboxes this Immersive uses. This can contain null elements, and can return an immutable list implementation if desired.
    • hasHitboxes

      public boolean hasHitboxes()
      Description copied from interface: ImmersiveInfo
      Whether this ImmersiveInfo contains valid hitboxes that are ready for use by users in-game. ImmersiveInfo.getAllHitboxes() will not be called if this method returns false for a given tick.
      Specified by:
      hasHitboxes in interface ImmersiveInfo
      Returns:
      Whether ImmersiveInfo.getAllHitboxes() can be safely called and contains expected data.
    • getBlockPosition

      public net.minecraft.core.BlockPos getBlockPosition()
      Description copied from interface: ImmersiveInfo
      Gets the block position of the block this ImmersiveInfo represents. This function should always return the same value for an individual ImmersiveInfo instance, and this function may be called after the block at this position no longer matches the Immersive it represents.
      For example, if this ImmersiveInfo was used to represent a furnace that was initially placed at x=1, y=2, and z=3, this function should always return the position x=1, y=2, and z=3, even after the furnace is destroyed or replaced by some other block.
      Specified by:
      getBlockPosition in interface ImmersiveInfo
      Returns:
      The position of the block this ImmersiveInfo represents.
    • setSlotHovered

      public void setSlotHovered(int hitboxIndex, int handIndex)
      Description copied from interface: ImmersiveInfo
      A notification to mark the given slot as hovered by the given hand index.
      Specified by:
      setSlotHovered in interface ImmersiveInfo
      Parameters:
      hitboxIndex - The index into ImmersiveInfo.getAllHitboxes() to mark as hovered, or -1 to indicate no slot is hovered by this hand.
      handIndex - 0 for the primary hand (primary controller in VR or the player hand in non-VR), and 1 for the secondary hand (secondary controller in VR, or nothing in non-VR).
    • getSlotHovered

      public int getSlotHovered(int handIndex)
      Specified by:
      getSlotHovered in interface ImmersiveInfo
      Parameters:
      handIndex - The hand that is checking for a hovered hitbox.
      Returns:
      The hitbox the handIndex is hovering, or -1 if it isn't hovering any slot.
    • isSlotHovered

      public boolean isSlotHovered(int hitboxIndex)
      Description copied from interface: BuiltImmersiveInfo
      Checks if the given hitbox is currently hovered by some hand or the mouse.
      Specified by:
      isSlotHovered in interface BuiltImmersiveInfo<E>
      Parameters:
      hitboxIndex - The hitbox index to check if hovered.
      Returns:
      Whether the given hitboxIndex is hovered.
    • getTicksExisted

      public long getTicksExisted()
      Specified by:
      getTicksExisted in interface ImmersiveInfo
      Returns:
      The number of ticks this info has existed for.
    • getExtraData

      public E getExtraData()
      Specified by:
      getExtraData in interface BuiltImmersiveInfo<E>
      Returns:
      The extra data instance attached to this info.
    • getItem

      public net.minecraft.world.item.ItemStack getItem(int hitboxIndex)
      Description copied from interface: BuiltImmersiveInfo
      Get the item stored at the given hitbox index. The item returned is an empty stack if the hitbox does not contain an item.
      Specified by:
      getItem in interface BuiltImmersiveInfo<E>
      Parameters:
      hitboxIndex - The hitbox index to get the item from.
      Returns:
      The item in that hitbox.
    • setFakeItem

      public void setFakeItem(int hitboxIndex, net.minecraft.world.item.ItemStack item)
      Description copied from interface: BuiltImmersiveInfo
      Sets an item into the provided hitbox only on the client-side. A network sync may overwrite this data!
      Specified by:
      setFakeItem in interface BuiltImmersiveInfo<E>
      Parameters:
      hitboxIndex - The index to set an item in.
      item - The item to set.
    • ticksExisted

      public long ticksExisted()
      Specified by:
      ticksExisted in interface BuiltImmersiveInfo<E>
      Returns:
      The number of times this Immersive has ticked.