Class BuiltImmersiveImpl<E,S extends NetworkStorage>
java.lang.Object
com.hammy275.immersivemc.client.immersive.BuiltImmersiveImpl<E,S>
- All Implemented Interfaces:
BuiltImmersive<E,
,S> Immersive<BuiltImmersiveInfo<E>,
S>
public final class BuiltImmersiveImpl<E,S extends NetworkStorage>
extends Object
implements BuiltImmersive<E,S>
-
Constructor Summary
-
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.<T extends NetworkStorage>
ImmersiveBuilderImpl<E,T> getBuilderClone
(ImmersiveHandler<T> newHandler) Creates a clone of this Immersive for creating an Immersive similar to this one.net.minecraft.core.BlockPos
getLightPos
(BuiltImmersiveInfo<E> infoIn) List<net.minecraft.core.BlockPos>
getLightPositions
(BuiltImmersiveInfo<E> info) Get the collection of ImmersiveInfos currently active for this Immersive.int
handleHitboxInteract
(BuiltImmersiveInfo<E> infoIn, 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
(BuiltImmersiveInfo<E> infoIn, S storage) Process the storage from the server for this Immersive.void
render
(BuiltImmersiveInfo<E> infoIn, 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
(BuiltImmersiveInfo<E> infoIn) Whether the provided info should render in the world.void
tick
(BuiltImmersiveInfo<E> infoIn) This method is called once per game tick.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.hammy275.immersivemc.api.client.immersive.Immersive
globalTick
-
Constructor Details
-
BuiltImmersiveImpl
-
-
Method Details
-
getHandler
- Specified by:
getHandler
in interfaceImmersive<E,
S extends NetworkStorage> - Returns:
- The
ImmersiveHandler
this Immersive uses.
-
configScreenInfo
Description copied from interface:Immersive
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.
- Specified by:
configScreenInfo
in interfaceImmersive<E,
S extends NetworkStorage> - 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.
-
shouldRender
Description copied from interface:Immersive
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.- Specified by:
shouldRender
in interfaceImmersive<E,
S extends NetworkStorage> - Parameters:
infoIn
- The info to check.- Returns:
- Whether the provided info should render to the world, which includes calling
Immersive.render(ImmersiveInfo, PoseStack, ImmersiveRenderHelpers, float)
.
-
tick
Description copied from interface:Immersive
This method is called once per game tick. This is where you should, for example, recalculate hitboxes if needed.- Specified by:
tick
in interfaceImmersive<E,
S extends NetworkStorage> - Parameters:
infoIn
- The info being ticked.
-
render
public void render(BuiltImmersiveInfo<E> infoIn, com.mojang.blaze3d.vertex.PoseStack stack, ImmersiveRenderHelpers helpers, float partialTicks) Description copied from interface:Immersive
Render the provided info.- Specified by:
render
in interfaceImmersive<E,
S extends NetworkStorage> - Parameters:
infoIn
- 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.
-
buildInfo
public BuiltImmersiveInfo<E> buildInfo(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level level) Description copied from interface:Immersive
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.- Specified by:
buildInfo
in interfaceImmersive<E,
S extends NetworkStorage> - 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.
-
shouldDisableRightClicksWhenVanillaInteractionsDisabled
Description copied from interface:Immersive
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.- Specified by:
shouldDisableRightClicksWhenVanillaInteractionsDisabled
in interfaceImmersive<E,
S extends NetworkStorage> - 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.
-
getTrackedObjects
Description copied from interface:Immersive
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 ofImmersive.buildInfo(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.- Specified by:
getTrackedObjects
in interfaceImmersive<E,
S extends NetworkStorage> - Returns:
- The collection of all ImmersiveInfos tied to this Immersive.
-
handleHitboxInteract
public int handleHitboxInteract(BuiltImmersiveInfo<E> infoIn, net.minecraft.client.player.LocalPlayer player, int hitboxIndex, net.minecraft.world.InteractionHand hand) Description copied from interface:Immersive
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.- Specified by:
handleHitboxInteract
in interfaceImmersive<E,
S extends NetworkStorage> - Parameters:
infoIn
- 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
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.
-
getLightPositions
-
getLightPos
-
processStorageFromNetwork
Description copied from interface:Immersive
Process the storage from the server for this Immersive. Not called for Immersives that return true forImmersive.getHandler()
'sImmersiveHandler.clientAuthoritative()
.- Specified by:
processStorageFromNetwork
in interfaceImmersive<E,
S extends NetworkStorage> - Parameters:
infoIn
- The info with storage being processed.storage
- The storage to be processed.
-
isVROnly
public boolean isVROnly()- Specified by:
isVROnly
in interfaceImmersive<E,
S extends NetworkStorage> - Returns:
- Whether this Immersive should only exist for VR users. The same value should always be returned by this method.
-
getBuilderClone
public <T extends NetworkStorage> ImmersiveBuilderImpl<E,T> getBuilderClone(ImmersiveHandler<T> newHandler) Description copied from interface:BuiltImmersive
Creates a clone of this Immersive for creating an Immersive similar to this one.- Specified by:
getBuilderClone
in interfaceBuiltImmersive<E,
S extends NetworkStorage> - Parameters:
newHandler
- The new handler for this Immersive.- Returns:
- A new builder instance.
-