diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 878120d13..a30caeb8a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -223,6 +223,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo inner class ConfigurableItemHandler( val input: IItemHandler? = null, val output: IItemHandler? = null, + inputOutput: IItemHandler? = null, val battery: IItemHandler? = null, val frontDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.FRONT), val backDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BACK), @@ -236,6 +237,9 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo val inputOutput: IItemHandler? init { + if ((input != null || output != null) && inputOutput != null) + throw IllegalArgumentException("Either specify input or/and output separately, or specify inputOutput") + val builder = ImmutableSet.Builder() builder.add(ItemHandlerMode.DISABLED) @@ -243,20 +247,28 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo if (input != null) builder.add(ItemHandlerMode.INPUT) if (output != null) builder.add(ItemHandlerMode.OUTPUT) if (input != null && output != null) builder.add(ItemHandlerMode.INPUT_OUTPUT) + + if (inputOutput != null) { + builder.add(ItemHandlerMode.INPUT) + builder.add(ItemHandlerMode.OUTPUT) + builder.add(ItemHandlerMode.INPUT_OUTPUT) + } + if (battery != null) builder.add(ItemHandlerMode.BATTERY) possibleViews = builder.build() if (input != null && output != null) { - inputOutput = CombinedItemHandler(input, output) + this.inputOutput = CombinedItemHandler(input, output) } else { - inputOutput = null + this.inputOutput = inputOutput } val caps = ArrayList() if (input != null) caps.add(input) if (output != null) caps.add(output) + if (inputOutput != null) caps.add(inputOutput) if (battery != null) caps.add(battery) sideless = UnmodifiableItemHandler(CombinedItemHandler(caps)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt index 9c423d202..4ad22dacc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt @@ -71,7 +71,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt val energyConfig = ConfigurableEnergy(energy) val itemConfig = ConfigurableItemHandler( - input = repairContainer.handler(object : HandlerFilter { + inputOutput = repairContainer.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { if (!stack.isRepairable || !stack.isDamaged) { return false @@ -95,16 +95,6 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt }.hasMatterValue } - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return false - } - }), - - output = repairContainer.handler(object : HandlerFilter { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - return false - } - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { return progressPerTick <= 0.0 || matterPerTick <= Decimal.ZERO }