Class LecternData<T extends CommonBookData>
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
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.
-
Field Details
-
book
public net.minecraft.world.item.ItemStack book -
bookData
-
pos
public transient net.minecraft.core.BlockPos pos -
level
public transient net.minecraft.world.level.Level level
-
-
Constructor Details
-
LecternData
-
-
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
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 interfaceNetworkStorage
- 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 interfaceNetworkStorage
- Parameters:
buffer
- Buffer to decode from.
-