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 Summary
Modifier and TypeFieldDescriptionfinal Function<BuiltImmersiveInfoImpl<?>,
net.minecraft.world.phys.Vec3> final boolean
final ForcedUpDownRenderDir
final boolean
final boolean
final boolean
net.minecraft.world.item.ItemStack
final float
final boolean
final boolean
final boolean
final boolean
final double
final double
final double
final Function<BuiltImmersiveInfoImpl<?>,
List<com.mojang.datafixers.util.Pair<net.minecraft.network.chat.Component, net.minecraft.world.phys.Vec3>>> final HitboxVRMovementInfo
-
Constructor Summary
ConstructorDescriptionRelativeHitboxInfoImpl
(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. -
Method Summary
Modifier and TypeMethodDescriptionboolean
calcDone()
clone()
cloneWithAddedOffset
(net.minecraft.world.phys.Vec3 offset) Clones this HitboxInfo, offsetting the position by the supplied offset.cloneWithNewOffset
(Function<BuiltImmersiveInfoImpl<?>, net.minecraft.world.phys.Vec3> newOffset) Clones this HitboxInfo replacing the offset with the supplied one.void
Force the position and box of this hitbox to be null.net.minecraft.world.phys.AABB
getAABB()
net.minecraft.core.Direction
boolean
hasAABB()
boolean
void
recalculate
(net.minecraft.world.level.Level level, HitboxPositioningMode mode, BuiltImmersiveInfoImpl<?> info) Main external function call.
-
Field Details
-
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, textSuppliernet.minecraft.world.phys.Vec3>>> -
forcedUpDownRenderDir
-
constantOffset
public final boolean constantOffset -
needs3dCompat
public final boolean needs3dCompat -
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 inRelativeHitboxInfoBuilderImpl
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 theImmersiveBuilderImpl
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. SeeHitboxPositioningMode
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
-
calcDone
public boolean calcDone()- Returns:
- Whether the relative to literal calculation has been performed at least one.
-
clone
-
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
Clones this HitboxInfo, offsetting the position by the supplied offset.- Specified by:
cloneWithAddedOffset
in interfaceRelativeHitboxInfo
- Parameters:
offset
- Offset relative to this HitboxInfo's offset.- Returns:
- HitboxInfo that is offset by offset in comparison to this HitboxInfo.
-
getBuilderClone
- Specified by:
getBuilderClone
in interfaceRelativeHitboxInfo
- Returns:
- A clone of this relative hitbox in builder form.
-
getHitbox
- Specified by:
getHitbox
in interfaceHitboxInfo
- Returns:
- Get the actual hitbox used for collision, intersection, etc.
-
isTriggerHitbox
public boolean isTriggerHitbox()- Specified by:
isTriggerHitbox
in interfaceHitboxInfo
- 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.
-