Compare commits

...
17 Commits
Author SHA1 Message Date
bdew 6a78467232 Fixed DataSlotResource.drainFluid draining 2x (bdew/generators#21) 2015-02-09 00:21:38 +02:00
bdew 561833db33 Refactored SlotSet to prevent textures being initialized on dedicated servers (bdew/generators#23) 2015-02-08 23:39:37 +02:00
bdew 0e345e6675 Added DecFormat.short 2015-02-05 00:52:42 +02:00
bdew e78e565ec8 Less retarded way to prevent duplicate class files in deobf 2015-02-04 21:57:52 +02:00
bdew 573330efd3 Prevent leftover fractional resources due to FP rounding errors 2015-02-04 20:27:51 +02:00
bdew 5e7c8bda2f attempt to de-derpify unobfuscated jars 2015-01-05 16:03:05 +02:00
bdew 9346d95052 Huge typos and code style cleanup 2014-12-23 17:54:59 +02:00
bdew f0169a15e5 updated copyright header and minor cleanup 2014-12-23 14:41:32 +02:00
bdew 1da90af3f1 Added multiblock stuff for item output and slot selection 2014-12-23 14:34:54 +02:00
bdew b015636514 Added InventoryProxy and MultipleInventoryAdapter 2014-12-23 14:29:13 +02:00
bdew 610be18c74 Added resource system 2014-12-23 14:27:21 +02:00
bdew 9c977904ab Added hack to the gradle script to prevent IDEA14 from derping 2014-12-18 16:43:11 +02:00
bdew cc107d7466 Version bump 2014-12-18 11:26:55 +02:00
bdew 4284f11ec4 Added DataSlotDouble 2014-12-18 11:26:25 +02:00
bdew 300726e660 reworked OutputConfig &co to be easier to extend 2014-12-18 11:26:12 +02:00
bdew 02850b9f85 added DecFormat, some cleanup 2014-12-18 11:20:18 +02:00
bdew 1618931c6d Allow fluid gauge to have no overlay, fixed typo 2014-11-05 16:29:59 +02:00
158 changed files with 1026 additions and 375 deletions

No files matched your search

+3 -1
View File
@@ -21,7 +21,7 @@ buildscript {
apply plugin: 'scala'
apply plugin: 'forge'
version = "1.5.1"
version = "1.6.2"
if (project.hasProperty('buildnum')) {
project.version = project.version + '.' + project.buildnum
@@ -49,6 +49,7 @@ sourceSets {
resources {
srcDir 'resources'
}
output.resourcesDir = output.classesDir // Hack for IDEA
}
}
@@ -70,6 +71,7 @@ task sourceJar(type: Jar) {
task deobfJar(type: Jar) {
from sourceSets.main.output
duplicatesStrategy "exclude"
}
jar {
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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
+3 -3
View File
@@ -4,7 +4,7 @@
*
* 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
@@ -14,11 +14,11 @@ import net.minecraft.client.renderer.texture.TextureMap
import org.lwjgl.input.Keyboard
/**
* Misc functions and shortcuts for clientside code
* Misc functions and shortcuts for client-side code
*/
object Client {
def minecraft = Minecraft.getMinecraft
def fontRenederer = Minecraft.getMinecraft.fontRenderer
def fontRenderer = Minecraft.getMinecraft.fontRenderer
def renderEngine = Minecraft.getMinecraft.renderEngine
def world = Minecraft.getMinecraft.theWorld
def player = Minecraft.getMinecraft.thePlayer
+2 -2
View File
@@ -4,7 +4,7 @@
*
* 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
@@ -22,7 +22,7 @@ import net.minecraftforge.oredict.OreDictionary
class CommandDumpRegistry extends CommandBase {
def getCommandName = "dumpregistry"
override def getRequiredPermissionLevel = 2
def getCommandUsage(icommandsender: ICommandSender) = "dumpregistry"
def getCommandUsage(c: ICommandSender) = "dumpregistry"
def processCommand(sender: ICommandSender, params: Array[String]) {
val mcHome = FMLInjectionData.data()(6).asInstanceOf[File] //is there a better way to get this?
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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
+30
View File
@@ -0,0 +1,30 @@
/*
* 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
import java.text.DecimalFormat
object DecFormat {
val thousandsFmt = new DecimalFormat("#,##0")
val dec2Fmt = new DecimalFormat("#,##0.00")
val dec1Fmt = new DecimalFormat("#,##0.0")
def round(x: Double) = thousandsFmt.format(x)
def round(x: Float) = thousandsFmt.format(x)
def round(x: Int) = thousandsFmt.format(x)
def dec2(x: Double) = dec2Fmt.format(x)
def dec2(x: Float) = dec2Fmt.format(x)
def dec2(x: Int) = dec2Fmt.format(x)
def short(x: Double) = if (x > 10) thousandsFmt.format(x) else if (x > 1) dec1Fmt.format(x) else dec2Fmt.format(x)
def short(x: Float) = if (x > 10) thousandsFmt.format(x) else if (x > 1) dec1Fmt.format(x) else dec2Fmt.format(x)
def short(x: Int) = if (x > 10) thousandsFmt.format(x) else if (x > 1) dec1Fmt.format(x) else dec2Fmt.format(x)
}
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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
+12 -7
View File
@@ -4,7 +4,7 @@
*
* 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
@@ -55,8 +55,8 @@ object Misc {
def addRecipeOD(result: ItemStack, pattern: Seq[String], items: Map[Char, AnyRef]) =
GameRegistry.addRecipe(new ShapedOreRecipe(result, flattenRecipe(pattern, items): _*))
def min[T](vals: T*)(implicit o: Ordering[T]): T = vals.min(o)
def max[T](vals: T*)(implicit o: Ordering[T]): T = vals.max(o)
def min[T: Ordering](values: T*) = values.min
def max[T: Ordering](values: T*) = values.max
def clamp[T](value: T, min: T, max: T)(implicit o: Ordering[T]): T = if (o.gt(value, max)) max else if (o.lt(value, min)) min else value
@@ -69,11 +69,11 @@ object Misc {
def haveModVersion(spec: String): Boolean = {
val req = VersionParser.parseVersionReference(spec)
val modid = req.getLabel
val modId = req.getLabel
if (!Loader.instance.getIndexedModList.containsKey(modid)) return false
if (!Loader.instance.getIndexedModList.containsKey(modId)) return false
val found: ArtifactVersion = Loader.instance.getIndexedModList.get(modid).getProcessedVersion
val found: ArtifactVersion = Loader.instance.getIndexedModList.get(modId).getProcessedVersion
if (found == null || !req.containsVersion(found)) return false
@@ -95,7 +95,12 @@ object Misc {
Option(origin.getWorldObj.getTileEntity(origin.xCoord + dir.offsetX,
origin.yCoord + dir.offsetY, origin.zCoord + dir.offsetZ)) flatMap (asInstanceOpt(_, cls))
def applyMutator[T](f: (T) => Unit, init: T): T = {
@inline def applyMutator[T](f: (T) => Unit, init: T): T = {
f(init)
init
}
@inline def applyMutator[T](init: T)(f: (T) => Unit) = {
f(init)
init
}
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.block
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.block
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.block
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.block
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.config
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.config
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.config
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.config
+7 -7
View File
@@ -4,7 +4,7 @@
*
* 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.covers
@@ -23,12 +23,12 @@ trait BlockCoverable[T <: TileCoverable] extends HasTE[T] {
@SideOnly(Side.CLIENT)
override def getRenderType = CoverRenderer.id
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, face: Int, xoffs: Float, yoffs: Float, zoffs: Float): Boolean = {
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, face: Int, xOffs: Float, yOffs: Float, zOffs: Float): Boolean = {
val te = getTE(world, x, y, z)
val side = Misc.forgeDirection(face)
if (player.getCurrentEquippedItem == null && player.isSneaking) {
for (cover <- Option(te.covers(side).cval)) {
for (cover <- Option(te.covers(side).value)) {
if (!world.isRemote) {
te.covers(side) := null
te.onCoversChanged()
@@ -45,7 +45,7 @@ trait BlockCoverable[T <: TileCoverable] extends HasTE[T] {
if te.isValidCover(side, activeStack) && coverItem.isValidTile(te, activeStack)
} {
if (!world.isRemote) {
for (cover <- Option(te.covers(side).cval))
for (cover <- Option(te.covers(side).value))
ItemUtils.throwItemAt(world, te.xCoord + side.offsetX, te.yCoord + side.offsetY, te.zCoord + side.offsetZ, cover.copy())
te.covers(side) := activeStack.splitStack(1)
@@ -56,19 +56,19 @@ trait BlockCoverable[T <: TileCoverable] extends HasTE[T] {
return true
}
super.onBlockActivated(world, x, y, z, player, face, xoffs, yoffs, zoffs)
super.onBlockActivated(world, x, y, z, player, face, xOffs, yOffs, zOffs)
}
def getCoverIcon(w: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection): Option[IIcon] =
for {
coverStack <- Option(getTE(w, x, y, z).covers(side).cval)
coverStack <- Option(getTE(w, x, y, z).covers(side).value)
coverItemMaybe <- Option(coverStack.getItem)
coverItem <- Misc.asInstanceOpt(coverItemMaybe, classOf[ItemCover])
} yield coverItem.getCoverIcon(coverStack)
override def breakBlock(world: World, x: Int, y: Int, z: Int, block: Block, meta: Int) {
if (!world.isRemote)
for ((dir, covOpt) <- getTE(world, x, y, z).covers; cover <- Option(covOpt.cval))
for ((dir, covOpt) <- getTE(world, x, y, z).covers; cover <- Option(covOpt.value))
ItemUtils.throwItemAt(world, x, y, z, cover)
super.breakBlock(world, x, y, z, block, meta)
}
+2 -2
View File
@@ -4,7 +4,7 @@
*
* 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.covers
@@ -15,7 +15,7 @@ import net.minecraftforge.common.util.ForgeDirection
trait ItemCover extends Item {
/**
* @return Icon to render, MUST be on terrain spritesheet (0), not item!
* @return Icon to render, MUST be on terrain sprite sheet (0), not item!
*/
def getCoverIcon(stack: ItemStack): IIcon
+2 -2
View File
@@ -4,7 +4,7 @@
*
* 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.covers
@@ -33,7 +33,7 @@ trait TileCoverable extends TileDataSlots {
def tickCovers() =
for {
(dir, coverSlot) <- covers
coverStack <- Option(coverSlot.cval)
coverStack <- Option(coverSlot.value)
coverItem <- Option(coverStack.getItem) flatMap (Misc.asInstanceOpt(_, classOf[ItemCover]))
} {
coverItem.tickCover(this, dir, coverStack)
+4 -4
View File
@@ -4,7 +4,7 @@
*
* 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.data
@@ -13,7 +13,7 @@ import net.bdew.lib.data.base.{DataSlotVal, TileDataSlots, UpdateKind}
import net.minecraft.nbt.NBTTagCompound
case class DataSlotBoolean(name: String, parent: TileDataSlots, default: Boolean = false) extends DataSlotVal[Boolean] {
var cval = default
def save(t: NBTTagCompound, kind: UpdateKind.Value) = t.setBoolean(name, cval)
def load(t: NBTTagCompound, kind: UpdateKind.Value) = cval = t.getBoolean(name)
var value = default
def save(t: NBTTagCompound, kind: UpdateKind.Value) = t.setBoolean(name, value)
def load(t: NBTTagCompound, kind: UpdateKind.Value) = value = t.getBoolean(name)
}
@@ -4,7 +4,7 @@
*
* 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.data
@@ -14,7 +14,7 @@ import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.ForgeDirection
case class DataSlotDirection(name: String, parent: TileDataSlots) extends DataSlotVal[ForgeDirection] {
var cval = ForgeDirection.UP
def save(t: NBTTagCompound, kind: UpdateKind.Value) = t.setByte(name, cval.ordinal().toByte)
def load(t: NBTTagCompound, kind: UpdateKind.Value) = cval = ForgeDirection.getOrientation(t.getByte(name))
var value = ForgeDirection.UP
def save(t: NBTTagCompound, kind: UpdateKind.Value) = t.setByte(name, value.ordinal().toByte)
def load(t: NBTTagCompound, kind: UpdateKind.Value) = value = ForgeDirection.getOrientation(t.getByte(name))
}
@@ -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.data
import net.bdew.lib.data.base.{DataSlotNumeric, TileDataSlots, UpdateKind}
import net.minecraft.nbt.NBTTagCompound
case class DataSlotDouble(name: String, parent: TileDataSlots, default: Double = 0) extends DataSlotNumeric[Double](default) {
def save(t: NBTTagCompound, kind: UpdateKind.Value) = t.setDouble(name, value)
def load(t: NBTTagCompound, kind: UpdateKind.Value) = value = t.getDouble(name)
}
+3 -3
View File
@@ -4,7 +4,7 @@
*
* 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.data
@@ -13,6 +13,6 @@ import net.bdew.lib.data.base.{DataSlotNumeric, TileDataSlots, UpdateKind}
import net.minecraft.nbt.NBTTagCompound
case class DataSlotFloat(name: String, parent: TileDataSlots, default: Float = 0) extends DataSlotNumeric[Float](default) {
def save(t: NBTTagCompound, kind: UpdateKind.Value) = t.setFloat(name, cval)
def load(t: NBTTagCompound, kind: UpdateKind.Value) = cval = t.getFloat(name)
def save(t: NBTTagCompound, kind: UpdateKind.Value) = t.setFloat(name, value)
def load(t: NBTTagCompound, kind: UpdateKind.Value) = value = t.getFloat(name)
}
@@ -4,7 +4,7 @@
*
* 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.data
@@ -17,20 +17,20 @@ import net.minecraft.nbt.NBTTagCompound
import org.apache.commons.lang3.StringUtils
case class DataSlotGameProfile(name: String, parent: TileDataSlots) extends DataSlotVal[GameProfile] {
override var cval: GameProfile = null
override var value: GameProfile = null
override def load(t: NBTTagCompound, kind: UpdateKind.Value) = {
cval = if (t.hasKey(name + "_uid") || t.hasKey(name + "_name")) {
val uid = if (t.hasKey(name + "_uid")) UUID.fromString(t.getString(name + "_uid")) else null
val uname = if (t.hasKey(name + "_name")) t.getString(name + "_name") else null
new GameProfile(uid, uname)
value = if (t.hasKey(name + "_uid") || t.hasKey(name + "_name")) {
val uId = if (t.hasKey(name + "_uid")) UUID.fromString(t.getString(name + "_uid")) else null
val uName = if (t.hasKey(name + "_name")) t.getString(name + "_name") else null
new GameProfile(uId, uName)
} else null
}
override def save(t: NBTTagCompound, kind: UpdateKind.Value) = {
if (cval != null) {
Option(cval.getId) map (id => t.setString(name + "_uid", id.toString))
Option(cval.getName) filterNot (name => StringUtils.isBlank(name)) map (name => t.setString(name + "_name", name))
if (value != null) {
Option(value.getId) map (id => t.setString(name + "_uid", id.toString))
Option(value.getName) filterNot (name => StringUtils.isBlank(name)) map (name => t.setString(name + "_name", name))
}
}
}
+3 -3
View File
@@ -4,7 +4,7 @@
*
* 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.data
@@ -13,6 +13,6 @@ import net.bdew.lib.data.base.{DataSlotNumeric, TileDataSlots, UpdateKind}
import net.minecraft.nbt.NBTTagCompound
case class DataSlotInt(name: String, parent: TileDataSlots, default: Int = 0) extends DataSlotNumeric[Int](default) {
def save(t: NBTTagCompound, kind: UpdateKind.Value) = t.setInteger(name, cval)
def load(t: NBTTagCompound, kind: UpdateKind.Value) = cval = t.getInteger(name)
def save(t: NBTTagCompound, kind: UpdateKind.Value) = t.setInteger(name, value)
def load(t: NBTTagCompound, kind: UpdateKind.Value) = value = t.getInteger(name)
}
@@ -4,7 +4,7 @@
*
* 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.data
@@ -14,19 +14,19 @@ import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
case class DataSlotItemStack(name: String, parent: TileDataSlots) extends DataSlotVal[ItemStack] {
var cval: ItemStack = null
var value: ItemStack = null
override def update(v: ItemStack) = {
if (!ItemStack.areItemStacksEqual(v, cval)) {
cval = if (v == null) null else v.copy()
if (!ItemStack.areItemStacksEqual(v, value)) {
value = if (v == null) null else v.copy()
parent.dataSlotChanged(this)
}
}
def save(t: NBTTagCompound, kind: UpdateKind.Value) = {
val tag = new NBTTagCompound()
if (cval != null) cval.writeToNBT(tag)
if (value != null) value.writeToNBT(tag)
t.setTag(name, tag)
}
def load(t: NBTTagCompound, kind: UpdateKind.Value) = cval = ItemStack.loadItemStackFromNBT(t.getCompoundTag(name))
def load(t: NBTTagCompound, kind: UpdateKind.Value) = value = ItemStack.loadItemStackFromNBT(t.getCompoundTag(name))
}
+4 -4
View File
@@ -4,7 +4,7 @@
*
* 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.data
@@ -12,15 +12,15 @@ package net.bdew.lib.data
import net.bdew.lib.data.base.DataSlotVal
abstract class DataSlotOption[T] extends DataSlotVal[Option[T]] {
override var cval: Option[T] = None
override var value: Option[T] = None
def set(v: T) {
if (v == null) sys.error("Null should never be used with DataSlotOption")
cval = Some(v)
value = Some(v)
}
def unset() {
cval = None
value = None
}
override def isSame(v: Option[T]) = {
+4 -4
View File
@@ -4,7 +4,7 @@
*
* 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.data
@@ -13,7 +13,7 @@ import net.bdew.lib.data.base.{DataSlotVal, TileDataSlots, UpdateKind}
import net.minecraft.nbt.NBTTagCompound
case class DataSlotString(name: String, parent: TileDataSlots, default: String = null) extends DataSlotVal[String] {
var cval: String = default
def save(t: NBTTagCompound, kind: UpdateKind.Value) = if (cval != null) t.setString(name, cval)
def load(t: NBTTagCompound, kind: UpdateKind.Value) = cval = if (t.hasKey(name)) t.getString(name) else null
var value: String = default
def save(t: NBTTagCompound, kind: UpdateKind.Value) = if (value != null) t.setString(name, value)
def load(t: NBTTagCompound, kind: UpdateKind.Value) = value = if (t.hasKey(name)) t.getString(name) else null
}
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.data
@@ -4,7 +4,7 @@
*
* 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.data.base
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.data.base
@@ -4,19 +4,19 @@
*
* 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.data.base
/**
* Base class for data slots that hold numeric values
* adds convinience operators to modify the value
* adds convenience operators to modify the value
*/
abstract class DataSlotNumeric[T](default: T)(implicit n: Numeric[T]) extends DataSlotVal[T] {
var cval = default
def +=(that: T) = update(n.plus(cval, that))
def -=(that: T) = update(n.minus(cval, that))
def *=(that: T) = update(n.times(cval, that))
var value = default
def +=(that: T) = update(n.plus(value, that))
def -=(that: T) = update(n.minus(value, that))
def *=(that: T) = update(n.times(value, that))
}
@@ -4,18 +4,18 @@
*
* 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.data.base
/**
* Base class for data slots that hold values with ordering operators, adds more convinience operators
* Base class for data slots that hold values with ordering operators, adds more convenience operators
* TODO: Do i need this? normal operators can be used with the implicit conversion
*/
abstract class DataSlotOrdered[T](implicit n: Ordering[T]) extends DataSlotVal[T] {
def :>(that: T) = n.compare(cval, that) > 0
def :<(that: T) = n.compare(cval, that) < 0
def :>=(that: T) = n.compare(cval, that) >= 0
def :<=(that: T) = n.compare(cval, that) <= 0
def :>(that: T) = n.compare(value, that) > 0
def :<(that: T) = n.compare(value, that) < 0
def :>=(that: T) = n.compare(value, that) >= 0
def :<=(that: T) = n.compare(value, that) <= 0
}
+8 -8
View File
@@ -4,7 +4,7 @@
*
* 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.data.base
@@ -13,27 +13,27 @@ import scala.language.implicitConversions
/**
* Base trait for data slots that hold primitive values
* Defines some convinience operators to access the value and an implicit conversion to the value
* Defines some convenience operators to access the value and an implicit conversion to the value
*/
trait DataSlotVal[T] extends DataSlot {
var cval: T
var value: T
def isSame(v: T) = v == cval
def isSame(v: T) = v == value
def :=(that: T) = update(that)
def :!=(that: T) = cval != that
def :==(that: T) = cval == that
def :!=(that: T) = value != that
def :==(that: T) = value == that
def update(v: T) {
if (!isSame(v)) {
cval = v
value = v
parent.dataSlotChanged(this)
}
}
}
object DataSlotVal {
implicit def slot2val[T](slot: DataSlotVal[T]): T = slot.cval
implicit def slot2val[T](slot: DataSlotVal[T]): T = slot.value
}
@@ -4,7 +4,7 @@
*
* 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.data.base
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.data.base
+3 -1
View File
@@ -4,7 +4,7 @@
*
* 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.gui
@@ -28,5 +28,7 @@ abstract class BaseContainer(te: IInventory) extends NoInvContainer {
getSlot(slot).putStack(stack)
return null
}
override def canInteractWith(player: EntityPlayer) = te.isUseableByPlayer(player)
}
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.gui
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.gui
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.gui
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.gui
+3 -3
View File
@@ -4,7 +4,7 @@
*
* 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.gui
@@ -44,6 +44,6 @@ object Color {
final val magenta = Color(1, 0, 1)
final val gray = Color(0.5F, 0.5F, 0.5F)
final val lightgray = Color(0.75F, 0.75F, 0.75F)
final val darkgray = Color(0.25F, 0.25F, 0.25F)
final val lightGray = Color(0.75F, 0.75F, 0.75F)
final val darkGray = Color(0.25F, 0.25F, 0.25F)
}
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.gui
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.gui
+7 -7
View File
@@ -4,7 +4,7 @@
*
* 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.gui
@@ -16,17 +16,17 @@ import net.minecraft.world.World
import scala.collection.mutable
class GuiHandler extends IGuiHandler {
val guis = mutable.Map.empty[Int, GuiProvider]
val GUIs = mutable.Map.empty[Int, GuiProvider]
def register(p: GuiProvider) = {
if (guis.isDefinedAt(p.guiId))
sys.error("GUI ID Collision - %d was registered for %s and attemted to register by %s".format(p.guiId, guis(p.guiId), p))
guis += (p.guiId -> p)
if (GUIs.isDefinedAt(p.guiId))
sys.error("GUI ID Collision - %d was registered for %s and attempted to register by %s".format(p.guiId, GUIs(p.guiId), p))
GUIs += (p.guiId -> p)
}
def getServerGuiElement(ID: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int): AnyRef =
guis(ID).getContainer(world.getTileEntity(x, y, z), player)
GUIs(ID).getContainer(world.getTileEntity(x, y, z), player)
def getClientGuiElement(ID: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int): AnyRef =
guis(ID).getGui(world.getTileEntity(x, y, z), player)
GUIs(ID).getGui(world.getTileEntity(x, y, z), player)
}
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.gui
+5 -5
View File
@@ -4,7 +4,7 @@
*
* 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.gui
@@ -28,13 +28,13 @@ abstract class NoInvContainer extends Container {
addSlotToContainer(new Slot(inv, i, xOffs + i * 18, yOffsHotbar))
}
override def slotClick(slotnum: Int, button: Int, modifiers: Int, player: EntityPlayer): ItemStack = {
if (inventorySlots.isDefinedAt(slotnum)) {
val slot = getSlot(slotnum)
override def slotClick(slotNum: Int, button: Int, modifiers: Int, player: EntityPlayer): ItemStack = {
if (inventorySlots.isDefinedAt(slotNum)) {
val slot = getSlot(slotNum)
if (slot != null && slot.isInstanceOf[SlotClickable])
return slot.asInstanceOf[SlotClickable].onClick(button, modifiers, player)
}
return super.slotClick(slotnum, button, modifiers, player)
return super.slotClick(slotNum, button, modifiers, player)
}
override def transferStackInSlot(player: EntityPlayer, slot: Int): ItemStack = null
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.gui
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.gui
+4 -4
View File
@@ -4,7 +4,7 @@
*
* 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.gui
@@ -30,12 +30,12 @@ class InterpolatedTexture(val texture: Texture, rect: Rect) extends Texture {
def v2 = rect.y2 * (texture.v2 - texture.v1) + texture.v1
}
class IconWrapper(val resource: ResourceLocation, picon: IIcon) extends Texture {
val icon = if (picon == null) {
class IconWrapper(val resource: ResourceLocation, aIcon: IIcon) extends Texture {
val icon = if (aIcon == null) {
if (resource == Texture.ITEMS) Client.itemMissingIcon
else if (resource == Texture.BLOCKS) Client.blockMissingIcon
else sys.error("Attempt to create IconWrapper for null IIcon")
} else picon
} else aIcon
def u1 = icon.getMinU
def u2 = icon.getMaxU
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.gui
+9 -5
View File
@@ -4,7 +4,7 @@
*
* 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
@@ -15,13 +15,17 @@ package object gui {
import scala.language.implicitConversions
implicit def awt2point(p: java.awt.Point) = BasePoint(p.x, p.y)
implicit def awt2point(p: java.awt.Point): BasePoint[Int] = BasePoint(p.x, p.y)
implicit def point2awt(p: BasePoint[Int]): java.awt.Point = new java.awt.Point(p.x, p.y)
implicit def tuple2point[T: Numeric](p: (T, T)) = BasePoint(p._1, p._2)
implicit def tuple2point[T: Numeric](p: (T, T)): BasePoint[T] = BasePoint(p._1, p._2)
// Converts different kinds of Point/Rect as long as there's an implicit for the underlying type
implicit def pointconvert[T, R](a: BasePoint[R])(implicit f: R => T, n: Numeric[T]) = BasePoint[T](f(a.x), f(a.y))
implicit def rectconvert[T, R](a: BaseRect[R])(implicit f: R => T, n: Numeric[T]) = BaseRect[T](f(a.x), f(a.y), f(a.w), f(a.h))
implicit def pointConvert[T, R](a: BasePoint[R])(implicit f: R => T, n: Numeric[T]): BasePoint[T] =
BasePoint[T](f(a.x), f(a.y))
implicit def rectConvert[T, R](a: BaseRect[R])(implicit f: R => T, n: Numeric[T]): BaseRect[T] =
BaseRect[T](f(a.x), f(a.y), f(a.w), f(a.h))
def Rect(x: Float, y: Float, w: Float, h: Float) = BaseRect(x, y, w, h)
def Point(x: Float, y: Float) = BasePoint(x, y)
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.gui.widgets
@@ -4,7 +4,7 @@
*
* 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.gui.widgets
@@ -4,7 +4,7 @@
*
* 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.gui.widgets
@@ -4,7 +4,7 @@
*
* 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.gui.widgets
@@ -4,7 +4,7 @@
*
* 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.gui.widgets
@@ -12,12 +12,12 @@ package net.bdew.lib.gui.widgets
import net.bdew.lib.data.base.DataSlotNumeric
import net.bdew.lib.gui._
class WidgetFillDataslot[T](val rect: Rect, val texture: Texture, dir: Direction.Direction, dslot: DataSlotNumeric[T], maxval: T)(implicit num: Numeric[T]) extends Widget {
class WidgetFillDataSlot[T](val rect: Rect, val texture: Texture, dir: Direction.Direction, dSlot: DataSlotNumeric[T], maxVal: T)(implicit num: Numeric[T]) extends Widget {
import num.mkNumericOps
override def draw(mouse: Point) {
val fill = dslot.cval.toFloat() / maxval.toFloat()
val fill = dSlot.value.toFloat() / maxVal.toFloat()
dir match {
case Direction.UP =>
parent.drawTextureInterpolate(rect, texture, 0, 1 - fill, 1, 1)
@@ -4,27 +4,23 @@
*
* 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.gui.widgets
import java.text.DecimalFormat
import net.bdew.lib.Misc
import net.bdew.lib.data.DataSlotTankBase
import net.bdew.lib.gui.{Color, Point, Rect, Texture}
import net.bdew.lib.{DecFormat, Misc}
import org.lwjgl.opengl.GL11
import scala.collection.mutable
class WidgetFluidGauge(val rect: Rect, overlay: Texture, dslot: DataSlotTankBase) extends Widget {
val formater = new DecimalFormat("#,###")
class WidgetFluidGauge(val rect: Rect, overlay: Texture, dSlot: DataSlotTankBase) extends Widget {
override def handleTooltip(p: Point, tip: mutable.MutableList[String]) {
if (dslot.getFluid != null) {
tip += dslot.getFluid.getFluid.getLocalizedName(dslot.getFluid)
tip += "%s/%s mB".format(formater.format(dslot.getFluidAmount), formater.format(dslot.getCapacity))
if (dSlot.getFluid != null) {
tip += dSlot.getFluid.getFluid.getLocalizedName(dSlot.getFluid)
tip += "%s/%s mB".format(DecFormat.round(dSlot.getFluidAmount), DecFormat.round(dSlot.getCapacity))
} else {
tip += Misc.toLocal("bdlib.label.empty")
}
@@ -34,11 +30,11 @@ class WidgetFluidGauge(val rect: Rect, overlay: Texture, dslot: DataSlotTankBase
GL11.glEnable(GL11.GL_BLEND)
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA)
val fstack = dslot.getFluid
if (fstack != null) {
val color = Color.fromInt(Misc.getFluidColor(fstack))
val icon = Texture(Texture.BLOCKS, Misc.getFluidIcon(fstack))
var fillHeight = if (dslot.getCapacity > 0) rect.h * fstack.amount / dslot.getCapacity else 0
val fStack = dSlot.getFluid
if (fStack != null) {
val color = Color.fromInt(Misc.getFluidColor(fStack))
val icon = Texture(Texture.BLOCKS, Misc.getFluidIcon(fStack))
var fillHeight = if (dSlot.getCapacity > 0) rect.h * fStack.amount / dSlot.getCapacity else 0
var yStart: Int = 0
while (fillHeight > 0) {
@@ -56,6 +52,7 @@ class WidgetFluidGauge(val rect: Rect, overlay: Texture, dslot: DataSlotTankBase
GL11.glColor3d(1, 1, 1)
GL11.glDisable(GL11.GL_BLEND)
parent.drawTexture(rect, overlay)
if (overlay != null)
parent.drawTexture(rect, overlay)
}
}
@@ -4,7 +4,7 @@
*
* 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.gui.widgets
@@ -4,14 +4,14 @@
*
* 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.gui.widgets
import net.bdew.lib.gui.Rect
abstract class WidgetMultipane(rect: Rect) extends WidgetSubcontainer(rect) {
abstract class WidgetMultiPane(rect: Rect) extends WidgetSubContainer(rect) {
def getActivePane: BaseWidget
def addPane[T <: BaseWidget](w: T): T = {
@@ -4,7 +4,7 @@
*
* 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.gui.widgets
@@ -14,6 +14,6 @@ import net.bdew.lib.gui._
import scala.collection.mutable
class WidgetProgressBar(rect: Rect, texture: Texture, dslot: DataSlotFloat) extends WidgetFillDataslot[Float](rect, texture, Direction.RIGHT, dslot, 1) {
override def handleTooltip(p: Point, tip: mutable.MutableList[String]) = tip += "%.0f".format(dslot.cval * 100) + "%"
class WidgetProgressBar(rect: Rect, texture: Texture, dSlot: DataSlotFloat) extends WidgetFillDataSlot[Float](rect, texture, Direction.RIGHT, dSlot, 1) {
override def handleTooltip(p: Point, tip: mutable.MutableList[String]) = tip += "%.0f".format(dSlot.value * 100) + "%"
}
@@ -4,14 +4,14 @@
*
* 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.gui.widgets
import net.bdew.lib.gui._
class WidgetSubcontainer(val rect: Rect) extends BaseWidget with WidgetContainer with SimpleDrawTarget {
class WidgetSubContainer(val rect: Rect) extends BaseWidget with WidgetContainer with SimpleDrawTarget {
def getZLevel = parent.getZLevel
def getFontRenderer = parent.getFontRenderer
def getOffsetFromWindow = parent.getOffsetFromWindow + rect.origin
@@ -4,7 +4,7 @@
*
* 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.gui.widgets
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.items
+9 -9
View File
@@ -4,7 +4,7 @@
*
* 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.items
@@ -25,11 +25,11 @@ object ItemUtils {
val dx = world.rand.nextFloat * 0.8
val dy = world.rand.nextFloat * 0.8
val dz = world.rand.nextFloat * 0.8
val entityitem: EntityItem = new EntityItem(world, x + dx, y + dy, z + dz, stack)
entityitem.motionX = world.rand.nextGaussian * 0.05
entityitem.motionY = world.rand.nextGaussian * 0.05 + 0.2
entityitem.motionZ = world.rand.nextGaussian * 0.05
world.spawnEntityInWorld(entityitem)
val entity = new EntityItem(world, x + dx, y + dy, z + dz, stack)
entity.motionX = world.rand.nextGaussian * 0.05
entity.motionY = world.rand.nextGaussian * 0.05 + 0.2
entity.motionZ = world.rand.nextGaussian * 0.05
world.spawnEntityInWorld(entity)
}
def dropItemToPlayer(world: World, player: EntityPlayer, stack: ItemStack) {
@@ -47,11 +47,11 @@ object ItemUtils {
return ItemStack.areItemStackTagsEqual(stack2, stack1)
}
def addStackToSlots(stack: ItemStack, inv: IInventory, slots: Iterable[Int], checkvalid: Boolean): ItemStack = {
def addStackToSlots(stack: ItemStack, inv: IInventory, slots: Iterable[Int], checkValid: Boolean): ItemStack = {
if (stack == null) return null
// Try merging into existing slots
for (slot <- slots if (!checkvalid || inv.isItemValidForSlot(slot, stack)) && isSameItem(stack, inv.getStackInSlot(slot))) {
for (slot <- slots if (!checkValid || inv.isItemValidForSlot(slot, stack)) && isSameItem(stack, inv.getStackInSlot(slot))) {
val target = inv.getStackInSlot(slot)
val toAdd = Misc.min(target.getMaxStackSize - target.stackSize, inv.getInventoryStackLimit - target.stackSize, stack.stackSize)
if (toAdd >= stack.stackSize) {
@@ -67,7 +67,7 @@ object ItemUtils {
}
// Now find empty slots and stick any leftovers there
for (slot <- slots if (!checkvalid || inv.isItemValidForSlot(slot, stack)) && inv.getStackInSlot(slot) == null) {
for (slot <- slots if (!checkValid || inv.isItemValidForSlot(slot, stack)) && inv.getStackInSlot(slot) == null) {
if (inv.getInventoryStackLimit < stack.stackSize) {
inv.setInventorySlotContents(slot, stack.splitStack(inv.getInventoryStackLimit))
} else {
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.items
@@ -4,7 +4,7 @@
*
* 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.items.inventory
@@ -15,15 +15,13 @@ import net.minecraft.inventory.Slot
import net.minecraft.item.ItemStack
class ContainerItemInventory(inv: InventoryItemAdapter, player: EntityPlayer) extends BaseContainer(inv) {
def canInteractWith(entityplayer: EntityPlayer) = entityplayer == player
override def slotClick(slotnum: Int, button: Int, modifiers: Int, player: EntityPlayer): ItemStack = {
if (slotnum > 0 && slotnum < inventorySlots.size()) {
val slot = inventorySlots.asInstanceOf[java.util.List[Slot]].get(slotnum)
override def slotClick(slotNum: Int, button: Int, modifiers: Int, player: EntityPlayer): ItemStack = {
if (slotNum > 0 && slotNum < inventorySlots.size()) {
val slot = inventorySlots.asInstanceOf[java.util.List[Slot]].get(slotNum)
if (slot.isSlotInInventory(inv.player.inventory, inv.slot))
return null
}
if (modifiers == 2 && button == inv.slot) return null
return super.slotClick(slotnum, button, modifiers, player)
return super.slotClick(slotNum, button, modifiers, player)
}
}
@@ -4,7 +4,7 @@
*
* 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.items.inventory
@@ -4,7 +4,7 @@
*
* 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.items.inventory
@@ -19,7 +19,7 @@ import net.minecraft.world.World
/**
* Mixin for items that have an internal inventory
* Subclasses are responsible for registering themself with the GuiHandler of their mod
* Subclasses are responsible for registering themselves with the GuiHandler of their mod
*/
trait ItemInventory extends Item with GuiProvider {
type TEClass = Any
+1 -1
View File
@@ -4,7 +4,7 @@
*
* 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.machine
@@ -4,7 +4,7 @@
*
* 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.machine
@@ -4,7 +4,7 @@
*
* 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.machine
@@ -4,7 +4,7 @@
*
* 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
@@ -4,7 +4,7 @@
*
* 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
@@ -13,7 +13,7 @@ import net.bdew.lib.gui.{Color, Texture}
import net.minecraft.util.IIcon
trait ResourceProvider {
// Icons for rendering, *must* be on block spritesheet
// Icons for rendering, *must* be on block sprite sheet
def edge: IIcon
def disabled: IIcon
def output: IIcon
+7 -7
View File
@@ -4,7 +4,7 @@
*
* 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
@@ -18,33 +18,33 @@ import scala.collection.mutable
object Tools {
def canConnect(world: World, core: BlockRef, kind: String): Boolean = {
val t = core.getTile[TileController](world).getOrElse(return false)
t.getNumOfMoudules(kind) < t.cfg.modules.getOrElse(kind, return false)
t.getNumOfModules(kind) < t.cfg.modules.getOrElse(kind, return false)
}
def findConnections(world: World, start: BlockRef, kind: String) =
(start.neighbours.values flatMap { case pos =>
(pos.tile(world) flatMap {
case t: TileModule => t.connected.cval
case t: TileModule => t.connected.value
case t: TileController => Some(pos)
case _ => None
}) filter (x => canConnect(world, x, kind))
}).toList.distinct
def getAdjancedConnected(w: World, core: BlockRef, pos: BlockRef, seen: mutable.Set[BlockRef]) =
def getConnectedNeighbours(w: World, core: BlockRef, pos: BlockRef, seen: mutable.Set[BlockRef]) =
pos.neighbours.values
.filterNot(seen.contains)
.flatMap(_.getTile[TileModule](w))
.filter(x => x.connected.contains(core))
.map(_.mypos)
.map(_.myPos)
def findReachableModules(world: World, core: BlockRef): Set[BlockRef] = {
val seen = mutable.Set.empty[BlockRef]
val queue = mutable.Queue.empty[BlockRef]
queue ++= getAdjancedConnected(world, core, core, seen)
queue ++= getConnectedNeighbours(world, core, core, seen)
while (queue.size > 0) {
val current = queue.dequeue()
seen.add(current)
queue ++= getAdjancedConnected(world, core, current, seen)
queue ++= getConnectedNeighbours(world, core, current, seen)
}
return seen.toSet
}
@@ -4,7 +4,7 @@
*
* 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.block
@@ -33,7 +33,7 @@ abstract class BlockController[T <: TileController](val name: String, material:
override def canConnect(world: IBlockAccess, origin: BlockRef, target: BlockRef) =
getTE(world, origin).modules.contains(target)
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, meta: Int, xoffs: Float, yoffs: Float, zoffs: Float): Boolean = {
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, meta: Int, xOffs: Float, yOffs: Float, zOffs: Float): Boolean = {
if (player.isSneaking) return false
if (world.isRemote) return true
getTE(world, x, y, z).onClick(player)
@@ -4,7 +4,7 @@
*
* 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.block
@@ -52,12 +52,12 @@ abstract class BlockModule[T <: TileModule](val name: String, val kind: String,
})
}
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, meta: Int, xoffs: Float, yoffs: Float, zoffs: Float): Boolean = {
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, meta: Int, xOffs: Float, yOffs: Float, zOffs: Float): Boolean = {
if (player.isSneaking) return false
if (world.isRemote) return true
val te = getTE(world, x, y, z)
(for {
p <- te.connected.cval
p <- te.connected.value
bl <- p.block(world)
} yield {
bl.onBlockActivated(world, p.x, p.y, p.z, player, meta, 0, 0, 0)
@@ -4,7 +4,7 @@
*
* 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.block
@@ -16,8 +16,8 @@ import net.minecraft.world.IBlockAccess
import net.minecraftforge.common.util.ForgeDirection
trait BlockOutput[T <: TileOutput[_]] extends BlockModule[T] with BlockAdditionalRender {
def getAdjancedFaces(face: ForgeDirection, bp: BlockRef) = {
val sides = ConnectedHelper.faceAdjanced(face)
def getNeighbourFaces(face: ForgeDirection, bp: BlockRef) = {
val sides = ConnectedHelper.neighbourFaces(face)
Seq(
(BlockFace(bp, sides.top), resources.arrowTop),
(BlockFace(bp, sides.right), resources.arrowRight),
@@ -32,7 +32,7 @@ trait BlockOutput[T <: TileOutput[_]] extends BlockModule[T] with BlockAdditiona
val bf = BlockFace(x, y, z, face)
if (core.outputFaces.contains(bf))
result :+= FaceOverlay(resources.output, resources.outputColors(core.outputFaces(bf)))
for ((bf, icon) <- getAdjancedFaces(face, bf.origin)) {
for ((bf, icon) <- getNeighbourFaces(face, bf.origin)) {
if (core.outputFaces.contains(bf))
result :+= FaceOverlay(icon, resources.outputColors(core.outputFaces(bf)))
}
@@ -4,7 +4,7 @@
*
* 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.data
@@ -15,6 +15,8 @@ import net.bdew.lib.data.base.{DataSlot, TileDataSlots, UpdateKind}
import net.minecraft.nbt.{NBTTagCompound, NBTTagIntArray, NBTTagList}
import net.minecraftforge.common.util.ForgeDirection
import scala.collection.mutable
case class DataSlotBlockFaceMap(name: String, parent: TileDataSlots) extends DataSlot {
val map = collection.mutable.Map.empty[BlockFace, Int]
@@ -43,5 +45,5 @@ object DataSlotBlockFaceMap {
import scala.language.implicitConversions
implicit def dsbfm2map(v: DataSlotBlockFaceMap) = v.map
implicit def dataSlotBlockFaceMap2map(v: DataSlotBlockFaceMap): mutable.Map[BlockFace, Int] = v.map
}
@@ -4,7 +4,7 @@
*
* 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.data
@@ -12,6 +12,8 @@ package net.bdew.lib.multiblock.data
import net.bdew.lib.data.base.{DataSlot, TileDataSlots, UpdateKind}
import net.minecraft.nbt.NBTTagCompound
import scala.collection.mutable
case class DataSlotOutputConfig(name: String, parent: TileDataSlots, slots: Int) extends DataSlot {
val map = collection.mutable.Map.empty[Int, OutputConfig]
@@ -23,12 +25,7 @@ case class DataSlotOutputConfig(name: String, parent: TileDataSlots, slots: Int)
for ((n, x) <- map) {
val tmp = new NBTTagCompound()
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)
tmp.setString("kind", x.id)
t.setTag(name + "_" + n, tmp)
}
}
@@ -38,11 +35,7 @@ case class DataSlotOutputConfig(name: String, parent: TileDataSlots, slots: Int)
for (i <- 0 until slots) {
if (t.hasKey(name + "_" + i)) {
val cfg = t.getCompoundTag(name + "_" + i)
val cfgObj = cfg.getString("kind") match {
case "power" => new OutputConfigPower
case "fluid" => new OutputConfigFluid
case _ => new OutputConfigInvalid
}
val cfgObj = OutputConfigManager.create(cfg.getString("kind"))
cfgObj.read(cfg)
map += i -> cfgObj
}
@@ -56,5 +49,5 @@ object DataSlotOutputConfig {
import scala.language.implicitConversions
implicit def dsbfm2map(v: DataSlotOutputConfig) = v.map
implicit def dataSlotOutputConfig2map(v: DataSlotOutputConfig): mutable.Map[Int, OutputConfig] = v.map
}
@@ -4,7 +4,7 @@
*
* 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.data
@@ -19,11 +19,11 @@ case class DataSlotPos(name: String, parent: TileDataSlots) extends DataSlotOpti
setUpdate(UpdateKind.SAVE, UpdateKind.WORLD)
def save(t: NBTTagCompound, kind: UpdateKind.Value) {
cval map (x => t.setTag(name, Misc.applyMutator(x.writeToNBT, new NBTTagCompound)))
value map (x => t.setTag(name, Misc.applyMutator(x.writeToNBT, new NBTTagCompound)))
}
def load(t: NBTTagCompound, kind: UpdateKind.Value) {
cval = if (t.hasKey(name))
value = if (t.hasKey(name))
Some(BlockRef.fromNBT(t.getCompoundTag(name)))
else
None
@@ -4,7 +4,7 @@
*
* 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.data
@@ -14,6 +14,8 @@ import net.bdew.lib.block.BlockRef
import net.bdew.lib.data.base.{DataSlot, TileDataSlots, UpdateKind}
import net.minecraft.nbt.{NBTTagCompound, NBTTagList}
import scala.collection.mutable
case class DataSlotPosSet(name: String, parent: TileDataSlots) extends DataSlot {
val set = collection.mutable.Set.empty[BlockRef]
@@ -38,5 +40,5 @@ object DataSlotPosSet {
import scala.language.implicitConversions
implicit def dsps2set(v: DataSlotPosSet) = v.set
implicit def dataSlotPosSet2set(v: DataSlotPosSet): mutable.Set[BlockRef] = v.set
}
@@ -4,7 +4,7 @@
*
* 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.data
@@ -14,13 +14,24 @@ import net.minecraft.nbt.NBTTagCompound
import sun.reflect.generics.reflectiveObjects.NotImplementedException
abstract class OutputConfig {
def id: String
def read(t: NBTTagCompound)
def write(t: NBTTagCompound)
def handleConfigPacket(m: MsgOutputCfg)
}
class OutputConfigInvalid extends OutputConfig {
override val id: String = "invalid"
def read(t: NBTTagCompound) {}
def write(t: NBTTagCompound) = throw new NotImplementedException
def handleConfigPacket(m: MsgOutputCfg) = throw new NotImplementedException
}
object OutputConfigManager {
var loaders = Map.empty[String, () => OutputConfig]
def register(id: String, loader: () => OutputConfig) = loaders += id -> loader
def create(id: String) = loaders.get(id).map(_.apply()).getOrElse(new OutputConfigInvalid)
register("fluid", () => new OutputConfigFluid)
register("power", () => new OutputConfigPower)
}
@@ -13,6 +13,7 @@ import net.bdew.lib.multiblock.network.MsgOutputCfg
import net.minecraft.nbt.NBTTagCompound
class OutputConfigFluid extends OutputConfig with OutputConfigRSControllable {
override def id = "fluid"
var avg = 0.0
var rsMode = RSMode.ALWAYS
@@ -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, MsgOutputCfgSlot}
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))
}
}
@@ -4,7 +4,7 @@
*
* 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.data
@@ -13,6 +13,7 @@ import net.bdew.lib.multiblock.network.MsgOutputCfg
import net.minecraft.nbt.NBTTagCompound
class OutputConfigPower(var unit: String = "MJ") extends OutputConfig with OutputConfigRSControllable {
override val id = "power"
var avg = 0.0
var rsMode = RSMode.ALWAYS
@@ -4,7 +4,7 @@
*
* 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.data
@@ -0,0 +1,35 @@
/*
* 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 cpw.mods.fml.relauncher.{Side, SideOnly}
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) {
slotMap += id -> this
def next = order(this)
@SideOnly(Side.CLIENT)
def texture = textures(this)
}
def default: Slot
val order: Map[Slot, Slot]
@SideOnly(Side.CLIENT)
def textures: Map[Slot, Texture]
def get(id: String) = slotMap(id)
}
@@ -4,7 +4,7 @@
*
* 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
@@ -23,6 +23,6 @@ class WidgetInfo(val rect: Rect, icon: Texture, text: => String, tooltip: => Str
override def draw(mouse: Point) {
parent.drawTexture(iconRect + rect.origin, icon)
parent.drawText(text, rect.origin +(12, 1), Color.darkgray, false)
parent.drawText(text, rect.origin +(12, 1), Color.darkGray, false)
}
}
@@ -4,7 +4,7 @@
*
* 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
@@ -10,13 +10,13 @@
package net.bdew.lib.multiblock.gui
import net.bdew.lib.Misc
import net.bdew.lib.gui.widgets.{WidgetButtonIcon, WidgetSubcontainer}
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 WidgetRSConfig(te: CIOutputFaces, output: Int, p: Point) extends WidgetSubcontainer(new Rect(p, 16, 16)) {
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))
@@ -4,7 +4,7 @@
*
* 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.interact
@@ -13,7 +13,7 @@ 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 outputFluid(amount: Int, doDrain: Boolean): FluidStack
def canOutputFluid(fluid: Fluid): Boolean
def getTankInfo: Array[FluidTankInfo]
}
@@ -0,0 +1,22 @@
/*
* 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.data.SlotSet
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
}
@@ -4,7 +4,7 @@
*
* 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.interact
@@ -42,7 +42,7 @@ trait CIOutputFaces extends TileController {
serverTick.listen(doOutputs)
override def moduleRemoved(module: TileModule) {
for ((bf, n) <- outputFaces if bf.origin == module.mypos) {
for ((bf, n) <- outputFaces if bf.origin == module.myPos) {
outputFaces -= bf
outputConfig -= n
}
@@ -4,7 +4,7 @@
*
* 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.interact
@@ -4,7 +4,7 @@
*
* 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.interact
@@ -4,7 +4,7 @@
*
* 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.interact
Loaded 100 of 158 files, more files were not shown because too many files have changed in this diff. Show more