MutableComponent.java
net.minecraft.network.chat.MutableComponent
信息
- 全限定名:net.minecraft.network.chat.MutableComponent
- 类型:public final class
- 包:net.minecraft.network.chat
- 源码路径:src/main/java/net/minecraft/network/chat/MutableComponent.java
- 起始行号:L11
- 实现:Component
- 职责:
TODO
字段/常量
-
contents- 类型:
ComponentContents - 修饰符:
private final - 源码定位:
L12 - 说明:
TODO
- 类型:
-
siblings- 类型:
List<Component> - 修饰符:
private final - 源码定位:
L13 - 说明:
TODO
- 类型:
-
style- 类型:
Style - 修饰符:
private - 源码定位:
L14 - 说明:
TODO
- 类型:
-
visualOrderText- 类型:
FormattedCharSequence - 修饰符:
private - 源码定位:
L15 - 说明:
TODO
- 类型:
-
decomposedWith- 类型:
Language - 修饰符:
private - 源码定位:
L16 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
MutableComponent(ComponentContents contents, List<Component> siblings, Style style) @ L18
- 构造器名:MutableComponent
- 源码定位:L18
- 修饰符:package-private
参数:
- contents: ComponentContents
- siblings: List
- style: Style
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static MutableComponent create(ComponentContents contents) @ L24
- 方法名:create
- 源码定位:L24
- 返回类型:MutableComponent
- 修饰符:public static
参数:
- contents: ComponentContents
说明:
TODO
public ComponentContents getContents() @ L28
- 方法名:getContents
- 源码定位:L28
- 返回类型:ComponentContents
- 修饰符:public
参数:
- 无
说明:
TODO
public List<Component> getSiblings() @ L33
- 方法名:getSiblings
- 源码定位:L33
- 返回类型:List
- 修饰符:public
参数:
- 无
说明:
TODO
public MutableComponent setStyle(Style style) @ L38
- 方法名:setStyle
- 源码定位:L38
- 返回类型:MutableComponent
- 修饰符:public
参数:
- style: Style
说明:
TODO
public Style getStyle() @ L43
- 方法名:getStyle
- 源码定位:L43
- 返回类型:Style
- 修饰符:public
参数:
- 无
说明:
TODO
public MutableComponent append(String text) @ L48
- 方法名:append
- 源码定位:L48
- 返回类型:MutableComponent
- 修饰符:public
参数:
- text: String
说明:
TODO
public MutableComponent append(Component component) @ L52
- 方法名:append
- 源码定位:L52
- 返回类型:MutableComponent
- 修饰符:public
参数:
- component: Component
说明:
TODO
public MutableComponent withStyle(UnaryOperator<Style> updater) @ L57
- 方法名:withStyle
- 源码定位:L57
- 返回类型:MutableComponent
- 修饰符:public
参数:
- updater: UnaryOperator
说明:
TODO
public MutableComponent withStyle(Style patch) @ L62
- 方法名:withStyle
- 源码定位:L62
- 返回类型:MutableComponent
- 修饰符:public
参数:
- patch: Style
说明:
TODO
public MutableComponent withStyle(ChatFormatting... formats) @ L67
- 方法名:withStyle
- 源码定位:L67
- 返回类型:MutableComponent
- 修饰符:public
参数:
- formats: ChatFormatting…
说明:
TODO
public MutableComponent withStyle(ChatFormatting format) @ L72
- 方法名:withStyle
- 源码定位:L72
- 返回类型:MutableComponent
- 修饰符:public
参数:
- format: ChatFormatting
说明:
TODO
public MutableComponent withColor(int color) @ L77
- 方法名:withColor
- 源码定位:L77
- 返回类型:MutableComponent
- 修饰符:public
参数:
- color: int
说明:
TODO
public MutableComponent withoutShadow() @ L82
- 方法名:withoutShadow
- 源码定位:L82
- 返回类型:MutableComponent
- 修饰符:public
参数:
- 无
说明:
TODO
public FormattedCharSequence getVisualOrderText() @ L87
- 方法名:getVisualOrderText
- 源码定位:L87
- 返回类型:FormattedCharSequence
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean equals(Object o) @ L98
- 方法名:equals
- 源码定位:L98
- 返回类型:boolean
- 修饰符:public
参数:
- o: Object
说明:
TODO
public int hashCode() @ L105
- 方法名:hashCode
- 源码定位:L105
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public String toString() @ L113
- 方法名:toString
- 源码定位:L113
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public final class MutableComponent implements Component {
private final ComponentContents contents;
private final List<Component> siblings;
private Style style;
private FormattedCharSequence visualOrderText = FormattedCharSequence.EMPTY;
private @Nullable Language decomposedWith;
MutableComponent(ComponentContents contents, List<Component> siblings, Style style) {
this.contents = contents;
this.siblings = siblings;
this.style = style;
}
public static MutableComponent create(ComponentContents contents) {
return new MutableComponent(contents, Lists.newArrayList(), Style.EMPTY);
}
@Override
public ComponentContents getContents() {
return this.contents;
}
@Override
public List<Component> getSiblings() {
return this.siblings;
}
public MutableComponent setStyle(Style style) {
this.style = style;
return this;
}
@Override
public Style getStyle() {
return this.style;
}
public MutableComponent append(String text) {
return text.isEmpty() ? this : this.append(Component.literal(text));
}
public MutableComponent append(Component component) {
this.siblings.add(component);
return this;
}
public MutableComponent withStyle(UnaryOperator<Style> updater) {
this.setStyle(updater.apply(this.getStyle()));
return this;
}
public MutableComponent withStyle(Style patch) {
this.setStyle(patch.applyTo(this.getStyle()));
return this;
}
public MutableComponent withStyle(ChatFormatting... formats) {
this.setStyle(this.getStyle().applyFormats(formats));
return this;
}
public MutableComponent withStyle(ChatFormatting format) {
this.setStyle(this.getStyle().applyFormat(format));
return this;
}
public MutableComponent withColor(int color) {
this.setStyle(this.getStyle().withColor(color));
return this;
}
public MutableComponent withoutShadow() {
this.setStyle(this.getStyle().withoutShadow());
return this;
}
@Override
public FormattedCharSequence getVisualOrderText() {
Language currentLanguage = Language.getInstance();
if (this.decomposedWith != currentLanguage) {
this.visualOrderText = currentLanguage.getVisualOrder(this);
this.decomposedWith = currentLanguage;
}
return this.visualOrderText;
}
@Override
public boolean equals(Object o) {
return this == o
? true
: o instanceof MutableComponent that && this.contents.equals(that.contents) && this.style.equals(that.style) && this.siblings.equals(that.siblings);
}
@Override
public int hashCode() {
int result = 1;
result = 31 * result + this.contents.hashCode();
result = 31 * result + this.style.hashCode();
return 31 * result + this.siblings.hashCode();
}
@Override
public String toString() {
StringBuilder result = new StringBuilder(this.contents.toString());
boolean hasStyle = !this.style.isEmpty();
boolean hasSiblings = !this.siblings.isEmpty();
if (hasStyle || hasSiblings) {
result.append('[');
if (hasStyle) {
result.append("style=");
result.append(this.style);
}
if (hasStyle && hasSiblings) {
result.append(", ");
}
if (hasSiblings) {
result.append("siblings=");
result.append(this.siblings);
}
result.append(']');
}
return result.toString();
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Language.getInstance()
- 引用位置:
-
- 引用位置:
参数/字段/实现/方法调用/返回值 - 关联成员:
Component.literal()
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
字段/返回值
- 引用位置: