Class ChestLikeHandler<S extends ListOfItemsStorage>

java.lang.Object
com.hammy275.immersivemc.common.immersive.handler.ContainerHandler<S>
com.hammy275.immersivemc.common.immersive.handler.ChestLikeHandler<S>
All Implemented Interfaces:
ImmersiveHandler<S>
Direct Known Subclasses:
BarrelHandler, ChestHandler, HopperHandler, ShulkerBoxHandler

public abstract class ChestLikeHandler<S extends ListOfItemsStorage> extends ContainerHandler<S>
  • Constructor Details

    • ChestLikeHandler

      public ChestLikeHandler()
  • Method Details

    • isValidBlock

      public 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.
    • makeInventoryContents

      public abstract S 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.
      Parameters:
      player - Player being sent to.
      pos - Position of the block being sent about.
      Returns:
      A NetworkStorage to be sent over the network.
    • makeBaseInventoryContents

      protected ListOfItemsStorage makeBaseInventoryContents(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos)
    • isDirtyForClientSync

      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<S extends ListOfItemsStorage>
      Overrides:
      isDirtyForClientSync in class ContainerHandler<S extends ListOfItemsStorage>
      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
    • getEmptyNetworkStorage

      public abstract S getEmptyNetworkStorage()
      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.
    • getBaseEmptyNetworkStorage

      protected ListOfItemsStorage getBaseEmptyNetworkStorage()
    • canPlaceItem

      public boolean canPlaceItem(net.minecraft.world.item.ItemStack item)
    • swap

      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).
      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.
    • onStopTracking

      public void onStopTracking(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos)
      Description copied from interface: ImmersiveHandler
      Function called whenever this immersive is no longer being tracked. Only ever called server-side.
      Parameters:
      player - Player who is no longer tracking this immersive.
      pos - Position of the block no longer being tracked.