Record Class WrittenBookContent
java.lang.Object
java.lang.Record
fr.fidorial.item.component.WrittenBookContent
- Record Components:
title- the title- the authorgeneration- how many times the book was copied, from0(original) to 3pages- the pagesresolved- whether the selectors, scores and NBT the pages hold were already resolved
- All Implemented Interfaces:
BookLike
public record WrittenBookContent(Component title, Component author, int generation, List<Component> pages, boolean resolved)
extends Record
implements BookLike
The contents of a signed book, under
minecraft:written_book_content.
As a BookLike, it can be opened directly with
Audience.openBook(BookLike).
The client only knows the title and author as plain text: they are flattened when the book is sent or saved, and the title is cut to 32 characters.
- Since:
- 0.1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe highest generation, a copy of a copy.static final intThe most pages a written book holds.static final intThe longest title, in plain text characters, the client accepts. -
Constructor Summary
ConstructorsConstructorDescriptionWrittenBookContent(Component title, Component author, int generation, List<Component> pages, boolean resolved) Creates an instance of aWrittenBookContentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionasBook()author()Returns the value of theauthorrecord component.final booleanIndicates whether some other object is "equal to" this one.intReturns the value of thegenerationrecord component.final inthashCode()Returns a hash code value for this object.static WrittenBookContentConverts an Adventure book, keeping its title, author and pages as they are.pages()Returns the value of thepagesrecord component.booleanresolved()Returns the value of theresolvedrecord component.title()Returns the value of thetitlerecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
MAX_TITLE_LENGTH
public static final int MAX_TITLE_LENGTHThe longest title, in plain text characters, the client accepts.- See Also:
-
MAX_PAGES
public static final int MAX_PAGESThe most pages a written book holds.- See Also:
-
MAX_GENERATION
public static final int MAX_GENERATIONThe highest generation, a copy of a copy.- See Also:
-
-
Constructor Details
-
WrittenBookContent
public WrittenBookContent(Component title, Component author, int generation, List<Component> pages, boolean resolved) Creates an instance of aWrittenBookContentrecord class.- Parameters:
title- the value for thetitlerecord componentauthor- the value for theauthorrecord componentgeneration- the value for thegenerationrecord componentpages- the value for thepagesrecord componentresolved- the value for theresolvedrecord component
-
-
Method Details
-
of
Converts an Adventure book, keeping its title, author and pages as they are.- Parameters:
book- the book- Returns:
- the contents of an original, already resolved written book
-
asBook
-
toString
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
title
-
author
-
generation
public int generation()Returns the value of thegenerationrecord component.- Returns:
- the value of the
generationrecord component
-
pages
-
resolved
-