Class ImmersiveChest
java.lang.Object
com.hammy275.immersivemc.client.immersive.AbstractImmersive<ChestInfo, ChestRenderState, ListOfItemsStorage>
com.hammy275.immersivemc.client.immersive.ImmersiveChest
- All Implemented Interfaces:
Immersive<ChestInfo, ChestRenderState, ListOfItemsStorage>
public class ImmersiveChest
extends AbstractImmersive<ChestInfo, ChestRenderState, ListOfItemsStorage>
-
Field Summary
FieldsFields inherited from class AbstractImmersive
infos -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildInfo(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level level) Constructs a new ImmersiveInfo based on the provided block position.booleanchestsValid(ChestInfo info) @Nullable ImmersiveConfigScreenInfoThe info needed to build a config screen button for this Immersive.Creates a new render state not populated with any rendering-related details.voidextractRenderState(ChestInfo info, ChestRenderState renderState, float partialTicks) Extract render state from the info into the provided render state object.static ChestInfofindImmersive(net.minecraft.world.level.block.entity.BlockEntity chest) @Nullable net.minecraft.world.phys.AABBgetDragHitbox(ChestInfo info) voidThis is the same asImmersive.tick(ImmersiveInfo), but called once per tick, instead of called once per tick per info.inthandleHitboxInteract(ChestInfo info, net.minecraft.client.player.LocalPlayer player, List<Integer> hitboxIndices, net.minecraft.world.InteractionHand hand, boolean modifierPressed) The method called when a player interacts with a hitbox.booleanisInputHitbox(ChestInfo info, int hitboxIndex) booleanisVROnly()static voidvoidprocessStorageFromNetwork(ChestInfo info, ListOfItemsStorage storage) Process the storage from the server for this Immersive.voidrender(ChestRenderState renderState, com.mojang.blaze3d.vertex.PoseStack stack, ImmersiveRenderHelpers helpers, float partialTick) Render the provided render state.booleanWhether normal right-click behavior for this block should be disabled when the option to disable interactions is enabled in ImmersiveMC.booleanshouldRender(ChestRenderState renderState) Whether the provided render state should render in the world.static booleanslotVisible(float openness, int slot) voidThis method is called once per game tick.Methods inherited from class AbstractImmersive
getTrackedObjects
-
Field Details
-
spacing
public static final double spacing- See Also:
-
-
Constructor Details
-
ImmersiveChest
public ImmersiveChest()
-
-
Method Details
-
globalTick
public void globalTick()Description copied from interface:ImmersiveThis is the same asImmersive.tick(ImmersiveInfo), but called once per tick, instead of called once per tick per info. -
buildInfo
Description copied from interface:ImmersiveConstructs a new ImmersiveInfo based on the provided block position. It's best to calculate initial hitboxes, etc. in this method to make the Immersive available for interaction as soon as possible.- Parameters:
pos- The position of a block that matches this Immersive.level- The level in which this info is being built.- Returns:
- An instance of an ImmersiveInfo implementation with the same position as provided.
-
handleHitboxInteract
public int handleHitboxInteract(ChestInfo info, net.minecraft.client.player.LocalPlayer player, List<Integer> hitboxIndices, net.minecraft.world.InteractionHand hand, boolean modifierPressed) Description copied from interface:ImmersiveThe method called when a player interacts with a hitbox.
If multiple hitboxes are being interacted with at the same time, only the first hitbox in iteration order fromImmersiveInfo.getAllHitboxes()that is being interacted with will have this function called.- Parameters:
info- The info containing the hitbox that was interacted with.player- The player that interacted with the hitbox. This player is always the player currently controlling the game window.hitboxIndices- The indices intoImmersiveInfo.getAllHitboxes()that were interacted with. The list is guaranteed to contain at least one element and all elements are not null.hand- The hand used for interaction.modifierPressed- Whether the modifier key (usually the button mapped to breaking blocks) was held for the interaction.- Returns:
- A number representing the number of ticks of cooldown to apply before the player can interact with
any Immersive again, or a negative number to denote no actual interaction has happened, such as
obtaining items from an output slot of an Immersive when the output slot has no items. This cooldown
should be the cooldown for desktop users if
Immersive.isVROnly()returns false, and it should be the cooldown for VR users ifImmersive.isVROnly()returns true. ImmersiveMC will modify this cooldown time to accommodate situations, such as VR users requiring an increased cooldown time.
-
shouldRender
Description copied from interface:ImmersiveWhether the provided render state should render in the world. It's good to return false here if this Immersive does not have its data ready for rendering.- Parameters:
renderState- The render state to check.- Returns:
- Whether the provided render state should render to the world, which includes calling
Immersive.render(ImmersiveRenderState, PoseStack, ImmersiveRenderHelpers, float).
-
render
public void render(ChestRenderState renderState, com.mojang.blaze3d.vertex.PoseStack stack, ImmersiveRenderHelpers helpers, float partialTick) Description copied from interface:ImmersiveRender the provided render state.- Parameters:
renderState- The render state to render.stack- The pose stack being rendered with.helpers- Some helper functions for rendering.partialTick- The fraction of time between the last tick and the current tick.
-
tick
Description copied from interface:ImmersiveThis method is called once per game tick. This is where you should, for example, recalculate hitboxes if needed.- Specified by:
tickin interfaceImmersive<ChestInfo, ChestRenderState, ListOfItemsStorage>- Overrides:
tickin classAbstractImmersive<ChestInfo, ChestRenderState, ListOfItemsStorage>- Parameters:
info- The info being ticked.
-
getDragHitbox
- Returns:
- The hitbox that determines whether dragging between multiple slots should continue or not. Can return
null here to not allow dragging. If non-null, the hitbox should contain all hitboxes where
Immersive.isInputHitbox(ImmersiveInfo, int)returns true.
-
isInputHitbox
- Parameters:
info- The info being checked with.hitboxIndex- The hitbox index being checked.- Returns:
- Whether the provided hitbox index is an input, such as for inputting items.
-
getHandler
- Returns:
- The
ImmersiveHandlerthis Immersive uses.
-
configScreenInfo
Description copied from interface:ImmersiveThe info needed to build a config screen button for this Immersive. If this method returns null, ImmersiveMC will not add a setting for this Immersive to its in-game configuration. Reasons to possibly return null from this method include, but are not limited to:- This Immersive cannot be controlled via a config.
- Another mod already handles configuring this Immersive.
- Returns:
- An ImmersiveConfigScreenInfo instance used for ImmersiveMC to add this Immersive to its in-game configuration screens, or null if ImmersiveMC should not do so.
-
shouldDisableRightClicksWhenVanillaInteractionsDisabled
Description copied from interface:ImmersiveWhether normal right-click behavior for this block should be disabled when the option to disable interactions is enabled in ImmersiveMC. This should usually return true if the block opens a GUI on right-click.- Parameters:
info- The info for the block that may want to disable right-clicks.- Returns:
- Whether to skip right-click behavior for this block when the option to disable click interactions is enabled in ImmersiveMC.
-
processStorageFromNetwork
Description copied from interface:ImmersiveProcess the storage from the server for this Immersive. Not called for Immersives that return true forImmersive.getHandler()'sImmersiveHandler.clientAuthoritative().- Parameters:
info- The info with storage being processed.storage- The storage to be processed.
-
isVROnly
public boolean isVROnly()- Returns:
- Whether this Immersive should only exist for VR users. The same value should always be returned by this method.
-
createRenderState
Description copied from interface:ImmersiveCreates a new render state not populated with any rendering-related details.- Returns:
- Created render state, as described.
-
extractRenderState
Description copied from interface:ImmersiveExtract render state from the info into the provided render state object.The extracted render state must be independent of the info it comes from such that mutations to the info do not affect the render state. For example, if the info contains a list of hitboxes, a modification to that list must NOT modify the list of hitboxes stored in the render state.
- Specified by:
extractRenderStatein interfaceImmersive<ChestInfo, ChestRenderState, ListOfItemsStorage>- Overrides:
extractRenderStatein classAbstractImmersive<ChestInfo, ChestRenderState, ListOfItemsStorage>- Parameters:
info- Info to extract render state from.renderState- Render state to populate from the info. Note that the API does NOT cover the state of this object when this function is called. It only defines that this should be fully populated from the provided info for rendering. As such, it's recommended to set the values for all fields in this object based on the provided info every time this method is called.partialTicks- The fraction of time between the last tick and the current tick.
-
chestsValid
-
findImmersive
-
openChest
-
slotVisible
public static boolean slotVisible(float openness, int slot)
-