WorldOptionsScreen.java
net.minecraft.client.gui.screens.options.WorldOptionsScreen
信息
- 全限定名:net.minecraft.client.gui.screens.options.WorldOptionsScreen
- 类型:public class
- 包:net.minecraft.client.gui.screens.options
- 源码路径:src/main/java/net/minecraft/client/gui/screens/options/WorldOptionsScreen.java
- 起始行号:L19
- 继承:Screen
- 实现:HasGamemasterPermissionReaction, HasDifficultyReaction
- 职责:
TODO
字段/常量
-
TITLE- 类型:
Component - 修饰符:
private static final - 源码定位:
L20 - 说明:
TODO
- 类型:
-
GAME_RULES- 类型:
Component - 修饰符:
private static final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
GAMERULES_DISABLED_TOOLTIP- 类型:
Tooltip - 修饰符:
private static final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
RESTRICTIONS- 类型:
Component - 修饰符:
private static final - 源码定位:
L23 - 说明:
TODO
- 类型:
-
lastScreen- 类型:
Screen - 修饰符:
private final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
layout- 类型:
HeaderAndFooterLayout - 修饰符:
private final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
difficultyButtons- 类型:
DifficultyButtons - 修饰符:
private final - 源码定位:
L26 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public WorldOptionsScreen(Screen lastScreen, Level level) @ L28
- 构造器名:WorldOptionsScreen
- 源码定位:L28
- 修饰符:public
参数:
- lastScreen: Screen
- level: Level
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected void init() @ L34
- 方法名:init
- 源码定位:L34
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
private Button createGameRulesButton() @ L47
- 方法名:createGameRulesButton
- 源码定位:L47
- 返回类型:Button
- 修饰符:private
参数:
- 无
说明:
TODO
private Button createRestrictionsButton() @ L61
- 方法名:createRestrictionsButton
- 源码定位:L61
- 返回类型:Button
- 修饰符:private
参数:
- 无
说明:
TODO
protected void repositionElements() @ L69
- 方法名:repositionElements
- 源码定位:L69
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
public void onClose() @ L74
- 方法名:onClose
- 源码定位:L74
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void onGamemasterPermissionChanged(boolean hasGamemasterPermission) @ L79
- 方法名:onGamemasterPermissionChanged
- 源码定位:L79
- 返回类型:void
- 修饰符:public
参数:
- hasGamemasterPermission: boolean
说明:
TODO
public void added() @ L89
- 方法名:added
- 源码定位:L89
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void onDifficultyChanged() @ L94
- 方法名:onDifficultyChanged
- 源码定位:L94
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class WorldOptionsScreen extends Screen implements HasGamemasterPermissionReaction, HasDifficultyReaction {
private static final Component TITLE = Component.translatable("options.worldOptions.title");
private static final Component GAME_RULES = Component.translatable("editGamerule.inGame.button");
private static final Tooltip GAMERULES_DISABLED_TOOLTIP = Tooltip.create(Component.translatable("editGamerule.inGame.disabled.tooltip"));
private static final Component RESTRICTIONS = Component.translatable("restrictions_screen.button");
private final Screen lastScreen;
private final HeaderAndFooterLayout layout = new HeaderAndFooterLayout(this);
private final DifficultyButtons difficultyButtons;
public WorldOptionsScreen(Screen lastScreen, Level level) {
super(TITLE);
this.lastScreen = lastScreen;
this.difficultyButtons = DifficultyButtons.create(this.minecraft, level, this);
}
@Override
protected void init() {
this.layout.addToHeader(new StringWidget(TITLE, this.font), LayoutSettings::alignHorizontallyCenter);
GridLayout content = this.layout.addToContents(new GridLayout(0, 0));
GridLayout.RowHelper gridHelper = content.columnSpacing(8).rowSpacing(4).createRowHelper(2);
gridHelper.addChild(this.difficultyButtons.layout());
gridHelper.addChild(this.createGameRulesButton());
gridHelper.addChild(this.createRestrictionsButton());
this.layout.addToFooter(Button.builder(CommonComponents.GUI_DONE, button -> this.onClose()).width(200).build());
this.layout.visitWidgets(x$0 -> this.addRenderableWidget(x$0));
this.repositionElements();
}
private Button createGameRulesButton() {
Button gameRulesButton = Button.builder(GAME_RULES, button -> {
if (this.minecraft.player != null) {
this.minecraft.setScreen(new InWorldGameRulesScreen(this.minecraft.player.connection, result -> this.minecraft.setScreen(this), this));
}
}).build();
if (this.minecraft.player == null || !this.minecraft.player.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER)) {
gameRulesButton.active = false;
gameRulesButton.setTooltip(GAMERULES_DISABLED_TOOLTIP);
}
return gameRulesButton;
}
private Button createRestrictionsButton() {
return Button.builder(RESTRICTIONS, var1 -> {
if (this.minecraft.player != null) {
this.minecraft.setScreen(new RestrictionsScreen(this, this.minecraft.player.chatAbilities()));
}
}).build();
}
@Override
protected void repositionElements() {
this.layout.arrangeElements();
}
@Override
public void onClose() {
this.minecraft.setScreen(this.lastScreen);
}
@Override
public void onGamemasterPermissionChanged(boolean hasGamemasterPermission) {
if (!hasGamemasterPermission) {
this.minecraft.setScreen(this.lastScreen);
if (this.minecraft.screen instanceof HasGamemasterPermissionReaction screen) {
screen.onGamemasterPermissionChanged(hasGamemasterPermission);
}
}
}
@Override
public void added() {
this.difficultyButtons.refresh(this.minecraft);
}
@Override
public void onDifficultyChanged() {
this.difficultyButtons.refresh(this.minecraft);
}
}引用的其他类
-
- 引用位置:
方法调用/返回值 - 关联成员:
Button.builder()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
StringWidget()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Tooltip.create()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
GridLayout()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
HeaderAndFooterLayout()
- 引用位置:
-
- 引用位置:
参数/字段/继承
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
RestrictionsScreen()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
DifficultyButtons.create()
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
HasGamemasterPermissionReaction
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
InWorldGameRulesScreen()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
参数
- 引用位置: