Skip to content

Commit 50e281a

Browse files
authored
Revert the conversion of some classes to record classes to not break addons (#62)
Signed-off-by: Kolja <104643407+Thatguyello@users.noreply.github.com> Co-authored-by: Kolja <104643407+Thatguyello@users.noreply.github.com>
1 parent daf16f4 commit 50e281a

File tree

6 files changed

+112
-51
lines changed

6 files changed

+112
-51
lines changed

src/generated/resources/assets/ae2/lang/en_us.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@
356356
"gui.ae2.Fuzzy": "Fuzzy",
357357
"gui.ae2.Gray": "Gray",
358358
"gui.ae2.Green": "Green",
359-
"gui.ae2.Highlight": "%sClick to show the location of this craft",
359+
"gui.ae2.Highlight": "%sClick to highlight",
360360
"gui.ae2.IOBuses": "ME Import/Export Bus",
361361
"gui.ae2.IOPort": "ME IO Port",
362362
"gui.ae2.ImportBus": "ME Import Bus",
@@ -1041,4 +1041,4 @@
10411041
"waila.ae2.Stored": "Stored: %s / %s",
10421042
"waila.ae2.Suppressed": "Suppressed",
10431043
"waila.ae2.Unlocked": "Unlocked"
1044-
}
1044+
}

