Class TrapdoorHandler
java.lang.Object
com.hammy275.immersivemc.common.immersive.handler.TrapdoorHandler
- All Implemented Interfaces:
BlockBasedImmersiveHandler<NullStorage>, ImmersiveHandler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether the client should be the one to begin tracking this immersive.booleanenabledInConfig(net.minecraft.world.entity.player.Player player) net.minecraft.resources.IdentifiergetID()booleanisDirtyForClientSync(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.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 class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BlockBasedImmersiveHandler
onStopTracking
-
Constructor Details
-
TrapdoorHandler
public TrapdoorHandler()
-
-
Method Details
-
makeInventoryContents
public NullStorage makeInventoryContents(net.minecraft.server.level.ServerPlayer tracker, net.minecraft.core.BlockPos pos) Description copied from interface:BlockBasedImmersiveHandlerCreates inventory contents on the server to send to clients.- Specified by:
makeInventoryContentsin interfaceBlockBasedImmersiveHandler<NullStorage>- Parameters:
tracker- Player being sent to.pos- Position of the block being sent about.- Returns:
- A NetworkStorage to be sent over the network.
-
getEmptyNetworkStorage
- Specified by:
getEmptyNetworkStoragein interfaceBlockBasedImmersiveHandler<NullStorage>- Returns:
- A new instance of the same type of NetworkStorage as made with
BlockBasedImmersiveHandler.makeInventoryContents(ServerPlayer, BlockPos), but in an empty state for purposes such as being decoded into by the client.
-
swap
public void swap(int slot, net.minecraft.world.InteractionHand hand, net.minecraft.core.BlockPos pos, net.minecraft.server.level.ServerPlayer tracker, ItemSwapAmount amount) Description copied from interface:BlockBasedImmersiveHandlerSwaps an item from a player's hand into this immersive (and/or vice-versa).- Specified by:
swapin interfaceBlockBasedImmersiveHandler<NullStorage>- 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
public boolean isDirtyForClientSync(net.minecraft.server.level.ServerPlayer tracker, net.minecraft.core.BlockPos pos) Description copied from interface:BlockBasedImmersiveHandlerFunction 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.- Specified by:
isDirtyForClientSyncin interfaceBlockBasedImmersiveHandler<NullStorage>- 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
public boolean isValidBlock(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level level) - Specified by:
isValidBlockin interfaceBlockBasedImmersiveHandler<NullStorage>- Parameters:
pos- Position to check.level- The level being checked in.- Returns:
- Whether the supplied block matches what this handler handles.
-
enabledInConfig
public boolean enabledInConfig(net.minecraft.world.entity.player.Player player) - Specified by:
enabledInConfigin interfaceImmersiveHandler- Parameters:
player- The player we're checking the config of.- Returns:
- Whether the immersive this handler handles is enabled. If you do not have a configuration system, this should always return true.
-
clientAuthoritative
public boolean clientAuthoritative()Description copied from interface:ImmersiveHandlerWhether the client should be the one to begin tracking this immersive. If this is true, the server should not send any data to the client about this Immersive, and does not know who is tracking this Immersive.- Specified by:
clientAuthoritativein interfaceImmersiveHandler- Returns:
- Whether this immersive should have tracking initiated by the client. The same value should always be returned by this method.
-
getID
public net.minecraft.resources.Identifier getID()- Specified by:
getIDin interfaceImmersiveHandler- Returns:
- A unique ID to identify this handler. The same value should always be returned by this method.
-