Skip to content

Commit 3977187

Browse files
authored
Merge pull request #519 from starcatmeow/1.19.2
Add Applied Mekanistics support to the ME Bridge
2 parents c1ce98e + 26e18b2 commit 3977187

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ dependencies {
264264
compileOnly fg.deobf("appeng:appliedenergistics2-forge:${appliedenergistics_version}")
265265
runtimeOnly fg.deobf("appeng:appliedenergistics2-forge:${appliedenergistics_version}")
266266

267+
// Applied Mekanistics
268+
implementation fg.deobf("curse.maven:applied-mekanistics-574300:${appliedmekanistics_version}")
269+
267270
// Curios
268271
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}:api")
269272
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}")

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ ae2things_version=4367610
3434
powah_version=4183078
3535
ae2additions_version=4646599
3636
kotlinforforge_version=3.12.0
37+
appliedmekanistics_version=4734608
3738

3839
# Mod dependencies which are needed for other mods
3940
# For minecolonies

src/main/java/de/srendi/advancedperipherals/common/addons/APAddons.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ public class APAddons {
1414
public static final String REFINEDSTORAGE_MODID = "refinedstorage";
1515
public static final String AE_THINGS_MODID = "ae2things";
1616
public static final String AE_ADDITIONS_MODID = "ae2additions";
17+
public static final String APP_MEKANISTICS_MODID = "appmek";
1718

1819
public static boolean curiosLoaded;
1920
public static boolean refinedStorageLoaded;
2021
public static boolean aeThingsLoaded;
2122
public static boolean aeAdditionsLoaded;
23+
public static boolean appMekLoaded;
2224

2325
private APAddons() {
2426
}
@@ -29,6 +31,7 @@ public static void commonSetup() {
2931
refinedStorageLoaded = modList.isLoaded(REFINEDSTORAGE_MODID);
3032
aeThingsLoaded = modList.isLoaded(AE_THINGS_MODID);
3133
aeAdditionsLoaded = modList.isLoaded(AE_ADDITIONS_MODID);
34+
appMekLoaded = modList.isLoaded(APP_MEKANISTICS_MODID);
3235

3336
if (refinedStorageLoaded)
3437
RefinedStorage.instance = new RefinedStorage();

src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/AppEngApi.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import de.srendi.advancedperipherals.common.util.inventory.ItemUtil;
2525
import io.github.projectet.ae2things.item.DISKDrive;
2626
import it.unimi.dsi.fastutil.objects.Object2LongMap;
27+
import me.ramidzkh.mekae2.ae2.MekanismKey;
2728
import net.minecraft.core.BlockPos;
2829
import net.minecraft.nbt.CompoundTag;
2930
import net.minecraft.world.item.ItemStack;
@@ -118,13 +119,25 @@ public static List<Object> listFluids(MEStorage monitor, ICraftingService servic
118119
return items;
119120
}
120121

122+
public static List<Object> listGases(MEStorage monitor, ICraftingService service, int flag) {
123+
List<Object> items = new ArrayList<>();
124+
for (Object2LongMap.Entry<AEKey> aeKey : monitor.getAvailableStacks()) {
125+
if (APAddons.appMekLoaded && aeKey.getKey() instanceof MekanismKey itemKey) {
126+
items.add(getObjectFromStack(Pair.of(aeKey.getLongValue(), itemKey), service));
127+
}
128+
}
129+
return items;
130+
}
131+
121132
public static <T extends AEKey> Map<String, Object> getObjectFromStack(Pair<Long, T> stack, @Nullable ICraftingService service) {
122133
if (stack.getRight() == null)
123134
return Collections.emptyMap();
124135
if (stack.getRight() instanceof AEItemKey itemKey)
125136
return getObjectFromItemStack(Pair.of(stack.getLeft(), itemKey), service);
126137
if (stack.getRight() instanceof AEFluidKey fluidKey)
127138
return getObjectFromFluidStack(Pair.of(stack.getLeft(), fluidKey), service);
139+
if (APAddons.appMekLoaded && (stack.getRight() instanceof MekanismKey gasKey))
140+
return getObjectFromGasStack(Pair.of(stack.getLeft(), gasKey), service);
128141

129142
AdvancedPeripherals.debug("Could not create table from unknown stack " + stack.getRight().getClass() + " - Report this to the maintainer of ap", Level.ERROR);
130143
return Collections.emptyMap();
@@ -151,13 +164,24 @@ private static Map<String, Object> getObjectFromFluidStack(Pair<Long, AEFluidKey
151164
long amount = stack.getLeft();
152165
map.put("name", ForgeRegistries.FLUIDS.getKey(stack.getRight().getFluid()).toString());
153166
map.put("amount", amount);
154-
map.put("displayName", stack.getRight().getDisplayName());
167+
map.put("displayName", stack.getRight().getDisplayName().getString());
155168
map.put("tags", LuaConverter.tagsToList(() -> stack.getRight().getFluid().builtInRegistryHolder().tags()));
156169
map.put("isCraftable", craftingService != null && craftingService.isCraftable(stack.getRight()));
157170

158171
return map;
159172
}
160173

174+
private static Map<String, Object> getObjectFromGasStack(Pair<Long, MekanismKey> stack, @Nullable ICraftingService craftingService) {
175+
Map<String, Object> map = new HashMap<>();
176+
long amount = stack.getLeft();
177+
map.put("name", stack.getRight().getStack().getTypeRegistryName().toString());
178+
map.put("amount", amount);
179+
map.put("displayName", stack.getRight().getDisplayName().getString());
180+
map.put("tags", LuaConverter.tagsToList(() -> stack.getRight().getStack().getType().getTags()));
181+
182+
return map;
183+
}
184+
161185
public static Map<String, Object> getObjectFromCPU(ICraftingCPU cpu) {
162186
Map<String, Object> map = new HashMap<>();
163187
long storage = cpu.getAvailableStorage();

src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,14 @@ public final MethodResult listFluid() {
447447
return MethodResult.of(AppEngApi.listFluids(AppEngApi.getMonitor(node), getCraftingService(), 0));
448448
}
449449

450+
@LuaFunction(mainThread = true)
451+
public final MethodResult listGas() {
452+
if (!isConnected())
453+
return notConnected();
454+
455+
return MethodResult.of(AppEngApi.listGases(AppEngApi.getMonitor(node), getCraftingService(), 0));
456+
}
457+
450458
@LuaFunction(mainThread = true)
451459
public final MethodResult listCraftableFluid() {
452460
if (!isConnected())

0 commit comments

Comments
 (0)