Add 1.18 port fixes
This commit is contained in:
@@ -48,7 +48,7 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected int parseAmount() {
|
protected int parseAmount() {
|
||||||
return (int) Math.ceil(EquationEvaluator.evaluate(amountField.getText()));
|
return (int) Math.ceil(EquationEvaluator.evaluate(amountField.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int clampAmount(int amount) {
|
protected int clampAmount(int amount) {
|
||||||
@@ -75,8 +75,8 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
|
|||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Button addActionButton(Pair<Integer, Integer> absolutePos, int xOffset, int yOffset, ITextComponent text,
|
public Button addActionButton(Pair<Integer, Integer> absolutePos, int xOffset, int yOffset, Component text,
|
||||||
IPressable onPress) {
|
Button.OnPress onPress) {
|
||||||
return addButton(absolutePos.getLeft() + xOffset, absolutePos.getRight() + yOffset, getOkCancelButtonWidth(),
|
return addButton(absolutePos.getLeft() + xOffset, absolutePos.getRight() + yOffset, getOkCancelButtonWidth(),
|
||||||
getOkCancelButtonHeight(), text, true, true, onPress);
|
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());
|
Pair<Integer, Integer> absolutePos = Pair.of(x + pos.getLeft(), y + pos.getRight());
|
||||||
|
|
||||||
okButton = addActionButton(absolutePos, 0, 0, getOkButtonText(), btn -> onOkButtonPressed(hasShiftDown()));
|
okButton = addActionButton(absolutePos, 0, 0, getOkButtonText(), btn -> onOkButtonPressed(hasShiftDown()));
|
||||||
cancelButton = addActionButton(absolutePos, 0, 24, new TranslationTextComponent("gui.cancel"), btn -> close());
|
cancelButton = addActionButton(absolutePos, 0, 24, new TranslatableComponent("gui.cancel"), btn -> close());
|
||||||
evaluateButton = addActionButton(absolutePos, 0, 48, new TranslationTextComponent("misc.refinedstorage.evaluate"),
|
evaluateButton = addActionButton(absolutePos, 0, 48, new TranslatableComponent("misc.refinedstorage.evaluate"),
|
||||||
btn -> onEvaluateButtonPressed(hasShiftDown()));
|
btn -> onEvaluateButtonPressed(hasShiftDown()));
|
||||||
|
|
||||||
amountField = new TextFieldWidget(font, x + getAmountPos().getLeft(), y + getAmountPos().getRight(), 69 - 6,
|
amountField = new EditBox(font, x + getAmountPos().getLeft(), y + getAmountPos().getRight(), 69 - 6, font.lineHeight, new TextComponent(""));
|
||||||
font.FONT_HEIGHT, new StringTextComponent(""));
|
amountField.setBordered(false);
|
||||||
amountField.setEnableBackgroundDrawing(false);
|
|
||||||
amountField.setVisible(true);
|
amountField.setVisible(true);
|
||||||
amountField.setValue(String.valueOf(getDefaultAmount()));
|
amountField.setValue(String.valueOf(getDefaultAmount()));
|
||||||
amountField.setTextColor(RenderSettings.INSTANCE.getSecondaryColor());
|
amountField.setTextColor(RenderSettings.INSTANCE.getSecondaryColor());
|
||||||
@@ -178,7 +177,7 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
|
|||||||
if (!canAmountGoNegative() && oldAmount == 1) {
|
if (!canAmountGoNegative() && oldAmount == 1) {
|
||||||
newAmount--;
|
newAmount--;
|
||||||
}
|
}
|
||||||
amountField.setText(String.valueOf(clampAmount(newAmount)));
|
amountField.setValue(String.valueOf(clampAmount(newAmount)));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
@@ -198,7 +197,7 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
|
|||||||
|
|
||||||
private void onEvaluateButtonPressed(boolean shiftDown) {
|
private void onEvaluateButtonPressed(boolean shiftDown) {
|
||||||
try {
|
try {
|
||||||
amountField.setText(String.valueOf(clampAmount(parseAmount())));
|
amountField.setValue(String.valueOf(clampAmount(parseAmount())));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
@@ -67,7 +67,7 @@ public class PriorityScreen extends AmountSpecifyingScreen<AbstractContainerMenu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onValidAmountSave(boolean shiftDown, int amount) {
|
protected void onValidAmountSaved(boolean shiftDown, int amount) {
|
||||||
BlockEntitySynchronizationManager.setParameter(priority, amount);
|
BlockEntitySynchronizationManager.setParameter(priority, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,7 @@ public class CraftingSettingsScreen extends AmountSpecifyingScreen<CraftingSetti
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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));
|
RS.NETWORK_HANDLER.sendToServer(new GridCraftingPreviewRequestMessage(stack.getId(), amount, shiftDown, stack instanceof FluidGridStack));
|
||||||
|
|
||||||
okButton.active = false;
|
okButton.active = false;
|
||||||
|
Reference in New Issue
Block a user