Record Class WrittenBookContent
java.lang.Object
java.lang.Record
net.minecraft.world.item.component.WrittenBookContent
- All Implemented Interfaces:
BookContent<Component, WrittenBookContent>, TooltipProvider
public record WrittenBookContent(Filterable<String> title, String author, int generation, List<Filterable<Component>> pages, boolean resolved)
extends Record
implements BookContent<Component, WrittenBookContent>, TooltipProvider
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe field for theauthorrecord component.static final Codec<WrittenBookContent> static final WrittenBookContentprivate final intThe field for thegenerationrecord component.static final intstatic final intprivate final List<Filterable<Component>> The field for thepagesrecord component.static final Codec<List<Filterable<Component>>> private final booleanThe field for theresolvedrecord component.static final StreamCodec<RegistryFriendlyByteBuf, WrittenBookContent> private final Filterable<String> The field for thetitlerecord component.static final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionWrittenBookContent(Filterable<String> title, String author, int generation, List<Filterable<Component>> pages, boolean resolved) Creates an instance of aWrittenBookContentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToTooltip(Item.TooltipContext context, Consumer<Component> consumer, TooltipFlag flag, DataComponentGetter components) author()Returns the value of theauthorrecord component.final booleanIndicates whether some other object is "equal to" this one.intReturns the value of thegenerationrecord component.getPages(boolean filterEnabled) final inthashCode()Returns a hash code value for this object.private static booleanisPageTooLarge(Component page, HolderLookup.Provider registries) private static Codec<Filterable<Component>> pages()Returns the value of thepagesrecord component.static Codec<List<Filterable<Component>>> pagesCodec(Codec<Component> contentCodec) @Nullable WrittenBookContentresolve(ResolutionContext context, HolderLookup.Provider registries) booleanresolved()Returns the value of theresolvedrecord component.static booleanresolveForItem(ItemStack itemStack, ResolutionContext context, HolderLookup.Provider registries) private static Optional<Filterable<Component>> resolvePage(ResolutionContext context, HolderLookup.Provider registries, Filterable<Component> page) title()Returns the value of thetitlerecord component.final StringtoString()Returns a string representation of this record class.withReplacedPages(List<Filterable<Component>> newPages)
-
Field Details
-
title
The field for thetitlerecord component. -
author
The field for theauthorrecord component. -
generation
private final int generationThe field for thegenerationrecord component. -
pages
The field for thepagesrecord component. -
resolved
private final boolean resolvedThe field for theresolvedrecord component. -
EMPTY
-
PAGE_LENGTH
public static final int PAGE_LENGTH- See Also:
-
TITLE_LENGTH
public static final int TITLE_LENGTH- See Also:
-
TITLE_MAX_LENGTH
public static final int TITLE_MAX_LENGTH- See Also:
-
MAX_GENERATION
public static final int MAX_GENERATION- See Also:
-
CONTENT_CODEC
-
PAGES_CODEC
-
CODEC
-
STREAM_CODEC
-
-
Constructor Details
-
WrittenBookContent
public WrittenBookContent(Filterable<String> title, String author, int generation, List<Filterable<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
-
pageCodec
-
pagesCodec
-
craftCopy
-
resolveForItem
public static boolean resolveForItem(ItemStack itemStack, ResolutionContext context, HolderLookup.Provider registries) -
resolve
public @Nullable WrittenBookContent resolve(ResolutionContext context, HolderLookup.Provider registries) -
markResolved
-
resolvePage
private static Optional<Filterable<Component>> resolvePage(ResolutionContext context, HolderLookup.Provider registries, Filterable<Component> page) -
isPageTooLarge
-
getPages
-
withReplacedPages
- Specified by:
withReplacedPagesin interfaceBookContent<Component, WrittenBookContent>
-
addToTooltip
public void addToTooltip(Item.TooltipContext context, Consumer<Component> consumer, TooltipFlag flag, DataComponentGetter components) - Specified by:
addToTooltipin interfaceTooltipProvider
-
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
Returns the value of thetitlerecord component.- Returns:
- the value of the
titlerecord component
-
author
Returns the value of theauthorrecord component.- Returns:
- the value of the
authorrecord component
-
generation
public int generation()Returns the value of thegenerationrecord component.- Returns:
- the value of the
generationrecord component
-
pages
Returns the value of thepagesrecord component.- Specified by:
pagesin interfaceBookContent<Component, WrittenBookContent>- Returns:
- the value of the
pagesrecord component
-
resolved
public boolean resolved()Returns the value of theresolvedrecord component.- Returns:
- the value of the
resolvedrecord component
-