diff --git a/src/net/bdew/lib/sensors/SimpleSensor.scala b/src/net/bdew/lib/sensors/SimpleSensor.scala index d2b92a5..1edd6b4 100644 --- a/src/net/bdew/lib/sensors/SimpleSensor.scala +++ b/src/net/bdew/lib/sensors/SimpleSensor.scala @@ -23,6 +23,8 @@ abstract class SimpleSensor extends SensorType { override def paramClicked(current: SensorParameter, item: ItemStack, button: Int, mod: Int) = if (item == null && button == 0 && mod == 0) Misc.nextInSeq(parameters, current) + else if (item == null && button == 1 && mod == 0) + Misc.prevInSeq(parameters, current) else current diff --git a/src/net/bdew/lib/sensors/SlotSensorParameter.scala b/src/net/bdew/lib/sensors/SlotSensorParameter.scala new file mode 100644 index 0000000..c445ace --- /dev/null +++ b/src/net/bdew/lib/sensors/SlotSensorParameter.scala @@ -0,0 +1,22 @@ +/* + * Copyright (c) bdew, 2013 - 2015 + * https://github.com/bdew/bdlib + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://bdew.net/minecraft-mod-public-license/ + */ + +package net.bdew.lib.sensors + +import net.bdew.lib.gui.SlotClickable +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.inventory.{IInventory, Slot} + +class SlotSensorParameter(inv: IInventory, index: Int, x: Int, y: Int, ds: DataSlotSensor) extends Slot(inv, index, x, y) with SlotClickable { + override def onClick(button: Int, mods: Int, player: EntityPlayer) = { + val newParam = ds.sensor.paramClicked(ds.param, player.inventory.getItemStack, button, mods) + ds := ds.value.copy(param = newParam) + player.inventory.getItemStack + } +} diff --git a/src/net/bdew/lib/sensors/SlotSensorType.scala b/src/net/bdew/lib/sensors/SlotSensorType.scala new file mode 100644 index 0000000..db48ae2 --- /dev/null +++ b/src/net/bdew/lib/sensors/SlotSensorType.scala @@ -0,0 +1,29 @@ +/* + * Copyright (c) bdew, 2013 - 2015 + * https://github.com/bdew/bdlib + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://bdew.net/minecraft-mod-public-license/ + */ + +package net.bdew.lib.sensors + +import net.bdew.lib.Misc +import net.bdew.lib.gui.SlotClickable +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.inventory.{IInventory, Slot} + +class SlotSensorType(inv: IInventory, index: Int, x: Int, y: Int, ds: DataSlotSensor, types: => Seq[SensorType]) extends Slot(inv, index, x, y) with SlotClickable { + override def onClick(button: Int, mods: Int, player: EntityPlayer) = { + if (mods == 0 && (button == 0 || button == 1) && types.size > 0 && player.inventory.getItemStack == null) { + val newSensor = + if (button == 0) + Misc.nextInSeq(types, ds.sensor) + else + Misc.prevInSeq(types, ds.sensor) + ds := SensorPair(newSensor, newSensor.defaultParameter) + } + player.inventory.getItemStack + } +}