mirror of
https://github.com/GTNewHorizons/bdlib.git
synced 2026-11-24 05:54:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0d3609e66 | ||
|
|
5a1c150a03 | ||
|
|
c5a7fc3d51 | ||
|
|
9787c4836e | ||
|
|
cd833163af | ||
|
|
5a9aedb4d5 | ||
|
|
2a7bbaeb97 | ||
|
|
58125ee291 | ||
|
|
d9cc8ace82 | ||
|
|
32617ff592 | ||
|
|
64683a0208 | ||
|
|
f593458511 |
No files matched your search
+1
-1
@@ -21,7 +21,7 @@ buildscript {
|
||||
apply plugin: 'scala'
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "1.4.3"
|
||||
version = "1.4.4"
|
||||
|
||||
if (project.hasProperty('buildnum')) {
|
||||
project.version = project.version + '.' + project.buildnum
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
rootProject.name='bdlib'
|
||||
rootProject.name = 'bdlib'
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.data
|
||||
|
||||
import net.bdew.lib.Misc
|
||||
import net.bdew.lib.data.base.{DataSlot, TileDataSlots, UpdateKind}
|
||||
import net.bdew.lib.tile.inventory.BaseInventory
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.{NBTTagCompound, NBTTagList}
|
||||
|
||||
case class DataSlotInventory(name: String, parent: TileDataSlots, size: Int) extends DataSlot with BaseInventory {
|
||||
setUpdate(UpdateKind.SAVE)
|
||||
|
||||
override def getSizeInventory = size
|
||||
override def markDirty() = parent.dataSlotChanged(this)
|
||||
|
||||
override def load(t: NBTTagCompound, kind: UpdateKind.Value) {
|
||||
inv = new Array[ItemStack](getSizeInventory)
|
||||
for (nbtItem <- Misc.iterNbtCompoundList(t, name)) {
|
||||
val slot = nbtItem.getByte("Slot")
|
||||
if (slot >= 0 && slot < inv.size) {
|
||||
inv(slot) = ItemStack.loadItemStackFromNBT(nbtItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def save(t: NBTTagCompound, kind: UpdateKind.Value) {
|
||||
val itemList = new NBTTagList
|
||||
for ((item, i) <- inv.view.zipWithIndex if item != null) {
|
||||
val itemNbt: NBTTagCompound = new NBTTagCompound
|
||||
itemNbt.setByte("Slot", i.asInstanceOf[Byte])
|
||||
item.writeToNBT(itemNbt)
|
||||
itemList.appendTag(itemNbt)
|
||||
}
|
||||
t.setTag(name, itemList)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ abstract class DataSlotTankBase(sz: Int) extends FluidTank(sz) with IFluidTank w
|
||||
|
||||
updateKind = Set(UpdateKind.GUI, UpdateKind.SAVE)
|
||||
|
||||
val sendCapacityOnUpdateKind = Set(UpdateKind.GUI)
|
||||
|
||||
def checkUpdate() {
|
||||
if (!isSame(oldStack, fluid)) {
|
||||
oldStack = if (fluid == null) null else fluid.copy()
|
||||
@@ -36,7 +38,7 @@ abstract class DataSlotTankBase(sz: Int) extends FluidTank(sz) with IFluidTank w
|
||||
def save(t: NBTTagCompound, k: UpdateKind.Value) {
|
||||
val tag = new NBTTagCompound()
|
||||
writeToNBT(tag)
|
||||
if (k == UpdateKind.GUI)
|
||||
if (sendCapacityOnUpdateKind.contains(k))
|
||||
tag.setInteger("size", getCapacity)
|
||||
t.setTag(name, tag)
|
||||
}
|
||||
@@ -45,7 +47,7 @@ abstract class DataSlotTankBase(sz: Int) extends FluidTank(sz) with IFluidTank w
|
||||
setFluid(null)
|
||||
val tag = t.getCompoundTag(name)
|
||||
readFromNBT(tag)
|
||||
if (k == UpdateKind.GUI)
|
||||
if (sendCapacityOnUpdateKind.contains(k))
|
||||
setCapacity(tag.getInteger("size"))
|
||||
}
|
||||
override def setFluid(fluid: FluidStack) = execWithChangeNotify(super.setFluid(fluid))
|
||||
|
||||
@@ -20,7 +20,7 @@ trait DrawTarget {
|
||||
def drawTextMultiline(text: String, r: Rect, color: Color)
|
||||
|
||||
def drawTextureInterpolate(r: Rect, t: Texture, x1: Float, y1: Float, x2: Float, y2: Float, color: Color = Color.white) =
|
||||
drawTexture(r.interpolate(x1, y1, x2, y2), Texture.interpolate(t, x1, y1, x2, y2))
|
||||
drawTexture(r.interpolate(x1, y1, x2, y2), Texture.interpolate(t, x1, y1, x2, y2), color)
|
||||
}
|
||||
|
||||
trait SimpleDrawTarget extends DrawTarget {
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.text.DecimalFormat
|
||||
|
||||
import net.bdew.lib.Misc
|
||||
import net.bdew.lib.data.DataSlotTankBase
|
||||
import net.bdew.lib.gui.{Point, Rect, Texture}
|
||||
import net.bdew.lib.gui.{Color, Point, Rect, Texture}
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
import scala.collection.mutable
|
||||
@@ -39,19 +39,21 @@ class WidgetFluidGauge(val rect: Rect, overlay: Texture, dslot: DataSlotTankBase
|
||||
val icon = Texture(Texture.BLOCKS, fstack.getFluid.getStillIcon)
|
||||
var fillHeight = if (dslot.getCapacity > 0) rect.h * fstack.amount / dslot.getCapacity else 0
|
||||
var yStart: Int = 0
|
||||
val color = Color.fromInt(fstack.getFluid.getColor(fstack))
|
||||
|
||||
while (fillHeight > 0) {
|
||||
if (fillHeight > 16) {
|
||||
parent.drawTexture(new Rect(rect.x, rect.y2 - 16 - yStart, rect.w, 16), icon)
|
||||
parent.drawTexture(new Rect(rect.x, rect.y2 - 16 - yStart, rect.w, 16), icon, color)
|
||||
fillHeight -= 16
|
||||
} else {
|
||||
parent.drawTextureInterpolate(new Rect(rect.x, rect.y2 - 16 - yStart, rect.w, 16), icon, 0, 1 - fillHeight / 16, 1, 1)
|
||||
parent.drawTextureInterpolate(new Rect(rect.x, rect.y2 - 16 - yStart, rect.w, 16), icon, 0, 1 - fillHeight / 16, 1, 1, color)
|
||||
fillHeight = 0
|
||||
}
|
||||
yStart = yStart + 16
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glColor3d(1, 1, 1)
|
||||
GL11.glDisable(GL11.GL_BLEND)
|
||||
|
||||
parent.drawTexture(rect, overlay)
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.bdew.lib.render.connected.{BlockAdditionalRender, ConnectedHelper, Fa
|
||||
import net.minecraft.world.IBlockAccess
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
trait BlockOutput[T <: TileOutput] extends BlockModule[T] with BlockAdditionalRender {
|
||||
trait BlockOutput[T <: TileOutput[_]] extends BlockModule[T] with BlockAdditionalRender {
|
||||
def getAdjancedFaces(face: ForgeDirection, bp: BlockRef) = {
|
||||
val sides = ConnectedHelper.faceAdjanced(face)
|
||||
Seq(
|
||||
|
||||
@@ -25,6 +25,7 @@ case class DataSlotOutputConfig(name: String, parent: TileDataSlots, slots: Int)
|
||||
x.write(tmp)
|
||||
val kind = x match {
|
||||
case _: OutputConfigPower => "power"
|
||||
case _: OutputConfigFluid => "fluid"
|
||||
case _ => sys.error("Unknown output config kind: " + x)
|
||||
}
|
||||
tmp.setString("kind", kind)
|
||||
@@ -39,7 +40,8 @@ case class DataSlotOutputConfig(name: String, parent: TileDataSlots, slots: Int)
|
||||
val cfg = t.getCompoundTag(name + "_" + i)
|
||||
val cfgObj = cfg.getString("kind") match {
|
||||
case "power" => new OutputConfigPower
|
||||
case x => new OutputConfigInvalid
|
||||
case "fluid" => new OutputConfigFluid
|
||||
case _ => new OutputConfigInvalid
|
||||
}
|
||||
cfgObj.read(cfg)
|
||||
map += i -> cfgObj
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 OutputConfigFluid extends OutputConfig with OutputConfigRSControllable {
|
||||
var avg = 0.0
|
||||
var rsMode = RSMode.ALWAYS
|
||||
|
||||
final val decay = 0.5
|
||||
|
||||
def updateAvg(v: Double) {
|
||||
avg = avg * decay + (1 - decay) * v
|
||||
}
|
||||
|
||||
def read(t: NBTTagCompound) {
|
||||
avg = t.getDouble("avg")
|
||||
rsMode = RSMode(t.getInteger("rsMode"))
|
||||
}
|
||||
|
||||
def write(t: NBTTagCompound) {
|
||||
t.setDouble("avg", avg)
|
||||
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))
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,9 @@ package net.bdew.lib.multiblock.data
|
||||
import net.bdew.lib.multiblock.network.MsgOutputCfg
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
|
||||
case class MsgOutputCfgPower(output: Int, rsMode: RSMode.Value) extends MsgOutputCfg
|
||||
|
||||
class OutputConfigPower extends OutputConfig {
|
||||
class OutputConfigPower(var unit: String = "MJ") extends OutputConfig with OutputConfigRSControllable {
|
||||
var avg = 0.0
|
||||
var rsMode = RSMode.ALWAYS
|
||||
var unit = "MJ"
|
||||
|
||||
final val decay = 0.5
|
||||
|
||||
@@ -38,7 +35,7 @@ class OutputConfigPower extends OutputConfig {
|
||||
}
|
||||
|
||||
def handleConfigPacket(m: MsgOutputCfg) = m match {
|
||||
case MsgOutputCfgPower(_, r) => rsMode = r
|
||||
case MsgOutputCfgRSMode(_, r) => rsMode = r
|
||||
case _ => sys.error("Invalid output config packet %s to config %s".format(m, this))
|
||||
}
|
||||
}
|
||||
@@ -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.data
|
||||
|
||||
import net.bdew.lib.multiblock.network.MsgOutputCfg
|
||||
|
||||
case class MsgOutputCfgRSMode(output: Int, rsMode: RSMode.Value) extends MsgOutputCfg
|
||||
|
||||
trait OutputConfigRSControllable extends OutputConfig {
|
||||
var rsMode: RSMode.Value
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
* https://raw.github.com/bdew/bdlib/master/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package net.bdew.lib.multiblock.gui
|
||||
|
||||
import net.bdew.lib.gui.widgets.{WidgetMultipane, WidgetSubcontainer}
|
||||
import net.bdew.lib.gui.{Rect, _}
|
||||
import net.bdew.lib.multiblock.data.OutputConfigPower
|
||||
import net.bdew.lib.multiblock.interact.CIOutputFaces
|
||||
|
||||
class WidgetOutputs(p: Point, te: CIOutputFaces, rows: Int) extends WidgetSubcontainer(new Rect(p, 92, 19 * rows)) {
|
||||
for (i <- 0 until rows)
|
||||
add(new WidgetOutputRow(Point(0, 19 * i), te, i))
|
||||
}
|
||||
|
||||
class WidgetOutputDisplay extends WidgetSubcontainer(Rect(20, 0, 72, 18))
|
||||
|
||||
class WidgetOutputRow(p: Point, te: CIOutputFaces, output: Int) extends WidgetMultipane(new Rect(p, 92, 18)) {
|
||||
add(new WidgetOutputIcon(Point(1, 1), te, output))
|
||||
val emptyPane = addPane(new WidgetSubcontainer(rect))
|
||||
val powerPane = addPane(new WidgetPowerOutput(te, output))
|
||||
|
||||
def getActivePane =
|
||||
te.outputConfig.get(output) match {
|
||||
case Some(x: OutputConfigPower) => powerPane
|
||||
case _ => emptyPane
|
||||
}
|
||||
}
|
||||
+9
-12
@@ -4,25 +4,22 @@
|
||||
*
|
||||
* 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
|
||||
* https://raw.github.com/bdew/bdlib/master/MMPL-1.0.txt
|
||||
* http://bdew.net/minecraft-mod-public-license/
|
||||
*/
|
||||
|
||||
package net.bdew.lib.multiblock.gui
|
||||
|
||||
import java.text.DecimalFormat
|
||||
|
||||
import net.bdew.lib.Misc
|
||||
import net.bdew.lib.gui.widgets.{WidgetButtonIcon, WidgetDynLabel}
|
||||
import net.bdew.lib.gui.{Color, Point}
|
||||
import net.bdew.lib.multiblock.data.{MsgOutputCfgPower, OutputConfigPower, RSMode}
|
||||
import net.bdew.lib.gui.widgets.{WidgetButtonIcon, WidgetSubcontainer}
|
||||
import net.bdew.lib.gui.{Point, Rect}
|
||||
import net.bdew.lib.multiblock.data.{MsgOutputCfgRSMode, OutputConfigRSControllable, RSMode}
|
||||
import net.bdew.lib.multiblock.interact.CIOutputFaces
|
||||
import net.bdew.lib.multiblock.network.NetHandler
|
||||
|
||||
class WidgetPowerOutput(te: CIOutputFaces, output: Int) extends WidgetOutputDisplay {
|
||||
def cfg = te.outputConfig(output).asInstanceOf[OutputConfigPower]
|
||||
val dec = new DecimalFormat("#,##0")
|
||||
val bt = add(new WidgetButtonIcon(Point(56, 1), clicked, te.resources.btBase, te.resources.btHover))
|
||||
add(new WidgetDynLabel("%s %s/t".format(dec.format(cfg.avg), cfg.unit), 1, 5, Color.darkgray))
|
||||
class WidgetRSConfig(te: CIOutputFaces, output: Int, p: Point) extends WidgetSubcontainer(new Rect(p, 16, 16)) {
|
||||
def cfg = te.outputConfig(output).asInstanceOf[OutputConfigRSControllable]
|
||||
|
||||
val bt = add(new WidgetButtonIcon(Point(0, 0), clicked, te.resources.btBase, te.resources.btHover))
|
||||
|
||||
val icons = Map(
|
||||
RSMode.ALWAYS -> te.resources.btEnabled,
|
||||
@@ -45,6 +42,6 @@ class WidgetPowerOutput(te: CIOutputFaces, output: Int) extends WidgetOutputDisp
|
||||
}
|
||||
|
||||
def clicked(b: WidgetButtonIcon) {
|
||||
NetHandler.sendToServer(MsgOutputCfgPower(output, next(cfg.rsMode)))
|
||||
NetHandler.sendToServer(MsgOutputCfgRSMode(output, next(cfg.rsMode)))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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 CIFluidOutput extends CIOutputFaces {
|
||||
def outputFluid(resource: FluidStack, doDrain: Boolean): FluidStack
|
||||
def outputFluid(ammount: Int, doDrain: Boolean): FluidStack
|
||||
def canOutputFluid(fluid: Fluid): Boolean
|
||||
def getTankInfo: Array[FluidTankInfo]
|
||||
}
|
||||
@@ -52,13 +52,13 @@ trait CIOutputFaces extends TileController {
|
||||
}
|
||||
|
||||
def doOutputs() {
|
||||
for ((x, n) <- outputFaces) {
|
||||
val t = x.origin.getTile[MIOutput](getWorldObj)
|
||||
if (t.isDefined) {
|
||||
if (!outputConfig.isDefinedAt(n) || outputConfig(n).isInstanceOf[OutputConfigInvalid])
|
||||
outputConfig(n) = t.get.makeCfgObject(x.face)
|
||||
t.get.doOutput(x.face, outputConfig(n))
|
||||
}
|
||||
for {
|
||||
(x, n) <- outputFaces
|
||||
t <- x.origin.getTile[MIOutput[_]](getWorldObj)
|
||||
} {
|
||||
if (!outputConfig.isDefinedAt(n) || !t.outputConfigType.isInstance(outputConfig(n)))
|
||||
outputConfig(n) = t.makeCfgObject(x.face)
|
||||
t.doOutput(x.face, outputConfig(n).asInstanceOf[t.OCType])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,11 @@ import net.bdew.lib.multiblock.data.OutputConfig
|
||||
import net.bdew.lib.multiblock.tile.TileModule
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
trait MIOutput extends TileModule {
|
||||
def doOutput(face: ForgeDirection, cfg: OutputConfig)
|
||||
trait MIOutput[T <: OutputConfig] extends TileModule {
|
||||
val outputConfigType: Class[T]
|
||||
type OCType = T
|
||||
|
||||
def doOutput(face: ForgeDirection, cfg: OCType)
|
||||
|
||||
def makeCfgObject(face: ForgeDirection): OutputConfig
|
||||
}
|
||||
@@ -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.tile
|
||||
|
||||
import net.bdew.lib.multiblock.data.{OutputConfigRSControllable, RSMode}
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
|
||||
trait RSControllableOutput extends TileEntity {
|
||||
def checkCanOutput(cfg: OutputConfigRSControllable): Boolean = {
|
||||
if (cfg.rsMode == RSMode.ALWAYS) return true
|
||||
if (cfg.rsMode == RSMode.NEVER) return false
|
||||
return getWorldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) ^ (cfg.rsMode == RSMode.RS_OFF)
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,9 @@ trait TileModule extends TileDataSlots {
|
||||
val kind: String
|
||||
val connected = new DataSlotPos("connected", this).setUpdate(UpdateKind.WORLD, UpdateKind.SAVE, UpdateKind.RENDER)
|
||||
|
||||
def getCoreAs[T: ClassTag] = connected flatMap (_.getTile[TileController with T](getWorldObj))
|
||||
def getCore = connected flatMap (_.getTile[TileController](getWorldObj))
|
||||
def getCoreAs[T <: TileController : ClassTag] = connected flatMap (_.getTile[T](getWorldObj))
|
||||
|
||||
def getCore = getCoreAs[TileController]
|
||||
|
||||
lazy val mypos = BlockRef(xCoord, yCoord, zCoord)
|
||||
|
||||
|
||||
@@ -9,29 +9,27 @@
|
||||
|
||||
package net.bdew.lib.multiblock.tile
|
||||
|
||||
import net.bdew.lib.multiblock.data.{OutputConfigPower, RSMode}
|
||||
import net.bdew.lib.Misc
|
||||
import net.bdew.lib.block.BlockFace
|
||||
import net.bdew.lib.multiblock.data.OutputConfig
|
||||
import net.bdew.lib.multiblock.interact.{CIOutputFaces, MIOutput}
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
abstract class TileOutput extends TileModule with MIOutput {
|
||||
val unit: String
|
||||
|
||||
abstract class TileOutput[T <: OutputConfig] extends TileModule with MIOutput[T] {
|
||||
override def getCore = getCoreAs[CIOutputFaces]
|
||||
|
||||
def checkCanOutput(cfg: OutputConfigPower): Boolean = {
|
||||
if (cfg.rsMode == RSMode.ALWAYS) return true
|
||||
if (cfg.rsMode == RSMode.NEVER) return false
|
||||
return worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) ^ (cfg.rsMode == RSMode.RS_OFF)
|
||||
}
|
||||
|
||||
def makeCfgObject(face: ForgeDirection) = {
|
||||
val cfg = new OutputConfigPower
|
||||
cfg.unit = unit
|
||||
cfg
|
||||
}
|
||||
def makeCfgObject(face: ForgeDirection): T
|
||||
|
||||
var rescanFaces = false
|
||||
|
||||
def getCfg(dir: ForgeDirection): Option[T] =
|
||||
for {
|
||||
core <- getCore
|
||||
onum <- core.outputFaces.get(BlockFace(mypos, dir))
|
||||
cfggen <- core.outputConfig.get(onum)
|
||||
cfg <- Misc.asInstanceOpt(cfggen, outputConfigType)
|
||||
} yield cfg
|
||||
|
||||
serverTick.listen(() => {
|
||||
if (rescanFaces) {
|
||||
rescanFaces = false
|
||||
@@ -50,7 +48,11 @@ abstract class TileOutput extends TileModule with MIOutput {
|
||||
|
||||
def doRescanFaces() {
|
||||
getCore map { core =>
|
||||
val connections = ForgeDirection.VALID_DIRECTIONS.filter(canConnectoToFace).toSet
|
||||
val connections = (
|
||||
ForgeDirection.VALID_DIRECTIONS
|
||||
filterNot { dir => core.modules.contains(mypos.neighbour(dir)) }
|
||||
filter canConnectoToFace
|
||||
).toSet
|
||||
val known = core.outputFaces.filter(_._1.origin == mypos).map(_._1.face).toSet
|
||||
val toAdd = connections -- known
|
||||
val toRemove = known -- connections
|
||||
|
||||
@@ -21,9 +21,9 @@ trait GenericConfigParser extends RecipeParser {
|
||||
| ("-" ~> decimalNumber) ^^ { case x => -x.toDouble }
|
||||
)
|
||||
|
||||
def cfgStatementNum = ident ~ "=" ~ signedNumber ^^ { case id ~ eq ~ n => CfgVal(id, EntryDouble(n.toDouble)) }
|
||||
def cfgStatementStr = ident ~ "=" ~ str ^^ { case id ~ eq ~ s => CfgVal(id, EntryStr(s)) }
|
||||
def cfgStatementNumList = ident ~ ("=" ~> "{" ~> signedNumber.* <~ "}") ^^ { case id ~ l => CfgVal(id, EntryNumList(l)) }
|
||||
def cfgStatementNum = str ~ "=" ~ signedNumber ^^ { case id ~ eq ~ n => CfgVal(id, EntryDouble(n.toDouble)) }
|
||||
def cfgStatementStr = str ~ "=" ~ str ^^ { case id ~ eq ~ s => CfgVal(id, EntryStr(s)) }
|
||||
def cfgStatementNumList = str ~ ("=" ~> "{" ~> signedNumber.* <~ "}") ^^ { case id ~ l => CfgVal(id, EntryNumList(l)) }
|
||||
def cfgStatementSub = cfgBlock ^^ { case (id, st) => CfgSub(id, st) }
|
||||
|
||||
def cfgStatement = cfgStatementNum | cfgStatementStr | cfgStatementSub | cfgStatementNumList
|
||||
@@ -31,7 +31,7 @@ trait GenericConfigParser extends RecipeParser {
|
||||
// A bit of type acrobatics because this is recursive (via cfgStatementSub)
|
||||
// the tuple is translated into the proper class in either cfgStatementSub or cfg
|
||||
def cfgBlock: Parser[(String, List[CfgStatement])] =
|
||||
"cfg" ~> ident ~ ("{" ~> cfgStatement.* <~ "}") ^^ { case id ~ st => (id, st) }
|
||||
"cfg" ~> str ~ ("{" ~> cfgStatement.* <~ "}") ^^ { case id ~ st => (id, st) }
|
||||
|
||||
def statementCfg = cfgBlock ^^ { case (id, st) => StCfg(id, st) }
|
||||
}
|
||||
Reference in new issue
Block a user