Skip to content

Commit

Permalink
- Vanilla AE2 support fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
KasumiNova committed Oct 15, 2024
1 parent d8f0810 commit 99ab839
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {

// Project properties
group = "github.kasuminova.ae2ctl"
version = "0.1.1"
version = "0.1.2"

// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import appeng.crafting.CraftingTreeProcess;
import com.github.bsideup.jabel.Desugar;
import github.kasuminova.ae2ctl.common.util.AEItemStackSet;
import github.kasuminova.ae2ctl.mixin.ae2.AccessorCraftingTreeProcess;
import github.kasuminova.ae2ctl.common.util.CraftingTreeProcessUtil;
import io.netty.buffer.ByteBuf;

import javax.annotation.Nonnull;
Expand All @@ -18,10 +18,9 @@ public record LiteCraftTreeProc(List<LiteCraftTreeNode> inputs) implements Compa

@Nullable
public static LiteCraftTreeProc of(final CraftingTreeProcess process) {
AccessorCraftingTreeProcess accessor = (AccessorCraftingTreeProcess) process;
List<LiteCraftTreeNode> inputs = new ArrayList<>();
LiteCraftTreeProc proc = new LiteCraftTreeProc(inputs);
for (CraftingTreeNode node : accessor.getNodes().keySet()) {
for (CraftingTreeNode node : CraftingTreeProcessUtil.getNodes(process).keySet()) {
inputs.add(LiteCraftTreeNode.of(node, proc));
}
// return null if no inputs
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package github.kasuminova.ae2ctl.common.util;

import appeng.crafting.CraftingTreeNode;
import appeng.crafting.CraftingTreeProcess;
import github.kasuminova.ae2ctl.AE2CTLegacy;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
import java.util.Map;

public class CraftingTreeProcessUtil {

private static final MethodHandle nodesHandle;

static {
try {
Field nodes = CraftingTreeProcess.class.getDeclaredField("nodes");
nodes.setAccessible(true);
nodesHandle = MethodHandles.lookup().unreflectGetter(nodes);
} catch (Throwable e) {
AE2CTLegacy.log.fatal("[AE2CTL-FATAL] Failed to initialize CraftingTreeProcessUtil!", e);
throw new RuntimeException(e);
}
}

public static Map<CraftingTreeNode, Long> getNodes(final CraftingTreeProcess process) {
try {
return (Map<CraftingTreeNode, Long>) nodesHandle.invoke(process);
} catch (Throwable e) {
AE2CTLegacy.log.fatal("[AE2CTL-FATAL] Failed to get nodes from CraftingTreeProcess!", e);
throw new RuntimeException(e);
}
}

}

This file was deleted.

3 changes: 1 addition & 2 deletions src/main/resources/mixins.ae2ctl.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
],
"mixins": [
"AccessorContainerCraftConfirm",
"AccessorCraftingTreeNode",
"AccessorCraftingTreeProcess"
"AccessorCraftingTreeNode"
]
}

0 comments on commit 99ab839

Please sign in to comment.