mirror of
https://github.com/GTNewHorizons/bdlib.git
synced 2026-11-26 15:02:55 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e90643ea1 | ||
|
|
a232ce52f3 | ||
|
|
35b3a77582 | ||
|
|
be3a1cf2aa | ||
|
|
e0f5d0ceda | ||
|
|
e4169f7a5d | ||
|
|
eb75a26c40 | ||
|
|
3431a6910e | ||
|
|
02598183b8 | ||
|
|
70c19bff5b |
No files matched your search
+2
-2
@@ -21,7 +21,7 @@ buildscript {
|
|||||||
apply plugin: 'scala'
|
apply plugin: 'scala'
|
||||||
apply plugin: 'forge'
|
apply plugin: 'forge'
|
||||||
|
|
||||||
version = "1.6.2"
|
version = "1.6.4"
|
||||||
|
|
||||||
if (project.hasProperty('buildnum')) {
|
if (project.hasProperty('buildnum')) {
|
||||||
project.version = project.version + '.' + project.buildnum
|
project.version = project.version + '.' + project.buildnum
|
||||||
@@ -34,7 +34,7 @@ archivesBaseName = "bdlib"
|
|||||||
ext.versuffix = "mc1710"
|
ext.versuffix = "mc1710"
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "1.7.10-10.13.2.1231"
|
version = "1.7.10-10.13.2.1291"
|
||||||
replace("BDLIB_VER", project.version)
|
replace("BDLIB_VER", project.version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
bdlib.multiblock.face.north=Nord
|
||||||
|
bdlib.multiblock.face.south=Sud
|
||||||
|
bdlib.multiblock.face.east=Est
|
||||||
|
bdlib.multiblock.face.west=Ouest
|
||||||
|
bdlib.multiblock.face.up=Haut
|
||||||
|
bdlib.multiblock.face.down=Bas
|
||||||
|
|
||||||
|
bdlib.multiblock.disabled=Désactivé(e)
|
||||||
|
bdlib.multiblock.incomplete=Cette machine est incomplète, elle requiert au moins :
|
||||||
|
bdlib.multiblock.notconnected=Pas connecté(e) à une machine valide
|
||||||
|
bdlib.multiblock.toomanyoutputs=Trop de sorties connectées, incapable d'attacher de nouvelles connexions
|
||||||
|
|
||||||
|
bdlib.rsmode.always=Toujours en marche
|
||||||
|
bdlib.rsmode.never=Désactivé(e)
|
||||||
|
bdlib.rsmode.rs_on=Activer par la redstone
|
||||||
|
bdlib.rsmode.rs_off=Désactiver par la redstone
|
||||||
|
|
||||||
|
bdlib.label.empty=Vide
|
||||||
@@ -20,6 +20,7 @@ import org.apache.logging.log4j.Logger
|
|||||||
object BdLib {
|
object BdLib {
|
||||||
var log: Logger = null
|
var log: Logger = null
|
||||||
|
|
||||||
|
def logDebug(msg: String, args: Any*) = log.debug(msg.format(args: _*))
|
||||||
def logInfo(msg: String, args: Any*) = log.info(msg.format(args: _*))
|
def logInfo(msg: String, args: Any*) = log.info(msg.format(args: _*))
|
||||||
def logWarn(msg: String, args: Any*) = log.warn(msg.format(args: _*))
|
def logWarn(msg: String, args: Any*) = log.warn(msg.format(args: _*))
|
||||||
def logError(msg: String, args: Any*) = log.error(msg.format(args: _*))
|
def logError(msg: String, args: Any*) = log.error(msg.format(args: _*))
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ import net.minecraftforge.common.util.ForgeDirection
|
|||||||
import scala.reflect.ClassTag
|
import scala.reflect.ClassTag
|
||||||
|
|
||||||
case class BlockRef(x: Int, y: Int, z: Int) {
|
case class BlockRef(x: Int, y: Int, z: Int) {
|
||||||
def block(w: IBlockAccess) = Option(w.getBlock(x, y, z))
|
def isValid(w: IBlockAccess) = y >= 0 && y < 256 // hardcoded because getHeight is unavailable on servers :(
|
||||||
def tile(w: IBlockAccess) = Option(w.getTileEntity(x, y, z))
|
|
||||||
def meta(w: IBlockAccess) = w.getBlockMetadata(x, y, z)
|
def block(w: IBlockAccess) = if (isValid(w)) Option(w.getBlock(x, y, z)) else None
|
||||||
|
def tile(w: IBlockAccess) = if (isValid(w)) Option(w.getTileEntity(x, y, z)) else None
|
||||||
|
def meta(w: IBlockAccess) = if (isValid(w)) w.getBlockMetadata(x, y, z) else 0
|
||||||
|
|
||||||
def blockIs(w: IBlockAccess, other: Block) = block(w).contains(other)
|
def blockIs(w: IBlockAccess, other: Block) = block(w).contains(other)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* 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.data
|
||||||
|
|
||||||
|
import net.bdew.lib.data.base.{TileDataSlots, UpdateKind}
|
||||||
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
|
import net.minecraftforge.fluids.{Fluid, FluidRegistry}
|
||||||
|
|
||||||
|
case class DataSlotFluidOption(name: String, parent: TileDataSlots) extends DataSlotOption[Fluid] {
|
||||||
|
setUpdate(UpdateKind.SAVE, UpdateKind.GUI)
|
||||||
|
|
||||||
|
override def save(t: NBTTagCompound, kind: UpdateKind.Value) {
|
||||||
|
value map { x => t.setString(name, x.getName) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override def load(t: NBTTagCompound, kind: UpdateKind.Value): Unit = {
|
||||||
|
if (t.hasKey(name)) {
|
||||||
|
val fluidName = t.getString(name)
|
||||||
|
if (FluidRegistry.isFluidRegistered(fluidName)) {
|
||||||
|
value = Option(FluidRegistry.getFluid(fluidName))
|
||||||
|
} else unset()
|
||||||
|
} else unset()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* 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.data
|
||||||
|
|
||||||
|
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, DataInputStream, DataOutputStream}
|
||||||
|
|
||||||
|
import net.bdew.lib.data.base.{DataSlot, TileDataSlots, UpdateKind}
|
||||||
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
|
|
||||||
|
import scala.collection.mutable
|
||||||
|
|
||||||
|
case class DataSlotMovingAverage(name: String, parent: TileDataSlots, size: Int) extends DataSlot {
|
||||||
|
val values = mutable.Queue.empty[Double]
|
||||||
|
var average: Double = 0
|
||||||
|
|
||||||
|
setUpdate(UpdateKind.GUI, UpdateKind.SAVE)
|
||||||
|
|
||||||
|
def reset() {
|
||||||
|
values.clear()
|
||||||
|
average = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
def update(v: Double) = {
|
||||||
|
values += v
|
||||||
|
if (values.length > size)
|
||||||
|
values.dequeue()
|
||||||
|
average = values.sum / values.length
|
||||||
|
parent.dataSlotChanged(this)
|
||||||
|
}
|
||||||
|
override def save(t: NBTTagCompound, kind: UpdateKind.Value) {
|
||||||
|
if (kind == UpdateKind.GUI) {
|
||||||
|
t.setDouble(name, average)
|
||||||
|
} else {
|
||||||
|
val b = new ByteArrayOutputStream()
|
||||||
|
val o = new DataOutputStream(b)
|
||||||
|
o.writeByte(values.size)
|
||||||
|
values.foreach(o.writeDouble)
|
||||||
|
t.setByteArray(name, b.toByteArray)
|
||||||
|
o.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override def load(t: NBTTagCompound, kind: UpdateKind.Value) {
|
||||||
|
if (kind == UpdateKind.GUI) {
|
||||||
|
average = t.getDouble(name)
|
||||||
|
} else {
|
||||||
|
values.clear()
|
||||||
|
if (t.hasKey(name)) {
|
||||||
|
val i = new DataInputStream(new ByteArrayInputStream(t.getByteArray(name)))
|
||||||
|
val len = i.readByte()
|
||||||
|
values ++= (for (x <- 0 until Math.min(len, size)) yield i.readDouble())
|
||||||
|
i.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,10 +19,13 @@ import scala.collection.mutable
|
|||||||
trait TileDataSlots extends TileExtended {
|
trait TileDataSlots extends TileExtended {
|
||||||
val dataSlots = mutable.HashMap.empty[String, DataSlot]
|
val dataSlots = mutable.HashMap.empty[String, DataSlot]
|
||||||
var lastChange = 0L
|
var lastChange = 0L
|
||||||
|
var lastGuiPacket = 0L
|
||||||
|
|
||||||
final val TRACE = false
|
final val TRACE = false
|
||||||
|
|
||||||
def doSave(kind: UpdateKind.Value, t: NBTTagCompound) {
|
def doSave(kind: UpdateKind.Value, t: NBTTagCompound) {
|
||||||
|
if (kind == UpdateKind.GUI)
|
||||||
|
t.setLong("BDLib_TS", getWorldObj.getTotalWorldTime)
|
||||||
for ((n, s) <- dataSlots if s.updateKind.contains(kind)) {
|
for ((n, s) <- dataSlots if s.updateKind.contains(kind)) {
|
||||||
s.save(t, kind)
|
s.save(t, kind)
|
||||||
if (TRACE) printf("%s: %s S=> %s\n".format(kind, n, t.getTag(n)))
|
if (TRACE) printf("%s: %s S=> %s\n".format(kind, n, t.getTag(n)))
|
||||||
@@ -30,6 +33,14 @@ trait TileDataSlots extends TileExtended {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def doLoad(kind: UpdateKind.Value, t: NBTTagCompound) {
|
def doLoad(kind: UpdateKind.Value, t: NBTTagCompound) {
|
||||||
|
if (kind == UpdateKind.GUI) {
|
||||||
|
val ts = t.getLong("BDLib_TS")
|
||||||
|
if (ts > lastGuiPacket) {
|
||||||
|
lastGuiPacket = ts
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
for ((n, s) <- dataSlots if s.updateKind.contains(kind)) {
|
for ((n, s) <- dataSlots if s.updateKind.contains(kind)) {
|
||||||
if (TRACE) printf("%s: %s L<= %s\n".format(kind, n, t.getTag(n)))
|
if (TRACE) printf("%s: %s L<= %s\n".format(kind, n, t.getTag(n)))
|
||||||
s.load(t, kind)
|
s.load(t, kind)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ case class BaseRect[T: Numeric](x: T, y: T, w: T, h: T) {
|
|||||||
|
|
||||||
def this(p: BasePoint[T], w: T, h: T) = this(p.x, p.y, w, h)
|
def this(p: BasePoint[T], w: T, h: T) = this(p.x, p.y, w, h)
|
||||||
|
|
||||||
def contains(p: BasePoint[T]) = n.gteq(p.x, x) && n.gteq(p.y, y) && n.lteq(p.x, x2) && n.lteq(p.y, y2)
|
def contains(p: BasePoint[T]) = n.gteq(p.x, x) && n.gteq(p.y, y) && n.lt(p.x, x2) && n.lt(p.y, y2)
|
||||||
|
|
||||||
def origin = BasePoint(x, y)
|
def origin = BasePoint(x, y)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* 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.multiblock.interact
|
||||||
|
|
||||||
|
import net.bdew.lib.multiblock.tile.TileController
|
||||||
|
import net.minecraft.inventory.IInventory
|
||||||
|
|
||||||
|
trait CIItemInput extends TileController {
|
||||||
|
def getItemInputInventory: IInventory
|
||||||
|
def canInputItemToSlot(slot: Int): Boolean
|
||||||
|
}
|
||||||
@@ -172,7 +172,7 @@ class RecipeLoader {
|
|||||||
if (l.size == 0) error("Concrete ItemStack requested for OD entry '%s' that is empty", id)
|
if (l.size == 0) error("Concrete ItemStack requested for OD entry '%s' that is empty", id)
|
||||||
val s = l.get(0).copy()
|
val s = l.get(0).copy()
|
||||||
s.stackSize = cnt
|
s.stackSize = cnt
|
||||||
BdLib.logInfo("Concrete ItemStack for OD entry '%s' -> %s", id, s)
|
BdLib.logDebug("Concrete ItemStack for OD entry '%s' -> %s", id, s)
|
||||||
return s
|
return s
|
||||||
case StackMacro(ch) => getConcreteStack(currCharMap(ch), cnt)
|
case StackMacro(ch) => getConcreteStack(currCharMap(ch), cnt)
|
||||||
case StackGeneric(mod, id) =>
|
case StackGeneric(mod, id) =>
|
||||||
@@ -197,7 +197,7 @@ class RecipeLoader {
|
|||||||
if (!currCharMap.contains(x)) error("Character %s is undefined", x)
|
if (!currCharMap.contains(x)) error("Character %s is undefined", x)
|
||||||
val r = getRecipeComponent(currCharMap(x))
|
val r = getRecipeComponent(currCharMap(x))
|
||||||
if (r.isInstanceOf[String]) needOd = true
|
if (r.isInstanceOf[String]) needOd = true
|
||||||
BdLib.logInfo("%s -> %s", x, r)
|
BdLib.logDebug("%s -> %s", x, r)
|
||||||
comp += (x -> r)
|
comp += (x -> r)
|
||||||
}
|
}
|
||||||
return (comp, needOd)
|
return (comp, needOd)
|
||||||
@@ -213,7 +213,7 @@ class RecipeLoader {
|
|||||||
list flatMap {
|
list flatMap {
|
||||||
case x: CraftingStatement =>
|
case x: CraftingStatement =>
|
||||||
if (res == x.result) {
|
if (res == x.result) {
|
||||||
BdLib.logInfo("Removing recipe %s", this)
|
BdLib.logDebug("Removing recipe %s", this)
|
||||||
None
|
None
|
||||||
} else Some(x)
|
} else Some(x)
|
||||||
case RsRecipes(inner) =>
|
case RsRecipes(inner) =>
|
||||||
@@ -248,15 +248,15 @@ class RecipeLoader {
|
|||||||
def processConfigStatement(s: ConfigStatement): Unit = s match {
|
def processConfigStatement(s: ConfigStatement): Unit = s match {
|
||||||
case CsConditionalConfig(cnd, thn, els) =>
|
case CsConditionalConfig(cnd, thn, els) =>
|
||||||
if (resolveCondition(cnd)) {
|
if (resolveCondition(cnd)) {
|
||||||
BdLib.logInfo("Condition %s - TRUE", cnd)
|
BdLib.logDebug("Condition %s - TRUE", cnd)
|
||||||
processConfigStatementsSafe(thn)
|
processConfigStatementsSafe(thn)
|
||||||
} else {
|
} else {
|
||||||
BdLib.logInfo("Condition %s - FALSE", cnd)
|
BdLib.logDebug("Condition %s - FALSE", cnd)
|
||||||
processConfigStatementsSafe(els)
|
processConfigStatementsSafe(els)
|
||||||
}
|
}
|
||||||
|
|
||||||
case CsClearRecipes(res) =>
|
case CsClearRecipes(res) =>
|
||||||
BdLib.logInfo("Clearing recipes that produce %s", res)
|
BdLib.logDebug("Clearing recipes that produce %s", res)
|
||||||
recipeStatements = clearStatements(recipeStatements, res)
|
recipeStatements = clearStatements(recipeStatements, res)
|
||||||
|
|
||||||
case CsRecipeBlock(lst) =>
|
case CsRecipeBlock(lst) =>
|
||||||
@@ -273,19 +273,19 @@ class RecipeLoader {
|
|||||||
def processRecipeStatement(st: RecipeStatement) = st match {
|
def processRecipeStatement(st: RecipeStatement) = st match {
|
||||||
case RsCharAssign(c, r) =>
|
case RsCharAssign(c, r) =>
|
||||||
currCharMap += (c -> r)
|
currCharMap += (c -> r)
|
||||||
BdLib.logInfo("Added %s = %s", c, r)
|
BdLib.logDebug("Added %s = %s", c, r)
|
||||||
|
|
||||||
case RsClassMacro(id, cls) =>
|
case RsClassMacro(id, cls) =>
|
||||||
currClassMacros += (id -> cls)
|
currClassMacros += (id -> cls)
|
||||||
BdLib.logInfo("Added def %s = %s", id, cls)
|
BdLib.logDebug("Added def %s = %s", id, cls)
|
||||||
|
|
||||||
case RsRecipeShaped(rec, res, cnt) =>
|
case RsRecipeShaped(rec, res, cnt) =>
|
||||||
BdLib.logInfo("Adding shaped recipe %s => %s * %d", rec, res, cnt)
|
BdLib.logDebug("Adding shaped recipe %s => %s * %d", rec, res, cnt)
|
||||||
val (comp, needOd) = resolveRecipeComponents(rec.mkString(""))
|
val (comp, needOd) = resolveRecipeComponents(rec.mkString(""))
|
||||||
val resStack = getConcreteStack(res, cnt)
|
val resStack = getConcreteStack(res, cnt)
|
||||||
|
|
||||||
if (resStack.getItemDamage == OreDictionary.WILDCARD_VALUE) {
|
if (resStack.getItemDamage == OreDictionary.WILDCARD_VALUE) {
|
||||||
BdLib.logInfo("Result meta is unset, defaulting to 0")
|
BdLib.logDebug("Result meta is unset, defaulting to 0")
|
||||||
resStack.setItemDamage(0)
|
resStack.setItemDamage(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,16 +294,16 @@ class RecipeLoader {
|
|||||||
else
|
else
|
||||||
Misc.addRecipe(resStack, rec, comp)
|
Misc.addRecipe(resStack, rec, comp)
|
||||||
|
|
||||||
BdLib.logInfo("Done... result=%s, od=%s", resStack, needOd)
|
BdLib.logDebug("Done... result=%s, od=%s", resStack, needOd)
|
||||||
|
|
||||||
case RsRecipeShapeless(rec, res, cnt) =>
|
case RsRecipeShapeless(rec, res, cnt) =>
|
||||||
BdLib.logInfo("Adding shapeless recipe %s => %s * %d", rec, res, cnt)
|
BdLib.logDebug("Adding shapeless recipe %s => %s * %d", rec, res, cnt)
|
||||||
val (comp, needOd) = resolveRecipeComponents(rec)
|
val (comp, needOd) = resolveRecipeComponents(rec)
|
||||||
val resStack = getConcreteStack(res, cnt)
|
val resStack = getConcreteStack(res, cnt)
|
||||||
val recTrans = rec.toCharArray.map(comp(_))
|
val recTrans = rec.toCharArray.map(comp(_))
|
||||||
|
|
||||||
if (resStack.getItemDamage == OreDictionary.WILDCARD_VALUE) {
|
if (resStack.getItemDamage == OreDictionary.WILDCARD_VALUE) {
|
||||||
BdLib.logInfo("Result meta is unset, defaulting to 0")
|
BdLib.logDebug("Result meta is unset, defaulting to 0")
|
||||||
resStack.setItemDamage(0)
|
resStack.setItemDamage(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,26 +312,26 @@ class RecipeLoader {
|
|||||||
else
|
else
|
||||||
GameRegistry.addShapelessRecipe(resStack, recTrans: _*)
|
GameRegistry.addShapelessRecipe(resStack, recTrans: _*)
|
||||||
|
|
||||||
BdLib.logInfo("Done... result=%s, od=%s", resStack, needOd)
|
BdLib.logDebug("Done... result=%s, od=%s", resStack, needOd)
|
||||||
|
|
||||||
case RsRecipeSmelting(in, out, cnt, xp) =>
|
case RsRecipeSmelting(in, out, cnt, xp) =>
|
||||||
BdLib.logInfo("Adding smelting recipe %s => %s * %d (%f xp)", in, out, cnt, xp)
|
BdLib.logDebug("Adding smelting recipe %s => %s * %d (%f xp)", in, out, cnt, xp)
|
||||||
val outStack = getConcreteStack(out, cnt)
|
val outStack = getConcreteStack(out, cnt)
|
||||||
if (outStack.getItemDamage == OreDictionary.WILDCARD_VALUE) {
|
if (outStack.getItemDamage == OreDictionary.WILDCARD_VALUE) {
|
||||||
BdLib.logInfo("Result meta is unset, defaulting to 0")
|
BdLib.logDebug("Result meta is unset, defaulting to 0")
|
||||||
outStack.setItemDamage(0)
|
outStack.setItemDamage(0)
|
||||||
}
|
}
|
||||||
for (inStack <- getAllConcreteStacks(in, 1)) {
|
for (inStack <- getAllConcreteStacks(in, 1)) {
|
||||||
GameRegistry.addSmelting(inStack, outStack, xp)
|
GameRegistry.addSmelting(inStack, outStack, xp)
|
||||||
BdLib.logInfo("added %s -> %s", inStack, outStack)
|
BdLib.logDebug("added %s -> %s", inStack, outStack)
|
||||||
}
|
}
|
||||||
|
|
||||||
case RsConditional(cnd, thn, els) =>
|
case RsConditional(cnd, thn, els) =>
|
||||||
if (resolveCondition(cnd)) {
|
if (resolveCondition(cnd)) {
|
||||||
BdLib.logInfo("Condition %s - TRUE", cnd)
|
BdLib.logDebug("Condition %s - TRUE", cnd)
|
||||||
processRecipeStatementsInSubcontext(thn)
|
processRecipeStatementsInSubcontext(thn)
|
||||||
} else {
|
} else {
|
||||||
BdLib.logInfo("Condition %s - FALSE", cnd)
|
BdLib.logDebug("Condition %s - FALSE", cnd)
|
||||||
processRecipeStatementsInSubcontext(els)
|
processRecipeStatementsInSubcontext(els)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,13 +339,13 @@ class RecipeLoader {
|
|||||||
processRecipeStatementsInSubcontext(list)
|
processRecipeStatementsInSubcontext(list)
|
||||||
|
|
||||||
case RsRegOredict(id, spec, wildcard) =>
|
case RsRegOredict(id, spec, wildcard) =>
|
||||||
BdLib.logInfo("Registering ore dictionary entry: %s -> %s", spec, id)
|
BdLib.logDebug("Registering ore dictionary entry: %s -> %s", spec, id)
|
||||||
val stack = getConcreteStack(spec)
|
val stack = getConcreteStack(spec)
|
||||||
if (wildcard) {
|
if (wildcard) {
|
||||||
BdLib.logInfo("Forcing wildcard damage (was %d)", stack.getItemDamage)
|
BdLib.logDebug("Forcing wildcard damage (was %d)", stack.getItemDamage)
|
||||||
stack.setItemDamage(OreDictionary.WILDCARD_VALUE)
|
stack.setItemDamage(OreDictionary.WILDCARD_VALUE)
|
||||||
}
|
}
|
||||||
BdLib.logInfo("Actual stack: %s", stack)
|
BdLib.logDebug("Actual stack: %s", stack)
|
||||||
OreDictionary.registerOre(id, stack)
|
OreDictionary.registerOre(id, stack)
|
||||||
|
|
||||||
case x =>
|
case x =>
|
||||||
@@ -371,7 +371,7 @@ class RecipeLoader {
|
|||||||
* Process main recipe statements list, clear the list afterwards
|
* Process main recipe statements list, clear the list afterwards
|
||||||
*/
|
*/
|
||||||
def processRecipeStatements() {
|
def processRecipeStatements() {
|
||||||
BdLib.logInfo("Processing %d recipe statements", recipeStatements.size)
|
BdLib.logDebug("Processing %d recipe statements", recipeStatements.size)
|
||||||
processRecipeStatementsSafe(recipeStatements)
|
processRecipeStatementsSafe(recipeStatements)
|
||||||
recipeStatements = List.empty
|
recipeStatements = List.empty
|
||||||
}
|
}
|
||||||
@@ -411,10 +411,10 @@ class RecipeLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def load(f: Reader) {
|
def load(f: Reader) {
|
||||||
BdLib.logInfo("Starting parsing")
|
BdLib.logDebug("Starting parsing")
|
||||||
val r = newParser().doParse(f)
|
val r = newParser().doParse(f)
|
||||||
BdLib.logInfo("Processing %d statements", r.size)
|
BdLib.logDebug("Processing %d statements", r.size)
|
||||||
processConfigStatementsSafe(r)
|
processConfigStatementsSafe(r)
|
||||||
BdLib.logInfo("Done")
|
BdLib.logDebug("Done")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ trait GenericConfigLoader extends RecipeLoader {
|
|||||||
|
|
||||||
def processConfigStatement(section: ConfigSection, s: CfgEntry): Unit = s match {
|
def processConfigStatement(section: ConfigSection, s: CfgEntry): Unit = s match {
|
||||||
case CfgVal(id, v) =>
|
case CfgVal(id, v) =>
|
||||||
BdLib.logInfo("Config: %s%s = %s", section.pfx, id, v)
|
BdLib.logDebug("Config: %s%s = %s", section.pfx, id, v)
|
||||||
section.set(id, v)
|
section.set(id, v)
|
||||||
case CfgSection(id, st) => processConfigBlock(section.getOrAddSection(id), st)
|
case CfgSection(id, st) => processConfigBlock(section.getOrAddSection(id), st)
|
||||||
case x =>
|
case x =>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ trait LootListLoader extends GenericConfigLoader {
|
|||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
if (itemStack.getItemDamage == OreDictionary.WILDCARD_VALUE) {
|
if (itemStack.getItemDamage == OreDictionary.WILDCARD_VALUE) {
|
||||||
BdLib.logInfo("meta/damage is unset in %s, defaulting to 0", ref)
|
BdLib.logDebug("meta/damage is unset in %s, defaulting to 0", ref)
|
||||||
itemStack.setItemDamage(0)
|
itemStack.setItemDamage(0)
|
||||||
}
|
}
|
||||||
Some((chance, itemStack))
|
Some((chance, itemStack))
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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.resource
|
||||||
|
|
||||||
|
import net.bdew.lib.Misc
|
||||||
|
import net.bdew.lib.data.DataSlotOption
|
||||||
|
import net.bdew.lib.data.base.{TileDataSlots, UpdateKind}
|
||||||
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
|
|
||||||
|
case class DataSlotResourceKindOption(name: String, parent: TileDataSlots) extends DataSlotOption[ResourceKind] {
|
||||||
|
setUpdate(UpdateKind.SAVE, UpdateKind.GUI)
|
||||||
|
|
||||||
|
override def save(t: NBTTagCompound, kind: UpdateKind.Value) {
|
||||||
|
value map { r =>
|
||||||
|
t.setTag(name,
|
||||||
|
Misc.applyMutator(new NBTTagCompound) { tag =>
|
||||||
|
r.helperObject.saveToNBT(tag, r)
|
||||||
|
tag.setString("kind", r.helperObject.id)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override def load(t: NBTTagCompound, kind: UpdateKind.Value) {
|
||||||
|
if (t.hasKey(name)) {
|
||||||
|
val tag = t.getCompoundTag(name)
|
||||||
|
value = if (tag.hasKey("kind")) {
|
||||||
|
ResourceManager.resourceHelpers.get(tag.getString("kind")).flatMap(_.loadFromNBT(tag))
|
||||||
|
} else None
|
||||||
|
} else unset()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user