Package net.minecraft.text
Class Style
java.lang.Object
net.minecraft.text.Style
public class Style extends Object
The style of a
Text, representing cosmetic attributes. It includes
font, formatting, click/hover events (actions), color, etc.
A style is immutable.
- See Also:
Text
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStyle.SerializerA JSON serializer forStyle. -
Field Summary
Fields Modifier and Type Field Description private Booleanboldprivate ClickEventclickEventprivate TextColorcolorstatic IdentifierDEFAULT_FONT_IDThe identifier for the default font of a style.static StyleEMPTYAn empty style.private Identifierfontprivate HoverEventhoverEventprivate Stringinsertionprivate Booleanitalicprivate Booleanobfuscatedprivate Booleanstrikethroughprivate Booleanunderlined -
Constructor Summary
Constructors Modifier Constructor Description privateStyle(TextColor color, Boolean bold, Boolean italic, Boolean underlined, Boolean strikethrough, Boolean obfuscated, ClickEvent clickEvent, HoverEvent hoverEvent, String insertion, Identifier font) -
Method Summary
Modifier and Type Method Description booleanequals(Object obj)ClickEventgetClickEvent()Returns the click event of this style.TextColorgetColor()Returns the color of this style.IdentifiergetFont()Returns the font of this style.HoverEventgetHoverEvent()Returns the hover event of this style.StringgetInsertion()Returns the insertion text of the style.inthashCode()booleanisBold()Returns whether the style has bold formatting.booleanisEmpty()Returns if this is the empty style.booleanisItalic()Returns whether the style has italic formatting.booleanisObfuscated()Returns whether the style has obfuscated formatting.booleanisStrikethrough()Returns whether the style has strikethrough formatting.booleanisUnderlined()Returns whether the style has underline formatting.StringtoString()StylewithBold(Boolean bold)Returns a new style with the bold attribute provided and all other attributes of this style.StylewithClickEvent(ClickEvent clickEvent)Returns a new style with the click event provided and all other attributes of this style.StylewithColor(TextColor color)Returns a new style with the color provided and all other attributes of this style.StylewithColor(Formatting color)Returns a new style with the color provided and all other attributes of this style.StylewithExclusiveFormatting(Formatting formatting)Returns a new style with the formatting provided and some applicable attributes of this style.StylewithFont(Identifier font)Returns a new style with the font provided and all other attributes of this style.StylewithFormatting(Formatting formatting)Returns a new style with the formatting provided and all other attributes of this style.StylewithFormatting(Formatting[] formattings)Returns a new style with the formattings provided and all other attributes of this style.StylewithHoverEvent(HoverEvent hoverEvent)Returns a new style with the hover event provided and all other attributes of this style.StylewithInsertion(String insertion)Returns a new style with the insertion provided and all other attributes of this style.StylewithItalic(Boolean italic)Returns a new style with the italic attribute provided and all other attributes of this style.StylewithParent(Style parent)Returns a new style with the undefined attributes of this style filled by theparentstyle.StylewithUnderline(Boolean underline)Returns a new style with the underline attribute provided and all other attributes of this style.
-
Field Details
-
EMPTY
An empty style. -
DEFAULT_FONT_ID
The identifier for the default font of a style. -
color
-
bold
-
italic
-
underlined
-
strikethrough
-
obfuscated
-
clickEvent
-
hoverEvent
-
insertion
-
font
-
-
Constructor Details
-
Style
private Style(@Nullable TextColor color, @Nullable Boolean bold, @Nullable Boolean italic, @Nullable Boolean underlined, @Nullable Boolean strikethrough, @Nullable Boolean obfuscated, @Nullable ClickEvent clickEvent, @Nullable HoverEvent hoverEvent, @Nullable String insertion, @Nullable Identifier font)
-
-
Method Details
-
getColor
Returns the color of this style. -
isBold
public boolean isBold()Returns whether the style has bold formatting.- See Also:
Formatting.BOLD
-
isItalic
public boolean isItalic()Returns whether the style has italic formatting.- See Also:
Formatting.ITALIC
-
isStrikethrough
public boolean isStrikethrough()Returns whether the style has strikethrough formatting.- See Also:
Formatting.STRIKETHROUGH
-
isUnderlined
public boolean isUnderlined()Returns whether the style has underline formatting.- See Also:
Formatting.UNDERLINE
-
isObfuscated
public boolean isObfuscated()Returns whether the style has obfuscated formatting.- See Also:
Formatting.OBFUSCATED
-
isEmpty
public boolean isEmpty()Returns if this is the empty style.- See Also:
EMPTY
-
getClickEvent
Returns the click event of this style. -
getHoverEvent
Returns the hover event of this style. -
getInsertion
Returns the insertion text of the style.An insertion is inserted when a piece of text clicked while shift key is down in the chat HUD.
-
getFont
Returns the font of this style. -
withColor
Returns a new style with the color provided and all other attributes of this style.- Parameters:
color- the new color
-
withColor
Returns a new style with the color provided and all other attributes of this style.- Parameters:
color- the new color
-
withBold
Returns a new style with the bold attribute provided and all other attributes of this style.- Parameters:
bold- the new bold property
-
withItalic
Returns a new style with the italic attribute provided and all other attributes of this style.- Parameters:
italic- the new italic property
-
withUnderline
Returns a new style with the underline attribute provided and all other attributes of this style. -
withClickEvent
Returns a new style with the click event provided and all other attributes of this style.- Parameters:
clickEvent- the new click event
-
withHoverEvent
Returns a new style with the hover event provided and all other attributes of this style.- Parameters:
hoverEvent- the new hover event
-
withInsertion
Returns a new style with the insertion provided and all other attributes of this style.- Parameters:
insertion- the new insertion string
-
withFont
Returns a new style with the font provided and all other attributes of this style.- Parameters:
font- the new font
-
withFormatting
Returns a new style with the formatting provided and all other attributes of this style.- Parameters:
formatting- the new formatting
-
withExclusiveFormatting
Returns a new style with the formatting provided and some applicable attributes of this style.When a color formatting is passed for
formatting, the other formattings, including bold, italic, strikethrough, underlined, and obfuscated, are all removed.- Parameters:
formatting- the new formatting
-
withFormatting
Returns a new style with the formattings provided and all other attributes of this style.- Parameters:
formattings- an array of new formattings
-
withParent
Returns a new style with the undefined attributes of this style filled by theparentstyle.- Parameters:
parent- the parent style
-
toString
-
equals
-
hashCode
public int hashCode()
-