diff --git a/src/main/java/dev/galacticraft/machinelib/api/block/entity/MachineBlockEntity.java b/src/main/java/dev/galacticraft/machinelib/api/block/entity/MachineBlockEntity.java index b5744ab..38daea9 100644 --- a/src/main/java/dev/galacticraft/machinelib/api/block/entity/MachineBlockEntity.java +++ b/src/main/java/dev/galacticraft/machinelib/api/block/entity/MachineBlockEntity.java @@ -23,6 +23,7 @@ package dev.galacticraft.machinelib.api.block.entity; import dev.galacticraft.machinelib.api.machine.MachineStatus; +import dev.galacticraft.machinelib.api.machine.configuration.IOFace; import dev.galacticraft.machinelib.api.menu.MachineMenu; import dev.galacticraft.machinelib.api.storage.MachineEnergyStorage; import dev.galacticraft.machinelib.api.storage.MachineFluidStorage; @@ -31,6 +32,7 @@ import dev.galacticraft.machinelib.api.storage.slot.FluidResourceSlot; import dev.galacticraft.machinelib.api.storage.slot.ItemResourceSlot; import dev.galacticraft.machinelib.api.transfer.ResourceFlow; +import dev.galacticraft.machinelib.api.transfer.ResourceType; import dev.galacticraft.machinelib.api.util.BlockFace; import dev.galacticraft.machinelib.api.util.StorageHelper; import dev.galacticraft.machinelib.impl.Constant; @@ -103,17 +105,20 @@ protected MachineBlockEntity(BlockEntityType type, } public static void registerProviders(@NotNull BlockEntityType type) { - EnergyStorage.SIDED.registerForBlockEntity((blockEntity, direction) -> { - if (direction == null) return blockEntity.energyStorage().getExposedStorage(ResourceFlow.BOTH); - return blockEntity.energyStorage().getExposedStorage(blockEntity.getIOConfig().get(Objects.requireNonNull(BlockFace.from(blockEntity.getBlockState(), direction))).getFlow()); + EnergyStorage.SIDED.registerForBlockEntity((machine, direction) -> { + if (direction == null) return machine.energyStorage().getExposedStorage(ResourceFlow.BOTH); + IOFace ioFace = machine.getIOConfig().get(Objects.requireNonNull(BlockFace.from(machine.getBlockState(), direction))); + return ioFace.getType().willAcceptResource(ResourceType.FLUID) ? machine.energyStorage().getExposedStorage(ioFace.getFlow()) : null; }, type); - ItemStorage.SIDED.registerForBlockEntity((blockEntity, direction) -> { - if (direction == null) return blockEntity.itemStorage().getExposedStorage(ResourceFlow.BOTH); - return blockEntity.itemStorage().getExposedStorage(blockEntity.getIOConfig().get(Objects.requireNonNull(BlockFace.from(blockEntity.getBlockState(), direction))).getFlow()); + ItemStorage.SIDED.registerForBlockEntity((machine, direction) -> { + if (direction == null) return machine.itemStorage().getExposedStorage(ResourceFlow.BOTH); + IOFace ioFace = machine.getIOConfig().get(Objects.requireNonNull(BlockFace.from(machine.getBlockState(), direction))); + return ioFace.getType().willAcceptResource(ResourceType.ITEM) ? machine.itemStorage().getExposedStorage(ioFace.getFlow()) : null; }, type); - FluidStorage.SIDED.registerForBlockEntity((blockEntity, direction) -> { - if (direction == null) return blockEntity.fluidStorage().getExposedStorage(ResourceFlow.BOTH); - return blockEntity.fluidStorage().getExposedStorage(blockEntity.getIOConfig().get(Objects.requireNonNull(BlockFace.from(blockEntity.getBlockState(), direction))).getFlow()); + FluidStorage.SIDED.registerForBlockEntity((machine, direction) -> { + if (direction == null) return machine.fluidStorage().getExposedStorage(ResourceFlow.BOTH); + IOFace ioFace = machine.getIOConfig().get(Objects.requireNonNull(BlockFace.from(machine.getBlockState(), direction))); + return ioFace.getType().willAcceptResource(ResourceType.ENERGY) ? machine.fluidStorage().getExposedStorage(ioFace.getFlow()) : null; }, type); } diff --git a/src/main/java/dev/galacticraft/machinelib/api/config/Config.java b/src/main/java/dev/galacticraft/machinelib/api/config/Config.java index 3342133..7e76e5e 100644 --- a/src/main/java/dev/galacticraft/machinelib/api/config/Config.java +++ b/src/main/java/dev/galacticraft/machinelib/api/config/Config.java @@ -61,14 +61,14 @@ static Config loadFrom(File file) { void setEnableColoredVanillaFluidNames(boolean enabled); /** - * {@return what unit fluids should be displayed in} + * {@return the unit that fluids should be displayed in} */ FluidUnits fluidUnits(); /** - * Sets what unit fluids should be displayed in. + * Sets the unit that fluids should be displayed in. * - * @param units what unit fluids should be displayed in + * @param units the unit that fluids should be displayed in */ void getFluidUnits(FluidUnits units);