Class AbstractDragImmersive
java.lang.Object
com.hammy275.immersivemc.client.immersive.AbstractDragImmersive
- All Implemented Interfaces:
Immersive<DragImmersiveInfo,NullStorage>
- Direct Known Subclasses:
ImmersiveDoor,ImmersiveLever,ImmersiveRepeater,ImmersiveTrapdoor
public abstract class AbstractDragImmersive
extends Object
implements Immersive<DragImmersiveInfo,NullStorage>
Immersive that's used for dragging between hitboxes, such as trapdoors.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract AbstractDragImmersive.AutoDragSettingsConfigures auto-dragging.@Nullable net.minecraft.world.phys.AABBGet the collection of ImmersiveInfos currently active for this Immersive.inthandleHitboxInteract(DragImmersiveInfo 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.protected abstract voidhitboxDragged(DragImmersiveInfo info, int controller, int oldIndex, int newIndex) Called whenever a drag occurs from some old hitbox index to a new one.booleanisInputHitbox(DragImmersiveInfo info, int hitboxIndex) booleanisVROnly()protected voidmakeHitboxes(DragImmersiveInfo info, net.minecraft.world.level.Level level) Add/set hitboxes into the info instance.voidprocessStorageFromNetwork(DragImmersiveInfo info, NullStorage storage) Process the storage from the server for this Immersive.voidrender(DragImmersiveInfo info, com.mojang.blaze3d.vertex.PoseStack stack, ImmersiveRenderHelpers helpers, float partialTick) Render the provided info.booleanWhether normal right-click behavior for this block should be disabled when the option to disable interactions is enabled in ImmersiveMC.booleanWhether the provided info should render in the world.voidtick(DragImmersiveInfo info) 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, waitMethods inherited from interface com.hammy275.immersivemc.api.client.immersive.Immersive
buildInfo, configScreenInfo, getHandler, globalTick
-
Field Details
-
trackedObjects
-
-
Constructor Details
-
AbstractDragImmersive
public AbstractDragImmersive()
-
-
Method Details
-
hitboxDragged
protected abstract void hitboxDragged(DragImmersiveInfo info, int controller, int oldIndex, int newIndex) Called whenever a drag occurs from some old hitbox index to a new one. This is an ideal spot to updateDragImmersiveInfo.startingHitboxIndexif not auto-dragging.- Parameters:
info- Info with dragging happening.controller- Controller number that is dragging.oldIndex- Old hitbox index. This will be -1 if starting a drag from "anywhere".newIndex- New hitbox index. This will never be -1.
-
autoDragSettings
Configures auto-dragging.- All integers in nonInteractable represent indexes into
DragImmersiveInfo.hitboxeswhich will count for dragging but will never be passed tohitboxDragged(DragImmersiveInfo, int, int, int)as either the old or new index. This is mainly intended for when you want to allow dragging between some hitboxes, but need an outer hitbox that keeps the dragging going; this function should return the index for that outer hitbox. - makeHitboxesEveryTick determines whether
makeHitboxes(DragImmersiveInfo, Level)is called every tick.
- Returns:
- Whether to use auto-dragging.
- All integers in nonInteractable represent indexes into
-
makeHitboxes
Add/set hitboxes into the info instance. Called automatically on each tick ifAbstractDragImmersive.AutoDragSettings.makeHitboxesEveryTickis true. Otherwise, it's not called.- Parameters:
info- Info to set hitboxes into.level- The current level.
-
getTrackedObjects
Description copied from interface:ImmersiveGet 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:
getTrackedObjectsin interfaceImmersive<DragImmersiveInfo,NullStorage> - Returns:
- The collection of all ImmersiveInfos tied to this Immersive.
-
handleHitboxInteract
public int handleHitboxInteract(DragImmersiveInfo 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.- Specified by:
handleHitboxInteractin interfaceImmersive<DragImmersiveInfo,NullStorage> - 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 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:
shouldRenderin interfaceImmersive<DragImmersiveInfo,NullStorage> - Parameters:
info- The info to check.- Returns:
- Whether the provided info should render to the world, which includes calling
Immersive.render(ImmersiveInfo, PoseStack, ImmersiveRenderHelpers, float).
-
render
public void render(DragImmersiveInfo info, com.mojang.blaze3d.vertex.PoseStack stack, ImmersiveRenderHelpers helpers, float partialTick) Description copied from interface:ImmersiveRender the provided info.- Specified by:
renderin interfaceImmersive<DragImmersiveInfo,NullStorage> - Parameters:
info- The info 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<DragImmersiveInfo,NullStorage> - Parameters:
info- The info being ticked.
-
getDragHitbox
- Specified by:
getDragHitboxin interfaceImmersive<DragImmersiveInfo,NullStorage> - 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
- Specified by:
isInputHitboxin interfaceImmersive<DragImmersiveInfo,NullStorage> - 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.
-
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.- Specified by:
shouldDisableRightClicksWhenVanillaInteractionsDisabledin interfaceImmersive<DragImmersiveInfo,NullStorage> - 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().- Specified by:
processStorageFromNetworkin interfaceImmersive<DragImmersiveInfo,NullStorage> - Parameters:
info- The info with storage being processed.storage- The storage to be processed.
-
isVROnly
public boolean isVROnly()- Specified by:
isVROnlyin interfaceImmersive<DragImmersiveInfo,NullStorage> - Returns:
- Whether this Immersive should only exist for VR users. The same value should always be returned by this method.
-