ImmersiveMC

ImmersiveMC

683k Downloads

Immersive Book

hammy275 opened this issue ยท 11 comments

commented

Should be able to read book without UI; just turn the pages!

commented

My main goal is to make this flexible code-wise. Ideally, we'd be able to extend this code to support things like:

  • Patchouli guide books
  • The guide book in the crafting table
commented

How does it look like currently? Is it displayed in the hand like the hotbar?

commented

It's currently the same as base Vivecraft, where you right click to open the book UI

commented

Yeah, I was talking about the GUI placement, which would be watch-like just like any other GUI I assume. Also would it be for the book stand or for a signed book and quill?

commented

Had totally forgotten about the lectern! Definitely both

commented

Let's break this down into parts, since there's going to be a lot to do for this.

  • Create a system for rendering immersives based on held items.
    • Should include mixins to suppress item rendering. Focus on only suppressing it for the player, and not all players.
  • Get Enchanting Table book rendering and understand how it works.
  • Get book model rendering on hand. Bag code will be super useful here.
  • Get text to render on the book.
    • Get a single string to render with no care for line-wrapping, etc.
    • Get line-wrapping working.
    • Get text to render on both pages properly.
    • Hook it into a written book.
    • Render it fully properly with hand rotation and such
  • Add animation using individual page model for page turning.
  • If not brutally difficult, get text to stick to pages when turning.
  • Add hitboxes for clickable text.
  • Make new texture for book model that fits more with vanilla's written book.
  • Config key
  • Port to other Minecraft versions of ImmersiveMC

Lectern support moved to #292 .

commented

Page turning ideas for self:

  • Use a central hitbox and edge hitboxes. Hand moves from edge to center to confirm turn. If it doesn't make it to center, cancel the turn. Seems really difficult to implement hitboxes, so may not go with this one unless all others fail. Some code for this is already in place.
  • Mark three points, left center, true center, and right center. When close enough to left or right, we turn the page until we're closer to the opposite than where we started. If we get too far away from left, right, and center, cancel page turn. Maybe also add points above and below each center one for better distance checking.
  • The above, but instead of using a fixed amount of points, use a dynamic amount of points, based on the scaleSize. More complex, but would likely feel better to users.
commented

Let's keep things relatively simple by using constants, but keeping it nice for users. Uses similar point systems as above:

  • Side points are on the left center and right center of the page. When a distance check is close enough, begin turning.
    • Turning ends when one becomes closer to the opposite point. For example, if turning right to left, we complete the turn when the hand is closer to the left point than the right.
    • We should NOT begin turning if the distance to the opposite side's point is < 2.2*singlePageWidth. This should prevent page turns from starting before the hand is on the edge of the page.
  • Center point exists purely to prevent cancelling. Is located at center of the book.
  • Left, center, and right above points also purely exist to prevent cancelling. Is located "above" their respective points (in the direction the book is opened).

Cancel Turning Conditions:

  • If the hand is too far from any of the points above.
  • If the distance to the farther point is larger than the distance between its opposite, its above opposite and itself. For example, if the user was turning from right to left, if the left point was farther away from the hand than the distance from the left point to the right point AND the above right point, we cancel.
    • Only actually need to check to the above right point here, as the distance between opposites will always be less than the distance between opposites with one of them offset on the Y axis.
commented

Positioning hitboxes for clickable text seems to be very, very difficult, so instead, we'll put an approximate point nearby (which we can do fine), and then do a distance check.

To prevent false interactions, we'll require a left click button press to interact with text. This will be a bit awkward if the book is held in the main hand, but should be good otherwise. From there, if we're close enough, we can do the click action of the text.

commented

u pute alto of thought into this, think it would be cool

commented

Opened a bug for some click events (#294), but other than that, this is finally done!