PlayerEntry.java
net.minecraft.client.gui.screens.social.PlayerEntry
信息
- 全限定名:net.minecraft.client.gui.screens.social.PlayerEntry
- 类型:public class
- 包:net.minecraft.client.gui.screens.social
- 源码路径:src/main/java/net/minecraft/client/gui/screens/social/PlayerEntry.java
- 起始行号:L37
- 继承:ContainerObjectSelectionList.Entry
- 职责:
TODO
字段/常量
-
DRAFT_REPORT_SPRITE- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L38 - 说明:
TODO
- 类型:
-
TOOLTIP_DELAY- 类型:
Duration - 修饰符:
private static final - 源码定位:
L39 - 说明:
TODO
- 类型:
-
REPORT_BUTTON_SPRITES- 类型:
WidgetSprites - 修饰符:
private static final - 源码定位:
L40 - 说明:
TODO
- 类型:
-
MUTE_BUTTON_SPRITES- 类型:
WidgetSprites - 修饰符:
private static final - 源码定位:
L45 - 说明:
TODO
- 类型:
-
UNMUTE_BUTTON_SPRITES- 类型:
WidgetSprites - 修饰符:
private static final - 源码定位:
L48 - 说明:
TODO
- 类型:
-
minecraft- 类型:
Minecraft - 修饰符:
private final - 源码定位:
L51 - 说明:
TODO
- 类型:
-
children- 类型:
List<AbstractWidget> - 修饰符:
private final - 源码定位:
L52 - 说明:
TODO
- 类型:
-
id- 类型:
UUID - 修饰符:
private final - 源码定位:
L53 - 说明:
TODO
- 类型:
-
playerName- 类型:
String - 修饰符:
private final - 源码定位:
L54 - 说明:
TODO
- 类型:
-
skinGetter- 类型:
Supplier<PlayerSkin> - 修饰符:
private final - 源码定位:
L55 - 说明:
TODO
- 类型:
-
isRemoved- 类型:
boolean - 修饰符:
private - 源码定位:
L56 - 说明:
TODO
- 类型:
-
hasRecentMessages- 类型:
boolean - 修饰符:
private - 源码定位:
L57 - 说明:
TODO
- 类型:
-
reportingEnabled- 类型:
boolean - 修饰符:
private final - 源码定位:
L58 - 说明:
TODO
- 类型:
-
hasDraftReport- 类型:
boolean - 修饰符:
private - 源码定位:
L59 - 说明:
TODO
- 类型:
-
chatReportable- 类型:
boolean - 修饰符:
private final - 源码定位:
L60 - 说明:
TODO
- 类型:
-
hideButton- 类型:
Button - 修饰符:
private - 源码定位:
L61 - 说明:
TODO
- 类型:
-
showButton- 类型:
Button - 修饰符:
private - 源码定位:
L62 - 说明:
TODO
- 类型:
-
reportButton- 类型:
Button - 修饰符:
private - 源码定位:
L63 - 说明:
TODO
- 类型:
-
tooltipHoverTime- 类型:
float - 修饰符:
private - 源码定位:
L64 - 说明:
TODO
- 类型:
-
HIDDEN- 类型:
Component - 修饰符:
private static final - 源码定位:
L65 - 说明:
TODO
- 类型:
-
BLOCKED- 类型:
Component - 修饰符:
private static final - 源码定位:
L66 - 说明:
TODO
- 类型:
-
OFFLINE- 类型:
Component - 修饰符:
private static final - 源码定位:
L67 - 说明:
TODO
- 类型:
-
HIDDEN_OFFLINE- 类型:
Component - 修饰符:
private static final - 源码定位:
L68 - 说明:
TODO
- 类型:
-
BLOCKED_OFFLINE- 类型:
Component - 修饰符:
private static final - 源码定位:
L69 - 说明:
TODO
- 类型:
-
REPORT_DISABLED_TOOLTIP- 类型:
Component - 修饰符:
private static final - 源码定位:
L70 - 说明:
TODO
- 类型:
-
HIDE_TEXT_TOOLTIP- 类型:
Component - 修饰符:
private static final - 源码定位:
L71 - 说明:
TODO
- 类型:
-
SHOW_TEXT_TOOLTIP- 类型:
Component - 修饰符:
private static final - 源码定位:
L72 - 说明:
TODO
- 类型:
-
REPORT_PLAYER_TOOLTIP- 类型:
Component - 修饰符:
private static final - 源码定位:
L73 - 说明:
TODO
- 类型:
-
SKIN_SIZE- 类型:
int - 修饰符:
private static final - 源码定位:
L74 - 说明:
TODO
- 类型:
-
PADDING- 类型:
int - 修饰符:
private static final - 源码定位:
L75 - 说明:
TODO
- 类型:
-
SKIN_SHADE- 类型:
int - 修饰符:
public static final - 源码定位:
L76 - 说明:
TODO
- 类型:
-
CHAT_TOGGLE_ICON_SIZE- 类型:
int - 修饰符:
private static final - 源码定位:
L77 - 说明:
TODO
- 类型:
-
BG_FILL- 类型:
int - 修饰符:
public static final - 源码定位:
L78 - 说明:
TODO
- 类型:
-
BG_FILL_REMOVED- 类型:
int - 修饰符:
public static final - 源码定位:
L79 - 说明:
TODO
- 类型:
-
PLAYERNAME_COLOR- 类型:
int - 修饰符:
public static final - 源码定位:
L80 - 说明:
TODO
- 类型:
-
PLAYER_STATUS_COLOR- 类型:
int - 修饰符:
public static final - 源码定位:
L81 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public PlayerEntry(Minecraft minecraft, SocialInteractionsScreen socialInteractionsScreen, UUID id, String playerName, Supplier<PlayerSkin> skinGetter, boolean chatReportable) @ L83
- 构造器名:PlayerEntry
- 源码定位:L83
- 修饰符:public
参数:
- minecraft: Minecraft
- socialInteractionsScreen: SocialInteractionsScreen
- id: UUID
- playerName: String
- skinGetter: Supplier
- chatReportable: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void refreshHasDraftReport(ReportingContext reportingContext) @ L170
- 方法名:refreshHasDraftReport
- 源码定位:L170
- 返回类型:void
- 修饰符:public
参数:
- reportingContext: ReportingContext
说明:
TODO
private Tooltip createReportButtonTooltip() @ L174
- 方法名:createReportButtonTooltip
- 源码定位:L174
- 返回类型:Tooltip
- 修饰符:private
参数:
- 无
说明:
TODO
public void extractContent(GuiGraphicsExtractor graphics, int mouseX, int mouseY, boolean hovered, float a) @ L180
- 方法名:extractContent
- 源码定位:L180
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- hovered: boolean
- a: float
说明:
TODO
public List<?extends GuiEventListener> children() @ L223
- 方法名:children
- 源码定位:L223
- 返回类型:List<?extends GuiEventListener>
- 修饰符:public
参数:
- 无
说明:
TODO
public List<?extends NarratableEntry> narratables() @ L228
- 方法名:narratables
- 源码定位:L228
- 返回类型:List<?extends NarratableEntry>
- 修饰符:public
参数:
- 无
说明:
TODO
public String getPlayerName() @ L233
- 方法名:getPlayerName
- 源码定位:L233
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public UUID getPlayerId() @ L237
- 方法名:getPlayerId
- 源码定位:L237
- 返回类型:UUID
- 修饰符:public
参数:
- 无
说明:
TODO
public Supplier<PlayerSkin> getSkinGetter() @ L241
- 方法名:getSkinGetter
- 源码定位:L241
- 返回类型:Supplier
- 修饰符:public
参数:
- 无
说明:
TODO
public void setRemoved(boolean isRemoved) @ L245
- 方法名:setRemoved
- 源码定位:L245
- 返回类型:void
- 修饰符:public
参数:
- isRemoved: boolean
说明:
TODO
public boolean isRemoved() @ L249
- 方法名:isRemoved
- 源码定位:L249
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public void setHasRecentMessages(boolean hasRecentMessages) @ L253
- 方法名:setHasRecentMessages
- 源码定位:L253
- 返回类型:void
- 修饰符:public
参数:
- hasRecentMessages: boolean
说明:
TODO
public boolean hasRecentMessages() @ L257
- 方法名:hasRecentMessages
- 源码定位:L257
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isChatReportable() @ L261
- 方法名:isChatReportable
- 源码定位:L261
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
private void onHiddenOrShown(boolean isHidden, Component message) @ L265
- 方法名:onHiddenOrShown
- 源码定位:L265
- 返回类型:void
- 修饰符:private
参数:
- isHidden: boolean
- message: Component
说明:
TODO
private void updateHideAndShowButton(boolean isHidden) @ L271
- 方法名:updateHideAndShowButton
- 源码定位:L271
- 返回类型:void
- 修饰符:private
参数:
- isHidden: boolean
说明:
TODO
private MutableComponent getEntryNarationMessage(MutableComponent buttonNarrationMessage) @ L277
- 方法名:getEntryNarationMessage
- 源码定位:L277
- 返回类型:MutableComponent
- 修饰符:private
参数:
- buttonNarrationMessage: MutableComponent
说明:
TODO
private Component getStatusComponent() @ L284
- 方法名:getStatusComponent
- 源码定位:L284
- 返回类型:Component
- 修饰符:private
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class PlayerEntry extends ContainerObjectSelectionList.Entry<PlayerEntry> {
private static final Identifier DRAFT_REPORT_SPRITE = Identifier.withDefaultNamespace("icon/draft_report");
private static final Duration TOOLTIP_DELAY = Duration.ofMillis(500L);
private static final WidgetSprites REPORT_BUTTON_SPRITES = new WidgetSprites(
Identifier.withDefaultNamespace("social_interactions/report_button"),
Identifier.withDefaultNamespace("social_interactions/report_button_disabled"),
Identifier.withDefaultNamespace("social_interactions/report_button_highlighted")
);
private static final WidgetSprites MUTE_BUTTON_SPRITES = new WidgetSprites(
Identifier.withDefaultNamespace("social_interactions/mute_button"), Identifier.withDefaultNamespace("social_interactions/mute_button_highlighted")
);
private static final WidgetSprites UNMUTE_BUTTON_SPRITES = new WidgetSprites(
Identifier.withDefaultNamespace("social_interactions/unmute_button"), Identifier.withDefaultNamespace("social_interactions/unmute_button_highlighted")
);
private final Minecraft minecraft;
private final List<AbstractWidget> children;
private final UUID id;
private final String playerName;
private final Supplier<PlayerSkin> skinGetter;
private boolean isRemoved;
private boolean hasRecentMessages;
private final boolean reportingEnabled;
private boolean hasDraftReport;
private final boolean chatReportable;
private @Nullable Button hideButton;
private @Nullable Button showButton;
private @Nullable Button reportButton;
private float tooltipHoverTime;
private static final Component HIDDEN = Component.translatable("gui.socialInteractions.status_hidden").withStyle(ChatFormatting.ITALIC);
private static final Component BLOCKED = Component.translatable("gui.socialInteractions.status_blocked").withStyle(ChatFormatting.ITALIC);
private static final Component OFFLINE = Component.translatable("gui.socialInteractions.status_offline").withStyle(ChatFormatting.ITALIC);
private static final Component HIDDEN_OFFLINE = Component.translatable("gui.socialInteractions.status_hidden_offline").withStyle(ChatFormatting.ITALIC);
private static final Component BLOCKED_OFFLINE = Component.translatable("gui.socialInteractions.status_blocked_offline").withStyle(ChatFormatting.ITALIC);
private static final Component REPORT_DISABLED_TOOLTIP = Component.translatable("gui.socialInteractions.tooltip.report.disabled");
private static final Component HIDE_TEXT_TOOLTIP = Component.translatable("gui.socialInteractions.tooltip.hide");
private static final Component SHOW_TEXT_TOOLTIP = Component.translatable("gui.socialInteractions.tooltip.show");
private static final Component REPORT_PLAYER_TOOLTIP = Component.translatable("gui.socialInteractions.tooltip.report");
private static final int SKIN_SIZE = 24;
private static final int PADDING = 4;
public static final int SKIN_SHADE = ARGB.color(190, 0, 0, 0);
private static final int CHAT_TOGGLE_ICON_SIZE = 20;
public static final int BG_FILL = ARGB.color(255, 74, 74, 74);
public static final int BG_FILL_REMOVED = ARGB.color(255, 48, 48, 48);
public static final int PLAYERNAME_COLOR = ARGB.color(255, 255, 255, 255);
public static final int PLAYER_STATUS_COLOR = ARGB.color(140, 255, 255, 255);
public PlayerEntry(
Minecraft minecraft,
SocialInteractionsScreen socialInteractionsScreen,
UUID id,
String playerName,
Supplier<PlayerSkin> skinGetter,
boolean chatReportable
) {
this.minecraft = minecraft;
this.id = id;
this.playerName = playerName;
this.skinGetter = skinGetter;
ReportingContext reportingContext = minecraft.getReportingContext();
this.reportingEnabled = reportingContext.sender().isEnabled();
this.chatReportable = chatReportable;
this.refreshHasDraftReport(reportingContext);
Component hideNarration = Component.translatable("gui.socialInteractions.narration.hide", playerName);
Component showNarration = Component.translatable("gui.socialInteractions.narration.show", playerName);
PlayerSocialManager socialManager = minecraft.getPlayerSocialManager();
boolean chatDisabledOrBlocked = minecraft.player.chatAbilities().canReceivePlayerMessages() || socialManager.isBlocked(id);
boolean notLocalPlayer = !minecraft.player.getUUID().equals(id);
if (!SharedConstants.DEBUG_SOCIAL_INTERACTIONS && !notLocalPlayer) {
this.children = ImmutableList.of();
} else {
this.reportButton = new ImageButton(
0,
0,
20,
20,
REPORT_BUTTON_SPRITES,
button -> reportingContext.draftReportHandled(
minecraft,
socialInteractionsScreen,
() -> minecraft.setScreen(new ReportPlayerScreen(socialInteractionsScreen, reportingContext, this, chatDisabledOrBlocked)),
false
),
Component.translatable("gui.socialInteractions.report")
) {
{
Objects.requireNonNull(PlayerEntry.this);
}
@Override
protected MutableComponent createNarrationMessage() {
return PlayerEntry.this.getEntryNarationMessage(super.createNarrationMessage());
}
};
this.reportButton.active = this.reportingEnabled;
this.reportButton.setTooltip(this.createReportButtonTooltip());
this.reportButton.setTooltipDelay(TOOLTIP_DELAY);
this.hideButton = new ImageButton(0, 0, 20, 20, MUTE_BUTTON_SPRITES, button -> {
socialManager.hidePlayer(id);
this.onHiddenOrShown(true, Component.translatable("gui.socialInteractions.hidden_in_chat", playerName));
}, Component.translatable("gui.socialInteractions.hide")) {
{
Objects.requireNonNull(PlayerEntry.this);
}
@Override
protected MutableComponent createNarrationMessage() {
return PlayerEntry.this.getEntryNarationMessage(super.createNarrationMessage());
}
};
this.hideButton.setTooltip(Tooltip.create(HIDE_TEXT_TOOLTIP, hideNarration));
this.hideButton.setTooltipDelay(TOOLTIP_DELAY);
this.showButton = new ImageButton(0, 0, 20, 20, UNMUTE_BUTTON_SPRITES, button -> {
socialManager.showPlayer(id);
this.onHiddenOrShown(false, Component.translatable("gui.socialInteractions.shown_in_chat", playerName));
}, Component.translatable("gui.socialInteractions.show")) {
{
Objects.requireNonNull(PlayerEntry.this);
}
@Override
protected MutableComponent createNarrationMessage() {
return PlayerEntry.this.getEntryNarationMessage(super.createNarrationMessage());
}
};
this.showButton.setTooltip(Tooltip.create(SHOW_TEXT_TOOLTIP, showNarration));
this.showButton.setTooltipDelay(TOOLTIP_DELAY);
this.children = new ArrayList<>();
this.children.add(this.hideButton);
this.children.add(this.reportButton);
this.updateHideAndShowButton(socialManager.isHidden(this.id));
}
}
public void refreshHasDraftReport(ReportingContext reportingContext) {
this.hasDraftReport = reportingContext.hasDraftReportFor(this.id);
}
private Tooltip createReportButtonTooltip() {
return !this.reportingEnabled
? Tooltip.create(REPORT_DISABLED_TOOLTIP)
: Tooltip.create(REPORT_PLAYER_TOOLTIP, Component.translatable("gui.socialInteractions.narration.report", this.playerName));
}
@Override
public void extractContent(GuiGraphicsExtractor graphics, int mouseX, int mouseY, boolean hovered, float a) {
int skinX = this.getContentX() + 4;
int skinY = this.getContentY() + (this.getContentHeight() - 24) / 2;
int textStartX = skinX + 24 + 4;
Component status = this.getStatusComponent();
int textStartY;
if (status == CommonComponents.EMPTY) {
graphics.fill(this.getContentX(), this.getContentY(), this.getContentRight(), this.getContentBottom(), BG_FILL);
textStartY = this.getContentY() + (this.getContentHeight() - 9) / 2;
} else {
graphics.fill(this.getContentX(), this.getContentY(), this.getContentRight(), this.getContentBottom(), BG_FILL_REMOVED);
textStartY = this.getContentY() + (this.getContentHeight() - (9 + 9)) / 2;
graphics.text(this.minecraft.font, status, textStartX, textStartY + 12, PLAYER_STATUS_COLOR);
}
PlayerFaceExtractor.extractRenderState(graphics, this.skinGetter.get(), skinX, skinY, 24);
graphics.text(this.minecraft.font, this.playerName, textStartX, textStartY, PLAYERNAME_COLOR);
if (this.isRemoved) {
graphics.fill(skinX, skinY, skinX + 24, skinY + 24, SKIN_SHADE);
}
if (this.hideButton != null && this.showButton != null && this.reportButton != null) {
float lastHoverTime = this.tooltipHoverTime;
this.hideButton.setX(this.getContentX() + (this.getContentWidth() - this.hideButton.getWidth() - 4) - 20 - 4);
this.hideButton.setY(this.getContentY() + (this.getContentHeight() - this.hideButton.getHeight()) / 2);
this.hideButton.extractRenderState(graphics, mouseX, mouseY, a);
this.showButton.setX(this.getContentX() + (this.getContentWidth() - this.showButton.getWidth() - 4) - 20 - 4);
this.showButton.setY(this.getContentY() + (this.getContentHeight() - this.showButton.getHeight()) / 2);
this.showButton.extractRenderState(graphics, mouseX, mouseY, a);
this.reportButton.setX(this.getContentX() + (this.getContentWidth() - this.showButton.getWidth() - 4));
this.reportButton.setY(this.getContentY() + (this.getContentHeight() - this.showButton.getHeight()) / 2);
this.reportButton.extractRenderState(graphics, mouseX, mouseY, a);
if (lastHoverTime == this.tooltipHoverTime) {
this.tooltipHoverTime = 0.0F;
}
}
if (this.hasDraftReport && this.reportButton != null) {
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, DRAFT_REPORT_SPRITE, this.reportButton.getX() + 5, this.reportButton.getY() + 1, 15, 15);
}
}
@Override
public List<? extends GuiEventListener> children() {
return this.children;
}
@Override
public List<? extends NarratableEntry> narratables() {
return this.children;
}
public String getPlayerName() {
return this.playerName;
}
public UUID getPlayerId() {
return this.id;
}
public Supplier<PlayerSkin> getSkinGetter() {
return this.skinGetter;
}
public void setRemoved(boolean isRemoved) {
this.isRemoved = isRemoved;
}
public boolean isRemoved() {
return this.isRemoved;
}
public void setHasRecentMessages(boolean hasRecentMessages) {
this.hasRecentMessages = hasRecentMessages;
}
public boolean hasRecentMessages() {
return this.hasRecentMessages;
}
public boolean isChatReportable() {
return this.chatReportable;
}
private void onHiddenOrShown(boolean isHidden, Component message) {
this.updateHideAndShowButton(isHidden);
this.minecraft.gui.getChat().addClientSystemMessage(message);
this.minecraft.getNarrator().saySystemNow(message);
}
private void updateHideAndShowButton(boolean isHidden) {
this.showButton.visible = isHidden;
this.hideButton.visible = !isHidden;
this.children.set(0, isHidden ? this.showButton : this.hideButton);
}
private MutableComponent getEntryNarationMessage(MutableComponent buttonNarrationMessage) {
Component status = this.getStatusComponent();
return status == CommonComponents.EMPTY
? Component.literal(this.playerName).append(", ").append(buttonNarrationMessage)
: Component.literal(this.playerName).append(", ").append(status).append(", ").append(buttonNarrationMessage);
}
private Component getStatusComponent() {
boolean isHidden = this.minecraft.getPlayerSocialManager().isHidden(this.id);
boolean isBlocked = this.minecraft.getPlayerSocialManager().isBlocked(this.id);
if (isBlocked && this.isRemoved) {
return BLOCKED_OFFLINE;
} else if (isHidden && this.isRemoved) {
return HIDDEN_OFFLINE;
} else if (isBlocked) {
return BLOCKED;
} else if (isHidden) {
return HIDDEN;
} else {
return this.isRemoved ? OFFLINE : CommonComponents.EMPTY;
}
}
}引用的其他类
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
ImageButton()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
PlayerFaceExtractor.extractRenderState()
- 引用位置:
-
- 引用位置:
方法调用/返回值 - 关联成员:
Tooltip.create()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
WidgetSprites()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
ReportPlayerScreen()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段/方法调用/返回值 - 关联成员:
Component.literal(), Component.translatable()
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Identifier.withDefaultNamespace()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ARGB.color()
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置: