Class CommonBookData
java.lang.Object
com.hammy275.immersivemc.common.immersive.CommonBookData
- All Implemented Interfaces:
NetworkStorage
- Direct Known Subclasses:
ClientBookData
Data used by both the client and server (if the server is needed) for a book that can be used in Immersives.
Handles being a book and page turning.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanintstatic final doublefloatstatic final intprotected intstatic final doublestatic final floatprotected OBB[]net.minecraft.world.entity.player.Playerprotected intprotected net.minecraft.world.phys.Vec3[]static final intfloatstatic final floatstatic final doublestatic final doublestatic final floatstatic final double -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddecode(net.minecraft.network.RegistryFriendlyByteBuf buffer) Decode the buffer into this object.voidencode(net.minecraft.network.RegistryFriendlyByteBuf buffer) Encode this storage into a buffer.net.minecraft.world.phys.Vec3getAwayVector(PosRot hand) intnet.minecraft.world.phys.Vec3getLeftRightVector(PosRot bookPosRot, boolean left) Get the vector pointing left or right.booleanisDirty()voidlastPage()voidnextPage()booleanbooleanvoidvoidsetDirty()voidsetMaxLeftPageIndex(int max) voidvoidsetPage(int newPageIndex) voidsetPage(int newPageIndex, boolean runCallback) voidstartNonVRPageTurnAnim(net.minecraft.world.entity.player.Player pageTurner, boolean isNextPage) Start an automatic page turn.protected voidstartVRPageTurn(PageChangeState state, int handIndex) Starts a VR page turnvoidShould be called every tick.
-
Field Details
-
scaleSize
public static final float scaleSize- See Also:
-
singlePageWidth
public static final double singlePageWidth- See Also:
-
pageHalfHeight
public static final double pageHalfHeight- See Also:
-
textStackScaleSize
public static final float textStackScaleSize- See Also:
-
textUpAmount
public static final double textUpAmount- See Also:
-
textInteractDistanceSqr
public static final double textInteractDistanceSqr- See Also:
-
pageTilt
public static final float pageTilt- See Also:
-
linesPerPage
public static final int linesPerPage- See Also:
-
pixelsPerLine
public static final int pixelsPerLine- See Also:
-
leftPageRot
public static final double leftPageRot -
startVRPageTurnCallback
-
onSetPageCallback
-
maxLeftPageIndex
protected int maxLeftPageIndex -
isDirty
protected boolean isDirty -
pageTurnBoxes
-
pageTurnPositions
protected net.minecraft.world.phys.Vec3[] pageTurnPositions -
pageTurner
public net.minecraft.world.entity.player.Player pageTurner -
pageTurnerHandIndex
protected int pageTurnerHandIndex -
leftPageIndex
public int leftPageIndex -
leftPageTurn
public float leftPageTurn -
rightPageTurn
public float rightPageTurn -
pageChangeState
-
-
Constructor Details
-
CommonBookData
public CommonBookData()
-
-
Method Details
-
tick
Should be called every tick.- Parameters:
bookPosRot- PosRot of the book itself.others- PosRots for things that can interact with the book (VR controllers).
-
nextPage
public void nextPage() -
lastPage
public void lastPage() -
setPage
public void setPage(int newPageIndex) -
setPage
public void setPage(int newPageIndex, boolean runCallback) -
getLeftPageIndex
public int getLeftPageIndex() -
setMaxLeftPageIndex
public void setMaxLeftPageIndex(int max) -
isDirty
public boolean isDirty() -
setDirty
public void setDirty() -
setNoLongerDirty
public void setNoLongerDirty() -
onFirstPage
public boolean onFirstPage() -
onLastPage
public boolean onLastPage() -
startNonVRPageTurnAnim
public void startNonVRPageTurnAnim(net.minecraft.world.entity.player.Player pageTurner, boolean isNextPage) Start an automatic page turn.- Parameters:
pageTurner- Player turning the page.isNextPage- Whether the page is turning to the next page or the previous.
-
getPageChangeState
-
encode
public void encode(net.minecraft.network.RegistryFriendlyByteBuf buffer) Description copied from interface:NetworkStorageEncode this storage into a buffer.- Specified by:
encodein interfaceNetworkStorage- Parameters:
buffer- Buffer to encode storage into.
-
decode
public void decode(net.minecraft.network.RegistryFriendlyByteBuf buffer) Description copied from interface:NetworkStorageDecode the buffer into this object.- Specified by:
decodein interfaceNetworkStorage- Parameters:
buffer- Buffer to decode from.
-
resetTurnState
public void resetTurnState() -
startVRPageTurn
Starts a VR page turn- Parameters:
state- The direction to turn the page.handIndex- The index of the hand turning the page.
-
getLeftRightVector
Get the vector pointing left or right.- Parameters:
bookPosRot- The PosRot of this book.left- Whether to get the left vector.- Returns:
- The left or right vector.
-
getAwayVector
- Parameters:
hand- Hand data- Returns:
- The vector pointing away from the book. This is the opposite of the look vector of an HMD looking directly at the book.
-