Class RelativeHitboxInfoImpl

java.lang.Object
com.hammy275.immersivemc.client.immersive.RelativeHitboxInfoImpl
All Implemented Interfaces:
RelativeHitboxInfo, HitboxInfo, Cloneable

public class RelativeHitboxInfoImpl extends Object implements RelativeHitboxInfo, HitboxInfo, Cloneable
  • Field Details

    • centerOffset

      public final Function<BuiltImmersiveInfoImpl<?>,net.minecraft.world.phys.Vec3> centerOffset
    • sizeX

      public final double sizeX
    • sizeY

      public final double sizeY
    • sizeZ

      public final double sizeZ
    • isInput

      public final boolean isInput
    • holdsItems

      public final boolean holdsItems
    • itemSpins

      public final boolean itemSpins
    • itemRenderSizeMultiplier

      public final float itemRenderSizeMultiplier
    • isTriggerHitbox

      public final boolean isTriggerHitbox
    • textSupplier

      public final Function<BuiltImmersiveInfoImpl<?>,List<com.mojang.datafixers.util.Pair<net.minecraft.network.chat.Component,net.minecraft.world.phys.Vec3>>> textSupplier
    • forcedUpDownRenderDir

      public final ForcedUpDownRenderDir forcedUpDownRenderDir
    • constantOffset

      public final boolean constantOffset
    • needs3dCompat

      public final boolean needs3dCompat
    • vrMovementInfo

      public final HitboxVRMovementInfo vrMovementInfo
    • renderItem

      public final boolean renderItem
    • renderItemCount

      public final boolean renderItemCount
    • item

      public net.minecraft.world.item.ItemStack item
  • Constructor Details

    • RelativeHitboxInfoImpl

      public RelativeHitboxInfoImpl(RelativeHitboxInfoBuilderImpl usedBuilder, Function<BuiltImmersiveInfoImpl<?>,net.minecraft.world.phys.Vec3> centerOffset, double sizeX, double sizeY, double sizeZ, boolean holdsItems, boolean isInput, boolean itemSpins, float itemRenderSizeMultiplier, boolean isTriggerHitbox, Function<BuiltImmersiveInfoImpl<?>,List<com.mojang.datafixers.util.Pair<net.minecraft.network.chat.Component,net.minecraft.world.phys.Vec3>>> textSupplier, ForcedUpDownRenderDir forcedUpDownDir, boolean constantOffset, boolean needs3dCompat, HitboxVRMovementInfo vrMovementInfo, boolean renderItem, boolean renderItemCount)
      Constructor. See the respective functions in RelativeHitboxInfoBuilderImpl for more information.
      Parameters:
      usedBuilder - The builder used to create this HitboxInfo. Only used to allow cloning this hitbox.
      centerOffset - Function that takes an info instance and returns the offset from the center position for the location of this hitbox.
      sizeX - Size of hitbox on relative X axis.
      sizeY - Size of hitbox on relative Y axis.
      sizeZ - Size of hitbox on relative Z axis.
      holdsItems - Whether this hitbox holds items.
      isInput - Whether this hitbox is an input hitbox.
      itemSpins - Whether the item in this hitbox should spin.
      itemRenderSizeMultiplier - Multiplier to the size passed in the ImmersiveBuilderImpl for the size the item should render at.
      isTriggerHitbox - Whether this hitbox is a trigger hitbox.
      textSupplier - A function taking an info instance and returning a list of text components.
      forcedUpDownDir - An override for upDownRenderDir to use instead of automatically determining it.
      constantOffset - Whether centerOffset's return value is constant.
      needs3dCompat - Whether the offset should be moved by a need for compatibility with 3D resource packs.
      vrMovementInfo - Hitbox VR movement info to recognize hand gestures and perform some action.
      renderItem - Whether to render the item in this hitbox if it can contain one.
      renderItemCount - Whether to render the item count in this hitbox if it can contain an item.
  • Method Details

    • forceNull

      public void forceNull()
      Force the position and box of this hitbox to be null.
    • recalculate

      public void recalculate(net.minecraft.world.level.Level level, HitboxPositioningMode mode, BuiltImmersiveInfoImpl<?> info)
      Main external function call. Calculates the actual, in-world data from the relative information provided.
      Parameters:
      level - Level instance.
      mode - Positioning mode. See HitboxPositioningMode for what each mode does.
      info - Info instance.
    • getAABB

      public net.minecraft.world.phys.AABB getAABB()
      Returns:
      Literal AABB for this hitbox.
    • getUpDownRenderDir

      public net.minecraft.core.Direction getUpDownRenderDir()
    • hasAABB

      public boolean hasAABB()
      Returns:
      Whether this has its calculated hitbox.
    • getTextData

      public List<TextData> getTextData()
    • calcDone

      public boolean calcDone()
      Returns:
      Whether the relative to literal calculation has been performed at least one.
    • clone

      public Object clone()
      Overrides:
      clone in class Object
      Returns:
      A clone of this info instance.
    • cloneWithNewOffset

      public RelativeHitboxInfoImpl cloneWithNewOffset(Function<BuiltImmersiveInfoImpl<?>,net.minecraft.world.phys.Vec3> newOffset)
      Clones this HitboxInfo replacing the offset with the supplied one.
      Parameters:
      newOffset - New offset for the clone.
      Returns:
      Clone with the offset replaced with newOffset.
    • cloneWithAddedOffset

      public RelativeHitboxInfoImpl cloneWithAddedOffset(net.minecraft.world.phys.Vec3 offset)
      Clones this HitboxInfo, offsetting the position by the supplied offset.
      Specified by:
      cloneWithAddedOffset in interface RelativeHitboxInfo
      Parameters:
      offset - Offset relative to this HitboxInfo's offset.
      Returns:
      HitboxInfo that is offset by offset in comparison to this HitboxInfo.
    • getBuilderClone

      public RelativeHitboxInfoBuilderImpl getBuilderClone()
      Specified by:
      getBuilderClone in interface RelativeHitboxInfo
      Returns:
      A clone of this relative hitbox in builder form.
    • getHitbox

      public BoundingBox getHitbox()
      Specified by:
      getHitbox in interface HitboxInfo
      Returns:
      Get the actual hitbox used for collision, intersection, etc.
    • isTriggerHitbox

      public boolean isTriggerHitbox()
      Specified by:
      isTriggerHitbox in interface HitboxInfo
      Returns:
      Whether this hitbox is a trigger hitbox. As of writing, this is if the break block button is required to be held while a hand is in this hitbox to activate it in VR.