Merge branch 'master' of github.com:MightyPirates/OpenComputers into master-MC1.7.10

This commit is contained in:
Florian Nücke 2014-09-25 17:04:10 +02:00
commit 5b0b487dfa
5 changed files with 21 additions and 7 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

View File

@ -14,10 +14,11 @@ object Slot {
val Floppy = "floppy"
val HDD = "hdd"
val Memory = "memory"
val Tablet = "tablet"
val Tool = "tool"
val Upgrade = "upgrade"
val All = Array(Card, ComponentBus, Container, CPU, Floppy, HDD, Memory, Tool, Upgrade)
val All = Array(Card, ComponentBus, Container, CPU, Floppy, HDD, Memory, Tablet, Tool, Upgrade)
def apply(driver: api.driver.Item, stack: ItemStack, f: Option[ItemStack => api.driver.Slot] = scala.None) = f.getOrElse(driver.slot _)(stack) match {
case li.cil.oc.api.driver.Slot.Card => Card
@ -31,6 +32,7 @@ object Slot {
case _ =>
val descriptor = api.Items.get(stack)
if (descriptor == api.Items.get("componentBus1") || descriptor == api.Items.get("componentBus2") || descriptor == api.Items.get("componentBus3")) ComponentBus
else if (descriptor == api.Items.get("tablet")) Tablet
else None
}
}

View File

@ -1,7 +1,9 @@
package li.cil.oc.common.tileentity
import cpw.mods.fml.relauncher.{Side, SideOnly}
import li.cil.oc.api.network.{Analyzable, Node, Visibility}
import li.cil.oc.api.Driver
import li.cil.oc.api.network.{Component, Analyzable, Node, Visibility}
import li.cil.oc.common.Slot
import li.cil.oc.common.item.Tablet
import li.cil.oc.server.{PacketSender => ServerPacketSender}
import li.cil.oc.util.ItemUtils
@ -11,7 +13,7 @@ import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.ForgeDirection
class Charger extends traits.Environment with traits.PowerAcceptor with traits.RedstoneAware with traits.Rotatable with traits.Inventory with Analyzable {
class Charger extends traits.Environment with traits.PowerAcceptor with traits.RedstoneAware with traits.Rotatable with traits.ComponentInventory with Analyzable {
val node = api.Network.newNode(this, Visibility.None).
withConnector(Settings.get.bufferConverter).
create()
@ -137,10 +139,20 @@ class Charger extends traits.Environment with traits.PowerAcceptor with traits.R
override def getSizeInventory = 1
override def getInventoryStackLimit = 1
override def isItemValidForSlot(slot: Int, stack: ItemStack) = (slot, Option(Driver.driverFor(stack))) match {
case (0, Some(driver)) => Slot(driver, stack) == Slot.Tablet
case _ => false
}
override def isItemValidForSlot(slot: Int, stack: ItemStack) =
slot == 0 && api.Items.get(stack) == api.Items.get("tablet")
override protected def onItemAdded(slot: Int, stack: ItemStack) {
super.onItemAdded(slot, stack)
components(slot) match {
case Some(environment) => environment.node match {
case component: Component => component.setVisibility(Visibility.Network)
}
case _ =>
}
}
// ----------------------------------------------------------------------- //

View File

@ -17,7 +17,7 @@ object Tablet extends Item {
}.headOption.map(FileSystem.createEnvironment(_, container)).orNull
}
override def slot(stack: ItemStack) = Slot.Disk
override def slot(stack: ItemStack) = Slot.None
override def dataTag(stack: ItemStack) = {
val data = new ItemUtils.TabletData(stack)