Skip to content

Commit bd7335f

Browse files
committed
fix: verify face configuration type
1 parent fd19d2e commit bd7335f

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/main/java/dev/galacticraft/machinelib/api/block/entity/MachineBlockEntity.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package dev.galacticraft.machinelib.api.block.entity;
2424

2525
import dev.galacticraft.machinelib.api.machine.MachineStatus;
26+
import dev.galacticraft.machinelib.api.machine.configuration.IOFace;
2627
import dev.galacticraft.machinelib.api.menu.MachineMenu;
2728
import dev.galacticraft.machinelib.api.storage.MachineEnergyStorage;
2829
import dev.galacticraft.machinelib.api.storage.MachineFluidStorage;
@@ -31,6 +32,7 @@
3132
import dev.galacticraft.machinelib.api.storage.slot.FluidResourceSlot;
3233
import dev.galacticraft.machinelib.api.storage.slot.ItemResourceSlot;
3334
import dev.galacticraft.machinelib.api.transfer.ResourceFlow;
35+
import dev.galacticraft.machinelib.api.transfer.ResourceType;
3436
import dev.galacticraft.machinelib.api.util.BlockFace;
3537
import dev.galacticraft.machinelib.api.util.StorageHelper;
3638
import dev.galacticraft.machinelib.impl.Constant;
@@ -103,17 +105,20 @@ protected MachineBlockEntity(BlockEntityType<? extends MachineBlockEntity> type,
103105
}
104106

105107
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;
109112
}, 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;
113117
}, 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;
117122
}, type);
118123
}
119124

src/main/java/dev/galacticraft/machinelib/api/config/Config.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ static Config loadFrom(File file) {
6161
void setEnableColoredVanillaFluidNames(boolean enabled);
6262

6363
/**
64-
* {@return what unit fluids should be displayed in}
64+
* {@return the unit that fluids should be displayed in}
6565
*/
6666
FluidUnits fluidUnits();
6767

6868
/**
69-
* Sets what unit fluids should be displayed in.
69+
* Sets the unit that fluids should be displayed in.
7070
*
71-
* @param units what unit fluids should be displayed in
71+
* @param units the unit that fluids should be displayed in
7272
*/
7373
void getFluidUnits(FluidUnits units);
7474

0 commit comments

Comments
 (0)