CommandBlockEditScreen.java
net.minecraft.client.gui.screens.inventory.CommandBlockEditScreen
信息
- 全限定名:net.minecraft.client.gui.screens.inventory.CommandBlockEditScreen
- 类型:public class
- 包:net.minecraft.client.gui.screens.inventory
- 源码路径:src/main/java/net/minecraft/client/gui/screens/inventory/CommandBlockEditScreen.java
- 起始行号:L12
- 继承:AbstractCommandBlockEditScreen
- 职责:
TODO
字段/常量
-
autoCommandBlock- 类型:
CommandBlockEntity - 修饰符:
private final - 源码定位:
L13 - 说明:
TODO
- 类型:
-
modeButton- 类型:
CycleButton<CommandBlockEntity.Mode> - 修饰符:
private - 源码定位:
L14 - 说明:
TODO
- 类型:
-
conditionalButton- 类型:
CycleButton<Boolean> - 修饰符:
private - 源码定位:
L15 - 说明:
TODO
- 类型:
-
autoexecButton- 类型:
CycleButton<Boolean> - 修饰符:
private - 源码定位:
L16 - 说明:
TODO
- 类型:
-
mode- 类型:
CommandBlockEntity.Mode - 修饰符:
private - 源码定位:
L17 - 说明:
TODO
- 类型:
-
conditional- 类型:
boolean - 修饰符:
private - 源码定位:
L18 - 说明:
TODO
- 类型:
-
autoexec- 类型:
boolean - 修饰符:
private - 源码定位:
L19 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public CommandBlockEditScreen(CommandBlockEntity commandBlock) @ L21
- 构造器名:CommandBlockEditScreen
- 源码定位:L21
- 修饰符:public
参数:
- commandBlock: CommandBlockEntity
说明:
TODO
方法
下面的方法块按源码顺序生成。
BaseCommandBlock getCommandBlock() @ L25
- 方法名:getCommandBlock
- 源码定位:L25
- 返回类型:BaseCommandBlock
- 修饰符:package-private
参数:
- 无
说明:
TODO
int getPreviousY() @ L30
- 方法名:getPreviousY
- 源码定位:L30
- 返回类型:int
- 修饰符:package-private
参数:
- 无
说明:
TODO
protected void init() @ L35
- 方法名:init
- 源码定位:L35
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
protected void addExtraControls() @ L41
- 方法名:addExtraControls
- 源码定位:L41
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
private void enableControls(boolean state) @ L71
- 方法名:enableControls
- 源码定位:L71
- 返回类型:void
- 修饰符:private
参数:
- state: boolean
说明:
TODO
public void updateGui() @ L79
- 方法名:updateGui
- 源码定位:L79
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void resize(int width, int height) @ L94
- 方法名:resize
- 源码定位:L94
- 返回类型:void
- 修饰符:public
参数:
- width: int
- height: int
说明:
TODO
protected void populateAndSendPacket() @ L100
- 方法名:populateAndSendPacket
- 源码定位:L100
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class CommandBlockEditScreen extends AbstractCommandBlockEditScreen {
private final CommandBlockEntity autoCommandBlock;
private CycleButton<CommandBlockEntity.Mode> modeButton;
private CycleButton<Boolean> conditionalButton;
private CycleButton<Boolean> autoexecButton;
private CommandBlockEntity.Mode mode = CommandBlockEntity.Mode.REDSTONE;
private boolean conditional;
private boolean autoexec;
public CommandBlockEditScreen(CommandBlockEntity commandBlock) {
this.autoCommandBlock = commandBlock;
}
@Override
BaseCommandBlock getCommandBlock() {
return this.autoCommandBlock.getCommandBlock();
}
@Override
int getPreviousY() {
return 135;
}
@Override
protected void init() {
super.init();
this.enableControls(false);
}
@Override
protected void addExtraControls() {
this.modeButton = this.addRenderableWidget(
CycleButton.<CommandBlockEntity.Mode>builder(mode -> {
return switch (mode) {
case SEQUENCE -> Component.translatable("advMode.mode.sequence");
case AUTO -> Component.translatable("advMode.mode.auto");
case REDSTONE -> Component.translatable("advMode.mode.redstone");
};
}, this.mode)
.withValues(CommandBlockEntity.Mode.values())
.displayOnlyValue()
.create(this.width / 2 - 50 - 100 - 4, 165, 100, 20, Component.translatable("advMode.mode"), (button, value) -> this.mode = value)
);
this.conditionalButton = this.addRenderableWidget(
CycleButton.booleanBuilder(
Component.translatable("advMode.mode.conditional"), Component.translatable("advMode.mode.unconditional"), this.conditional
)
.displayOnlyValue()
.create(this.width / 2 - 50, 165, 100, 20, Component.translatable("advMode.type"), (button, value) -> this.conditional = value)
);
this.autoexecButton = this.addRenderableWidget(
CycleButton.booleanBuilder(
Component.translatable("advMode.mode.autoexec.bat"), Component.translatable("advMode.mode.redstoneTriggered"), this.autoexec
)
.displayOnlyValue()
.create(this.width / 2 + 50 + 4, 165, 100, 20, Component.translatable("advMode.triggering"), (button, value) -> this.autoexec = value)
);
}
private void enableControls(boolean state) {
this.doneButton.active = state;
this.outputButton.active = state;
this.modeButton.active = state;
this.conditionalButton.active = state;
this.autoexecButton.active = state;
}
public void updateGui() {
BaseCommandBlock commandBlock = this.autoCommandBlock.getCommandBlock();
this.commandEdit.setValue(commandBlock.getCommand());
boolean trackOutput = commandBlock.isTrackOutput();
this.mode = this.autoCommandBlock.getMode();
this.conditional = this.autoCommandBlock.isConditional();
this.autoexec = this.autoCommandBlock.isAutomatic();
this.outputButton.setValue(trackOutput);
this.modeButton.setValue(this.mode);
this.conditionalButton.setValue(this.conditional);
this.autoexecButton.setValue(this.autoexec);
this.updatePreviousOutput(trackOutput);
this.enableControls(true);
}
@Override
public void resize(int width, int height) {
super.resize(width, height);
this.enableControls(true);
}
@Override
protected void populateAndSendPacket() {
this.minecraft
.getConnection()
.send(
new ServerboundSetCommandBlockPacket(
this.autoCommandBlock.getBlockPos(),
this.commandEdit.getValue(),
this.mode,
this.autoCommandBlock.getCommandBlock().isTrackOutput(),
this.conditional,
this.autoexec
)
);
}
}引用的其他类
-
- 引用位置:
字段/方法调用 - 关联成员:
CycleButton.booleanBuilder()
- 引用位置:
-
AbstractCommandBlockEditScreen
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
ServerboundSetCommandBlockPacket
- 引用位置:
构造调用 - 关联成员:
ServerboundSetCommandBlockPacket()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
参数/字段/方法调用 - 关联成员:
CommandBlockEntity.Mode.values()
- 引用位置: