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 boolean
int
static final double
float
static final int
protected int
static final double
static final float
protected OBB[]
net.minecraft.world.entity.player.Player
protected int
protected net.minecraft.world.phys.Vec3[]
static final int
float
static final float
static final double
static final double
static final float
static final double
-
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.net.minecraft.world.phys.Vec3
getAwayVector
(PosRot hand) int
net.minecraft.world.phys.Vec3
getLeftRightVector
(PosRot bookPosRot, boolean left) Get the vector pointing left or right.boolean
isDirty()
void
lastPage()
void
nextPage()
boolean
boolean
void
void
setDirty()
void
setMaxLeftPageIndex
(int max) void
void
setPage
(int newPageIndex) void
setPage
(int newPageIndex, boolean runCallback) void
startNonVRPageTurnAnim
(net.minecraft.world.entity.player.Player pageTurner, boolean isNextPage) Start an automatic page turn.protected void
startVRPageTurn
(PageChangeState state, int handIndex) Starts a VR page turnvoid
Should 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: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.
-
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.
-