Skip to content

Commit

Permalink
First pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Julia Dijkstra committed Feb 16, 2025
1 parent 5509a0f commit c3452f2
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ protected long addOrderAmount(final int i) {
return resultL;
}

protected int getAmount() {
protected long getAmount() {
String out = this.amountTextField.getText();
double resultD = Calculator.conversion(out);

if (resultD <= 0 || Double.isNaN(resultD)) {
return 0;
} else {
return (int) ArithHelper.round(resultD, 0);
return (long) ArithHelper.round(resultD, 0);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void drawBG(final int offsetX, final int offsetY, final int mouseX, final

try {

int resultI = getAmount();
long resultI = getAmount();

this.nextBtn.enabled = resultI > 0;
} catch (final NumberFormatException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void drawBG(final int offsetX, final int offsetY, final int mouseX, final
this.nextBtn.displayString = GuiText.Set.getLocal();

try {
int resultI = getAmount();
long resultI = getAmount();

this.symbolSwitch.set(resultI >= 0 ? ActionItems.MULTIPLY : ActionItems.DIVIDE);
this.nextBtn.enabled = resultI < -1 || resultI > 1;
Expand All @@ -98,7 +98,7 @@ protected void actionPerformed(final GuiButton btn) {
try {

if (btn == this.nextBtn && btn.enabled) {
int resultI = getAmount();
long resultI = getAmount();
if (resultI > 1 || resultI < -1) NetworkHandler.instance
.sendToServer(new PacketPatternMultiSet(this.originalGui.ordinal(), resultI));
}
Expand All @@ -108,22 +108,22 @@ protected void actionPerformed(final GuiButton btn) {
}

if (btn == this.symbolSwitch) {
int resultI = -getAmount();
this.amountTextField.setText(Integer.toString(resultI));
long resultI = -getAmount();
this.amountTextField.setText(Long.toString(resultI));
}

}

@Override
protected int getAmount() {
protected long getAmount() {
String out = this.amountTextField.getText();

double resultD = Calculator.conversion(out);

if (Double.isNaN(resultD)) {
return DEFAULT_VALUE;
} else {
return (int) ArithHelper.round(resultD, 0);
return (long) ArithHelper.round(resultD, 0);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void drawBG(final int offsetX, final int offsetY, final int mouseX, final
this.nextBtn.enabled = valueIndex >= 0;

try {
int resultI = getAmount();
long resultI = getAmount();
this.nextBtn.enabled = resultI > 0;
} catch (final NumberFormatException e) {
this.nextBtn.enabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ public void doubleStacks(int val) {
* ((val & 2) != 0 ? -1 : 1));
}

static boolean canMultiplyOrDivide(SlotFake[] slots, int mult) {
static boolean canMultiplyOrDivide(SlotFake[] slots, long mult) {
if (mult > 0) {
for (Slot s : slots) {
if (s.getStack() != null) {
Expand All @@ -589,7 +589,7 @@ static boolean canMultiplyOrDivide(SlotFake[] slots, int mult) {
return false;
}

static void multiplyOrDivideStacksInternal(SlotFake[] slots, int mult) {
static void multiplyOrDivideStacksInternal(SlotFake[] slots, long mult) {
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
if (mult > 0) {
for (final Slot s : enabledSlots) {
Expand All @@ -616,7 +616,7 @@ static void multiplyOrDivideStacksInternal(SlotFake[] slots, int mult) {
*
* @param multi Positive numbers are multiplied and negative numbers are divided
*/
public void multiplyOrDivideStacks(int multi) {
public void multiplyOrDivideStacks(long multi) {
if (!isCraftingMode()) {
if (canMultiplyOrDivide(this.craftingSlots, multi) && canMultiplyOrDivide(this.outputSlots, multi)) {
multiplyOrDivideStacksInternal(this.craftingSlots, multi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public void doubleStacks(int val) {
* ((val & 2) != 0 ? -1 : 1));
}

public void multiplyOrDivideStacks(int multi) {
public void multiplyOrDivideStacks(long multi) {
if (canMultiplyOrDivide(this.craftingSlots, multi) && canMultiplyOrDivide(this.outputSlots, multi)) {
multiplyOrDivideStacksInternal(this.craftingSlots, multi);
multiplyOrDivideStacksInternal(this.outputSlots, multi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@
public class PacketPatternMultiSet extends AppEngPacket {

private final GuiBridge originGui;
private final int multi;
private final long multi;

public PacketPatternMultiSet(final ByteBuf stream) {
this.originGui = GuiBridge.values()[stream.readInt()];
this.multi = stream.readInt();
}

public PacketPatternMultiSet(int originalGui, int multi) {
public PacketPatternMultiSet(int originalGui, long multi) {
this.originGui = GuiBridge.values()[originalGui];
this.multi = multi;

final ByteBuf data = Unpooled.buffer();

data.writeInt(this.getPacketID());
data.writeInt(originalGui);
data.writeInt(this.multi);
data.writeLong(this.multi);

this.configureWrite(data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class PacketPatternValueSet extends AppEngPacket {

private final GuiBridge originGui;
private final int amount;
private final long amount;
private final int valueIndex;

public PacketPatternValueSet(final ByteBuf stream) {
Expand All @@ -29,7 +29,7 @@ public PacketPatternValueSet(final ByteBuf stream) {
this.valueIndex = stream.readInt();
}

public PacketPatternValueSet(int originalGui, int amount, int valueIndex) {
public PacketPatternValueSet(int originalGui, long amount, int valueIndex) {
this.originGui = GuiBridge.values()[originalGui];
this.amount = amount;
this.valueIndex = valueIndex;
Expand All @@ -38,7 +38,7 @@ public PacketPatternValueSet(int originalGui, int amount, int valueIndex) {

data.writeInt(this.getPacketID());
data.writeInt(originalGui);
data.writeInt(this.amount);
data.writeLong(this.amount);
data.writeInt(this.valueIndex);

this.configureWrite(data);
Expand Down

0 comments on commit c3452f2

Please sign in to comment.