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(
|
inner class ConfigurableItemHandler(
|
||||||
val input: IItemHandler? = null,
|
val input: IItemHandler? = null,
|
||||||
val output: IItemHandler? = null,
|
val output: IItemHandler? = null,
|
||||||
|
inputOutput: IItemHandler? = null,
|
||||||
val battery: IItemHandler? = null,
|
val battery: IItemHandler? = null,
|
||||||
val frontDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.FRONT),
|
val frontDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.FRONT),
|
||||||
val backDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BACK),
|
val backDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BACK),
|
||||||
@ -236,6 +237,9 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo
|
|||||||
val inputOutput: IItemHandler?
|
val inputOutput: IItemHandler?
|
||||||
|
|
||||||
init {
|
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>()
|
val builder = ImmutableSet.Builder<ItemHandlerMode>()
|
||||||
|
|
||||||
builder.add(ItemHandlerMode.DISABLED)
|
builder.add(ItemHandlerMode.DISABLED)
|
||||||
@ -243,20 +247,28 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo
|
|||||||
if (input != null) builder.add(ItemHandlerMode.INPUT)
|
if (input != null) builder.add(ItemHandlerMode.INPUT)
|
||||||
if (output != null) builder.add(ItemHandlerMode.OUTPUT)
|
if (output != null) builder.add(ItemHandlerMode.OUTPUT)
|
||||||
if (input != null && output != null) builder.add(ItemHandlerMode.INPUT_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)
|
if (battery != null) builder.add(ItemHandlerMode.BATTERY)
|
||||||
|
|
||||||
possibleViews = builder.build()
|
possibleViews = builder.build()
|
||||||
|
|
||||||
if (input != null && output != null) {
|
if (input != null && output != null) {
|
||||||
inputOutput = CombinedItemHandler(input, output)
|
this.inputOutput = CombinedItemHandler(input, output)
|
||||||
} else {
|
} else {
|
||||||
inputOutput = null
|
this.inputOutput = inputOutput
|
||||||
}
|
}
|
||||||
|
|
||||||
val caps = ArrayList<IItemHandler>()
|
val caps = ArrayList<IItemHandler>()
|
||||||
|
|
||||||
if (input != null) caps.add(input)
|
if (input != null) caps.add(input)
|
||||||
if (output != null) caps.add(output)
|
if (output != null) caps.add(output)
|
||||||
|
if (inputOutput != null) caps.add(inputOutput)
|
||||||
if (battery != null) caps.add(battery)
|
if (battery != null) caps.add(battery)
|
||||||
|
|
||||||
sideless = UnmodifiableItemHandler(CombinedItemHandler(caps))
|
sideless = UnmodifiableItemHandler(CombinedItemHandler(caps))
|
||||||
|
@ -71,7 +71,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt
|
|||||||
|
|
||||||
val energyConfig = ConfigurableEnergy(energy)
|
val energyConfig = ConfigurableEnergy(energy)
|
||||||
val itemConfig = ConfigurableItemHandler(
|
val itemConfig = ConfigurableItemHandler(
|
||||||
input = repairContainer.handler(object : HandlerFilter {
|
inputOutput = repairContainer.handler(object : HandlerFilter {
|
||||||
override fun canInsert(slot: Int, stack: ItemStack): Boolean {
|
override fun canInsert(slot: Int, stack: ItemStack): Boolean {
|
||||||
if (!stack.isRepairable || !stack.isDamaged) {
|
if (!stack.isRepairable || !stack.isDamaged) {
|
||||||
return false
|
return false
|
||||||
@ -95,16 +95,6 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt
|
|||||||
}.hasMatterValue
|
}.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 {
|
override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean {
|
||||||
return progressPerTick <= 0.0 || matterPerTick <= Decimal.ZERO
|
return progressPerTick <= 0.0 || matterPerTick <= Decimal.ZERO
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user