Skip to content

Commit 191d3b9

Browse files
committed
Add RS 2.0.0-beta.13 support
1 parent c28dbc4 commit 191d3b9

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod_id=advancedperipherals
1010
mod_version=0.7.55b
1111
minecraft_version=1.21.1
1212
mod_artifact_suffix=
13-
neo_version=21.1.186
13+
neo_version=21.1.194
1414
parchment_minecraft_version=1.21.1
1515
parchment_mappings_version=2024.11.17
1616
loader_version=4
@@ -30,11 +30,11 @@ cc_version=1.116.0
3030
ae2things_version=5637783
3131
appliedenergistics_version=19.2.13
3232
appliedmekanistics_version=5978711
33-
refinedstorage_version=2.0.0-beta.8
33+
refinedstorage_version=2.0.0-beta.13
3434
refinedstorage_mekanism_version=1.0.0
3535
minecolonies_version=1.1.1020-1.21.1-snapshot
3636
patchouli_version=1.21-88
37-
mekanism_version=1.21.1-10.7.9.72
37+
mekanism_version=1.21.1-10.7.15.81
3838
powah_version=6143661
3939

4040
# Mod dependencies which are needed for other mods

src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RSCraftJob.java

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.refinedmods.refinedstorage.api.autocrafting.status.TaskStatus;
77
import com.refinedmods.refinedstorage.api.autocrafting.task.TaskId;
88
import com.refinedmods.refinedstorage.api.network.autocrafting.AutocraftingNetworkComponent;
9+
import com.refinedmods.refinedstorage.api.network.impl.autocrafting.TimeoutableCancellationToken;
910
import com.refinedmods.refinedstorage.api.resource.ResourceKey;
1011
import com.refinedmods.refinedstorage.api.storage.Actor;
1112
import dan200.computercraft.api.peripheral.IComputerAccess;
@@ -28,7 +29,7 @@ public class RSCraftJob extends BasicCraftJob {
2829
private TaskStatus craftingTask;
2930
private Preview preview;
3031
private Future<Optional<Preview>> futureCalculationResult;
31-
private Future<Optional<TaskId>> futureTask;
32+
private Optional<TaskId> futureTask = Optional.empty();
3233

3334
public RSCraftJob(IComputerAccess computer, Level world, long amount, ResourceKey toCraft, AutocraftingNetworkComponent calculationResult) {
3435
super(computer, "rs", world, amount);
@@ -139,26 +140,11 @@ public void tick() {
139140
}
140141
}
141142
// The following is to get the TaskStatus from the issued task
142-
if (futureTask == null || !futureTask.isDone() || craftingTask != null) {
143+
if (futureTask.isEmpty() || craftingTask != null) {
143144
return;
144145
}
145-
Optional<TaskId> optionalId;
146146

147-
try {
148-
optionalId = futureTask.get();
149-
} catch (InterruptedException | ExecutionException ex) {
150-
AdvancedPeripherals.debug("Tried to get the task but the task was not done. Should be done", ex);
151-
fireEvent(true, StatusConstants.UNKNOWN_ERROR);
152-
return;
153-
}
154-
155-
if (optionalId.isEmpty()) {
156-
// This indicates that the second calculation was not successful. Well I guess. There is no java doc and I currently
157-
// don't get an answer from the maintainer. So maybe we want to fire the crafting event
158-
return;
159-
}
160-
161-
TaskId id = optionalId.get();
147+
TaskId id = futureTask.get();
162148
for (TaskStatus status : autocraftingComponent.getStatuses()) {
163149
if (status.info().id().equals(id)) {
164150
this.craftingTask = status;
@@ -171,7 +157,7 @@ public void tick() {
171157

172158
@Override
173159
protected void maybeCraft() {
174-
if (startedCrafting || futureTask != null || futureCalculationResult == null || !futureCalculationResult.isDone()) {
160+
if (startedCrafting || futureTask.isPresent() || futureCalculationResult == null || !futureCalculationResult.isDone()) {
175161
return;
176162
}
177163

@@ -209,9 +195,9 @@ protected void maybeCraft() {
209195
return;
210196
}
211197

212-
// How RS2 handles crafting is a bit cursed. We first create a preview which calculates the recipes, and then we check if the preview was successful
198+
// We first create a preview which calculates the recipes, and then we check if the preview was successful
213199
// If it was, we again start a task which again calculates the recipes, and then we hope nothing changed from the first calculation
214-
futureTask = autocraftingComponent.startTask(toCraft, amount, Actor.EMPTY, false, CancellationToken.NONE);
200+
futureTask = autocraftingComponent.startTask(toCraft, amount, Actor.EMPTY, false, new TimeoutableCancellationToken());
215201
}
216202

217203
@Override
@@ -226,7 +212,7 @@ protected void startCalculation() {
226212
return;
227213
}
228214

229-
futureCalculationResult = autocraftingComponent.getPreview(toCraft, amount, CancellationToken.NONE);
215+
futureCalculationResult = autocraftingComponent.getPreview(toCraft, amount, new TimeoutableCancellationToken());
230216
fireEvent(false, StatusConstants.CALCULATION_STARTED);
231217
}
232218

0 commit comments

Comments
 (0)