mirror of
https://github.com/GTNewHorizons/bdlib.git
synced 2026-11-20 04:09:37 +00:00
Added multiblock stuff for item output and slot selection
This commit is contained in:
1 parent
b015636514
commit
1da90af3f1
6 files changed
+145
No files matched your search
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2014
|
||||
* 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.multiblock.data
|
||||
|
||||
import net.bdew.lib.multiblock.network.MsgOutputCfg
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
|
||||
trait OutputConfigSlots {
|
||||
val slotsDef: SlotSet
|
||||
var slot = slotsDef.default
|
||||
}
|
||||
|
||||
class OutputConfigFluidSlots(val slotsDef: SlotSet) extends OutputConfigFluid with OutputConfigSlots {
|
||||
override def id = slotsDef.outputConfigId
|
||||
override def read(t: NBTTagCompound) {
|
||||
super.read(t)
|
||||
slot = slotsDef.get(t.getString("slot"))
|
||||
}
|
||||
override def write(t: NBTTagCompound) {
|
||||
super.write(t)
|
||||
t.setString("slot", slot.id)
|
||||
}
|
||||
override def handleConfigPacket(m: MsgOutputCfg) = m match {
|
||||
case MsgOutputCfgSlot(n, id) => slot = slotsDef.get(id)
|
||||
case _ => super.handleConfigPacket(m)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2014
|
||||
* 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.multiblock.data
|
||||
|
||||
import net.bdew.lib.multiblock.network.MsgOutputCfg
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
|
||||
class OutputConfigItems extends OutputConfig with OutputConfigRSControllable {
|
||||
override def id = "items"
|
||||
var rsMode = RSMode.ALWAYS
|
||||
|
||||
def read(t: NBTTagCompound) {
|
||||
rsMode = RSMode(t.getInteger("rsMode"))
|
||||
}
|
||||
|
||||
def write(t: NBTTagCompound) {
|
||||
t.setInteger("rsMode", rsMode.id)
|
||||
}
|
||||
|
||||
def handleConfigPacket(m: MsgOutputCfg) = m match {
|
||||
case MsgOutputCfgRSMode(_, r) => rsMode = r
|
||||
case _ => sys.error("Invalid output config packet %s to config %s".format(m, this))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2014
|
||||
* 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.multiblock.data
|
||||
|
||||
import net.bdew.lib.gui.Texture
|
||||
|
||||
abstract class SlotSet(val outputConfigId: String) {
|
||||
// outputConfigId should be registered in OutputConfigManager
|
||||
|
||||
var slotMap = Map.empty[String, Slot]
|
||||
|
||||
case class Slot(id: String, name: String, texture: Texture) {
|
||||
slotMap += id -> this
|
||||
def next = order(this)
|
||||
}
|
||||
|
||||
def default: Slot
|
||||
val order: Map[Slot, Slot]
|
||||
|
||||
def get(id: String) = slotMap(id)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2014
|
||||
* 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.multiblock.interact
|
||||
|
||||
import net.minecraftforge.fluids.{Fluid, FluidStack, FluidTankInfo}
|
||||
|
||||
trait CIFluidOutputSelect extends CIOutputFaces {
|
||||
val outputSlotsDef: SlotSet
|
||||
def outputFluid(slot: outputSlotsDef.Slot, resource: FluidStack, doDrain: Boolean): FluidStack
|
||||
def outputFluid(slot: outputSlotsDef.Slot, amount: Int, doDrain: Boolean): FluidStack
|
||||
def canOutputFluid(slot: outputSlotsDef.Slot, fluid: Fluid): Boolean
|
||||
def getTankInfo: Array[FluidTankInfo]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2014
|
||||
* 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.multiblock.interact
|
||||
|
||||
import net.bdew.lib.multiblock.tile.TileController
|
||||
import net.minecraft.inventory.IInventory
|
||||
|
||||
trait CIItemOutput extends TileController {
|
||||
def getItemOutputInventory: IInventory
|
||||
def canOutputItemFromSlot(slot: Int): Boolean
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) bdew, 2013 - 2014
|
||||
* 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.multiblock.network
|
||||
|
||||
case class MsgOutputCfgSlot(output: Int, slot: String) extends MsgOutputCfg
|
||||
Reference in new issue
Block a user