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
Modifier and TypeFieldDescriptionprotected boolean
boolean
final int
static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
void
Do rendering This is the render method that should be called by outside functionsprotected void
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[]
getLightPositions
(I info) 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 tickabstract 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
hasMultipleLightPositions
(I info) Override to use getLightPositions instead of getLightPosboolean
protected abstract void
Initializes an `info` instance after it's constructed.protected abstract boolean
inputSlotShouldRenderHelpHitbox
(I info, int slotNum) boolean
isVROnly()
void
Run when there are no infosvoid
Called just before handleRightClick() and handleTriggerHitboxRightClick()void
net.minecraft.world.phys.Vec3
Gets player position while accounting for partial ticks (getFrameTime())abstract void
processStorageFromNetwork
(AbstractPlayerAttachmentInfo info, S storage) abstract I
refreshOrTrackObject
(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level level) protected abstract void
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 positionprotected 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
-
Field Details
-
maxLight
public static final int maxLight -
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
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
- Returns:
- ImmersiveHandler that this immersive uses. Can return null if this immersive doesn't receive item data from the server through FetchInventoryPacket.
-
hitboxesAvailable
-
shouldRender
-
render
-
enabledInConfig
public abstract boolean enabledInConfig() -
inputSlotShouldRenderHelpHitbox
-
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
-
initInfo
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
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
-
slotHelpBoxIsSelected
-
processStorageFromNetwork
-
tick
-
getCooldownVR
public int getCooldownVR() -
getCooldownDesktop
public int getCooldownDesktop() -
doTick
-
getLightPos
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
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
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
Do rendering This is the render method that should be called by outside functions -
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 renderstack
- PoseStack inpos
- Position to render atsize
- Size to render atfacing
- 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 renderingrenderItemCounts
- Whether to render an item count with the itemspinDegrees
- 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
-
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 frompos
- 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.
-