Record Class WrittenBookHelpers.BookTextRenderer
java.lang.Object
java.lang.Record
com.hammy275.immersivemc.client.immersive.book.WrittenBookHelpers.BookTextRenderer
- All Implemented Interfaces:
BookRenderable
- Enclosing class:
WrittenBookHelpers
public static record WrittenBookHelpers.BookTextRenderer(Function<Boolean,net.minecraft.network.chat.FormattedText> textSupplier, float textStackScaleSize, net.minecraft.world.phys.Vec3 offset)
extends Record
implements BookRenderable
-
Constructor Summary
ConstructorsConstructorDescriptionBookTextRenderer
(Function<Boolean, net.minecraft.network.chat.FormattedText> textSupplier, float textStackScaleSize, net.minecraft.world.phys.Vec3 offset) Creates an instance of aBookTextRenderer
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.net.minecraft.world.phys.Vec3
getStartOffset
(ClientBookData data, boolean leftPage, PosRot bookPosRot) Called to get the offset on the page to start rendering from.final int
hashCode()
Returns a hash code value for this object.net.minecraft.world.phys.Vec3
offset()
Returns the value of theoffset
record component.void
render
(com.mojang.blaze3d.vertex.PoseStack stack, ClientBookData data, boolean leftPage, int light, PosRot bookPosRot) Called to render this.float
Returns the value of thetextStackScaleSize
record component.Returns the value of thetextSupplier
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
BookTextRenderer
public BookTextRenderer(Function<Boolean, net.minecraft.network.chat.FormattedText> textSupplier, float textStackScaleSize, net.minecraft.world.phys.Vec3 offset) Creates an instance of aBookTextRenderer
record class.- Parameters:
textSupplier
- the value for thetextSupplier
record componenttextStackScaleSize
- the value for thetextStackScaleSize
record componentoffset
- the value for theoffset
record component
-
-
Method Details
-
render
public void render(com.mojang.blaze3d.vertex.PoseStack stack, ClientBookData data, boolean leftPage, int light, PosRot bookPosRot) Description copied from interface:BookRenderable
Called to render this.- Specified by:
render
in interfaceBookRenderable
- Parameters:
stack
- The PoseStack to use with rendering. This is already centered on the page and rotated appropriately.data
- The book data being rendered.leftPage
- Whether this is rendering on the left page or the right.light
- Light value.bookPosRot
- The book's position and rotation.
-
getStartOffset
public net.minecraft.world.phys.Vec3 getStartOffset(ClientBookData data, boolean leftPage, PosRot bookPosRot) Description copied from interface:BookRenderable
Called to get the offset on the page to start rendering from. +X is towards the book center, +Y is towards the top of the page, and +Z is towards the player's face if they're looking directly at the book.
The coordinate system is described by example below. The rest should be pretty inferrable.- The center of the page is located at (0, 0, 0)
- (1, 0, 0) is the very center of the book
- (0, 1, 0) is the top-center of the page
- (0, 0, 1) is an arbitrary unit closer to the player's face.
- Specified by:
getStartOffset
in interfaceBookRenderable
- Parameters:
data
- The book data being rendered.leftPage
- Whether this is rendering on the left page or the right.bookPosRot
- The book's position and rotation.- Returns:
- The offset to use as described above.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
textSupplier
Returns the value of thetextSupplier
record component.- Returns:
- the value of the
textSupplier
record component
-
textStackScaleSize
public float textStackScaleSize()Returns the value of thetextStackScaleSize
record component.- Returns:
- the value of the
textStackScaleSize
record component
-
offset
public net.minecraft.world.phys.Vec3 offset()Returns the value of theoffset
record component.- Returns:
- the value of the
offset
record component
-