Interface BlockBasedImmersiveHandler<S extends NetworkStorage>
- Type Parameters:
S- The type ofNetworkStorageused to sync data from server to client ifImmersiveHandler.clientAuthoritative()returns false.
- All Superinterfaces:
ImmersiveHandler
- All Known Subinterfaces:
MultiblockBlockBasedImmersiveHandler<S>, WorldStorageHandler<S>
- All Known Implementing Classes:
AnvilHandler, ApothSalvagingTableHandler, BarrelHandler, BeaconHandler, BrewingStandHandler, ChestHandler, ChestLikeHandler, ChiseledBookshelfHandler, ContainerHandler, CraftingHandler, DoorHandler, ETableHandler, FurnaceHandler, GrindstoneHandler, HopperHandler, IronFurnacesFurnaceHandler, ItemWorldStorageHandler, JukeboxHandler, LecternHandler, LeverHandler, RepeaterHandler, ShulkerBoxHandler, SmithingTableHandler, TCCraftingStationHandler, TrapdoorHandler, VisualWorkbenchHandler
public non-sealed interface BlockBasedImmersiveHandler<S extends NetworkStorage>
extends ImmersiveHandler
The
ImmersiveHandler for block-based Immersives.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanisDirtyForClientSync(net.minecraft.server.level.ServerPlayer tracker, net.minecraft.core.BlockPos pos) Function to determine whether the block has changed its contents to sync to the client since its last sync.booleanisValidBlock(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level level) makeInventoryContents(net.minecraft.server.level.ServerPlayer tracker, net.minecraft.core.BlockPos pos) Creates inventory contents on the server to send to clients.default voidonStopTracking(net.minecraft.server.level.ServerPlayer tracker, net.minecraft.core.BlockPos pos) Function called whenever this immersive is no longer being tracked.voidswap(int slot, net.minecraft.world.InteractionHand hand, net.minecraft.core.BlockPos pos, net.minecraft.server.level.ServerPlayer tracker, ItemSwapAmount amount) Swaps an item from a player's hand into this immersive (and/or vice-versa).Methods inherited from interface ImmersiveHandler
clientAuthoritative, enabledInConfig, getID
-
Method Details
-
makeInventoryContents
S makeInventoryContents(net.minecraft.server.level.ServerPlayer tracker, net.minecraft.core.BlockPos pos) Creates inventory contents on the server to send to clients.- Parameters:
tracker- Player being sent to.pos- Position of the block being sent about.- Returns:
- A NetworkStorage to be sent over the network.
-
getEmptyNetworkStorage
S getEmptyNetworkStorage()- Returns:
- A new instance of the same type of NetworkStorage as made with
makeInventoryContents(ServerPlayer, BlockPos), but in an empty state for purposes such as being decoded into by the client.
-
swap
void swap(int slot, net.minecraft.world.InteractionHand hand, net.minecraft.core.BlockPos pos, net.minecraft.server.level.ServerPlayer tracker, ItemSwapAmount amount) Swaps an item from a player's hand into this immersive (and/or vice-versa).- Parameters:
slot- Slot being swapped with in this immersive.hand- Player's hand being swapped with.pos- Position of block being swapped with.tracker- Player who is swapping.amount- An object representing the amount of items to swap. UseItemSwapAmount.getNumItemsToSwap(), passing in the item stack size of the item in the player's hand to get the amount of items to swap.
-
isDirtyForClientSync
boolean isDirtyForClientSync(net.minecraft.server.level.ServerPlayer tracker, net.minecraft.core.BlockPos pos) Function to determine whether the block has changed its contents to sync to the client since its last sync. Dirtiness is addressed every tick, so for every tick, you should clear ALL flags used for dirtiness.- Parameters:
tracker- Player to potentially send new data to.pos- Position of block to check.- Returns:
- Whether the given block has changed since it was last synced to the client
-
isValidBlock
boolean isValidBlock(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level level) - Parameters:
pos- Position to check.level- The level being checked in.- Returns:
- Whether the supplied block matches what this handler handles.
-
onStopTracking
default void onStopTracking(net.minecraft.server.level.ServerPlayer tracker, net.minecraft.core.BlockPos pos) Function called whenever this immersive is no longer being tracked. Only ever called server-side.- Parameters:
tracker- Player who is no longer tracking this immersive.pos- Position of the block no longer being tracked.
-