Interface Immersive<I extends ImmersiveInfo,S extends NetworkStorage>
- Type Parameters:
I
- TheImmersiveInfo
implementation this Immersive uses.S
- The type of storage to use for sending Immersive data over the network.
- All Known Subinterfaces:
BuiltImmersive<E,
S>
- All Known Implementing Classes:
AbstractDragImmersive
,AbstractImmersive
,BuiltImmersiveImpl
,ImmersiveBeacon
,ImmersiveChest
,ImmersiveLectern
,ImmersiveLever
,ImmersiveRepeater
,ImmersiveTrapdoor
public interface Immersive<I extends ImmersiveInfo,S extends NetworkStorage>
Represents the client-side implementation of a block-based Immersive implementation.
To clarify what an Immersive is, from the user's perspective, an Immersive is a single category of thing that ImmersiveMC supports. Whether that be furnaces, throwing, or petting, those are all considered Immersives.
From a programming perspective, the term Immersive is used to represent a few different concepts:
To clarify what an Immersive is, from the user's perspective, an Immersive is a single category of thing that ImmersiveMC supports. Whether that be furnaces, throwing, or petting, those are all considered Immersives.
From a programming perspective, the term Immersive is used to represent a few different concepts:
- The aforementioned user definition of an Immersive.
- The aforementioned user definition of an Immersive, but only for implementations that take advantage of this interface. This is also referred to as a block-based Immersive.
- The client-side exclusive logic of a block-based Immersive.
ImmersiveBuilder
). When combined with a ImmersiveHandler
, you have
a fully-functioning (block-based) Immersive!-
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.@Nullable ImmersiveConfigScreenInfo
The info needed to build a config screen button for this Immersive.Get the collection of ImmersiveInfos currently active for this Immersive.default void
This is the same astick(ImmersiveInfo)
, but called once per tick, instead of called once per tick per info.int
handleHitboxInteract
(I info, net.minecraft.client.player.LocalPlayer player, int hitboxIndex, net.minecraft.world.InteractionHand hand) The method called when a player interacts with a hitbox.boolean
isVROnly()
void
processStorageFromNetwork
(I info, S storage) Process the storage from the server for this Immersive.void
render
(I info, com.mojang.blaze3d.vertex.PoseStack stack, ImmersiveRenderHelpers helpers, float partialTicks) Render the provided info.boolean
Whether normal right-click behavior for this block should be disabled when the option to disable interactions is enabled in ImmersiveMC.boolean
shouldRender
(I info) Whether the provided info should render in the world.void
This method is called once per game tick.
-
Method Details
-
getTrackedObjects
Collection<I> getTrackedObjects()Get the collection of ImmersiveInfos currently active for this Immersive. The contents of the list may be modified by ImmersiveMC with the intention of updating the actual set of active ImmersiveInfos.
For example, if this Immersive represented a furnace, and the furnace was broken, ImmersiveMC would remove the ImmersiveInfo from the collection returned by this function to indicate that this Immersive should no longer handle the block, as it is no longer a furnace. As another example, if this Immersive represented a furnace, and a player placed a furnace, ImmersiveMC would add the result ofbuildInfo(BlockPos, Level)
to the collection returned by this function.
In short, you should the actual collection of ImmersiveInfos used by this Immersive instead of a copy of it, unless you want to deal with a lot of extra work.- Returns:
- The collection of all ImmersiveInfos tied to this Immersive.
-
buildInfo
Constructs 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
int handleHitboxInteract(I info, net.minecraft.client.player.LocalPlayer player, int hitboxIndex, net.minecraft.world.InteractionHand hand) The 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.hitboxIndex
- The index intoImmersiveInfo.getAllHitboxes()
that was interacted with.hand
- The hand used for 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
isVROnly()
returns false, and it should be the cooldown for VR users ifisVROnly()
returns true. ImmersiveMC will modify this cooldown time to accommodate situations, such as VR users requiring an increased cooldown time.
-
tick
This method is called once per game tick. This is where you should, for example, recalculate hitboxes if needed.- Parameters:
info
- The info being ticked.
-
shouldRender
Whether the provided info should render in the world. It's good to return false here if this Immersive does not have its data ready for rendering.- Parameters:
info
- The info to check.- Returns:
- Whether the provided info should render to the world, which includes calling
render(ImmersiveInfo, PoseStack, ImmersiveRenderHelpers, float)
.
-
render
void render(I info, com.mojang.blaze3d.vertex.PoseStack stack, ImmersiveRenderHelpers helpers, float partialTicks) Render the provided info.- Parameters:
info
- The info to render.stack
- The pose stack being rendered with.helpers
- Some helper functions for rendering.partialTicks
- The fraction of time between the last tick and the current tick.
-
getHandler
ImmersiveHandler<S> getHandler()- Returns:
- The
ImmersiveHandler
this Immersive uses.
-
configScreenInfo
The 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
Whether 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
Process the storage from the server for this Immersive. Not called for Immersives that return true forgetHandler()
'sImmersiveHandler.clientAuthoritative()
.- Parameters:
info
- The info with storage being processed.storage
- The storage to be processed.
-
isVROnly
boolean isVROnly()- Returns:
- Whether this Immersive should only exist for VR users. The same value should always be returned by this method.
-
globalTick
default void globalTick()This is the same astick(ImmersiveInfo)
, but called once per tick, instead of called once per tick per info.
-