java.lang.Object
com.hammy275.immersivemc.common.immersive.handler.LecternHandler
All Implemented Interfaces:
ImmersiveHandler<LecternData<CommonBookData>>

public class LecternHandler extends Object implements ImmersiveHandler<LecternData<CommonBookData>>
  • Constructor Details Link icon

    • LecternHandler Link icon

      public LecternHandler()
  • Method Details Link icon

    • makeInventoryContents Link icon

      public LecternData<CommonBookData> makeInventoryContents(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos)
      Description copied from interface: ImmersiveHandler
      Creates inventory contents on the server to send to clients.
      Specified by:
      makeInventoryContents in interface ImmersiveHandler<LecternData<CommonBookData>>
      Parameters:
      player - Player being sent to.
      pos - Position of the block being sent about.
      Returns:
      A NetworkStorage to be sent over the network.
    • getEmptyNetworkStorage Link icon

      public LecternData<CommonBookData> getEmptyNetworkStorage()
      Specified by:
      getEmptyNetworkStorage in interface ImmersiveHandler<LecternData<CommonBookData>>
      Returns:
      A new instance of the same type of NetworkStorage as made with makeInventoryContents(), but in an empty state for purposes such as being decoded into by the client.
    • swap Link icon

      public void swap(int slot, net.minecraft.world.InteractionHand hand, net.minecraft.core.BlockPos pos, net.minecraft.server.level.ServerPlayer player, ItemSwapAmount amount)
      Description copied from interface: ImmersiveHandler
      Swaps an item from a player's hand into this immersive (and/or vice-versa).
      Specified by:
      swap in interface ImmersiveHandler<LecternData<CommonBookData>>
      Parameters:
      slot - Slot being swapped with in this immersive.
      hand - Player's hand being swapped with.
      pos - Position of block being swapped with.
      player - Player who is swapping.
      amount - An object representing the amount of items to swap. Use ItemSwapAmount.getNumItemsToSwap(), passing in the item stack size of the item in the player's hand to get the amount of items to swap.
    • isDirtyForClientSync Link icon

      public boolean isDirtyForClientSync(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos)
      Description copied from interface: ImmersiveHandler
      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.
      Specified by:
      isDirtyForClientSync in interface ImmersiveHandler<LecternData<CommonBookData>>
      Parameters:
      player - 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 Link icon

      public boolean isValidBlock(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level level)
      Specified by:
      isValidBlock in interface ImmersiveHandler<LecternData<CommonBookData>>
      Parameters:
      pos - Position to check.
      level - The level being checked in.
      Returns:
      Whether the supplied block matches what this handler handles.
    • enabledInConfig Link icon

      public boolean enabledInConfig(net.minecraft.world.entity.player.Player player)
      Specified by:
      enabledInConfig in interface ImmersiveHandler<LecternData<CommonBookData>>
      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 Link icon

      public boolean clientAuthoritative()
      Description copied from interface: ImmersiveHandler
      Whether blocks matching this Immersive should be initiated by the client. If this is true, the server should not send any data to the client about this Immersive, and will never track that a client isn't tracking the Immersive or ImmersiveHandler.makeInventoryContents(ServerPlayer, BlockPos) for it.
      Specified by:
      clientAuthoritative in interface ImmersiveHandler<LecternData<CommonBookData>>
      Returns:
      Whether this immersive should have tracking initiated by the client. The same value should always be returned by this method.
    • getID Link icon

      public net.minecraft.resources.ResourceLocation getID()
      Specified by:
      getID in interface ImmersiveHandler<LecternData<CommonBookData>>
      Returns:
      A unique ID to identify this handler. The same value should always be returned by this method.