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
FieldsModifier and TypeFieldDescriptionfinal Function<BuiltImmersiveInfo<?>, net.minecraft.world.phys.Vec3> final booleanfinal Function<BuiltImmersiveInfo<?>, ForcedUpDownRenderDir> final booleanfinal booleanfinal booleanfinal booleannet.minecraft.world.item.ItemStackfinal floatfinal booleanfinal booleanfinal booleanfinal booleanfinal doublefinal doublefinal doublefinal Function<BuiltImmersiveInfo<?>, List<com.mojang.datafixers.util.Pair<net.minecraft.network.chat.Component, net.minecraft.world.phys.Vec3>>> final HitboxVRMovementInfo -
Constructor Summary
ConstructorsConstructorDescriptionRelativeHitboxInfoImpl(RelativeHitboxInfoBuilderImpl usedBuilder, Function<BuiltImmersiveInfo<?>, net.minecraft.world.phys.Vec3> centerOffset, double sizeX, double sizeY, double sizeZ, boolean holdsItems, boolean isInput, boolean itemSpins, float itemRenderSizeMultiplier, boolean isTriggerHitbox, Function<BuiltImmersiveInfo<?>, List<com.mojang.datafixers.util.Pair<net.minecraft.network.chat.Component, net.minecraft.world.phys.Vec3>>> textSupplier, Function<BuiltImmersiveInfo<?>, ForcedUpDownRenderDir> forcedUpDownDir, boolean constantOffset, boolean needs3dCompat, HitboxVRMovementInfo vrMovementInfo, boolean renderItem, boolean renderItemCount, boolean forcedUpDownRenderDirConstant) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleancalcDone()clone()cloneWithAddedOffset(net.minecraft.world.phys.Vec3 offset) Clones this HitboxInfo, offsetting the position by the supplied offset.cloneWithNewOffset(Function<BuiltImmersiveInfo<?>, net.minecraft.world.phys.Vec3> newOffset) Clones this HitboxInfo replacing the offset with the supplied one.voidForce the position and box of this hitbox to be null.net.minecraft.world.phys.AABBgetAABB()net.minecraft.world.phys.AABBgetRenderHitbox(float partialTick) net.minecraft.core.DirectionbooleanhasAABB()booleanvoidvoidrecalculate(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<BuiltImmersiveInfo<?>,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 -
forcedUpDownRenderDirConstant
public final boolean forcedUpDownRenderDirConstant -
item
public net.minecraft.world.item.ItemStack item
-
-
Constructor Details
-
RelativeHitboxInfoImpl
public RelativeHitboxInfoImpl(RelativeHitboxInfoBuilderImpl usedBuilder, Function<BuiltImmersiveInfo<?>, net.minecraft.world.phys.Vec3> centerOffset, double sizeX, double sizeY, double sizeZ, boolean holdsItems, boolean isInput, boolean itemSpins, float itemRenderSizeMultiplier, boolean isTriggerHitbox, Function<BuiltImmersiveInfo<?>, List<com.mojang.datafixers.util.Pair<net.minecraft.network.chat.Component, net.minecraft.world.phys.Vec3>>> textSupplier, Function<BuiltImmersiveInfo<?>, ForcedUpDownRenderDir> forcedUpDownDir, boolean constantOffset, boolean needs3dCompat, HitboxVRMovementInfo vrMovementInfo, boolean renderItem, boolean renderItemCount, boolean forcedUpDownRenderDirConstant) Constructor. See the respective functions inRelativeHitboxInfoBuilderImplfor 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 theImmersiveBuilderImplfor 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. SeeHitboxPositioningModefor what each mode does.info- Info instance.
-
getRenderHitbox
public net.minecraft.world.phys.AABB getRenderHitbox(float partialTick) - Specified by:
getRenderHitboxin interfaceHitboxInfo- Parameters:
partialTick- The partial tick between the current tick and the next.- Returns:
- The bounding box to be used for rendering.
-
onOrientationChange
public void onOrientationChange() -
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<BuiltImmersiveInfo<?>, 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:
cloneWithAddedOffsetin 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:
getBuilderClonein interfaceRelativeHitboxInfo- Returns:
- A clone of this relative hitbox in builder form.
-
getHitbox
- Specified by:
getHitboxin interfaceHitboxInfo- Returns:
- Get the actual hitbox used for collision, intersection, etc.
-
isTriggerHitbox
public boolean isTriggerHitbox()- Specified by:
isTriggerHitboxin 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.
-