Class ImmersiveBuilderImpl<E,S extends NetworkStorage>
java.lang.Object
com.hammy275.immersivemc.client.immersive.ImmersiveBuilderImpl<E,S>
- All Implemented Interfaces:
ImmersiveBuilder<E,
S>
public class ImmersiveBuilderImpl<E,S extends NetworkStorage>
extends Object
implements ImmersiveBuilder<E,S>
-
Constructor Summary
ConstructorDescriptionImmersiveBuilderImpl
(ImmersiveHandler<S> handler, @Nullable Class<E> extraInfoDataClazz) -
Method Summary
Modifier and TypeMethodDescriptionadd3x3Grid
(RelativeHitboxInfo relativeHitboxInfo, double distBetweenBoxes) Adds a 3x3 grid of hitboxes, such as for the crafting table.addHitbox
(RelativeHitboxInfo relativeHitboxInfo) Adds a hitbox.build()
Builds this Immersive.<T extends NetworkStorage>
ImmersiveBuilderImpl<E,T> copy
(ImmersiveHandler<T> newHandler) Create a copy of this ImmersiveBuilder, setting the extra storage consumer to null.<F,
T extends NetworkStorage>
ImmersiveBuilderImpl<F,T> copy
(ImmersiveHandler<T> newHandler, Class<F> newExtraInfoDataClass) Create a copy of this ImmersiveBuilder, setting the extra storage consumer, the extra render ready, the slot active function, the on remove function, the slot renders item guide function, the right click handler, and the Immersive config info to null/no-op on the copy.modifyHitbox
(int index, Function<RelativeHitboxInfoBuilder, RelativeHitboxInfo> modifier) Modify a hitbox.modifyHitboxes
(int startIndex, int endIndex, Function<RelativeHitboxInfoBuilder, RelativeHitboxInfo> modifier) Modify a range of hitboxes, inclusive for both ends.overwriteHitbox
(int index, RelativeHitboxInfo relativeHitboxInfo) Overwrites hitbox at index with a new hitbox.setConfigChecker
(Supplier<Boolean> checker) Sets a function used to retrieve the config value for whether this immersive is enabled.Set the config screen info associated with this Immersive.setExtraStorageConsumer
(BiConsumer<S, BuiltImmersiveInfo<E>> storageConsumer) Sets a consumer that acts after an incoming NetworkStorage is parsed.setHitboxInteractHandler
(HitboxInteractHandler<E> handler) Sets what should happen when a hitbox is interacted with.setOnRemove
(Consumer<BuiltImmersiveInfo<E>> onRemove) Set function to run on an info before it's removed.setPositioningMode
(HitboxPositioningMode newMode) Sets the way hitboxes are positioned on the block.setRenderSize
(float size) Sets the size for items rendered by this immersive.setShouldRenderItemGuideFunction
(BiFunction<BuiltImmersiveInfo<E>, Integer, Boolean> itemGuideActive) Set whether the item guide for this slot should be active.setSlotActiveFunction
(BiFunction<BuiltImmersiveInfo<E>, Integer, Boolean> slotActive) Sets a function that determines whether a given slot should be active (rendered, reacts to interactions, etc.).setVROnly
(boolean vrOnly) Sets whether this immersive is only for VR users.shouldDisableRightClicksWhenInteractionsDisabled
(boolean doDisable) Set whether to disable right-click interactions on this immersive when the option to disable said interactions is enabled.
-
Constructor Details
-
ImmersiveBuilderImpl
public ImmersiveBuilderImpl(ImmersiveHandler<S> handler, @Nullable @Nullable Class<E> extraInfoDataClazz)
-
-
Method Details
-
setRenderSize
Sets the size for items rendered by this immersive.- Specified by:
setRenderSize
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
size
- The size of the item when rendering.- Returns:
- Builder object.
-
addHitbox
Adds a hitbox. Note that item hitboxes MUST be added in slot-order. Aka, the underlying block's slot 0 should be added before its slot 1, etc.- Specified by:
addHitbox
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
relativeHitboxInfo
- HitboxInfo to add. Can use HitboxInfoBuilder to make it easier to create.- Returns:
- Builder object.
-
add3x3Grid
public ImmersiveBuilderImpl<E,S> add3x3Grid(RelativeHitboxInfo relativeHitboxInfo, double distBetweenBoxes) Adds a 3x3 grid of hitboxes, such as for the crafting table. Adds the top row from left to right, then the middle row from left to right, then the bottom row from left to right.- Specified by:
add3x3Grid
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
relativeHitboxInfo
- HitboxInfo for center box. Can use HitboxInfoBuilder to make it easier to create.distBetweenBoxes
- Distance between boxes.- Returns:
- Builder object.
-
setPositioningMode
Sets the way hitboxes are positioned on the block.- Specified by:
setPositioningMode
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
newMode
- New mode for positioning.- Returns:
- Builder object.
-
setConfigChecker
Sets a function used to retrieve the config value for whether this immersive is enabled.- Specified by:
setConfigChecker
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
checker
- Checker to retrieve config value. Something such as () -> ActiveConfig.active().myConfigValue works here.- Returns:
- Builder object.
-
setHitboxInteractHandler
Sets what should happen when a hitbox is interacted with.- Specified by:
setHitboxInteractHandler
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
handler
- Function that takes an info instance, a player doing the interaction, the slot being interacted with, and the hand being interacted with. This function should return a number denoting the cooldown until the user can interact with Immersives again, or a negative number to denote that no interaction took place.- Returns:
- Builder object.
-
setVROnly
Sets whether this immersive is only for VR users.- Specified by:
setVROnly
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
vrOnly
- Whether this immersive should now be VR only.- Returns:
- Builder object.
-
setExtraStorageConsumer
public ImmersiveBuilderImpl<E,S> setExtraStorageConsumer(BiConsumer<S, BuiltImmersiveInfo<E>> storageConsumer) Sets a consumer that acts after an incoming NetworkStorage is parsed. For example, this is used for the anvil to retrieve the level amount and store it in extra data.- Specified by:
setExtraStorageConsumer
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
storageConsumer
- New storage consumer.- Returns:
- Builder object.
-
setSlotActiveFunction
public ImmersiveBuilderImpl<E,S> setSlotActiveFunction(BiFunction<BuiltImmersiveInfo<E>, Integer, Boolean> slotActive) Sets a function that determines whether a given slot should be active (rendered, reacts to interactions, etc.).- Specified by:
setSlotActiveFunction
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
slotActive
- Function that takes an info instance and a slot number and returns whether the slot is active.- Returns:
- Builder object.
-
setOnRemove
Set function to run on an info before it's removed.- Specified by:
setOnRemove
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
onRemove
- Function to run on info just before removal.- Returns:
- Builder object.
-
shouldDisableRightClicksWhenInteractionsDisabled
public ImmersiveBuilderImpl<E,S> shouldDisableRightClicksWhenInteractionsDisabled(boolean doDisable) Set whether to disable right-click interactions on this immersive when the option to disable said interactions is enabled.- Specified by:
shouldDisableRightClicksWhenInteractionsDisabled
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
doDisable
- Whether to disable as described above.- Returns:
- Builder object.
-
setShouldRenderItemGuideFunction
public ImmersiveBuilderImpl<E,S> setShouldRenderItemGuideFunction(BiFunction<BuiltImmersiveInfo<E>, Integer, Boolean> itemGuideActive) Set whether the item guide for this slot should be active. This result is AND'd with the built-in checker, which is simply if the slot holds items but currently isn't holding one.- Specified by:
setShouldRenderItemGuideFunction
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
itemGuideActive
- Function that returns whether the given slot is active given the info.- Returns:
- Builder object.
-
setConfigScreenInfo
Description copied from interface:ImmersiveBuilder
Set the config screen info associated with this Immersive.- Specified by:
setConfigScreenInfo
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
info
- The config screen info to associate with this Immersive.- Returns:
- Builder object.
-
overwriteHitbox
Overwrites hitbox at index with a new hitbox. Useful when cloning.- Specified by:
overwriteHitbox
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
index
- Index to overwrite.relativeHitboxInfo
- New hitbox information.- Returns:
- Builder object.
-
modifyHitbox
public ImmersiveBuilderImpl<E,S> modifyHitbox(int index, Function<RelativeHitboxInfoBuilder, RelativeHitboxInfo> modifier) Modify a hitbox.- Specified by:
modifyHitbox
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
index
- Index of hitbox to modify.modifier
- A function that takes the old hitbox as a builder and returns new hitbox info.- Returns:
- Builder object.
-
modifyHitboxes
public ImmersiveBuilderImpl<E,S> modifyHitboxes(int startIndex, int endIndex, Function<RelativeHitboxInfoBuilder, RelativeHitboxInfo> modifier) Modify a range of hitboxes, inclusive for both ends.- Specified by:
modifyHitboxes
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Parameters:
startIndex
- Starting index of range of hitboxes to modify inclusive.endIndex
- Ending index of range of hitboxes to modify inclusive.modifier
- A function that takes the old hitbox as a builder and returns new hitbox info.- Returns:
- Builder object.
-
build
Description copied from interface:ImmersiveBuilder
Builds this Immersive.- Specified by:
build
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Returns:
- The built Immersive from this builder.
-
copy
Create a copy of this ImmersiveBuilder, setting the extra storage consumer to null.- Specified by:
copy
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Returns:
- A best-effort copy of this ImmersiveBuilder.
-
copy
public <F,T extends NetworkStorage> ImmersiveBuilderImpl<F,T> copy(ImmersiveHandler<T> newHandler, Class<F> newExtraInfoDataClass) Description copied from interface:ImmersiveBuilder
Create a copy of this ImmersiveBuilder, setting the extra storage consumer, the extra render ready, the slot active function, the on remove function, the slot renders item guide function, the right click handler, and the Immersive config info to null/no-op on the copy.- Specified by:
copy
in interfaceImmersiveBuilder<E,
S extends NetworkStorage> - Returns:
- A best-effort copy of this ImmersiveBuilder.
-