Post-merge fixes. Reformat. Optimize Imports.
This commit is contained in:
@@ -642,7 +642,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends HandledScr
|
||||
this.itemRenderer.zOffset = 0.0F;
|
||||
}
|
||||
|
||||
protected ITextComponent getGuiDisplayName(final Text in) {
|
||||
protected Text getGuiDisplayName(final Text in) {
|
||||
return title.getString().isEmpty() ? in : title;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,16 +136,16 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
|
||||
this.selectCPU.setMessage(getNextCpuButtonLabel());
|
||||
}
|
||||
|
||||
private ITextComponent getNextCpuButtonLabel() {
|
||||
if (this.container.hasNoCPU()) {
|
||||
private Text getNextCpuButtonLabel() {
|
||||
if (this.handler.hasNoCPU()) {
|
||||
return GuiText.NoCraftingCPUs.text();
|
||||
}
|
||||
|
||||
ITextComponent cpuName;
|
||||
if (this.container.cpuName == null) {
|
||||
Text cpuName;
|
||||
if (this.handler.cpuName == null) {
|
||||
cpuName = GuiText.Automatic.text();
|
||||
} else {
|
||||
cpuName = this.container.cpuName;
|
||||
cpuName = this.handler.cpuName;
|
||||
}
|
||||
|
||||
return GuiText.CraftingCPU.withSuffix(": ").append(cpuName);
|
||||
|
||||
@@ -63,11 +63,11 @@ public class CraftingStatusScreen extends CraftingCPUScreen<CraftingStatusContai
|
||||
this.selectCPU.setMessage(getNextCpuButtonLabel());
|
||||
}
|
||||
|
||||
private ITextComponent getNextCpuButtonLabel() {
|
||||
private Text getNextCpuButtonLabel() {
|
||||
if (this.handler.noCPU) {
|
||||
return GuiText.NoCraftingJobs.text();
|
||||
}
|
||||
return GuiText.CraftingCPU.withSuffix(": ").append(container.cpuName);
|
||||
return GuiText.CraftingCPU.withSuffix(": ").append(handler.cpuName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,15 +52,15 @@ public class LevelEmitterScreen extends UpgradeableScreen<LevelEmitterContainer>
|
||||
this.level = new NumberEntryWidget(this, 20, 17, 138, 62, NumberEntryType.LEVEL_ITEM_COUNT);
|
||||
this.level.setTextFieldBounds(25, 44, 75);
|
||||
this.level.addButtons(children::add, this::addButton);
|
||||
this.level.setValue(container.getReportingValue());
|
||||
this.level.setValue(handler.getReportingValue());
|
||||
this.level.setOnChange(this::saveReportingValue);
|
||||
this.level.setOnConfirm(this::closeScreen);
|
||||
this.level.setOnConfirm(this::onClose);
|
||||
|
||||
this.changeFocus(true);
|
||||
}
|
||||
|
||||
private void saveReportingValue() {
|
||||
this.level.getLongValue().ifPresent(container::setReportingValue);
|
||||
this.level.getLongValue().ifPresent(handler::setReportingValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,7 @@ import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import me.shedaniel.math.Rectangle;
|
||||
@@ -297,13 +298,13 @@ public class MEMonitorableScreen<T extends MEMonitorableContainer> extends AEBas
|
||||
this.currentMouseY = mouseY;
|
||||
|
||||
// Show the number of active crafting jobs
|
||||
if (this.craftingStatusBtn != null && container.activeCraftingJobs != -1) {
|
||||
if (this.craftingStatusBtn != null && handler.activeCraftingJobs != -1) {
|
||||
// The stack size renderer expects a 16x16 slot, while the button is normally
|
||||
// bigger
|
||||
int x = this.craftingStatusBtn.x + (this.craftingStatusBtn.getWidth() - 16) / 2;
|
||||
int y = this.craftingStatusBtn.y + (this.craftingStatusBtn.getHeightRealms() - 16) / 2;
|
||||
StackSizeRenderer.renderSizeLabel(font, x - this.guiLeft, y - this.guiTop,
|
||||
String.valueOf(container.activeCraftingJobs));
|
||||
int y = this.craftingStatusBtn.y + (this.craftingStatusBtn.getHeight() - 16) / 2;
|
||||
StackSizeRenderer.renderSizeLabel(textRenderer, x - this.x, y - this.y,
|
||||
new LiteralText(String.valueOf(handler.activeCraftingJobs)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ import java.util.OptionalInt;
|
||||
import java.util.OptionalLong;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.NumberEntryType;
|
||||
@@ -27,8 +27,7 @@ import appeng.core.AEConfig;
|
||||
*/
|
||||
public class NumberEntryWidget extends DrawableHelper {
|
||||
|
||||
private static final ITextComponent INVALID_NUMBER = new TranslationTextComponent(
|
||||
"gui.appliedenergistics2.validation.InvalidNumber");
|
||||
private static final Text INVALID_NUMBER = new TranslatableText("gui.appliedenergistics2.validation.InvalidNumber");
|
||||
private static final String NUMBER_LESS_THAN_MIN_VALUE = "gui.appliedenergistics2.validation.NumberLessThanMinValue";
|
||||
private static final Text PLUS = Text.of("+");
|
||||
private static final Text MINUS = Text.of("-");
|
||||
@@ -60,18 +59,17 @@ public class NumberEntryWidget extends DrawableHelper {
|
||||
this.y = y;
|
||||
this.type = type;
|
||||
|
||||
FontRenderer font = parent.getMinecraft().fontRenderer;
|
||||
int inputX = parent.getGuiLeft() + x;
|
||||
int inputY = parent.getGuiTop() + y;
|
||||
this.textField = new ConfirmableTextField(font, inputX, inputY, width, font.FONT_HEIGHT,
|
||||
StringTextComponent.EMPTY);
|
||||
this.textField.setEnableBackgroundDrawing(false);
|
||||
this.textField.setMaxStringLength(16);
|
||||
this.textField.setTextColor(TEXT_COLOR_NORMAL);
|
||||
TextRenderer font = parent.getClient().textRenderer;
|
||||
int inputX = parent.getX() + x;
|
||||
int inputY = parent.getY() + y;
|
||||
this.textField = new ConfirmableTextField(font, inputX, inputY, width, font.fontHeight, LiteralText.EMPTY);
|
||||
this.textField.setHasBorder(false);
|
||||
this.textField.setMaxLength(16);
|
||||
this.textField.setEditableColor(TEXT_COLOR_NORMAL);
|
||||
this.textField.setVisible(true);
|
||||
this.textField.setFocused2(true);
|
||||
parent.setFocusedDefault(this.textField);
|
||||
this.textField.setResponder(text -> {
|
||||
this.textField.setSelected(true);
|
||||
parent.setInitialFocus(this.textField);
|
||||
this.textField.setChangedListener(text -> {
|
||||
validate();
|
||||
if (onChange != null) {
|
||||
this.onChange.run();
|
||||
@@ -190,8 +188,8 @@ public class NumberEntryWidget extends DrawableHelper {
|
||||
|
||||
public void setValue(long value) {
|
||||
this.textField.setText(String.valueOf(Math.max(minValue, value)));
|
||||
this.textField.setCursorPositionEnd();
|
||||
this.textField.setSelectionPos(0);
|
||||
this.textField.setCursorToEnd();
|
||||
this.textField.setSelectionStart(0);
|
||||
validate();
|
||||
}
|
||||
|
||||
@@ -204,20 +202,20 @@ public class NumberEntryWidget extends DrawableHelper {
|
||||
}
|
||||
|
||||
private void validate() {
|
||||
List<ITextComponent> validationErrors = new ArrayList<>();
|
||||
List<Text> validationErrors = new ArrayList<>();
|
||||
|
||||
String text = textField.getText().trim();
|
||||
try {
|
||||
long value = Long.parseLong(text, 10);
|
||||
if (value < minValue) {
|
||||
validationErrors.add(new TranslationTextComponent(NUMBER_LESS_THAN_MIN_VALUE, minValue));
|
||||
validationErrors.add(new TranslatableText(NUMBER_LESS_THAN_MIN_VALUE, minValue));
|
||||
}
|
||||
} catch (NumberFormatException ignored) {
|
||||
validationErrors.add(INVALID_NUMBER);
|
||||
}
|
||||
|
||||
boolean valid = validationErrors.isEmpty();
|
||||
this.textField.setTextColor(valid ? TEXT_COLOR_NORMAL : TEXT_COLOR_ERROR);
|
||||
this.textField.setEditableColor(valid ? TEXT_COLOR_NORMAL : TEXT_COLOR_ERROR);
|
||||
if (this.validationIcon != null) {
|
||||
this.validationIcon.setValid(valid);
|
||||
this.validationIcon.setTooltip(validationErrors);
|
||||
|
||||
@@ -40,8 +40,8 @@ public class PriorityScreen extends AEBaseScreen<PriorityContainer> {
|
||||
this.subGui = new AESubScreen(this, container.getPriorityHost());
|
||||
|
||||
// This is the effective size of the background image
|
||||
xSize = 175;
|
||||
ySize = 128;
|
||||
backgroundWidth = 175;
|
||||
backgroundHeight = 128;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,7 +51,7 @@ public class PriorityScreen extends AEBaseScreen<PriorityContainer> {
|
||||
this.priority = new NumberEntryWidget(this, 20, 30, 138, 62, NumberEntryType.PRIORITY);
|
||||
this.priority.setTextFieldBounds(62, 57, 50);
|
||||
this.priority.setMinValue(Integer.MIN_VALUE);
|
||||
this.priority.setValue(this.container.getPriorityValue());
|
||||
this.priority.setValue(this.handler.getPriorityValue());
|
||||
this.priority.addButtons(children::add, this::addButton);
|
||||
|
||||
this.subGui.addBackButton(this::addButton, 154, 0);
|
||||
@@ -68,7 +68,7 @@ public class PriorityScreen extends AEBaseScreen<PriorityContainer> {
|
||||
private void savePriority() {
|
||||
OptionalInt priority = this.priority.getIntValue();
|
||||
if (priority.isPresent()) {
|
||||
container.setPriority(priority.getAsInt());
|
||||
handler.setPriority(priority.getAsInt());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,21 +20,21 @@ package appeng.client.gui.widgets;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class ConfirmableTextField extends TextFieldWidget {
|
||||
|
||||
private Runnable onConfirm;
|
||||
|
||||
public ConfirmableTextField(FontRenderer fontRenderer, int x, int y, int width, int height, ITextComponent text) {
|
||||
public ConfirmableTextField(TextRenderer fontRenderer, int x, int y, int width, int height, Text text) {
|
||||
super(fontRenderer, x, y, width, height, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||
if (canWrite() && (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER)) {
|
||||
if (isActive() && (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER)) {
|
||||
if (this.onConfirm != null) {
|
||||
this.onConfirm.run();
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ package appeng.client.gui.widgets;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.sound.SoundManager;
|
||||
import net.minecraft.client.texture.TextureManager;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.LiteralText;
|
||||
@@ -48,9 +48,9 @@ public abstract class IconButton extends ButtonWidget implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playDownSound(SoundHandler soundHandler) {
|
||||
public void playDownSound(SoundManager soundManager) {
|
||||
if (!disableClickSound) {
|
||||
super.playDownSound(soundHandler);
|
||||
super.playDownSound(soundManager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public abstract class IconButton extends ButtonWidget implements ITooltip {
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if (isHovered()) {
|
||||
renderToolTip(matrixStack, mouseX, mouseY);
|
||||
renderToolTip(matrices, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,18 +3,17 @@ package appeng.client.gui.widgets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
/**
|
||||
* Displays a small icon that shows validation errors for some input control.
|
||||
*/
|
||||
public class ValidationIcon extends IconButton {
|
||||
|
||||
private final List<ITextComponent> tooltip = new ArrayList<>();
|
||||
private final List<Text> tooltip = new ArrayList<>();
|
||||
|
||||
private boolean valid;
|
||||
|
||||
@@ -33,7 +32,7 @@ public class ValidationIcon extends IconButton {
|
||||
}
|
||||
}
|
||||
|
||||
public void setTooltip(List<ITextComponent> lines) {
|
||||
public void setTooltip(List<Text> lines) {
|
||||
this.tooltip.clear();
|
||||
this.tooltip.addAll(lines);
|
||||
}
|
||||
@@ -54,12 +53,12 @@ public class ValidationIcon extends IconButton {
|
||||
return;
|
||||
}
|
||||
|
||||
Minecraft client = Minecraft.getInstance();
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
Screen screen = client.currentScreen;
|
||||
if (screen == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
screen.func_243308_b(matrices, this.tooltip, x, y);
|
||||
screen.renderTooltip(matrices, this.tooltip, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user