diff --git a/build.gradle b/build.gradle index 4005d91..edb6932 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ buildscript { apply plugin: 'scala' apply plugin: 'forge' -version = "1.5.2" +version = "1.6.0" if (project.hasProperty('buildnum')) { project.version = project.version + '.' + project.buildnum diff --git a/src/net/bdew/lib/Client.scala b/src/net/bdew/lib/Client.scala index 6929a13..87f67c2 100644 --- a/src/net/bdew/lib/Client.scala +++ b/src/net/bdew/lib/Client.scala @@ -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 diff --git a/src/net/bdew/lib/CommandDumpRegistry.scala b/src/net/bdew/lib/CommandDumpRegistry.scala index dc30d37..38847a9 100644 --- a/src/net/bdew/lib/CommandDumpRegistry.scala +++ b/src/net/bdew/lib/CommandDumpRegistry.scala @@ -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? diff --git a/src/net/bdew/lib/Misc.scala b/src/net/bdew/lib/Misc.scala index 7de2142..38fad59 100644 --- a/src/net/bdew/lib/Misc.scala +++ b/src/net/bdew/lib/Misc.scala @@ -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 diff --git a/src/net/bdew/lib/covers/BlockCoverable.scala b/src/net/bdew/lib/covers/BlockCoverable.scala index 472f26a..989e592 100644 --- a/src/net/bdew/lib/covers/BlockCoverable.scala +++ b/src/net/bdew/lib/covers/BlockCoverable.scala @@ -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) } diff --git a/src/net/bdew/lib/covers/ItemCover.scala b/src/net/bdew/lib/covers/ItemCover.scala index 248eb6e..84c7000 100644 --- a/src/net/bdew/lib/covers/ItemCover.scala +++ b/src/net/bdew/lib/covers/ItemCover.scala @@ -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 diff --git a/src/net/bdew/lib/covers/TileCoverable.scala b/src/net/bdew/lib/covers/TileCoverable.scala index 3a54f8f..33b4847 100644 --- a/src/net/bdew/lib/covers/TileCoverable.scala +++ b/src/net/bdew/lib/covers/TileCoverable.scala @@ -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) diff --git a/src/net/bdew/lib/data/DataSlotBoolean.scala b/src/net/bdew/lib/data/DataSlotBoolean.scala index 9297dc1..726caa4 100644 --- a/src/net/bdew/lib/data/DataSlotBoolean.scala +++ b/src/net/bdew/lib/data/DataSlotBoolean.scala @@ -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) } diff --git a/src/net/bdew/lib/data/DataSlotDirection.scala b/src/net/bdew/lib/data/DataSlotDirection.scala index a3a2064..5b324ba 100644 --- a/src/net/bdew/lib/data/DataSlotDirection.scala +++ b/src/net/bdew/lib/data/DataSlotDirection.scala @@ -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)) } diff --git a/src/net/bdew/lib/data/DataSlotDouble.scala b/src/net/bdew/lib/data/DataSlotDouble.scala index af32ca6..df52446 100644 --- a/src/net/bdew/lib/data/DataSlotDouble.scala +++ b/src/net/bdew/lib/data/DataSlotDouble.scala @@ -13,6 +13,6 @@ 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, cval) - def load(t: NBTTagCompound, kind: UpdateKind.Value) = cval = t.getDouble(name) + def save(t: NBTTagCompound, kind: UpdateKind.Value) = t.setDouble(name, value) + def load(t: NBTTagCompound, kind: UpdateKind.Value) = value = t.getDouble(name) } diff --git a/src/net/bdew/lib/data/DataSlotFloat.scala b/src/net/bdew/lib/data/DataSlotFloat.scala index 8b824fc..975e5dd 100644 --- a/src/net/bdew/lib/data/DataSlotFloat.scala +++ b/src/net/bdew/lib/data/DataSlotFloat.scala @@ -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) } diff --git a/src/net/bdew/lib/data/DataSlotGameProfile.scala b/src/net/bdew/lib/data/DataSlotGameProfile.scala index 9caf0f8..c06def9 100644 --- a/src/net/bdew/lib/data/DataSlotGameProfile.scala +++ b/src/net/bdew/lib/data/DataSlotGameProfile.scala @@ -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)) } } } diff --git a/src/net/bdew/lib/data/DataSlotInt.scala b/src/net/bdew/lib/data/DataSlotInt.scala index 6b229f5..cf41635 100644 --- a/src/net/bdew/lib/data/DataSlotInt.scala +++ b/src/net/bdew/lib/data/DataSlotInt.scala @@ -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) } diff --git a/src/net/bdew/lib/data/DataSlotItemStack.scala b/src/net/bdew/lib/data/DataSlotItemStack.scala index fb791f7..f18997a 100644 --- a/src/net/bdew/lib/data/DataSlotItemStack.scala +++ b/src/net/bdew/lib/data/DataSlotItemStack.scala @@ -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)) } diff --git a/src/net/bdew/lib/data/DataSlotOption.scala b/src/net/bdew/lib/data/DataSlotOption.scala index 8b9de32..ae4269e 100644 --- a/src/net/bdew/lib/data/DataSlotOption.scala +++ b/src/net/bdew/lib/data/DataSlotOption.scala @@ -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]) = { diff --git a/src/net/bdew/lib/data/DataSlotString.scala b/src/net/bdew/lib/data/DataSlotString.scala index e470832..34d7116 100644 --- a/src/net/bdew/lib/data/DataSlotString.scala +++ b/src/net/bdew/lib/data/DataSlotString.scala @@ -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 } diff --git a/src/net/bdew/lib/data/base/DataSlotNumeric.scala b/src/net/bdew/lib/data/base/DataSlotNumeric.scala index 5aabab4..247ffd6 100644 --- a/src/net/bdew/lib/data/base/DataSlotNumeric.scala +++ b/src/net/bdew/lib/data/base/DataSlotNumeric.scala @@ -11,12 +11,12 @@ 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)) } diff --git a/src/net/bdew/lib/data/base/DataSlotOrdered.scala b/src/net/bdew/lib/data/base/DataSlotOrdered.scala index 5fba491..6531c7f 100644 --- a/src/net/bdew/lib/data/base/DataSlotOrdered.scala +++ b/src/net/bdew/lib/data/base/DataSlotOrdered.scala @@ -10,12 +10,12 @@ 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 } diff --git a/src/net/bdew/lib/data/base/DataSlotVal.scala b/src/net/bdew/lib/data/base/DataSlotVal.scala index 06878ca..e78c7de 100644 --- a/src/net/bdew/lib/data/base/DataSlotVal.scala +++ b/src/net/bdew/lib/data/base/DataSlotVal.scala @@ -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 } \ No newline at end of file diff --git a/src/net/bdew/lib/gui/BaseContainer.scala b/src/net/bdew/lib/gui/BaseContainer.scala index ffb5be7..94b767d 100644 --- a/src/net/bdew/lib/gui/BaseContainer.scala +++ b/src/net/bdew/lib/gui/BaseContainer.scala @@ -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) } diff --git a/src/net/bdew/lib/gui/Color.scala b/src/net/bdew/lib/gui/Color.scala index 40460c7..a4f36b6 100644 --- a/src/net/bdew/lib/gui/Color.scala +++ b/src/net/bdew/lib/gui/Color.scala @@ -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) } diff --git a/src/net/bdew/lib/gui/GuiHandler.scala b/src/net/bdew/lib/gui/GuiHandler.scala index 16df909..2a7ae79 100644 --- a/src/net/bdew/lib/gui/GuiHandler.scala +++ b/src/net/bdew/lib/gui/GuiHandler.scala @@ -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) } diff --git a/src/net/bdew/lib/gui/NoInvContainer.scala b/src/net/bdew/lib/gui/NoInvContainer.scala index bed3a4f..1af59e8 100644 --- a/src/net/bdew/lib/gui/NoInvContainer.scala +++ b/src/net/bdew/lib/gui/NoInvContainer.scala @@ -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 diff --git a/src/net/bdew/lib/gui/Texture.scala b/src/net/bdew/lib/gui/Texture.scala index fd388c2..5ea3ec1 100644 --- a/src/net/bdew/lib/gui/Texture.scala +++ b/src/net/bdew/lib/gui/Texture.scala @@ -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 diff --git a/src/net/bdew/lib/gui/package.scala b/src/net/bdew/lib/gui/package.scala index ee33d72..ec12876 100644 --- a/src/net/bdew/lib/gui/package.scala +++ b/src/net/bdew/lib/gui/package.scala @@ -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) diff --git a/src/net/bdew/lib/gui/widgets/WidgetFillDataslot.scala b/src/net/bdew/lib/gui/widgets/WidgetFillDataslot.scala index e67f95e..f17da1f 100644 --- a/src/net/bdew/lib/gui/widgets/WidgetFillDataslot.scala +++ b/src/net/bdew/lib/gui/widgets/WidgetFillDataslot.scala @@ -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) diff --git a/src/net/bdew/lib/gui/widgets/WidgetFluidGauge.scala b/src/net/bdew/lib/gui/widgets/WidgetFluidGauge.scala index f21ccb1..6ddae21 100644 --- a/src/net/bdew/lib/gui/widgets/WidgetFluidGauge.scala +++ b/src/net/bdew/lib/gui/widgets/WidgetFluidGauge.scala @@ -16,11 +16,11 @@ import org.lwjgl.opengl.GL11 import scala.collection.mutable -class WidgetFluidGauge(val rect: Rect, overlay: Texture, dslot: DataSlotTankBase) extends Widget { +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(DecFormat.round(dslot.getFluidAmount), DecFormat.round(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") } @@ -30,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 + 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 fillHeight = if (dSlot.getCapacity > 0) rect.h * fStack.amount / dSlot.getCapacity else 0 var yStart: Int = 0 while (fillHeight > 0) { diff --git a/src/net/bdew/lib/gui/widgets/WidgetMultipane.scala b/src/net/bdew/lib/gui/widgets/WidgetMultipane.scala index 9a1b499..79ae3f3 100644 --- a/src/net/bdew/lib/gui/widgets/WidgetMultipane.scala +++ b/src/net/bdew/lib/gui/widgets/WidgetMultipane.scala @@ -11,7 +11,7 @@ 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 = { diff --git a/src/net/bdew/lib/gui/widgets/WidgetProgressBar.scala b/src/net/bdew/lib/gui/widgets/WidgetProgressBar.scala index 72ff57b..83acb40 100644 --- a/src/net/bdew/lib/gui/widgets/WidgetProgressBar.scala +++ b/src/net/bdew/lib/gui/widgets/WidgetProgressBar.scala @@ -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) + "%" } diff --git a/src/net/bdew/lib/gui/widgets/WidgetSubcontainer.scala b/src/net/bdew/lib/gui/widgets/WidgetSubcontainer.scala index b6b4210..32a0ef3 100644 --- a/src/net/bdew/lib/gui/widgets/WidgetSubcontainer.scala +++ b/src/net/bdew/lib/gui/widgets/WidgetSubcontainer.scala @@ -11,7 +11,7 @@ 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 diff --git a/src/net/bdew/lib/items/ItemUtils.scala b/src/net/bdew/lib/items/ItemUtils.scala index cf773e5..0904484 100644 --- a/src/net/bdew/lib/items/ItemUtils.scala +++ b/src/net/bdew/lib/items/ItemUtils.scala @@ -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 { diff --git a/src/net/bdew/lib/items/inventory/ContainerItemInventory.scala b/src/net/bdew/lib/items/inventory/ContainerItemInventory.scala index fc49048..ccab35f 100644 --- a/src/net/bdew/lib/items/inventory/ContainerItemInventory.scala +++ b/src/net/bdew/lib/items/inventory/ContainerItemInventory.scala @@ -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) } } diff --git a/src/net/bdew/lib/items/inventory/ItemInventory.scala b/src/net/bdew/lib/items/inventory/ItemInventory.scala index e9d5390..01f0b9f 100644 --- a/src/net/bdew/lib/items/inventory/ItemInventory.scala +++ b/src/net/bdew/lib/items/inventory/ItemInventory.scala @@ -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 diff --git a/src/net/bdew/lib/multiblock/ResourceProvider.scala b/src/net/bdew/lib/multiblock/ResourceProvider.scala index 72f87ef..47cf435 100644 --- a/src/net/bdew/lib/multiblock/ResourceProvider.scala +++ b/src/net/bdew/lib/multiblock/ResourceProvider.scala @@ -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 diff --git a/src/net/bdew/lib/multiblock/Tools.scala b/src/net/bdew/lib/multiblock/Tools.scala index 6c2e746..c2af9ed 100644 --- a/src/net/bdew/lib/multiblock/Tools.scala +++ b/src/net/bdew/lib/multiblock/Tools.scala @@ -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 } diff --git a/src/net/bdew/lib/multiblock/block/BlockController.scala b/src/net/bdew/lib/multiblock/block/BlockController.scala index 92be0ab..5e7c353 100644 --- a/src/net/bdew/lib/multiblock/block/BlockController.scala +++ b/src/net/bdew/lib/multiblock/block/BlockController.scala @@ -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) diff --git a/src/net/bdew/lib/multiblock/block/BlockModule.scala b/src/net/bdew/lib/multiblock/block/BlockModule.scala index d9252e1..3629a0b 100644 --- a/src/net/bdew/lib/multiblock/block/BlockModule.scala +++ b/src/net/bdew/lib/multiblock/block/BlockModule.scala @@ -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) diff --git a/src/net/bdew/lib/multiblock/block/BlockOutput.scala b/src/net/bdew/lib/multiblock/block/BlockOutput.scala index 4e69603..7395b1e 100644 --- a/src/net/bdew/lib/multiblock/block/BlockOutput.scala +++ b/src/net/bdew/lib/multiblock/block/BlockOutput.scala @@ -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))) } diff --git a/src/net/bdew/lib/multiblock/data/DataSlotBlockFaceMap.scala b/src/net/bdew/lib/multiblock/data/DataSlotBlockFaceMap.scala index 412b202..418ef06 100644 --- a/src/net/bdew/lib/multiblock/data/DataSlotBlockFaceMap.scala +++ b/src/net/bdew/lib/multiblock/data/DataSlotBlockFaceMap.scala @@ -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 } diff --git a/src/net/bdew/lib/multiblock/data/DataSlotOutputConfig.scala b/src/net/bdew/lib/multiblock/data/DataSlotOutputConfig.scala index 02d7fbb..a568fc2 100644 --- a/src/net/bdew/lib/multiblock/data/DataSlotOutputConfig.scala +++ b/src/net/bdew/lib/multiblock/data/DataSlotOutputConfig.scala @@ -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] @@ -47,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 } diff --git a/src/net/bdew/lib/multiblock/data/DataSlotPos.scala b/src/net/bdew/lib/multiblock/data/DataSlotPos.scala index 92687ea..e93d0bc 100644 --- a/src/net/bdew/lib/multiblock/data/DataSlotPos.scala +++ b/src/net/bdew/lib/multiblock/data/DataSlotPos.scala @@ -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 diff --git a/src/net/bdew/lib/multiblock/data/DataSlotPosSet.scala b/src/net/bdew/lib/multiblock/data/DataSlotPosSet.scala index 0a41261..c248893 100644 --- a/src/net/bdew/lib/multiblock/data/DataSlotPosSet.scala +++ b/src/net/bdew/lib/multiblock/data/DataSlotPosSet.scala @@ -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 } diff --git a/src/net/bdew/lib/multiblock/gui/WidgetInfo.scala b/src/net/bdew/lib/multiblock/gui/WidgetInfo.scala index 319e70b..6aa69d0 100644 --- a/src/net/bdew/lib/multiblock/gui/WidgetInfo.scala +++ b/src/net/bdew/lib/multiblock/gui/WidgetInfo.scala @@ -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) } } diff --git a/src/net/bdew/lib/multiblock/gui/WidgetRSConfig.scala b/src/net/bdew/lib/multiblock/gui/WidgetRSConfig.scala index 60ed889..5c61b90 100644 --- a/src/net/bdew/lib/multiblock/gui/WidgetRSConfig.scala +++ b/src/net/bdew/lib/multiblock/gui/WidgetRSConfig.scala @@ -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)) diff --git a/src/net/bdew/lib/multiblock/interact/CIOutputFaces.scala b/src/net/bdew/lib/multiblock/interact/CIOutputFaces.scala index 98eeeeb..b818ac3 100644 --- a/src/net/bdew/lib/multiblock/interact/CIOutputFaces.scala +++ b/src/net/bdew/lib/multiblock/interact/CIOutputFaces.scala @@ -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 } diff --git a/src/net/bdew/lib/multiblock/tile/TileController.scala b/src/net/bdew/lib/multiblock/tile/TileController.scala index 81fbe66..7283a21 100644 --- a/src/net/bdew/lib/multiblock/tile/TileController.scala +++ b/src/net/bdew/lib/multiblock/tile/TileController.scala @@ -27,9 +27,9 @@ trait TileController extends TileDataSlots { var revalidateOnNextTick = true var modulesChanged = true - lazy val mypos = BlockRef(xCoord, yCoord, zCoord) + lazy val myPos = BlockRef(xCoord, yCoord, zCoord) - def getNumOfMoudules(kind: String) = modules.map(_.getTile[TileModule](getWorldObj)).flatten.count(_.kind == kind) + def getNumOfModules(kind: String) = modules.map(_.getTile[TileModule](getWorldObj)).flatten.count(_.kind == kind) def onModulesChanged() def onClick(player: EntityPlayer) @@ -64,11 +64,11 @@ trait TileController extends TileDataSlots { BdLib.logWarn("Block at %s is not a valid module, removing from machine %s at %d,%d,%d", x, this.getClass.getSimpleName, xCoord, yCoord, zCoord) modules.remove(x) }) - val reachable = Tools.findReachableModules(getWorldObj, mypos) - val toremove = modules.filterNot(reachable.contains).flatMap(_.getTile[TileModule](getWorldObj)) + val reachable = Tools.findReachableModules(getWorldObj, myPos) + val toRemove = modules.filterNot(reachable.contains).flatMap(_.getTile[TileModule](getWorldObj)) acceptNewModules = false - toremove.foreach(moduleRemoved) - toremove.foreach(_.coreRemoved()) + toRemove.foreach(moduleRemoved) + toRemove.foreach(_.coreRemoved()) acceptNewModules = true modulesChanged = true modules.map(x => diff --git a/src/net/bdew/lib/multiblock/tile/TileControllerGui.scala b/src/net/bdew/lib/multiblock/tile/TileControllerGui.scala index 31f4982..04bf405 100644 --- a/src/net/bdew/lib/multiblock/tile/TileControllerGui.scala +++ b/src/net/bdew/lib/multiblock/tile/TileControllerGui.scala @@ -16,7 +16,7 @@ abstract class TileControllerGui extends TileController { def openGui(player: EntityPlayer) def onClick(player: EntityPlayer) = { - val missing = cfg.required.filter({ case (mod, cnt) => getNumOfMoudules(mod) < cnt }) + val missing = cfg.required.filter({ case (mod, cnt) => getNumOfModules(mod) < cnt }) if (missing.size > 0) { player.addChatMessage(new ChatComponentTranslation("bdlib.multiblock.incomplete") .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))) diff --git a/src/net/bdew/lib/multiblock/tile/TileModule.scala b/src/net/bdew/lib/multiblock/tile/TileModule.scala index 99629dc..c0389fc 100644 --- a/src/net/bdew/lib/multiblock/tile/TileModule.scala +++ b/src/net/bdew/lib/multiblock/tile/TileModule.scala @@ -24,11 +24,11 @@ trait TileModule extends TileDataSlots { def getCore = getCoreAs[TileController] - lazy val mypos = BlockRef(xCoord, yCoord, zCoord) + lazy val myPos = BlockRef(xCoord, yCoord, zCoord) def connect(target: TileController) { if (target.moduleConnected(this)) { - connected.set(target.mypos) + connected.set(target.myPos) getWorldObj.markBlockForUpdate(xCoord, yCoord, zCoord) getWorldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType) } @@ -47,7 +47,7 @@ trait TileModule extends TileDataSlots { def tryConnect() { if (getCore.isEmpty) { for { - conn <- Tools.findConnections(getWorldObj, mypos, kind).headOption + conn <- Tools.findConnections(getWorldObj, myPos, kind).headOption core <- conn.getTile[TileController](getWorldObj) } { connect(core) diff --git a/src/net/bdew/lib/multiblock/tile/TileOutput.scala b/src/net/bdew/lib/multiblock/tile/TileOutput.scala index f706265..db84140 100644 --- a/src/net/bdew/lib/multiblock/tile/TileOutput.scala +++ b/src/net/bdew/lib/multiblock/tile/TileOutput.scala @@ -25,9 +25,9 @@ abstract class TileOutput[T <: OutputConfig] extends TileModule with MIOutput[T] def getCfg(dir: ForgeDirection): Option[T] = for { core <- getCore - onum <- core.outputFaces.get(BlockFace(mypos, dir)) - cfggen <- core.outputConfig.get(onum) - cfg <- Misc.asInstanceOpt(cfggen, outputConfigType) + oNum <- core.outputFaces.get(BlockFace(myPos, dir)) + cfgGen <- core.outputConfig.get(oNum) + cfg <- Misc.asInstanceOpt(cfgGen, outputConfigType) } yield cfg serverTick.listen(() => { @@ -42,7 +42,7 @@ abstract class TileOutput[T <: OutputConfig] extends TileModule with MIOutput[T] if (connected.isDefined) rescanFaces = true } - def canConnectoToFace(d: ForgeDirection): Boolean + def canConnectToFace(d: ForgeDirection): Boolean def onConnectionsChanged(added: Set[ForgeDirection], removed: Set[ForgeDirection]) {} @@ -50,14 +50,14 @@ abstract class TileOutput[T <: OutputConfig] extends TileModule with MIOutput[T] getCore map { core => val connections = ( ForgeDirection.VALID_DIRECTIONS - filterNot { dir => core.modules.contains(mypos.neighbour(dir)) } - filter canConnectoToFace + filterNot { dir => core.modules.contains(myPos.neighbour(dir)) } + filter canConnectToFace ).toSet - val known = core.outputFaces.filter(_._1.origin == mypos).map(_._1.face).toSet + val known = core.outputFaces.filter(_._1.origin == myPos).map(_._1.face).toSet val toAdd = connections -- known val toRemove = known -- connections - toRemove.foreach(x => core.removeOutput(mypos, x)) - toAdd.foreach(x => core.newOutput(mypos, x, makeCfgObject(x))) + toRemove.foreach(x => core.removeOutput(myPos, x)) + toAdd.foreach(x => core.newOutput(myPos, x, makeCfgObject(x))) if (toAdd.size > 0 || toRemove.size > 0) { onConnectionsChanged(toAdd, toRemove) getWorldObj.markBlockForUpdate(xCoord, yCoord, zCoord) diff --git a/src/net/bdew/lib/network/NetChannel.scala b/src/net/bdew/lib/network/NetChannel.scala index 14e405a..4279094 100644 --- a/src/net/bdew/lib/network/NetChannel.scala +++ b/src/net/bdew/lib/network/NetChannel.scala @@ -51,7 +51,7 @@ class NetChannel(val name: String) { } def init() { - if (channels != null) sys.error("Attempted to initalize a channel twice (%s)".format(name)) + if (channels != null) sys.error("Attempted to initialize a channel twice (%s)".format(name)) channels = NetworkRegistry.INSTANCE.newChannel(name, new SerializedMessageCodec) BdLib.logInfo("Initialized network channel '%s' for mod '%s'", name, Misc.getActiveModId) addHandler(Side.SERVER, ServerHandler) diff --git a/src/net/bdew/lib/player/PlayerCache.scala b/src/net/bdew/lib/player/PlayerCache.scala index c79527f..824d95b 100644 --- a/src/net/bdew/lib/player/PlayerCache.scala +++ b/src/net/bdew/lib/player/PlayerCache.scala @@ -51,11 +51,11 @@ class PlayerCache[T] extends mutable.Map[EntityPlayer, T] { override def iterator = map.iterator @SubscribeEvent - def hadlePlayerLogout(ev: PlayerLoggedOutEvent) = reset(ev.player) + def handlePlayerLogout(ev: PlayerLoggedOutEvent) = reset(ev.player) @SubscribeEvent - def hadlePlayerChangedDimension(ev: PlayerChangedDimensionEvent) = reset(ev.player) + def handlePlayerChangedDimension(ev: PlayerChangedDimensionEvent) = reset(ev.player) @SubscribeEvent - def hadlePlayerRespawn(ev: PlayerRespawnEvent) = reset(ev.player) + def handlePlayerRespawn(ev: PlayerRespawnEvent) = reset(ev.player) } diff --git a/src/net/bdew/lib/power/TileBaseProcessor.scala b/src/net/bdew/lib/power/TileBaseProcessor.scala index 51ff6ef..2ca8e4f 100644 --- a/src/net/bdew/lib/power/TileBaseProcessor.scala +++ b/src/net/bdew/lib/power/TileBaseProcessor.scala @@ -56,12 +56,12 @@ with TilePoweredBase { def isWorking: Boolean /** - * Try starting a new operation, return true if succesful + * Try starting a new operation, return true if successful */ def tryStart(): Boolean /** - * Perform output when operation is done, return true if succesful + * Perform output when operation is done, return true if successful */ def tryFinish(): Boolean } diff --git a/src/net/bdew/lib/recipes/RecipeLoader.scala b/src/net/bdew/lib/recipes/RecipeLoader.scala index 7b670c6..c60482e 100644 --- a/src/net/bdew/lib/recipes/RecipeLoader.scala +++ b/src/net/bdew/lib/recipes/RecipeLoader.scala @@ -99,29 +99,28 @@ class RecipeLoader { /** * Fetches an ItemStack using reflection from static fields - * Item and Block instaces are converted to ItemStacks + * Item and Block instances are converted to ItemStacks * @param clsName Name of class to fetch from (can be a class macro) * @param fldName Field name * @param meta Metadata or damage * @param cnt Stack size - * @return Matching itemstack + * @return Matching item stack */ def reflectStack(clsName: String, fldName: String, meta: Int, cnt: Int): ItemStack = { val realName = getRealClassName(clsName) - val cls = Class.forName(realName) - val fld = cls.getField(fldName).get(null) + val fld = Class.forName(realName).getField(fldName).get(null) return sanitizeReflectedItem(fld, "%s.%s".format(realName, fldName), meta, cnt) } /** * Fetches an ItemStack using reflection from static getters - * Item and Block instaces are converted to ItemStacks + * Item and Block instances are converted to ItemStacks * @param clsName Name of class to fetch from (can be a class macro) * @param method Method name * @param param Parameter to method * @param meta Metadata or damage * @param cnt Stack size - * @return Matching itemstack + * @return Matching item stack */ def reflectStackGetter(clsName: String, method: String, param: String, meta: Int, cnt: Int): ItemStack = { var realName: String = clsName @@ -138,9 +137,7 @@ class RecipeLoader { realName = getRealClassName(clsName) } - val cls = Class.forName(realName) - val meth = cls.getMethod(realMethod, classOf[String]) - val res = meth.invoke(null, param) + val res = Class.forName(realName).getMethod(realMethod, classOf[String]).invoke(null, param) return sanitizeReflectedItem(res, "%s.%s(%s)".format(realName, realMethod, param), meta, cnt) } diff --git a/src/net/bdew/lib/recipes/RecipeParser.scala b/src/net/bdew/lib/recipes/RecipeParser.scala index ffc6888..a8d1daa 100644 --- a/src/net/bdew/lib/recipes/RecipeParser.scala +++ b/src/net/bdew/lib/recipes/RecipeParser.scala @@ -26,8 +26,8 @@ class RecipeParser extends JavaTokenParsers { // Possible metadata suffix (defaults to wildcard value) def maybeMeta = ("@" ~> int).? ^^ (_.getOrElse(OreDictionary.WILDCARD_VALUE)) - // Possible modid prefix (defaults to minecraft) - def maybeModid = (str <~ ":").? ^^ (_.getOrElse("minecraft")) + // Possible modId prefix (defaults to minecraft) + def maybeModId = (str <~ ":").? ^^ (_.getOrElse("minecraft")) // Qualified class name def clsPath = (ident <~ ".").* ~ ident @@ -50,8 +50,8 @@ class RecipeParser extends JavaTokenParsers { // === Item references === def specOD = "OD" ~> ":" ~> ident ^^ StackOreDict - def specBlock = "B" ~> ":" ~> maybeModid ~ str ~ maybeMeta ^^ { case m ~ n ~ i => StackBlock(m, n, i) } - def specItem = "I" ~> ":" ~> maybeModid ~ str ~ maybeMeta ^^ { case m ~ n ~ i => StackItem(m, n, i) } + def specBlock = "B" ~> ":" ~> maybeModId ~ str ~ maybeMeta ^^ { case m ~ n ~ i => StackBlock(m, n, i) } + def specItem = "I" ~> ":" ~> maybeModId ~ str ~ maybeMeta ^^ { case m ~ n ~ i => StackItem(m, n, i) } def specGenericStack = "S" ~> ":" ~> str ~ ":" ~ str ^^ { case m ~ c ~ n => StackGeneric(m, n) } def specMacro = "$" ~> recipeChar ^^ StackMacro diff --git a/src/net/bdew/lib/recipes/RecipesHelper.scala b/src/net/bdew/lib/recipes/RecipesHelper.scala index b837ece..8ce649b 100644 --- a/src/net/bdew/lib/recipes/RecipesHelper.scala +++ b/src/net/bdew/lib/recipes/RecipesHelper.scala @@ -17,7 +17,7 @@ import net.bdew.lib.BdLib object RecipesHelper { /** * Perform full loading of a set of config - * @param modName Name of the mod, used in logging an derrors + * @param modName Name of the mod, used in logging and errors * @param listResource Resource Name of the internal config list file * @param configDir Base path to user config giles * @param resBaseName Base resource name for internal config files @@ -44,9 +44,9 @@ object RecipesHelper { if (overrideFile.exists()) { tryLoadConfig(new FileReader(overrideFile), overrideFile.getCanonicalPath, modName, loader) } else { - val resname = resBaseName + fileName - tryLoadConfig(new InputStreamReader(getClass.getResourceAsStream(resname)), - getClass.getResource(resname).toString, modName, loader) + val resource = resBaseName + fileName + tryLoadConfig(new InputStreamReader(getClass.getResourceAsStream(resource)), + getClass.getResource(resource).toString, modName, loader) } } diff --git a/src/net/bdew/lib/recipes/ast-conditions.scala b/src/net/bdew/lib/recipes/ast-conditions.scala index 436d72e..85b6311 100644 --- a/src/net/bdew/lib/recipes/ast-conditions.scala +++ b/src/net/bdew/lib/recipes/ast-conditions.scala @@ -33,7 +33,7 @@ case class CndHaveMod(mod: String) extends Condition case class CndHaveAPI(api: String) extends Condition /** - * True if oredict entery is present + * True if oredict entry is present * Syntax: HaveOD {string} * Parser: [[RecipeParser.cndHaveOD]] */ diff --git a/src/net/bdew/lib/recipes/ast-stackref.scala b/src/net/bdew/lib/recipes/ast-stackref.scala index aaa0a19..2d7eb59 100644 --- a/src/net/bdew/lib/recipes/ast-stackref.scala +++ b/src/net/bdew/lib/recipes/ast-stackref.scala @@ -29,8 +29,8 @@ abstract class StackRef case class StackOreDict(id: String) extends StackRef /** - * Generic Referende - * Syntax: S:{modid}:{name} + * Generic Reference + * Syntax: S:{modId}:{name} * Parser: [[net.bdew.lib.recipes.RecipeParser.specGenericStack]] * @param mod modId of owner mod * @param name name of the stack @@ -39,7 +39,7 @@ case class StackGeneric(mod: String, name: String) extends StackRef /** * Block reference - * Syntax: B:[{modid}:]{name} [@ {meta}] + * Syntax: B:[{modId}:]{name} [@ {meta}] * Parser: [[net.bdew.lib.recipes.RecipeParser.specBlock]] * @param mod modId of owner mod, default is "minecraft" * @param name Registered name @@ -49,7 +49,7 @@ case class StackBlock(mod: String, name: String, meta: Int) extends StackRef /** * Item reference - * Syntax: I:[{modid}:]{name} [@ {meta}] + * Syntax: I:[{modId}:]{name} [@ {meta}] * Parser: [[net.bdew.lib.recipes.RecipeParser.specItem]] * @param mod modId of owner mod, default is "minecraft" * @param name Registered name @@ -58,7 +58,7 @@ case class StackBlock(mod: String, name: String, meta: Int) extends StackRef case class StackItem(mod: String, name: String, meta: Int) extends StackRef /** - * Reference to an Item/Block/ItemStack pulic static field + * Reference to an Item/Block/ItemStack public static field * Syntax: {path}.{to}.{class}[{field}] [@ {meta}] * Parser: [[net.bdew.lib.recipes.RecipeParser.specReflect]] * @param cls Class name @@ -68,7 +68,7 @@ case class StackItem(mod: String, name: String, meta: Int) extends StackRef case class StackReflect(cls: String, field: String, meta: Int) extends StackRef /** - * Reference to an Item/Block/ItemStack pulic static getter + * Reference to an Item/Block/ItemStack public static getter * Syntax: {path}.{to}.{class}.{method}({string}) [@ {meta}] * Parser: [[net.bdew.lib.recipes.RecipeParser.specGetter]] * @param cls Class name diff --git a/src/net/bdew/lib/recipes/ast-statements-cfg.scala b/src/net/bdew/lib/recipes/ast-statements-cfg.scala index 74c528e..819ba26 100644 --- a/src/net/bdew/lib/recipes/ast-statements-cfg.scala +++ b/src/net/bdew/lib/recipes/ast-statements-cfg.scala @@ -35,7 +35,7 @@ case class CsRecipeBlock(list: List[RecipeStatement]) extends ConfigStatement case class CsConditionalConfig(cond: Condition, thn: List[ConfigStatement], els: List[ConfigStatement]) extends ConfigStatement /** - * Removes previously defined recieps for a specific result + * Removes previously defined recipes for a specific result * Syntax: clearRecipes: {spec} * Parser: [[RecipeParser.clearRecipes]] * @param res Recipes that produce this result will be cleared diff --git a/src/net/bdew/lib/recipes/ast-statements-recipe.scala b/src/net/bdew/lib/recipes/ast-statements-recipe.scala index 8ca5565..0b24c4f 100644 --- a/src/net/bdew/lib/recipes/ast-statements-recipe.scala +++ b/src/net/bdew/lib/recipes/ast-statements-recipe.scala @@ -54,7 +54,7 @@ case class RsRecipes(list: List[RecipeStatement]) extends RecipeStatement case class RsConditional(cond: Condition, thn: List[RecipeStatement], els: List[RecipeStatement]) extends RecipeStatement /** - * Base class for staments that represent a crafting recipe, that has a result + * Base class for statements that represent a crafting recipe, that has a result */ abstract class CraftingStatement extends RecipeStatement { def result: StackRef @@ -90,7 +90,7 @@ case class RsRecipeShaped(rec: Seq[String], result: StackRef, cnt: Int) extends * Syntax: shapeless: {characters} => {result} [* {count}] * Parser: [[net.bdew.lib.recipes.RecipeParser.recipeShapeless]] * - * @param rec Recipe pattehrn + * @param rec Recipe pattern * @param result Result reference * @param cnt Number of output items */ diff --git a/src/net/bdew/lib/recipes/gencfg/ConfigSection.scala b/src/net/bdew/lib/recipes/gencfg/ConfigSection.scala index f178c82..cdb372e 100644 --- a/src/net/bdew/lib/recipes/gencfg/ConfigSection.scala +++ b/src/net/bdew/lib/recipes/gencfg/ConfigSection.scala @@ -27,7 +27,7 @@ case class ConfigSection(pfx: String = "") extends ConfigEntry with Iterable[(St def keys = raw.keys - def rawget[T](id: String, t: Class[T]): T = { + def getRaw[T](id: String, t: Class[T]): T = { val v = raw(id) if (t.isInstance(v)) return v.asInstanceOf[T] @@ -37,10 +37,10 @@ case class ConfigSection(pfx: String = "") extends ConfigEntry with Iterable[(St def set(id: String, v: ConfigEntry) = raw += id -> v - def getDouble(id: String) = rawget(id, classOf[EntryDouble]).v - def getString(id: String) = rawget(id, classOf[EntryStr]).v - def getDoubleList(id: String) = rawget(id, classOf[EntryNumList]).v - def getSection(id: String) = rawget(id, classOf[ConfigSection]) + def getDouble(id: String) = getRaw(id, classOf[EntryDouble]).v + def getString(id: String) = getRaw(id, classOf[EntryStr]).v + def getDoubleList(id: String) = getRaw(id, classOf[EntryNumList]).v + def getSection(id: String) = getRaw(id, classOf[ConfigSection]) final val trueVals = Set("y", "true", "yes", "on") def getBoolean(id: String) = trueVals.contains(getString(id).toLowerCase) @@ -49,7 +49,7 @@ case class ConfigSection(pfx: String = "") extends ConfigEntry with Iterable[(St def getOrAddSection(id: String) = { if (raw.isDefinedAt(id)) { - rawget(id, classOf[ConfigSection]) + getRaw(id, classOf[ConfigSection]) } else { val newSection = new ConfigSection(pfx + id + ".") set(id, newSection) diff --git a/src/net/bdew/lib/render/IconPreloader.scala b/src/net/bdew/lib/render/IconPreloader.scala index c44b413..264ff02 100644 --- a/src/net/bdew/lib/render/IconPreloader.scala +++ b/src/net/bdew/lib/render/IconPreloader.scala @@ -12,6 +12,7 @@ package net.bdew.lib.render import cpw.mods.fml.common.eventhandler.SubscribeEvent import net.bdew.lib.gui.{IconWrapper, Texture} import net.minecraft.client.renderer.texture.IIconRegister +import net.minecraft.util.IIcon import net.minecraftforge.client.event.TextureStitchEvent import net.minecraftforge.common.MinecraftForge @@ -25,7 +26,7 @@ class IconPreloader(kind: Int) { val sheet = kind match { case 0 => Texture.BLOCKS case 1 => Texture.ITEMS - case x => sys.error("Invalid spritesheet number: %d".format(x)) + case x => sys.error("Invalid sprite sheet number: %d".format(x)) } case class TextureLoc(loc: String) { @@ -35,8 +36,8 @@ class IconPreloader(kind: Int) { import scala.language.implicitConversions - implicit def entry2icon(v: TextureLoc) = v.texture.icon - implicit def entry2texture(v: TextureLoc) = v.texture + implicit def entry2icon(v: TextureLoc): IIcon = v.texture.icon + implicit def entry2texture(v: TextureLoc): IconWrapper = v.texture def registerIcons(reg: IIconRegister) {} diff --git a/src/net/bdew/lib/render/connected/ConnectedHelper.scala b/src/net/bdew/lib/render/connected/ConnectedHelper.scala index 2308e68..3dc51c5 100644 --- a/src/net/bdew/lib/render/connected/ConnectedHelper.scala +++ b/src/net/bdew/lib/render/connected/ConnectedHelper.scala @@ -34,7 +34,7 @@ object ConnectedHelper { RectF(0, 0, 1, 1) ) - val faceAdjanced = (for (x <- ForgeDirection.VALID_DIRECTIONS) yield x -> new FaceAdjanced(x)).toMap + val neighbourFaces = (for (x <- ForgeDirection.VALID_DIRECTIONS) yield x -> new neighbourFaces(x)).toMap // Maps edge number + face to 3d vertices val draw = @@ -83,7 +83,7 @@ object ConnectedHelper { def doDraw(pos: Vec3F, icon: IIcon) { for (v <- vertices) - addVertextWithUV(v.pos + pos, mapToIcon(v.tex, icon)) + addVertexWithUV(v.pos + pos, mapToIcon(v.tex, icon)) } } @@ -95,10 +95,10 @@ object ConnectedHelper { def mapToIcon(v: Vec2F, i: IIcon) = Vec2F(i.getInterpolatedU(v.u * 16), i.getInterpolatedV((1 - v.v) * 16)) - def addVertextWithUV(p: Vec3F, t: Vec2F) = + def addVertexWithUV(p: Vec3F, t: Vec2F) = Tessellator.instance.addVertexWithUV(p.x, p.y, p.z, t.u, t.v) - class FaceAdjanced(d: ForgeDirection) { + class neighbourFaces(d: ForgeDirection) { val top = d match { case ForgeDirection.UP => ForgeDirection.NORTH case ForgeDirection.DOWN => ForgeDirection.SOUTH diff --git a/src/net/bdew/lib/render/connected/ConnectedRenderer.scala b/src/net/bdew/lib/render/connected/ConnectedRenderer.scala index 94c1257..5411a74 100644 --- a/src/net/bdew/lib/render/connected/ConnectedRenderer.scala +++ b/src/net/bdew/lib/render/connected/ConnectedRenderer.scala @@ -48,7 +48,7 @@ object ConnectedRenderer extends BaseBlockRenderHandler { def drawFaceEdges(world: IBlockAccess, pos: ConnectedHelper.Vec3F, face: ForgeDirection, block: ConnectedTextureBlock) { val edge = block.edgeIcon val canConnect = block.canConnect(world, pos.asBlockRef, _: BlockRef) - val sides = ConnectedHelper.faceAdjanced(face) + val sides = ConnectedHelper.neighbourFaces(face) val m = ConnectedHelper.brightnessMultiplier(face) Tessellator.instance.setColorOpaque_F(m, m, m) diff --git a/src/net/bdew/lib/rotate/BaseRotateableBlock.scala b/src/net/bdew/lib/rotate/BaseRotatableBlock.scala similarity index 92% rename from src/net/bdew/lib/rotate/BaseRotateableBlock.scala rename to src/net/bdew/lib/rotate/BaseRotatableBlock.scala index 369ab70..65d0496 100644 --- a/src/net/bdew/lib/rotate/BaseRotateableBlock.scala +++ b/src/net/bdew/lib/rotate/BaseRotatableBlock.scala @@ -9,7 +9,7 @@ package net.bdew.lib.rotate -import java.util.EnumSet +import java.util import cpw.mods.fml.relauncher.{Side, SideOnly} import net.minecraft.block.Block @@ -20,9 +20,9 @@ import net.minecraft.world.{IBlockAccess, World} import net.minecraftforge.common.util.ForgeDirection /** - * Basic logic for block rotatation + * Basic logic for block rotation */ -trait BaseRotateableBlock extends Block { +trait BaseRotatableBlock extends Block { /** * Override this method to provide your textures, also called when rendering as item @@ -37,8 +37,8 @@ trait BaseRotateableBlock extends Block { /** * Set of valid rotations, default is all of them */ - def getValidFacings: EnumSet[ForgeDirection] = { - return EnumSet.allOf(classOf[ForgeDirection]) + def getValidFacings: util.EnumSet[ForgeDirection] = { + return util.EnumSet.allOf(classOf[ForgeDirection]) } /** @@ -47,7 +47,7 @@ trait BaseRotateableBlock extends Block { def getDefaultFacing: ForgeDirection = ForgeDirection.UP /** - * Those will be overrided to provide concrete storage + * Those will be overridden to provide concrete storage */ def setFacing(world: World, x: Int, y: Int, z: Int, facing: ForgeDirection) def getFacing(world: IBlockAccess, x: Int, y: Int, z: Int): ForgeDirection diff --git a/src/net/bdew/lib/rotate/RotateableTile.scala b/src/net/bdew/lib/rotate/RotatableTile.scala similarity index 91% rename from src/net/bdew/lib/rotate/RotateableTile.scala rename to src/net/bdew/lib/rotate/RotatableTile.scala index 2ebfbb1..d369782 100644 --- a/src/net/bdew/lib/rotate/RotateableTile.scala +++ b/src/net/bdew/lib/rotate/RotatableTile.scala @@ -12,6 +12,6 @@ package net.bdew.lib.rotate import net.bdew.lib.data.DataSlotDirection import net.bdew.lib.data.base.{TileDataSlots, UpdateKind} -trait RotateableTile extends TileDataSlots { +trait RotatableTile extends TileDataSlots { var rotation = DataSlotDirection("rotation", this).setUpdate(UpdateKind.SAVE, UpdateKind.WORLD) } diff --git a/src/net/bdew/lib/rotate/RotateableTileBlock.scala b/src/net/bdew/lib/rotate/RotatableTileBlock.scala similarity index 73% rename from src/net/bdew/lib/rotate/RotateableTileBlock.scala rename to src/net/bdew/lib/rotate/RotatableTileBlock.scala index 6b88521..1594f41 100644 --- a/src/net/bdew/lib/rotate/RotateableTileBlock.scala +++ b/src/net/bdew/lib/rotate/RotatableTileBlock.scala @@ -15,17 +15,17 @@ import net.minecraft.world.{IBlockAccess, World} import net.minecraftforge.common.util.ForgeDirection /** - * Stores rotation data in tile entity. The TE should implement {@link RotateableTile} + * Stores rotation data in tile entity. The TE should implement [[RotatableTile]] */ -trait RotateableTileBlock extends BaseRotateableBlock with ITileEntityProvider { +trait RotatableTileBlock extends BaseRotatableBlock with ITileEntityProvider { def setFacing(world: World, x: Int, y: Int, z: Int, facing: ForgeDirection) { - world.getTileEntity(x, y, z).asInstanceOf[RotateableTile].rotation := facing + world.getTileEntity(x, y, z).asInstanceOf[RotatableTile].rotation := facing } def getFacing(world: IBlockAccess, x: Int, y: Int, z: Int): ForgeDirection = { - val te: RotateableTile = world.getTileEntity(x, y, z).asInstanceOf[RotateableTile] + val te: RotatableTile = world.getTileEntity(x, y, z).asInstanceOf[RotatableTile] if (te == null || te.rotation == null) { - FMLCommonHandler.instance().getFMLLogger.warn("Failed getting rocation for block at %d, %d, %d".format(x, y, z)) + FMLCommonHandler.instance().getFMLLogger.warn("Failed getting rotation for block at %d, %d, %d".format(x, y, z)) return getDefaultFacing } return te.rotation diff --git a/src/net/bdew/lib/tile/inventory/BaseInventory.scala b/src/net/bdew/lib/tile/inventory/BaseInventory.scala index 95ac8f0..f504c54 100644 --- a/src/net/bdew/lib/tile/inventory/BaseInventory.scala +++ b/src/net/bdew/lib/tile/inventory/BaseInventory.scala @@ -40,12 +40,12 @@ trait BaseInventory extends IInventory { markDirty() return item } else { - val newstack = item.splitStack(n) + val newStack = item.splitStack(n) if (item.stackSize == 0) { inv(slot) = null } markDirty() - return newstack + return newStack } } else { return null