AdvancedPeripherals
AdvancedPeripherals copied to clipboard
AE2 ME Bridge getCraftingCPUs never return info about cpu
Describe
cpu is never passed so you can't really obverse from lua what the cpus are doing
https://github.com/IntelligenceModding/AdvancedPeripherals/blob/dde30dafd91ba836e870a82a1ea48dbaf8375547/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/AEApi.java#L479
This block never get entered https://github.com/IntelligenceModding/AdvancedPeripherals/blob/dev/1.21.1/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/AEApi.java#L493-L503
Steps to reproduce
.
Multiplayer?
Yes
Version
1.21.1-0.7.55b (Latest 1.21.1)
Minecraft, Forge and maybe other related mods versions
Neoforge
Screenshots or Videos
No response
Crashlog/log
No response
Draft of what I changed which allow me to have a screen like this
public static Object parseCraftingJob(CraftingJobStatus status, @Nullable AECraftJob craftJob,
@Nullable ICraftingCPU cpu) {
Map<String, Object> properties = new HashMap<>();
properties.put("bridge_id", craftJob == null ? -1 : craftJob.getId());
properties.put("quantity", status.crafting().amount());
properties.put("resource", parseGenericStack(status.crafting()));
properties.put("elapsed_time_nanos", status.elapsedTimeNanos());
properties.put("progress", status.progress());
properties.put("total_items", status.totalItems());
if (cpu != null) {
if (cpu instanceof CraftingCPUCluster cpuCluster) {
var craftingCpuLogic = cpuCluster.craftingLogic;
long pending = craftingCpuLogic.getPendingOutputs(status.crafting().what());
long active = craftingCpuLogic.getWaitingFor(status.crafting().what());
long crafted = status.crafting().amount() - (pending + active);
properties.put("completion", crafted / (double) status.crafting().amount());
properties.put("crafted", crafted);
properties.put("id", craftingCpuLogic.getLastLink().getCraftingID().toString());
properties.put("cpu", parseCraftingCPU(cpu, true));
} else if (cpu instanceof AdvCraftingCPU advCpu) {
try {
var craftingCpuLogic = advCpu.craftingLogic;
Field jobField = AdvCraftingCPULogic.class.getDeclaredField("job");
jobField.setAccessible(true);
var waitingForField = ExecutingCraftingJob.class.getDeclaredField("waitingFor");
waitingForField.setAccessible(true);
var tasksField = ExecutingCraftingJob.class.getDeclaredField("tasks");
tasksField.setAccessible(true);
Class<?> taskProgressClass = null;
for (Class<?> c : ExecutingCraftingJob.class.getDeclaredClasses()) {
if (c.getSimpleName().equals("TaskProgress")) {
taskProgressClass = c;
break;
}
}
Field valueField = null;
valueField = taskProgressClass.getDeclaredField("value");
valueField.setAccessible(true);
ExecutingCraftingJob job = (ExecutingCraftingJob) jobField.get(craftingCpuLogic);
if (job != null) {
var waitingFor = (ListCraftingInventory) waitingForField.get(job);
var tasks = (Map<IPatternDetails, ?>) tasksField.get(job);
var scheduled_crafts = new ArrayList<>();
for (var t : tasks.entrySet()) {
scheduled_crafts.addAll(t.getKey().getOutputs().stream()
.map(AEApi::parseGenericStack).collect(Collectors.toList()));
}
properties.put("active_crafts", parseKeyCounter(waitingFor.list));
properties.put("scheduled_crafts", scheduled_crafts);
}
properties.put("id", craftingCpuLogic.getLastLink().getCraftingID().toString());
properties.put("cpu", parseCraftingCPU(cpu, true));
} catch (Exception e) {
e.printStackTrace();
}
}
}
return properties;
}