TestBlockEditScreen.java
net.minecraft.client.gui.screens.inventory.TestBlockEditScreen
信息
- 全限定名:net.minecraft.client.gui.screens.inventory.TestBlockEditScreen
- 类型:public class
- 包:net.minecraft.client.gui.screens.inventory
- 源码路径:src/main/java/net/minecraft/client/gui/screens/inventory/TestBlockEditScreen.java
- 起始行号:L21
- 继承:Screen
- 职责:
TODO
字段/常量
-
MODES- 类型:
List<TestBlockMode> - 修饰符:
private static final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
TITLE- 类型:
Component - 修饰符:
private static final - 源码定位:
L23 - 说明:
TODO
- 类型:
-
MESSAGE_LABEL- 类型:
Component - 修饰符:
private static final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
position- 类型:
BlockPos - 修饰符:
private final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
mode- 类型:
TestBlockMode - 修饰符:
private - 源码定位:
L26 - 说明:
TODO
- 类型:
-
message- 类型:
String - 修饰符:
private - 源码定位:
L27 - 说明:
TODO
- 类型:
-
messageEdit- 类型:
EditBox - 修饰符:
private - 源码定位:
L28 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public TestBlockEditScreen(TestBlockEntity block) @ L30
- 构造器名:TestBlockEditScreen
- 源码定位:L30
- 修饰符:public
参数:
- block: TestBlockEntity
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void init() @ L37
- 方法名:init
- 源码定位:L37
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
protected void setInitialFocus() @ L54
- 方法名:setInitialFocus
- 源码定位:L54
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L63
- 方法名:extractRenderState
- 源码定位:L63
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
public boolean isPauseScreen() @ L74
- 方法名:isPauseScreen
- 源码定位:L74
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isInGameUi() @ L79
- 方法名:isInGameUi
- 源码定位:L79
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
private void onDone() @ L84
- 方法名:onDone
- 源码定位:L84
- 返回类型:void
- 修饰符:private
参数:
- 无
说明:
TODO
public void onClose() @ L90
- 方法名:onClose
- 源码定位:L90
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
private void onCancel() @ L95
- 方法名:onCancel
- 源码定位:L95
- 返回类型:void
- 修饰符:private
参数:
- 无
说明:
TODO
private void updateMode(TestBlockMode value) @ L99
- 方法名:updateMode
- 源码定位:L99
- 返回类型:void
- 修饰符:private
参数:
- value: TestBlockMode
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class TestBlockEditScreen extends Screen {
private static final List<TestBlockMode> MODES = List.of(TestBlockMode.values());
private static final Component TITLE = Component.translatable(Blocks.TEST_BLOCK.getDescriptionId());
private static final Component MESSAGE_LABEL = Component.translatable("test_block.message");
private final BlockPos position;
private TestBlockMode mode;
private String message;
private @Nullable EditBox messageEdit;
public TestBlockEditScreen(TestBlockEntity block) {
super(TITLE);
this.position = block.getBlockPos();
this.mode = block.getMode();
this.message = block.getMessage();
}
@Override
public void init() {
this.messageEdit = new EditBox(this.font, this.width / 2 - 152, 80, 240, 20, Component.translatable("test_block.message"));
this.messageEdit.setMaxLength(128);
this.messageEdit.setValue(this.message);
this.addRenderableWidget(this.messageEdit);
this.updateMode(this.mode);
this.addRenderableWidget(
CycleButton.builder(TestBlockMode::getDisplayName, this.mode)
.withValues(MODES)
.displayOnlyValue()
.create(this.width / 2 - 4 - 150, 185, 50, 20, TITLE, (button, value) -> this.updateMode(value))
);
this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, button -> this.onDone()).bounds(this.width / 2 - 4 - 150, 210, 150, 20).build());
this.addRenderableWidget(Button.builder(CommonComponents.GUI_CANCEL, button -> this.onCancel()).bounds(this.width / 2 + 4, 210, 150, 20).build());
}
@Override
protected void setInitialFocus() {
if (this.messageEdit != null) {
this.setInitialFocus(this.messageEdit);
} else {
super.setInitialFocus();
}
}
@Override
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
super.extractRenderState(graphics, mouseX, mouseY, a);
graphics.centeredText(this.font, this.title, this.width / 2, 10, -1);
if (this.mode != TestBlockMode.START) {
graphics.text(this.font, MESSAGE_LABEL, this.width / 2 - 153, 70, -6250336);
}
graphics.text(this.font, this.mode.getDetailedMessage(), this.width / 2 - 153, 174, -6250336);
}
@Override
public boolean isPauseScreen() {
return false;
}
@Override
public boolean isInGameUi() {
return true;
}
private void onDone() {
this.message = this.messageEdit.getValue();
this.minecraft.getConnection().send(new ServerboundSetTestBlockPacket(this.position, this.mode, this.message));
this.onClose();
}
@Override
public void onClose() {
this.onCancel();
}
private void onCancel() {
this.minecraft.setScreen(null);
}
private void updateMode(TestBlockMode value) {
this.mode = value;
this.messageEdit.visible = value != TestBlockMode.START;
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Button.builder()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
CycleButton.builder()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
EditBox()
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
ServerboundSetTestBlockPacket()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段/方法调用 - 关联成员:
TestBlockMode.values()
- 引用位置: