|
17 | 17 | import com.refinedmods.refinedstorage.api.storage.StateTrackedStorage; |
18 | 18 | import com.refinedmods.refinedstorage.api.storage.Storage; |
19 | 19 | import com.refinedmods.refinedstorage.api.storage.composite.CompositeStorage; |
| 20 | +import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; |
| 21 | +import com.refinedmods.refinedstorage.common.api.autocrafting.Autocrafter; |
20 | 22 | import com.refinedmods.refinedstorage.common.api.storage.SerializableStorage; |
21 | 23 | import com.refinedmods.refinedstorage.common.api.support.network.InWorldNetworkNodeContainer; |
22 | 24 | import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; |
|
42 | 44 | import de.srendi.advancedperipherals.common.util.inventory.ItemUtil; |
43 | 45 | import mekanism.api.MekanismAPI; |
44 | 46 | import mekanism.api.chemical.ChemicalStack; |
| 47 | +import net.minecraft.world.Container; |
45 | 48 | import net.minecraft.world.item.ItemStack; |
46 | 49 | import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; |
47 | 50 | import net.neoforged.neoforge.fluids.FluidStack; |
@@ -383,6 +386,34 @@ public static List<Object> listDrives(Network network) { |
383 | 386 | return drives; |
384 | 387 | } |
385 | 388 |
|
| 389 | + public static List<Object> getCrafters(Network network, net.minecraft.world.level.Level level) { |
| 390 | + List<Object> crafters = new ArrayList<>(); |
| 391 | + |
| 392 | + GraphNetworkComponent graphNetworkComponent = network.getComponent(GraphNetworkComponent.class); |
| 393 | + AutocraftingNetworkComponent autocrafting = network.getComponent(AutocraftingNetworkComponent.class); |
| 394 | + |
| 395 | + for (Autocrafter autocrafter : graphNetworkComponent.getContainers(Autocrafter.class)) { |
| 396 | + Map<String, Object> properties = new HashMap<>(); |
| 397 | + properties.put("name", autocrafter.getAutocrafterName().getString()); |
| 398 | + properties.put("position", LuaConverter.posToObject(autocrafter.getLocalPosition())); |
| 399 | + properties.put("visible", autocrafter.isVisibleToTheAutocrafterManager()); |
| 400 | + |
| 401 | + List<Object> patterns = new ArrayList<>(); |
| 402 | + Container container = autocrafter.getPatternContainer(); |
| 403 | + for (int i = 0; i < container.getContainerSize(); i++) { |
| 404 | + ItemStack stack = container.getItem(i); |
| 405 | + if (stack.isEmpty()) |
| 406 | + continue; |
| 407 | + Pattern pattern = RefinedStorageApi.INSTANCE.getPattern(stack, level).orElse(null); |
| 408 | + if (pattern != null) |
| 409 | + patterns.add(parsePattern(pattern, autocrafting)); |
| 410 | + } |
| 411 | + properties.put("patterns", patterns); |
| 412 | + crafters.add(properties); |
| 413 | + } |
| 414 | + return crafters; |
| 415 | + } |
| 416 | + |
386 | 417 | /** |
387 | 418 | * Finds a pattern from filters. |
388 | 419 | * |
|
0 commit comments