Class CommonBookData

java.lang.Object
com.hammy275.immersivemc.common.immersive.CommonBookData
All Implemented Interfaces:
NetworkStorage
Direct Known Subclasses:
ClientBookData

public class CommonBookData extends Object implements NetworkStorage
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 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

      public Consumer<CommonBookData> startVRPageTurnCallback
    • onSetPageCallback

      public Consumer<Integer> onSetPageCallback
    • maxLeftPageIndex

      protected int maxLeftPageIndex
    • isDirty

      protected boolean isDirty
    • pageTurnBoxes

      protected OBB[] 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

      public PageChangeState pageChangeState
  • Constructor Details

    • CommonBookData

      public CommonBookData()
  • Method Details

    • tick

      public void tick(PosRot bookPosRot, PosRot... others)
      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

      public PageChangeState 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 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.
    • resetTurnState

      public void resetTurnState()
    • startVRPageTurn

      protected void startVRPageTurn(PageChangeState state, int handIndex)
      Starts a VR page turn
      Parameters:
      state - The direction to turn the page.
      handIndex - The index of the hand turning the page.
    • getLeftRightVector

      public net.minecraft.world.phys.Vec3 getLeftRightVector(PosRot bookPosRot, boolean left)
      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

      public net.minecraft.world.phys.Vec3 getAwayVector(PosRot hand)
      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.