java.lang.Object
com.hammy275.immersivemc.common.immersive.storage.network.impl.LecternData<T>
Type Parameters:
T - Should always be CommonBookData when not extending this class.
All Implemented Interfaces:
NetworkStorage
Direct Known Subclasses:
ClientLecternData

public class LecternData<T extends CommonBookData> extends Object implements NetworkStorage
Represents data about a lectern. Contains the data for its book, the book itself, and the position and level the lectern is in.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    net.minecraft.world.item.ItemStack
     
     
    net.minecraft.world.level.Level
     
    net.minecraft.core.BlockPos
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    LecternData(T bookData)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    decode(net.minecraft.network.RegistryFriendlyByteBuf buffer)
    Decode the buffer into this object.
    void
    encode(net.minecraft.network.RegistryFriendlyByteBuf buffer)
    Encode this storage into a buffer.
    protected int
     
    getLecternPosRot(net.minecraft.core.BlockPos pos)
    Get the PosRot of a book in a lectern.
    void
    setBook(net.minecraft.world.item.ItemStack book, @Nullable net.minecraft.world.level.block.entity.LecternBlockEntity lecternServerSide)
    Sets the book in this data.
    void
    tick(@Nullable net.minecraft.world.entity.player.Player player)
    Function to be run every tick to tick this data.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • book

      public net.minecraft.world.item.ItemStack book
    • bookData

      public T extends CommonBookData bookData
    • pos

      public transient net.minecraft.core.BlockPos pos
    • level

      public transient net.minecraft.world.level.Level level
  • Constructor Details

    • LecternData

      public LecternData(T bookData)
  • Method Details

    • setBook

      public void setBook(net.minecraft.world.item.ItemStack book, @Nullable @Nullable net.minecraft.world.level.block.entity.LecternBlockEntity lecternServerSide)
      Sets the book in this data.
      Parameters:
      book - Book to set or item to set that isn't a book.
      lecternServerSide - The lectern if this method is being called from the server.
    • tick

      public void tick(@Nullable @Nullable net.minecraft.world.entity.player.Player player)
      Function to be run every tick to tick this data.
      Parameters:
      player - The current player if on the client, or null if on the server.
    • getLecternPosRot

      public PosRot getLecternPosRot(net.minecraft.core.BlockPos pos)
      Get the PosRot of a book in a lectern.
      Parameters:
      pos - Position of the lectern.
      Returns:
      The PosRot of the book in the lectern.
    • findMaxLeftPageIndex

      protected int findMaxLeftPageIndex()
    • encode

      public void encode(net.minecraft.network.RegistryFriendlyByteBuf buffer)
      Description copied from interface: NetworkStorage
      Encode this storage into a buffer.
      Specified by:
      encode in interface NetworkStorage
      Parameters:
      buffer - Buffer to encode storage into.
    • decode

      public void decode(net.minecraft.network.RegistryFriendlyByteBuf buffer)
      Description copied from interface: NetworkStorage
      Decode the buffer into this object.
      Specified by:
      decode in interface NetworkStorage
      Parameters:
      buffer - Buffer to decode from.