Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ dependencies {
compileOnly fg.deobf("appeng:appliedenergistics2-forge:${appliedenergistics_version}")
runtimeOnly fg.deobf("appeng:appliedenergistics2-forge:${appliedenergistics_version}")

// Applied Mekanistics
implementation fg.deobf("curse.maven:applied-mekanistics-574300:${appliedmekanistics_version}")

// Curios
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}:api")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}")
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ae2things_version=4367610
powah_version=4183078
ae2additions_version=4646599
kotlinforforge_version=3.12.0
appliedmekanistics_version=4734608

# Mod dependencies which are needed for other mods
# For minecolonies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ public class APAddons {
public static final String REFINEDSTORAGE_MODID = "refinedstorage";
public static final String AE_THINGS_MODID = "ae2things";
public static final String AE_ADDITIONS_MODID = "ae2additions";
public static final String APP_MEKANISTICS_MODID = "appmek";

public static boolean curiosLoaded;
public static boolean refinedStorageLoaded;
public static boolean aeThingsLoaded;
public static boolean aeAdditionsLoaded;
public static boolean appMekLoaded;

private APAddons() {
}
Expand All @@ -29,6 +31,7 @@ public static void commonSetup() {
refinedStorageLoaded = modList.isLoaded(REFINEDSTORAGE_MODID);
aeThingsLoaded = modList.isLoaded(AE_THINGS_MODID);
aeAdditionsLoaded = modList.isLoaded(AE_ADDITIONS_MODID);
appMekLoaded = modList.isLoaded(APP_MEKANISTICS_MODID);

if (refinedStorageLoaded)
RefinedStorage.instance = new RefinedStorage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import de.srendi.advancedperipherals.common.util.inventory.ItemUtil;
import io.github.projectet.ae2things.item.DISKDrive;
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import me.ramidzkh.mekae2.ae2.MekanismKey;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -118,13 +119,25 @@ public static List<Object> listFluids(MEStorage monitor, ICraftingService servic
return items;
}

public static List<Object> listGases(MEStorage monitor, ICraftingService service, int flag) {
List<Object> items = new ArrayList<>();
for (Object2LongMap.Entry<AEKey> aeKey : monitor.getAvailableStacks()) {
if (APAddons.appMekLoaded && aeKey.getKey() instanceof MekanismKey itemKey) {
items.add(getObjectFromStack(Pair.of(aeKey.getLongValue(), itemKey), service));
}
}
return items;
}

public static <T extends AEKey> Map<String, Object> getObjectFromStack(Pair<Long, T> stack, @Nullable ICraftingService service) {
if (stack.getRight() == null)
return Collections.emptyMap();
if (stack.getRight() instanceof AEItemKey itemKey)
return getObjectFromItemStack(Pair.of(stack.getLeft(), itemKey), service);
if (stack.getRight() instanceof AEFluidKey fluidKey)
return getObjectFromFluidStack(Pair.of(stack.getLeft(), fluidKey), service);
if (APAddons.appMekLoaded && (stack.getRight() instanceof MekanismKey gasKey))
return getObjectFromGasStack(Pair.of(stack.getLeft(), gasKey), service);

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

return map;
}

private static Map<String, Object> getObjectFromGasStack(Pair<Long, MekanismKey> stack, @Nullable ICraftingService craftingService) {
Map<String, Object> map = new HashMap<>();
long amount = stack.getLeft();
map.put("name", stack.getRight().getStack().getTypeRegistryName().toString());
map.put("amount", amount);
map.put("displayName", stack.getRight().getDisplayName().getString());
map.put("tags", LuaConverter.tagsToList(() -> stack.getRight().getStack().getType().getTags()));

return map;
}

public static Map<String, Object> getObjectFromCPU(ICraftingCPU cpu) {
Map<String, Object> map = new HashMap<>();
long storage = cpu.getAvailableStorage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,14 @@ public final MethodResult listFluid() {
return MethodResult.of(AppEngApi.listFluids(AppEngApi.getMonitor(node), getCraftingService(), 0));
}

@LuaFunction(mainThread = true)
public final MethodResult listGas() {
if (!isConnected())
return notConnected();

return MethodResult.of(AppEngApi.listGases(AppEngApi.getMonitor(node), getCraftingService(), 0));
}

@LuaFunction(mainThread = true)
public final MethodResult listCraftableFluid() {
if (!isConnected())
Expand Down