mirror of
https://github.com/GTNewHorizons/bdlib.git
synced 2026-11-23 21:50:07 +00:00
Added slot types for sensors
This commit is contained in:
1 parent
6439ef8f08
commit
8415ee7a00
3 files changed
+53
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user