Add 1.18 port fixes

This commit is contained in:
mooofins
2022-07-24 17:25:45 -07:00
committed by Raoul
parent a218a8276b
commit b2f6441568
3 changed files with 11 additions and 12 deletions

View File

@@ -48,7 +48,7 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
}
protected int parseAmount() {
return (int) Math.ceil(EquationEvaluator.evaluate(amountField.getText()));
return (int) Math.ceil(EquationEvaluator.evaluate(amountField.getValue()));
}
protected int clampAmount(int amount) {
@@ -75,8 +75,8 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
return 20;
}
public Button addActionButton(Pair<Integer, Integer> absolutePos, int xOffset, int yOffset, ITextComponent text,
IPressable onPress) {
public Button addActionButton(Pair<Integer, Integer> absolutePos, int xOffset, int yOffset, Component text,
Button.OnPress onPress) {
return addButton(absolutePos.getLeft() + xOffset, absolutePos.getRight() + yOffset, getOkCancelButtonWidth(),
getOkCancelButtonHeight(), text, true, true, onPress);
}
@@ -87,13 +87,12 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
Pair<Integer, Integer> absolutePos = Pair.of(x + pos.getLeft(), y + pos.getRight());
okButton = addActionButton(absolutePos, 0, 0, getOkButtonText(), btn -> onOkButtonPressed(hasShiftDown()));
cancelButton = addActionButton(absolutePos, 0, 24, new TranslationTextComponent("gui.cancel"), btn -> close());
evaluateButton = addActionButton(absolutePos, 0, 48, new TranslationTextComponent("misc.refinedstorage.evaluate"),
cancelButton = addActionButton(absolutePos, 0, 24, new TranslatableComponent("gui.cancel"), btn -> close());
evaluateButton = addActionButton(absolutePos, 0, 48, new TranslatableComponent("misc.refinedstorage.evaluate"),
btn -> onEvaluateButtonPressed(hasShiftDown()));
amountField = new TextFieldWidget(font, x + getAmountPos().getLeft(), y + getAmountPos().getRight(), 69 - 6,
font.FONT_HEIGHT, new StringTextComponent(""));
amountField.setEnableBackgroundDrawing(false);
amountField = new EditBox(font, x + getAmountPos().getLeft(), y + getAmountPos().getRight(), 69 - 6, font.lineHeight, new TextComponent(""));
amountField.setBordered(false);
amountField.setVisible(true);
amountField.setValue(String.valueOf(getDefaultAmount()));
amountField.setTextColor(RenderSettings.INSTANCE.getSecondaryColor());
@@ -178,7 +177,7 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
if (!canAmountGoNegative() && oldAmount == 1) {
newAmount--;
}
amountField.setText(String.valueOf(clampAmount(newAmount)));
amountField.setValue(String.valueOf(clampAmount(newAmount)));
} catch (IllegalArgumentException e) {
// NO OP
}
@@ -198,7 +197,7 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
private void onEvaluateButtonPressed(boolean shiftDown) {
try {
amountField.setText(String.valueOf(clampAmount(parseAmount())));
amountField.setValue(String.valueOf(clampAmount(parseAmount())));
} catch (IllegalArgumentException e) {
// NO OP
}

View File

@@ -67,7 +67,7 @@ public class PriorityScreen extends AmountSpecifyingScreen<AbstractContainerMenu
}
@Override
protected void onValidAmountSave(boolean shiftDown, int amount) {
protected void onValidAmountSaved(boolean shiftDown, int amount) {
BlockEntitySynchronizationManager.setParameter(priority, amount);
}
}

View File

@@ -62,7 +62,7 @@ public class CraftingSettingsScreen extends AmountSpecifyingScreen<CraftingSetti
}
@Override
protected void onValidAmountSave(boolean shiftDown, int amount) {
protected void onValidAmountSaved(boolean shiftDown, int amount) {
RS.NETWORK_HANDLER.sendToServer(new GridCraftingPreviewRequestMessage(stack.getId(), amount, shiftDown, stack instanceof FluidGridStack));
okButton.active = false;