2424import de .srendi .advancedperipherals .common .util .inventory .ItemUtil ;
2525import io .github .projectet .ae2things .item .DISKDrive ;
2626import it .unimi .dsi .fastutil .objects .Object2LongMap ;
27+ import me .ramidzkh .mekae2 .ae2 .MekanismKey ;
2728import net .minecraft .core .BlockPos ;
2829import net .minecraft .nbt .CompoundTag ;
2930import 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 ();
0 commit comments