ConfigurableItemHandler now has inputOutput variant
This commit is contained in:
parent
e3993f439e
commit
d47e5b3d7a
@ -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<ItemHandlerMode>()
|
||||
|
||||
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<IItemHandler>()
|
||||
|
||||
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))
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user