Class BlockBasedImmersiveBuilderImpl<E, ER, S extends NetworkStorage>
java.lang.Object
com.hammy275.immersivemc.client.immersive.BlockBasedImmersiveBuilderImpl<E,ER,S>
- All Implemented Interfaces:
BlockBasedImmersiveBuilder<E,ER, S>
public class BlockBasedImmersiveBuilderImpl<E, ER, S extends NetworkStorage>
extends Object
implements BlockBasedImmersiveBuilder<E,ER,S>
-
Constructor Summary
ConstructorsConstructorDescriptionBlockBasedImmersiveBuilderImpl(BlockBasedImmersiveHandler<S> handler, @Nullable Class<E> extraInfoDataClazz, @Nullable Class<ER> extraInfoDataRenderStateClazz, @Nullable BiConsumer<BuiltBlockBasedImmersiveInfo<E>, ER> extraInfoDataRenderStateExtractor) -
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>
BlockBasedImmersiveBuilderImpl<E, ER, T> copy(BlockBasedImmersiveHandler<T> newHandler) Create a copy of this ImmersiveBuilder, setting the extra storage consumer to null.<F, FR, T extends NetworkStorage>
BlockBasedImmersiveBuilderImpl<F, FR, T> copy(BlockBasedImmersiveHandler<T> newHandler, Class<F> newExtraInfoDataClass, Class<FR> newExtraInfoDataRenderStateClass, BiConsumer<BuiltBlockBasedImmersiveInfo<F>, FR> newExtraInfoDataRenderStateExtractor) 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.Set the config screen info associated with this Immersive.setDragHitboxCreator(@Nullable Function<BuiltBlockBasedImmersiveInfo<E>, net.minecraft.world.phys.AABB> dragHitboxCreator) Sets the function used to generate the drag hitbox.setExtraRenderer(ExtraRenderer<ER> renderer) Set an extra function to run when rendering.setExtraStorageConsumer(BiConsumer<S, BuiltBlockBasedImmersiveInfo<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<BuiltBlockBasedImmersiveInfo<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<BuiltBlockBasedImmersiveRenderState<ER>, Integer, Boolean> itemGuideActive) Set whether the item guide for this slot should be active.setSlotActiveFunction(BiFunction<BuiltBlockBasedImmersiveInfo<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.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BlockBasedImmersiveBuilder
setNoDragHitbox
-
Constructor Details
-
BlockBasedImmersiveBuilderImpl
public BlockBasedImmersiveBuilderImpl(BlockBasedImmersiveHandler<S> handler, @Nullable @Nullable Class<E> extraInfoDataClazz, @Nullable @Nullable Class<ER> extraInfoDataRenderStateClazz, @Nullable @Nullable BiConsumer<BuiltBlockBasedImmersiveInfo<E>, ER> extraInfoDataRenderStateExtractor)
-
-
Method Details
-
setRenderSize
Sets the size for items rendered by this immersive.- Specified by:
setRenderSizein interfaceBlockBasedImmersiveBuilder<E, ER, 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:
addHitboxin interfaceBlockBasedImmersiveBuilder<E, ER, S extends NetworkStorage>- Parameters:
relativeHitboxInfo- HitboxInfo to add. Can use HitboxInfoBuilder to make it easier to create.- Returns:
- Builder object.
-
add3x3Grid
public BlockBasedImmersiveBuilder<E,ER, add3x3GridS> (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:
add3x3Gridin interfaceBlockBasedImmersiveBuilder<E, ER, 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:
setPositioningModein interfaceBlockBasedImmersiveBuilder<E, ER, S extends NetworkStorage>- Parameters:
newMode- New mode for positioning.- Returns:
- Builder object.
-
setHitboxInteractHandler
public BlockBasedImmersiveBuilder<E,ER, setHitboxInteractHandlerS> (HitboxInteractHandler<E> handler) Sets what should happen when a hitbox is interacted with.- Specified by:
setHitboxInteractHandlerin interfaceBlockBasedImmersiveBuilder<E, ER, 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:
setVROnlyin interfaceBlockBasedImmersiveBuilder<E, ER, S extends NetworkStorage>- Parameters:
vrOnly- Whether this immersive should now be VR only.- Returns:
- Builder object.
-
setExtraStorageConsumer
public BlockBasedImmersiveBuilder<E,ER, setExtraStorageConsumerS> (BiConsumer<S, BuiltBlockBasedImmersiveInfo<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:
setExtraStorageConsumerin interfaceBlockBasedImmersiveBuilder<E, ER, S extends NetworkStorage>- Parameters:
storageConsumer- New storage consumer.- Returns:
- Builder object.
-
setSlotActiveFunction
public BlockBasedImmersiveBuilder<E,ER, setSlotActiveFunctionS> (BiFunction<BuiltBlockBasedImmersiveInfo<E>, Integer, Boolean> slotActive) Sets a function that determines whether a given slot should be active (rendered, reacts to interactions, etc.).- Specified by:
setSlotActiveFunctionin interfaceBlockBasedImmersiveBuilder<E, ER, 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
public BlockBasedImmersiveBuilder<E,ER, setOnRemoveS> (Consumer<BuiltBlockBasedImmersiveInfo<E>> onRemove) Set function to run on an info before it's removed.- Specified by:
setOnRemovein interfaceBlockBasedImmersiveBuilder<E, ER, S extends NetworkStorage>- Parameters:
onRemove- Function to run on info just before removal.- Returns:
- Builder object.
-
shouldDisableRightClicksWhenInteractionsDisabled
public BlockBasedImmersiveBuilder<E,ER, shouldDisableRightClicksWhenInteractionsDisabledS> (boolean doDisable) Set whether to disable right-click interactions on this immersive when the option to disable said interactions is enabled.- Specified by:
shouldDisableRightClicksWhenInteractionsDisabledin interfaceBlockBasedImmersiveBuilder<E, ER, S extends NetworkStorage>- Parameters:
doDisable- Whether to disable as described above.- Returns:
- Builder object.
-
setShouldRenderItemGuideFunction
public BlockBasedImmersiveBuilder<E,ER, setShouldRenderItemGuideFunctionS> (BiFunction<BuiltBlockBasedImmersiveRenderState<ER>, 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:
setShouldRenderItemGuideFunctionin interfaceBlockBasedImmersiveBuilder<E, ER, 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:BlockBasedImmersiveBuilderSet the config screen info associated with this Immersive.- Specified by:
setConfigScreenInfoin interfaceBlockBasedImmersiveBuilder<E, ER, S extends NetworkStorage>- Parameters:
info- The config screen info to associate with this Immersive.- Returns:
- Builder object.
-
setExtraRenderer
Description copied from interface:BlockBasedImmersiveBuilderSet an extra function to run when rendering.- Specified by:
setExtraRendererin interfaceBlockBasedImmersiveBuilder<E, ER, S extends NetworkStorage>- Parameters:
renderer- Extra function to run when rendering, taking the info and the light for the Immersive.- Returns:
- Builder object.
-
overwriteHitbox
public BlockBasedImmersiveBuilder<E,ER, overwriteHitboxS> (int index, RelativeHitboxInfo relativeHitboxInfo) Overwrites hitbox at index with a new hitbox. Useful when cloning.- Specified by:
overwriteHitboxin interfaceBlockBasedImmersiveBuilder<E, ER, S extends NetworkStorage>- Parameters:
index- Index to overwrite.relativeHitboxInfo- New hitbox information.- Returns:
- Builder object.
-
modifyHitbox
public BlockBasedImmersiveBuilder<E,ER, modifyHitboxS> (int index, Function<RelativeHitboxInfoBuilder, RelativeHitboxInfo> modifier) Modify a hitbox.- Specified by:
modifyHitboxin interfaceBlockBasedImmersiveBuilder<E, ER, 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 BlockBasedImmersiveBuilder<E,ER, modifyHitboxesS> (int startIndex, int endIndex, Function<RelativeHitboxInfoBuilder, RelativeHitboxInfo> modifier) Modify a range of hitboxes, inclusive for both ends.- Specified by:
modifyHitboxesin interfaceBlockBasedImmersiveBuilder<E, ER, 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.
-
setDragHitboxCreator
public BlockBasedImmersiveBuilder<E,ER, setDragHitboxCreatorS> (@Nullable @Nullable Function<BuiltBlockBasedImmersiveInfo<E>, net.minecraft.world.phys.AABB> dragHitboxCreator) Description copied from interface:BlockBasedImmersiveBuilderSets the function used to generate the drag hitbox. SeeImmersive.getDragHitbox(ImmersiveInfo)for info about what the drag hitbox is.- Specified by:
setDragHitboxCreatorin interfaceBlockBasedImmersiveBuilder<E, ER, S extends NetworkStorage>- Parameters:
dragHitboxCreator- The drag hitbox creator or null (the default) to let ImmersiveMC generate one for you.- Returns:
- Builder object.
-
build
Description copied from interface:BlockBasedImmersiveBuilderBuilds this Immersive.- Specified by:
buildin interfaceBlockBasedImmersiveBuilder<E, ER, S extends NetworkStorage>- Returns:
- The built Immersive from this builder.
-
copy
public <T extends NetworkStorage> BlockBasedImmersiveBuilderImpl<E,ER, copyT> (BlockBasedImmersiveHandler<T> newHandler) Create a copy of this ImmersiveBuilder, setting the extra storage consumer to null.- Specified by:
copyin interfaceBlockBasedImmersiveBuilder<E, ER, S extends NetworkStorage>- Returns:
- A best-effort copy of this ImmersiveBuilder.
-
copy
public <F, FR, T extends NetworkStorage> BlockBasedImmersiveBuilderImpl<F,FR, copyT> (BlockBasedImmersiveHandler<T> newHandler, Class<F> newExtraInfoDataClass, Class<FR> newExtraInfoDataRenderStateClass, BiConsumer<BuiltBlockBasedImmersiveInfo<F>, FR> newExtraInfoDataRenderStateExtractor) Description copied from interface:BlockBasedImmersiveBuilderCreate 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:
copyin interfaceBlockBasedImmersiveBuilder<E, ER, S extends NetworkStorage>- Returns:
- A best-effort copy of this ImmersiveBuilder.
-