src/main/java/appeng/client/gui/me/crafting/CraftConfirmScreen.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected void updateBeforeRender() {
9191
this.selectCPU.setMessage(getNextCpuButtonLabel());
9292

9393
CraftingPlanSummary plan = menu.getPlan();
94-
boolean planIsStartable = plan != null && !plan.simulation();
94+
boolean planIsStartable = plan != null && !plan.isSimulation();
9595
var start = !this.menu.hasNoCPU() && planIsStartable;
9696
this.start.active = start;
9797
this.startWithFollow.active = start;
@@ -102,10 +102,10 @@ protected void updateBeforeRender() {
102102
Component planDetails = GuiText.CalculatingWait.text();
103103
Component cpuDetails = Component.empty();
104104
if (plan != null) {
105-
String byteUsed = NumberUtil.formatNumber(plan.usedBytes());
105+
String byteUsed = NumberUtil.formatNumber(plan.getUsedBytes());
106106
planDetails = GuiText.BytesUsed.text(byteUsed);
107107

108-
if (plan.simulation()) {
108+
if (plan.isSimulation()) {
109109
cpuDetails = GuiText.PartialPlan.text();
110110
} else if (this.menu.getCpuAvailableBytes() > 0) {
111111
cpuDetails = GuiText.ConfirmCraftCpuStatus.text(
@@ -119,7 +119,7 @@ protected void updateBeforeRender() {
119119
setTextContent(TEXT_ID_DIALOG_TITLE, GuiText.CraftingPlan.text(planDetails));
120120
setTextContent("cpu_status", cpuDetails);
121121

122-
final int size = plan != null ? plan.entries().size() : 0;
122+
final int size = plan != null ? plan.getEntries().size() : 0;
123123
scrollbar.setRange(0, this.table.getScrollableRows(size), 1);
124124
}
125125

@@ -144,7 +144,7 @@ public void drawFG(GuiGraphics guiGraphics, int offsetX, int offsetY, int mouseX
144144

145145
CraftingPlanSummary plan = menu.getPlan();
146146
if (plan != null) {
147-
this.table.render(guiGraphics, mouseX, mouseY, plan.entries(), scrollbar.getCurrentScroll());
147+
this.table.render(guiGraphics, mouseX, mouseY, plan.getEntries(), scrollbar.getCurrentScroll());
148148
}
149149

150150
}
@@ -186,19 +186,19 @@ private void exportCraft() {
186186
cpuStats.addProperty("isFollowing", menu.isFollowing);
187187
cpuStats.addProperty("availableBytes", menu.getCpuAvailableBytes());
188188
cpuStats.addProperty("coProcessors", menu.getCpuCoProcessors());
189-
cpuStats.addProperty("usedBytes", plan.usedBytes());
189+
cpuStats.addProperty("usedBytes", plan.getUsedBytes());
190190
exportObject.add("cpu", cpuStats);
191191
var entryArray = new JsonArray();
192-
for (var entry : plan.entries()) {
192+
for (var entry : plan.getEntries()) {
193193
var entryObject = new JsonObject();
194-
entryObject.addProperty("what", entry.what().getId().toString());
195-
entryObject.addProperty("missingAmount", entry.missingAmount());
196-
entryObject.addProperty("storedAmount", entry.storedAmount());
197-
entryObject.addProperty("craftAmount", entry.craftAmount());
198-
entryObject.addProperty("availableAmount", entry.availableAmount());
194+
entryObject.addProperty("what", entry.getWhat().getId().toString());
195+
entryObject.addProperty("missingAmount", entry.getMissingAmount());
196+
entryObject.addProperty("storedAmount", entry.getStoredAmount());
197+
entryObject.addProperty("craftAmount", entry.getCraftAmount());
198+
entryObject.addProperty("availableAmount", entry.getAvailableAmount());
199199
entryArray.add(entryObject);
200200
}
201-
exportObject.add("entries", entryArray);
201+
exportObject.add("getEntries", entryArray);
202202
CraftExporter.exportCraft(exportObject, getPlayer(), CraftExporter.ExportType.CRAFTING_PLAN);
203203
}
204204
}

src/main/java/appeng/client/gui/me/crafting/CraftConfirmTableRenderer.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,59 +40,59 @@ public CraftConfirmTableRenderer(AEBaseScreen<?> screen, int x, int y) {
4040
@Override
4141
protected List<Component> getEntryDescription(CraftingPlanSummaryEntry entry) {
4242
List<Component> lines = new ArrayList<>(3);
43-
if (entry.storedAmount() > 0) {
44-
String amount = entry.what().formatAmount(entry.storedAmount(), AmountFormat.SLOT);
43+
if (entry.getStoredAmount() > 0) {
44+
String amount = entry.getWhat().formatAmount(entry.getStoredAmount(), AmountFormat.SLOT);
4545
lines.add(GuiText.FromStorage.text(amount));
4646
}
4747

48-
if (entry.missingAmount() > 0) {
49-
String amount = entry.what().formatAmount(entry.missingAmount(), AmountFormat.SLOT);
48+
if (entry.getMissingAmount() > 0) {
49+
String amount = entry.getWhat().formatAmount(entry.getMissingAmount(), AmountFormat.SLOT);
5050
lines.add(GuiText.Missing.text(amount));
5151
}
5252

53-
if (entry.craftAmount() > 0) {
54-
String amount = entry.what().formatAmount(entry.craftAmount(), AmountFormat.SLOT);
53+
if (entry.getCraftAmount() > 0) {
54+
String amount = entry.getWhat().formatAmount(entry.getCraftAmount(), AmountFormat.SLOT);
5555
lines.add(GuiText.ToCraft.text(amount));
5656
}
5757
// Same check as above because we want the percentage to be the last element
58-
if (entry.storedAmount() > 0) {
58+
if (entry.getStoredAmount() > 0) {
5959
var percentage = NumberUtil.createPercentageComponent(
60-
entry.missingAmount() == 0 ? entry.storedAmount() : entry.missingAmount(),
61-
entry.availableAmount(),
62-
entry.missingAmount() > 0);
60+
entry.getMissingAmount() == 0 ? entry.getStoredAmount() : entry.getMissingAmount(),
61+
entry.getAvailableAmount(),
62+
entry.getMissingAmount() > 0);
6363
lines.add(GuiText.UsedAmount.text().withStyle(percentage.getStyle()).append(percentage));
6464
}
6565
return lines;
6666
}
6767

6868
@Override
6969
protected AEKey getEntryStack(CraftingPlanSummaryEntry entry) {
70-
return entry.what();
70+
return entry.getWhat();
7171
}
7272

7373
@Override
7474
protected List<Component> getEntryTooltip(CraftingPlanSummaryEntry entry) {
75-
List<Component> lines = AEKeyRendering.getTooltip(entry.what());
75+
List<Component> lines = AEKeyRendering.getTooltip(entry.getWhat());
7676
// The tooltip compares the unabbreviated amounts
77-
if (entry.storedAmount() > 0) {
77+
if (entry.getStoredAmount() > 0) {
7878
lines.add(GuiText.FromStorage
79-
.text(entry.what().formatAmount(entry.storedAmount(), AmountFormat.FULL)));
79+
.text(entry.getWhat().formatAmount(entry.getStoredAmount(), AmountFormat.FULL)));
8080
}
81-
if (entry.missingAmount() > 0) {
81+
if (entry.getMissingAmount() > 0) {
8282
lines.add(GuiText.Missing.text(
83-
entry.what().formatAmount(entry.missingAmount(), AmountFormat.FULL)));
83+
entry.getWhat().formatAmount(entry.getMissingAmount(), AmountFormat.FULL)));
8484
}
8585

86-
if (entry.craftAmount() > 0) {
86+
if (entry.getCraftAmount() > 0) {
8787
lines.add(GuiText.ToCraft
88-
.text(entry.what().formatAmount(entry.craftAmount(), AmountFormat.FULL)));
88+
.text(entry.getWhat().formatAmount(entry.getCraftAmount(), AmountFormat.FULL)));
8989
}
9090
// Same check as above because we want the percentage to be the last element
91-
if (entry.storedAmount() > 0) {
91+
if (entry.getStoredAmount() > 0) {
9292
var percentage = NumberUtil.createPercentageComponent(
93-
entry.missingAmount() == 0 ? entry.storedAmount() : entry.missingAmount(),
94-
entry.availableAmount(),
95-
entry.missingAmount() > 0);
93+
entry.getMissingAmount() == 0 ? entry.getStoredAmount() : entry.getMissingAmount(),
94+
entry.getAvailableAmount(),
95+
entry.getMissingAmount() > 0);
9696
lines.add(GuiText.UsedAmount.text().withStyle(percentage.getStyle()).append(percentage));
9797
}
9898

@@ -101,7 +101,7 @@ protected List<Component> getEntryTooltip(CraftingPlanSummaryEntry entry) {
101101

102102
@Override
103103
protected int getEntryOverlayColor(CraftingPlanSummaryEntry entry) {
104-
return entry.missingAmount() > 0 ? 0x1AFF0000 : 0;
104+
return entry.getMissingAmount() > 0 ? 0x1AFF0000 : 0;
105105
}
106106

107107
}

src/main/java/appeng/menu/me/crafting/CraftConfirmMenu.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private boolean cpuMatches(ICraftingCPU c) {
255255
if (this.plan == null) {
256256
return true;
257257
}
258-
return c.getAvailableStorage() >= this.plan.usedBytes() && !c.isBusy();
258+
return c.getAvailableStorage() >= this.plan.getUsedBytes() && !c.isBusy();
259259
}
260260

261261
public void startJob() {

src/main/java/appeng/menu/me/crafting/CraftingPlanSummary.java

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,38 @@
3636

3737
/**
3838
* A crafting plan intended to be sent to the client.
39-
*
40-
* @param usedBytes
41-
* @param simulation
4239
*/
43-
public record CraftingPlanSummary(long usedBytes, boolean simulation, List<CraftingPlanSummaryEntry> entries) {
40+
public class CraftingPlanSummary {
41+
42+
/**
43+
* @see ICraftingPlan#bytes()
44+
*/
45+
private final long usedBytes;
46+
47+
/**
48+
* @see ICraftingPlan#simulation()
49+
*/
50+
private final boolean simulation;
51+
52+
private final List<CraftingPlanSummaryEntry> entries;
53+
54+
public CraftingPlanSummary(long usedBytes, boolean simulation, List<CraftingPlanSummaryEntry> entries) {
55+
this.usedBytes = usedBytes;
56+
this.simulation = simulation;
57+
this.entries = entries;
58+
}
59+
60+
public long getUsedBytes() {
61+
return usedBytes;
62+
}
63+
64+
public boolean isSimulation() {
65+
return simulation;
66+
}
67+
68+
public List<CraftingPlanSummaryEntry> getEntries() {
69+
return entries;
70+
}
4471

4572
public void write(FriendlyByteBuf buffer) {
4673
buffer.writeVarLong(usedBytes);
@@ -105,7 +132,7 @@ private KeyStats mapping(AEKey key) {
105132

106133
var storage = grid.getStorageService().getInventory();
107134
var crafting = grid.getCraftingService();
108-
var cached = grid.getStorageService().getCachedInventory();
135+
var cached = grid.getStorageService().getCachedInventory(); // TODO: Fix this, still kinda broken
109136

110137
for (var out : plan.entrySet()) {
111138
long missingAmount;
@@ -120,6 +147,7 @@ private KeyStats mapping(AEKey key) {
120147
}
121148
availableAmount = cached.get(out.getKey());
122149
long craftAmount = out.getValue().crafting;
150+
123151
entries.add(new CraftingPlanSummaryEntry(
124152
out.getKey(),
125153
missingAmount,

src/main/java/appeng/menu/me/crafting/CraftingPlanSummaryEntry.java

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,49 @@
2828
* Describes an entry in the crafting plan which describes how many items of one type are missing, already stored in the
2929
* network, or have to be crafted.
3030
*/
31-
public record CraftingPlanSummaryEntry(AEKey what, long missingAmount, long storedAmount,
32-
long craftAmount, long availableAmount) implements Comparable<CraftingPlanSummaryEntry> {
33-
31+
public class CraftingPlanSummaryEntry implements Comparable<CraftingPlanSummaryEntry> {
3432
private static final Comparator<CraftingPlanSummaryEntry> COMPARATOR = Comparator
35-
.comparing(CraftingPlanSummaryEntry::missingAmount)
36-
.thenComparing(CraftingPlanSummaryEntry::craftAmount)
37-
.thenComparing(CraftingPlanSummaryEntry::storedAmount)
38-
.thenComparing(CraftingPlanSummaryEntry::availableAmount)
33+
.comparing(CraftingPlanSummaryEntry::getMissingAmount)
34+
.thenComparing(CraftingPlanSummaryEntry::getCraftAmount)
35+
.thenComparing(CraftingPlanSummaryEntry::getStoredAmount)
36+
.thenComparing(CraftingPlanSummaryEntry::getAvailableAmount)
3937
.reversed();
4038

39+
private final AEKey what;
40+
private final long missingAmount;
41+
private final long storedAmount;
42+
private final long craftAmount;
43+
private final long availableAmount;
44+
45+
public CraftingPlanSummaryEntry(AEKey what, long missingAmount, long storedAmount, long craftAmount,
46+
long availableAmount) {
47+
this.what = what;
48+
this.missingAmount = missingAmount;
49+
this.storedAmount = storedAmount;
50+
this.craftAmount = craftAmount;
51+
this.availableAmount = availableAmount;
52+
}
53+
54+
public AEKey getWhat() {
55+
return what;
56+
}
57+
58+
public long getMissingAmount() {
59+
return missingAmount;
60+
}
61+
62+
public long getStoredAmount() {
63+
return storedAmount;
64+
}
65+
66+
public long getCraftAmount() {
67+
return craftAmount;
68+
}
69+
70+
public long getAvailableAmount() {
71+
return availableAmount;
72+
}
73+
4174
@Override
4275
public int compareTo(final CraftingPlanSummaryEntry o) {
4376
return COMPARATOR.compare(this, o);

0 commit comments

Comments
 (0)