Class AbstractPlayerAttachmentImmersive<I extends AbstractPlayerAttachmentInfo,S extends NetworkStorage>

java.lang.Object
com.hammy275.immersivemc.client.immersive.AbstractPlayerAttachmentImmersive<I,S>
Type Parameters:
I - Info type
Direct Known Subclasses:
ImmersiveBackpack, ImmersiveHitboxes

public abstract class AbstractPlayerAttachmentImmersive<I extends AbstractPlayerAttachmentInfo,S extends NetworkStorage> extends Object
Abstract immersive anything
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    boolean
     
    protected final List<I>
     
    final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    boolean
     
    void
    doRender(I info, com.mojang.blaze3d.vertex.PoseStack stack, boolean isInVR)
    Do rendering This is the render method that should be called by outside functions
    protected void
    doTick(I info, boolean isInVR)
     
    abstract boolean
     
    protected void
    enqueueItemGuideRender(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, float alpha, boolean isSelected, int light)
     
    static net.minecraft.world.phys.Vec3[]
    get3x3HorizontalGrid(net.minecraft.core.BlockPos blockPos, double spacing, net.minecraft.core.Direction blockForward, boolean use3DCompat)
     
    int
     
    int
     
    static net.minecraft.core.Direction
    getForwardFromPlayer(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos pos)
    Gets the forward direction of the block based on the player Put simply, this returns the best direction such that the block is "facing" the play by looking that direction.
    static net.minecraft.core.Direction
    getForwardFromPlayerUpAndDown(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos pos)
     
    static net.minecraft.core.Direction
    getForwardFromPlayerUpAndDownFilterBlockFacing(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos pos, boolean filterOnBlockFacing)
    Same as getForwardFromPlayer, but can return the block facing up or down, alongside any of the four directions of N/E/S/W.
    abstract @Nullable ImmersiveHandler<S>
     
    static net.minecraft.core.Direction
    getLeftOfDirection(net.minecraft.core.Direction forward)
    Gets the direction to the left from the Direction's perspective, assuming the Direction is looking at the player.
    int
    getLight(net.minecraft.core.BlockPos pos)
     
    int
    getLight(net.minecraft.core.BlockPos[] positions)
     
    abstract net.minecraft.core.BlockPos
    getLightPos(I info)
    Gets the BlockPos used for lighting calculations.
    net.minecraft.core.BlockPos[]
    Override to return multiple light positions instead of one for light calculations if hasMultipleLightPositions() return true.
    static net.minecraft.world.phys.Vec3
    getTopCenterOfBlock(net.minecraft.core.BlockPos pos)
     
     
    void
    Tick method that will always run exactly once per client tick
    abstract void
    handleRightClick(AbstractPlayerAttachmentInfo info, net.minecraft.world.entity.player.Player player, int closest, net.minecraft.world.InteractionHand hand)
     
    void
    handleTriggerHitboxRightClick(InfoTriggerHitboxes info, net.minecraft.world.entity.player.Player player, int hitboxNum)
     
    boolean
    Override to use getLightPositions instead of getLightPos
    boolean
     
    protected abstract void
    initInfo(I info)
    Initializes an `info` instance after it's constructed.
    protected abstract boolean
    inputSlotShouldRenderHelpHitbox(I info, int slotNum)
     
    boolean
     
    void
    Run when there are no infos
    void
    Called just before handleRightClick() and handleTriggerHitboxRightClick()
    void
    onRemove(I info)
     
    net.minecraft.world.phys.Vec3
    Gets player position while accounting for partial ticks (getFrameTime())
    abstract void
     
    abstract I
    refreshOrTrackObject(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level level)
     
    protected abstract void
    render(I info, com.mojang.blaze3d.vertex.PoseStack stack, boolean isInVR)
     
    protected void
    renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox)
     
    protected void
    renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean alwaysRender)
     
    static void
    renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean alwaysRender, float red, float green, float blue)
     
    static void
    renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean alwaysRender, float red, float green, float blue, float alpha)
     
    void
    renderItem(net.minecraft.world.item.ItemStack item, com.mojang.blaze3d.vertex.PoseStack stack, net.minecraft.world.phys.Vec3 pos, float size, net.minecraft.core.Direction facing, BoundingBox hitbox, boolean renderItemCounts, int light)
     
    void
    renderItem(net.minecraft.world.item.ItemStack item, com.mojang.blaze3d.vertex.PoseStack stack, net.minecraft.world.phys.Vec3 pos, float size, net.minecraft.core.Direction facing, net.minecraft.core.Direction upDown, BoundingBox hitbox, boolean renderItemCounts, int spinDegrees, int light)
    Renders an item at the specified position
    protected void
    renderTick(I info, boolean isInVR)
    Called just before render() for data that needs to be updated just before render time, rather than on a tick-based interval.
    abstract boolean
     
    abstract boolean
    shouldRender(I info, boolean isInVR)
     
    abstract boolean
    shouldTrack(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level level)
     
    protected boolean
    slotHelpBoxIsSelected(I info, int slotNum)
     
    void
    tick(I info, boolean isInVR)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • maxLight

      public static final int maxLight
    • infos

      protected final List<I extends AbstractPlayerAttachmentInfo> infos
    • maxImmersives

      public final int maxImmersives
    • forceDisableItemGuide

      protected boolean forceDisableItemGuide
    • forceTickEvenIfNoTrack

      public boolean forceTickEvenIfNoTrack
  • Constructor Details

    • AbstractPlayerAttachmentImmersive

      public AbstractPlayerAttachmentImmersive(int maxImmersives)
  • Method Details

    • playerPos

      public net.minecraft.world.phys.Vec3 playerPos()
      Gets player position while accounting for partial ticks (getFrameTime())
      Returns:
      Player position while accounting for partial ticks
    • renderTick

      protected void renderTick(I info, boolean isInVR)
      Called just before render() for data that needs to be updated just before render time, rather than on a tick-based interval. WARNING: This is called per render-pass, and will completely mess with the player position!
    • globalTick

      public void globalTick()
      Tick method that will always run exactly once per client tick
    • clientAuthoritative

      public boolean clientAuthoritative()
      Returns:
      Whether this immersive should have tracking initiated by the client. If true, no data should ever be sent from the server to the client for this immersive.
    • getHandler

      @Nullable public abstract @Nullable ImmersiveHandler<S> getHandler()
      Returns:
      ImmersiveHandler that this immersive uses. Can return null if this immersive doesn't receive item data from the server through FetchInventoryPacket.
    • hitboxesAvailable

      public boolean hitboxesAvailable(AbstractPlayerAttachmentInfo info)
    • shouldRender

      public abstract boolean shouldRender(I info, boolean isInVR)
    • render

      protected abstract void render(I info, com.mojang.blaze3d.vertex.PoseStack stack, boolean isInVR)
    • enabledInConfig

      public abstract boolean enabledInConfig()
    • inputSlotShouldRenderHelpHitbox

      protected abstract boolean inputSlotShouldRenderHelpHitbox(I info, int slotNum)
    • shouldTrack

      public abstract boolean shouldTrack(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level level)
    • refreshOrTrackObject

      @Nullable public abstract I refreshOrTrackObject(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level level)
    • shouldBlockClickIfEnabled

      public abstract boolean shouldBlockClickIfEnabled(AbstractPlayerAttachmentInfo info)
    • initInfo

      protected abstract void initInfo(I info)
      Initializes an `info` instance after it's constructed. Useful for immersives that have non-changing hitboxes/positions.
      Parameters:
      info - Info instance that should be initialized
    • onAnyRightClick

      public void onAnyRightClick(AbstractPlayerAttachmentInfo info)
      Called just before handleRightClick() and handleTriggerHitboxRightClick()
      Parameters:
      info - Info instance that had a hitbox click
    • isVROnly

      public boolean isVROnly()
    • handleRightClick

      public abstract void handleRightClick(AbstractPlayerAttachmentInfo info, net.minecraft.world.entity.player.Player player, int closest, net.minecraft.world.InteractionHand hand)
    • handleTriggerHitboxRightClick

      public void handleTriggerHitboxRightClick(InfoTriggerHitboxes info, net.minecraft.world.entity.player.Player player, int hitboxNum)
    • onRemove

      public void onRemove(I info)
    • slotHelpBoxIsSelected

      protected boolean slotHelpBoxIsSelected(I info, int slotNum)
    • processStorageFromNetwork

      public abstract void processStorageFromNetwork(AbstractPlayerAttachmentInfo info, S storage)
    • tick

      public void tick(I info, boolean isInVR)
    • getCooldownVR

      public int getCooldownVR()
    • getCooldownDesktop

      public int getCooldownDesktop()
    • doTick

      protected void doTick(I info, boolean isInVR)
    • getLightPos

      public abstract net.minecraft.core.BlockPos getLightPos(I info)
      Gets the BlockPos used for lighting calculations. Called immediately after doTick(), so anything set up then, it will be in info to use. Note that this should not be inside another block (even the immmersive!). The best option is to set this to be one of the blocks that must be unoccupied for the immersive to render (the block above the crafting table, for example).
      Parameters:
      info - The immersive info instance.
      Returns:
      The BlockPos for lighting.
    • hasMultipleLightPositions

      public boolean hasMultipleLightPositions(I info)
      Override to use getLightPositions instead of getLightPos
      Parameters:
      info - Info to determine if to use multiple light positions
      Returns:
      Whether to use getLightPositions() or getLightPos()
    • getLightPositions

      public net.minecraft.core.BlockPos[] getLightPositions(I info)
      Override to return multiple light positions instead of one for light calculations if hasMultipleLightPositions() return true.
      Parameters:
      info - Info to get positions from
      Returns:
      All positions for lighting
    • doRender

      public void doRender(I info, com.mojang.blaze3d.vertex.PoseStack stack, boolean isInVR)
      Do rendering This is the render method that should be called by outside functions
    • getTrackedObjects

      public List<I> getTrackedObjects()
    • noInfosTick

      public void noInfosTick()
      Run when there are no infos
    • renderItem

      public void renderItem(net.minecraft.world.item.ItemStack item, com.mojang.blaze3d.vertex.PoseStack stack, net.minecraft.world.phys.Vec3 pos, float size, net.minecraft.core.Direction facing, BoundingBox hitbox, boolean renderItemCounts, int light)
    • renderItem

      public void renderItem(net.minecraft.world.item.ItemStack item, com.mojang.blaze3d.vertex.PoseStack stack, net.minecraft.world.phys.Vec3 pos, float size, net.minecraft.core.Direction facing, net.minecraft.core.Direction upDown, BoundingBox hitbox, boolean renderItemCounts, int spinDegrees, int light)
      Renders an item at the specified position
      Parameters:
      item - Item to render
      stack - PoseStack in
      pos - Position to render at
      size - Size to render at
      facing - Direction to face (should be the direction of the block). Can be null to look at camera.
      upDown - Direction upwards or downwards. Can be null if not facing up or down.
      hitbox - Hitbox for debug rendering
      renderItemCounts - Whether to render an item count with the item
      spinDegrees - Degress to spin on x/z. Overwritten if facing is nonnull.
    • enqueueItemGuideRender

      protected void enqueueItemGuideRender(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, float alpha, boolean isSelected, int light)
    • renderHitbox

      protected void renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox)
    • renderHitbox

      protected void renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean alwaysRender)
    • renderHitbox

      public static void renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean alwaysRender, float red, float green, float blue)
    • renderHitbox

      public static void renderHitbox(com.mojang.blaze3d.vertex.PoseStack stack, BoundingBox hitbox, boolean alwaysRender, float red, float green, float blue, float alpha)
    • getLeftOfDirection

      public static net.minecraft.core.Direction getLeftOfDirection(net.minecraft.core.Direction forward)
      Gets the direction to the left from the Direction's perspective, assuming the Direction is looking at the player. This makes it to the right for the player.
      Parameters:
      forward - Forward direction of the block
      Returns:
      The aforementioned left
    • getTopCenterOfBlock

      public static net.minecraft.world.phys.Vec3 getTopCenterOfBlock(net.minecraft.core.BlockPos pos)
    • getForwardFromPlayer

      public static net.minecraft.core.Direction getForwardFromPlayer(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos pos)
      Gets the forward direction of the block based on the player Put simply, this returns the best direction such that the block is "facing" the play by looking that direction.
      Parameters:
      player - Player to get forward from
      pos - Blosck position of the
      Returns:
      The forward direction of a block to use.
    • get3x3HorizontalGrid

      public static net.minecraft.world.phys.Vec3[] get3x3HorizontalGrid(net.minecraft.core.BlockPos blockPos, double spacing, net.minecraft.core.Direction blockForward, boolean use3DCompat)
    • getLight

      public int getLight(net.minecraft.core.BlockPos pos)
    • getLight

      public int getLight(net.minecraft.core.BlockPos[] positions)
    • clearImmersives

      public void clearImmersives()
    • getForwardFromPlayerUpAndDown

      public static net.minecraft.core.Direction getForwardFromPlayerUpAndDown(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos pos)
    • getForwardFromPlayerUpAndDownFilterBlockFacing

      public static net.minecraft.core.Direction getForwardFromPlayerUpAndDownFilterBlockFacing(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos pos, boolean filterOnBlockFacing)
      Same as getForwardFromPlayer, but can return the block facing up or down, alongside any of the four directions of N/E/S/W.
      Parameters:
      player - Player.
      pos - Position of block.
      filterOnBlockFacing - If true, the axis of the block's DirectionalBlock.FACING will not be returned from this function. The block should have this property if this is true, of course!
      Returns:
      Any Direction, representing what direction the block should be facing based on the player's position.