mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 19:25:20 -04:00
Allow inserting tablets into disk drives to access their first internal drive.
This commit is contained in:
parent
cbb08e3b1c
commit
211034bbde
@ -83,6 +83,7 @@ class Proxy {
|
||||
api.Driver.add(driver.item.Keyboard)
|
||||
api.Driver.add(driver.item.RedstoneCard)
|
||||
api.Driver.add(driver.item.Screen)
|
||||
api.Driver.add(driver.item.Tablet)
|
||||
api.Driver.add(driver.item.UpgradeAngel)
|
||||
api.Driver.add(driver.item.UpgradeBattery)
|
||||
api.Driver.add(driver.item.UpgradeChunkloader)
|
||||
|
32
src/main/scala/li/cil/oc/server/driver/item/Tablet.scala
Normal file
32
src/main/scala/li/cil/oc/server/driver/item/Tablet.scala
Normal file
@ -0,0 +1,32 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.util.ItemUtils
|
||||
import li.cil.oc.{Settings, api}
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
|
||||
object Tablet extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("tablet"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = {
|
||||
val data = new ItemUtils.TabletData(stack)
|
||||
data.items.collect {
|
||||
case Some(fs) if FileSystem.worksWith(fs) => fs
|
||||
}.headOption.map(FileSystem.createEnvironment(_, container)).orNull
|
||||
}
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Disk
|
||||
|
||||
override def dataTag(stack: ItemStack) = {
|
||||
val data = new ItemUtils.TabletData(stack)
|
||||
val index = data.items.indexWhere {
|
||||
case Some(fs) => FileSystem.worksWith(fs)
|
||||
case _ => false
|
||||
}
|
||||
if (index >= 0 && stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "items")) {
|
||||
stack.getTagCompound.getTagList(Settings.namespace + "items").tagAt(index).asInstanceOf[NBTTagCompound].getCompoundTag("tag")
|
||||
}
|
||||
else new NBTTagCompound()
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user