New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fancy rendering of printouts #553

Open
wants to merge 3 commits into
base: master
from

Conversation

Projects
None yet
1 participant
@SquidDev
Contributor

SquidDev commented Jun 18, 2018

This renders the contents of printed pages directly when holding them in your hand or displaying them in an item frame. Please note that this implementation isn't currently super optimal as we end up constructing TextBuffers every frame. I would like to get some feedback on a couple of things before going there.

Some things to discuss

  • Item frame interaction is a little funky, as a lot of the behaviour is hard-coded for maps. The key problems are:

    • Rotating will use multiples of 45⁰ for angles (instead of map's 90), meaning it will stick out the side. We could invert the rotation and then apply our own in the event handler, but it's a little ugly.
    • We use the default item frame background instead of a solid one. I don't think this is too much of an issue as it's not normally visible (aside from on the edges), but is problematic when the map is rotated.

    While it would be possible to PR some extensions item frame rendering extensions into Forge for this, I'd rather discuss things here first.

Screenshots

Printout in hand Printout as map

Originally suggested in SquidDev-CC/CC-Tweaked#39.

SquidDev added some commits Jun 18, 2018

Add basic support for fancy rendering of printouts
 - When held in first-person, single pages are displayed like a map.
 - When placed in an item frame, the page is drawn instead of the actual
   item.
Rewrite printout rendering
 - The current page is always centred when rendering in a GUI, with
   the turned pages moving from the sides.
 - Pages are no longer evenly distributed from the centre - they follow
   an exponential decay curve, so ones further out are closer together
   (a bit like an open book).
 - Render pages and books in item frames/in-hand (rather than just
   single pages).

This currently does some very dirty things with z values in order to
prevent z-fighting. It would be nice to avoid that, though turning off
writing to the z buffer causes issues with the bounding box.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment