DisplayInfo.java
net.minecraft.advancements.DisplayInfo
信息
- 全限定名:net.minecraft.advancements.DisplayInfo
- 类型:public class
- 包:net.minecraft.advancements
- 源码路径:src/main/java/net/minecraft/advancements/DisplayInfo.java
- 起始行号:L13
- 职责:
TODO
字段/常量
-
CODEC- 类型:
Codec<DisplayInfo> - 修饰符:
public static final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
STREAM_CODEC- 类型:
StreamCodec<RegistryFriendlyByteBuf,DisplayInfo> - 修饰符:
public static final - 源码定位:
L27 - 说明:
TODO
- 类型:
-
title- 类型:
Component - 修饰符:
private final - 源码定位:
L30 - 说明:
TODO
- 类型:
-
description- 类型:
Component - 修饰符:
private final - 源码定位:
L31 - 说明:
TODO
- 类型:
-
icon- 类型:
ItemStackTemplate - 修饰符:
private final - 源码定位:
L32 - 说明:
TODO
- 类型:
-
background- 类型:
Optional<ClientAsset.ResourceTexture> - 修饰符:
private final - 源码定位:
L33 - 说明:
TODO
- 类型:
-
type- 类型:
AdvancementType - 修饰符:
private final - 源码定位:
L34 - 说明:
TODO
- 类型:
-
showToast- 类型:
boolean - 修饰符:
private final - 源码定位:
L35 - 说明:
TODO
- 类型:
-
announceChat- 类型:
boolean - 修饰符:
private final - 源码定位:
L36 - 说明:
TODO
- 类型:
-
hidden- 类型:
boolean - 修饰符:
private final - 源码定位:
L37 - 说明:
TODO
- 类型:
-
x- 类型:
float - 修饰符:
private - 源码定位:
L38 - 说明:
TODO
- 类型:
-
y- 类型:
float - 修饰符:
private - 源码定位:
L39 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public DisplayInfo(ItemStackTemplate icon, Component title, Component description, Optional<ClientAsset.ResourceTexture> background, AdvancementType type, boolean showToast, boolean announceChat, boolean hidden) @ L41
- 构造器名:DisplayInfo
- 源码定位:L41
- 修饰符:public
参数:
- icon: ItemStackTemplate
- title: Component
- description: Component
- background: Optional<ClientAsset.ResourceTexture>
- type: AdvancementType
- showToast: boolean
- announceChat: boolean
- hidden: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void setLocation(float x, float y) @ L61
- 方法名:setLocation
- 源码定位:L61
- 返回类型:void
- 修饰符:public
参数:
- x: float
- y: float
说明:
TODO
public Component getTitle() @ L66
- 方法名:getTitle
- 源码定位:L66
- 返回类型:Component
- 修饰符:public
参数:
- 无
说明:
TODO
public Component getDescription() @ L70
- 方法名:getDescription
- 源码定位:L70
- 返回类型:Component
- 修饰符:public
参数:
- 无
说明:
TODO
public ItemStackTemplate getIcon() @ L74
- 方法名:getIcon
- 源码定位:L74
- 返回类型:ItemStackTemplate
- 修饰符:public
参数:
- 无
说明:
TODO
public Optional<ClientAsset.ResourceTexture> getBackground() @ L78
- 方法名:getBackground
- 源码定位:L78
- 返回类型:Optional<ClientAsset.ResourceTexture>
- 修饰符:public
参数:
- 无
说明:
TODO
public AdvancementType getType() @ L82
- 方法名:getType
- 源码定位:L82
- 返回类型:AdvancementType
- 修饰符:public
参数:
- 无
说明:
TODO
public float getX() @ L86
- 方法名:getX
- 源码定位:L86
- 返回类型:float
- 修饰符:public
参数:
- 无
说明:
TODO
public float getY() @ L90
- 方法名:getY
- 源码定位:L90
- 返回类型:float
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean shouldShowToast() @ L94
- 方法名:shouldShowToast
- 源码定位:L94
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean shouldAnnounceChat() @ L98
- 方法名:shouldAnnounceChat
- 源码定位:L98
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isHidden() @ L102
- 方法名:isHidden
- 源码定位:L102
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
private void serializeToNetwork(RegistryFriendlyByteBuf output) @ L106
- 方法名:serializeToNetwork
- 源码定位:L106
- 返回类型:void
- 修饰符:private
参数:
- output: RegistryFriendlyByteBuf
说明:
TODO
private static DisplayInfo fromNetwork(RegistryFriendlyByteBuf input) @ L130
- 方法名:fromNetwork
- 源码定位:L130
- 返回类型:DisplayInfo
- 修饰符:private static
参数:
- input: RegistryFriendlyByteBuf
说明:
TODO
代码
public class DisplayInfo {
public static final Codec<DisplayInfo> CODEC = RecordCodecBuilder.create(
i -> i.group(
ItemStackTemplate.CODEC.fieldOf("icon").forGetter(DisplayInfo::getIcon),
ComponentSerialization.CODEC.fieldOf("title").forGetter(DisplayInfo::getTitle),
ComponentSerialization.CODEC.fieldOf("description").forGetter(DisplayInfo::getDescription),
ClientAsset.ResourceTexture.CODEC.optionalFieldOf("background").forGetter(DisplayInfo::getBackground),
AdvancementType.CODEC.optionalFieldOf("frame", AdvancementType.TASK).forGetter(DisplayInfo::getType),
Codec.BOOL.optionalFieldOf("show_toast", true).forGetter(DisplayInfo::shouldShowToast),
Codec.BOOL.optionalFieldOf("announce_to_chat", true).forGetter(DisplayInfo::shouldAnnounceChat),
Codec.BOOL.optionalFieldOf("hidden", false).forGetter(DisplayInfo::isHidden)
)
.apply(i, DisplayInfo::new)
);
public static final StreamCodec<RegistryFriendlyByteBuf, DisplayInfo> STREAM_CODEC = StreamCodec.ofMember(
DisplayInfo::serializeToNetwork, DisplayInfo::fromNetwork
);
private final Component title;
private final Component description;
private final ItemStackTemplate icon;
private final Optional<ClientAsset.ResourceTexture> background;
private final AdvancementType type;
private final boolean showToast;
private final boolean announceChat;
private final boolean hidden;
private float x;
private float y;
public DisplayInfo(
ItemStackTemplate icon,
Component title,
Component description,
Optional<ClientAsset.ResourceTexture> background,
AdvancementType type,
boolean showToast,
boolean announceChat,
boolean hidden
) {
this.title = title;
this.description = description;
this.icon = icon;
this.background = background;
this.type = type;
this.showToast = showToast;
this.announceChat = announceChat;
this.hidden = hidden;
}
public void setLocation(float x, float y) {
this.x = x;
this.y = y;
}
public Component getTitle() {
return this.title;
}
public Component getDescription() {
return this.description;
}
public ItemStackTemplate getIcon() {
return this.icon;
}
public Optional<ClientAsset.ResourceTexture> getBackground() {
return this.background;
}
public AdvancementType getType() {
return this.type;
}
public float getX() {
return this.x;
}
public float getY() {
return this.y;
}
public boolean shouldShowToast() {
return this.showToast;
}
public boolean shouldAnnounceChat() {
return this.announceChat;
}
public boolean isHidden() {
return this.hidden;
}
private void serializeToNetwork(RegistryFriendlyByteBuf output) {
ComponentSerialization.TRUSTED_STREAM_CODEC.encode(output, this.title);
ComponentSerialization.TRUSTED_STREAM_CODEC.encode(output, this.description);
ItemStackTemplate.STREAM_CODEC.encode(output, this.icon);
output.writeEnum(this.type);
int flags = 0;
if (this.background.isPresent()) {
flags |= 1;
}
if (this.showToast) {
flags |= 2;
}
if (this.hidden) {
flags |= 4;
}
output.writeInt(flags);
this.background.map(ClientAsset::id).ifPresent(output::writeIdentifier);
output.writeFloat(this.x);
output.writeFloat(this.y);
}
private static DisplayInfo fromNetwork(RegistryFriendlyByteBuf input) {
Component title = ComponentSerialization.TRUSTED_STREAM_CODEC.decode(input);
Component description = ComponentSerialization.TRUSTED_STREAM_CODEC.decode(input);
ItemStackTemplate icon = ItemStackTemplate.STREAM_CODEC.decode(input);
AdvancementType frame = input.readEnum(AdvancementType.class);
int flags = input.readInt();
Optional<ClientAsset.ResourceTexture> background = (flags & 1) != 0
? Optional.of(new ClientAsset.ResourceTexture(input.readIdentifier()))
: Optional.empty();
boolean showToast = (flags & 2) != 0;
boolean hidden = (flags & 4) != 0;
DisplayInfo info = new DisplayInfo(icon, title, description, background, frame, showToast, false, hidden);
info.setLocation(input.readFloat(), input.readFloat());
return info;
}
}引用的其他类
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
参数/字段/方法调用/构造调用/返回值 - 关联成员:
ClientAsset.ResourceTexture(), ResourceTexture()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
StreamCodec.ofMember()
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置: