|
23 | 23 | package dev.galacticraft.machinelib.api.block.entity;
|
24 | 24 |
|
25 | 25 | import dev.galacticraft.machinelib.api.machine.MachineStatus;
|
| 26 | +import dev.galacticraft.machinelib.api.machine.configuration.IOFace; |
26 | 27 | import dev.galacticraft.machinelib.api.menu.MachineMenu;
|
27 | 28 | import dev.galacticraft.machinelib.api.storage.MachineEnergyStorage;
|
28 | 29 | import dev.galacticraft.machinelib.api.storage.MachineFluidStorage;
|
|
31 | 32 | import dev.galacticraft.machinelib.api.storage.slot.FluidResourceSlot;
|
32 | 33 | import dev.galacticraft.machinelib.api.storage.slot.ItemResourceSlot;
|
33 | 34 | import dev.galacticraft.machinelib.api.transfer.ResourceFlow;
|
| 35 | +import dev.galacticraft.machinelib.api.transfer.ResourceType; |
34 | 36 | import dev.galacticraft.machinelib.api.util.BlockFace;
|
35 | 37 | import dev.galacticraft.machinelib.api.util.StorageHelper;
|
36 | 38 | import dev.galacticraft.machinelib.impl.Constant;
|
@@ -103,17 +105,20 @@ protected MachineBlockEntity(BlockEntityType<? extends MachineBlockEntity> type,
|
103 | 105 | }
|
104 | 106 |
|
105 | 107 | public static <T extends MachineBlockEntity> void registerProviders(@NotNull BlockEntityType<? extends T> type) {
|
106 |
| - EnergyStorage.SIDED.registerForBlockEntity((blockEntity, direction) -> { |
107 |
| - if (direction == null) return blockEntity.energyStorage().getExposedStorage(ResourceFlow.BOTH); |
108 |
| - return blockEntity.energyStorage().getExposedStorage(blockEntity.getIOConfig().get(Objects.requireNonNull(BlockFace.from(blockEntity.getBlockState(), direction))).getFlow()); |
| 108 | + EnergyStorage.SIDED.registerForBlockEntity((machine, direction) -> { |
| 109 | + if (direction == null) return machine.energyStorage().getExposedStorage(ResourceFlow.BOTH); |
| 110 | + IOFace ioFace = machine.getIOConfig().get(Objects.requireNonNull(BlockFace.from(machine.getBlockState(), direction))); |
| 111 | + return ioFace.getType().willAcceptResource(ResourceType.FLUID) ? machine.energyStorage().getExposedStorage(ioFace.getFlow()) : null; |
109 | 112 | }, type);
|
110 |
| - ItemStorage.SIDED.registerForBlockEntity((blockEntity, direction) -> { |
111 |
| - if (direction == null) return blockEntity.itemStorage().getExposedStorage(ResourceFlow.BOTH); |
112 |
| - return blockEntity.itemStorage().getExposedStorage(blockEntity.getIOConfig().get(Objects.requireNonNull(BlockFace.from(blockEntity.getBlockState(), direction))).getFlow()); |
| 113 | + ItemStorage.SIDED.registerForBlockEntity((machine, direction) -> { |
| 114 | + if (direction == null) return machine.itemStorage().getExposedStorage(ResourceFlow.BOTH); |
| 115 | + IOFace ioFace = machine.getIOConfig().get(Objects.requireNonNull(BlockFace.from(machine.getBlockState(), direction))); |
| 116 | + return ioFace.getType().willAcceptResource(ResourceType.ITEM) ? machine.itemStorage().getExposedStorage(ioFace.getFlow()) : null; |
113 | 117 | }, type);
|
114 |
| - FluidStorage.SIDED.registerForBlockEntity((blockEntity, direction) -> { |
115 |
| - if (direction == null) return blockEntity.fluidStorage().getExposedStorage(ResourceFlow.BOTH); |
116 |
| - return blockEntity.fluidStorage().getExposedStorage(blockEntity.getIOConfig().get(Objects.requireNonNull(BlockFace.from(blockEntity.getBlockState(), direction))).getFlow()); |
| 118 | + FluidStorage.SIDED.registerForBlockEntity((machine, direction) -> { |
| 119 | + if (direction == null) return machine.fluidStorage().getExposedStorage(ResourceFlow.BOTH); |
| 120 | + IOFace ioFace = machine.getIOConfig().get(Objects.requireNonNull(BlockFace.from(machine.getBlockState(), direction))); |
| 121 | + return ioFace.getType().willAcceptResource(ResourceType.ENERGY) ? machine.fluidStorage().getExposedStorage(ioFace.getFlow()) : null; |
117 | 122 | }, type);
|
118 | 123 | }
|
119 | 124 |
|
|
0 commit comments