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

Conflicts:
	src/main/scala/li/cil/oc/Constants.scala
	src/main/scala/li/cil/oc/CreativeTab.scala
	src/main/scala/li/cil/oc/client/Proxy.scala
	src/main/scala/li/cil/oc/client/renderer/HighlightRenderer.scala
	src/main/scala/li/cil/oc/client/renderer/block/Print.scala
	src/main/scala/li/cil/oc/client/renderer/item/ItemRenderer.scala
	src/main/scala/li/cil/oc/client/renderer/tileentity/RobotRenderer.scala
	src/main/scala/li/cil/oc/common/Achievement.scala
	src/main/scala/li/cil/oc/common/GuiHandler.scala
	src/main/scala/li/cil/oc/common/Loot.scala
	src/main/scala/li/cil/oc/common/PacketHandler.scala
	src/main/scala/li/cil/oc/common/Proxy.scala
	src/main/scala/li/cil/oc/common/block/RobotAfterimage.scala
	src/main/scala/li/cil/oc/common/block/RobotProxy.scala
	src/main/scala/li/cil/oc/common/block/Screen.scala
	src/main/scala/li/cil/oc/common/component/Terminal.scala
	src/main/scala/li/cil/oc/common/component/TextBuffer.scala
	src/main/scala/li/cil/oc/common/entity/Drone.scala
	src/main/scala/li/cil/oc/common/init/Blocks.scala
	src/main/scala/li/cil/oc/common/init/Items.scala
	src/main/scala/li/cil/oc/common/item/Analyzer.scala
	src/main/scala/li/cil/oc/common/item/Delegator.scala
	src/main/scala/li/cil/oc/common/item/Tablet.scala
	src/main/scala/li/cil/oc/common/recipe/Recipes.scala
	src/main/scala/li/cil/oc/common/template/DroneTemplate.scala
	src/main/scala/li/cil/oc/common/template/MicrocontrollerTemplate.scala
	src/main/scala/li/cil/oc/common/template/NavigationUpgradeTemplate.scala
	src/main/scala/li/cil/oc/common/template/RobotTemplate.scala
	src/main/scala/li/cil/oc/common/template/ServerTemplate.scala
	src/main/scala/li/cil/oc/common/template/TabletTemplate.scala
	src/main/scala/li/cil/oc/common/tileentity/Keyboard.scala
	src/main/scala/li/cil/oc/common/tileentity/Microcontroller.scala
	src/main/scala/li/cil/oc/common/tileentity/Switch.scala
	src/main/scala/li/cil/oc/common/tileentity/traits/TextBuffer.scala
	src/main/scala/li/cil/oc/integration/fmp/PrintPart.scala
	src/main/scala/li/cil/oc/integration/opencomputers/DriverBlockEnvironments.scala
	src/main/scala/li/cil/oc/integration/opencomputers/DriverCPU.scala
	src/main/scala/li/cil/oc/integration/opencomputers/DriverComponentBus.scala
	src/main/scala/li/cil/oc/integration/opencomputers/DriverContainerCard.scala
	src/main/scala/li/cil/oc/integration/opencomputers/DriverContainerUpgrade.scala
	src/main/scala/li/cil/oc/integration/opencomputers/DriverFileSystem.scala
	src/main/scala/li/cil/oc/integration/opencomputers/DriverGraphicsCard.scala
	src/main/scala/li/cil/oc/integration/opencomputers/DriverLootDisk.scala
	src/main/scala/li/cil/oc/integration/opencomputers/DriverMemory.scala
	src/main/scala/li/cil/oc/integration/opencomputers/DriverRedstoneCard.scala
	src/main/scala/li/cil/oc/integration/opencomputers/DriverUpgradeBattery.scala
	src/main/scala/li/cil/oc/integration/opencomputers/DriverUpgradeDatabase.scala
	src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala
This commit is contained in:
Florian Nücke 2015-04-07 16:04:33 +02:00
commit dda596f1d6
27 changed files with 395 additions and 190 deletions

View File

@ -21,7 +21,7 @@ object OpenComputers {
final val Version = "@VERSION@"
var log = LogManager.getLogger("OpenComputers")
var log = LogManager.getLogger(Name)
@SidedProxy(clientSide = "li.cil.oc.client.Proxy", serverSide = "li.cil.oc.server.Proxy")
var proxy: Proxy = null

View File

@ -19,6 +19,7 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.init.Items
import net.minecraft.item.ItemBlock
import net.minecraft.tileentity.TileEntity
import net.minecraft.util.EnumChatFormatting
import net.minecraft.util.EnumFacing
import net.minecraft.util.Vec3
import net.minecraftforge.client.IItemRenderer.ItemRenderType
@ -437,7 +438,7 @@ object RobotRenderer extends TileEntitySpecialRenderer {
t.draw
GL11.glEnable(GL11.GL_TEXTURE_2D) // For the font.
f.drawString(name, -halfWidth, 0, 0xFFFFFFFF)
f.drawString((if (EventHandler.isItTime) EnumChatFormatting.OBFUSCATED.toString else "") + name, -halfWidth, 0, 0xFFFFFFFF)
RenderState.enableDepthMask()
RenderState.enableLighting()

View File

@ -1,6 +1,7 @@
package li.cil.oc.common
import li.cil.oc.Constants
import li.cil.oc.OpenComputers
import li.cil.oc.api.detail.ItemInfo
import li.cil.oc.common.init.Items
import net.minecraft.entity.player.EntityPlayer
@ -12,116 +13,306 @@ import net.minecraftforge.common.AchievementPage
import scala.collection.mutable
object Achievement {
val All = mutable.ArrayBuffer.empty[Achievement]
val All = mutable.ArrayBuffer.empty[MCAchievement]
val CraftingMap = mutable.Map.empty[ItemInfo, MCAchievement]
val CustomCraftingMap = mutable.Map.empty[ItemStack, MCAchievement]
val AssemblingMap = mutable.Map.empty[ItemInfo, MCAchievement]
val Transistor = new Achievement("oc.transistor", "oc.transistor",
2, 0, Items.get(Constants.ItemName.Transistor).createItemStack(1), null, Constants.ItemName.Transistor).setIndependent()
val Disassembler = new Achievement("oc.disassembler", "oc.disassembler",
2, 2, Items.get(Constants.BlockName.Disassembler).createItemStack(1), Transistor, Constants.BlockName.Disassembler)
val Microchip = new Achievement("oc.chip", "oc.chip",
4, 0, Items.get(Constants.ItemName.ChipTier1).createItemStack(1), Transistor, Constants.ItemName.ChipTier1, Constants.ItemName.ChipTier2, Constants.ItemName.ChipTier3)
val Capacitor = new Achievement("oc.capacitor", "oc.capacitor",
6, -1, Items.get(Constants.BlockName.Capacitor).createItemStack(1), Microchip, Constants.BlockName.Capacitor)
val Assembler = new Achievement("oc.assembler", "oc.assembler",
8, -2, Items.get(Constants.BlockName.Assembler).createItemStack(1), Capacitor, Constants.BlockName.Assembler)
val Microcontroller = new Achievement("oc.microcontroller", "oc.microcontroller",
10, -2, Items.get(Constants.BlockName.Microcontroller).createItemStack(1), Assembler)
val Robot = new Achievement("oc.robot", "oc.robot",
10, -3, Items.get(Constants.BlockName.Robot).createItemStack(1), Assembler)
val Drone = new Achievement("oc.drone", "oc.drone",
10, -4, Items.get(Constants.ItemName.Drone).createItemStack(1), Assembler)
val Tablet = new Achievement("oc.tablet", "oc.tablet",
10, -5, Items.get(Constants.ItemName.Tablet).createItemStack(1), Assembler)
val Charger = new Achievement("oc.charger", "oc.charger",
8, -1, Items.get(Constants.BlockName.Charger).createItemStack(1), Capacitor, Constants.BlockName.Charger)
val CPU = new Achievement("oc.cpu", "oc.cpu",
6, 0, Items.get(Constants.ItemName.CPUTier1).createItemStack(1), Microchip, Constants.ItemName.CPUTier1, Constants.ItemName.CPUTier2, Constants.ItemName.CPUTier3)
val MotionSensor = new Achievement("oc.motionSensor", "oc.motionSensor",
8, 0, Items.get(Constants.BlockName.MotionSensor).createItemStack(1), CPU, Constants.BlockName.MotionSensor)
val Geolyzer = new Achievement("oc.geolyzer", "oc.geolyzer",
8, 1, Items.get(Constants.BlockName.Geolyzer).createItemStack(1), CPU, Constants.BlockName.Geolyzer)
val RedstoneIO = new Achievement("oc.redstoneIO", "oc.redstoneIO",
8, 2, Items.get(Constants.BlockName.Redstone).createItemStack(1), CPU, Constants.BlockName.Redstone)
val EEPROM = new Achievement("oc.eeprom", "oc.eeprom",
6, 3, Items.get(Constants.ItemName.EEPROM).createItemStack(1), Microchip, Constants.ItemName.EEPROM)
val Memory = new Achievement("oc.ram", "oc.ram",
6, 4, Items.get(Constants.ItemName.RAMTier1).createItemStack(1), Microchip, Constants.ItemName.RAMTier1, Constants.ItemName.RAMTier2, Constants.ItemName.RAMTier3, Constants.ItemName.RAMTier4, Constants.ItemName.RAMTier5, Constants.ItemName.RAMTier6)
val HDD = new Achievement("oc.hdd", "oc.hdd",
6, 5, Items.get(Constants.ItemName.HDDTier1).createItemStack(1), Microchip, Constants.ItemName.HDDTier1, Constants.ItemName.HDDTier2, Constants.ItemName.HDDTier3)
val Case = new Achievement("oc.case", "oc.case",
6, 6, Items.get(Constants.BlockName.CaseTier1).createItemStack(1), Microchip, Constants.BlockName.CaseTier1, Constants.BlockName.CaseTier2, Constants.BlockName.CaseTier3)
val Rack = new Achievement("oc.rack", "oc.rack",
8, 6, Items.get(Constants.BlockName.ServerRack).createItemStack(1), Case, Constants.BlockName.ServerRack)
val Server = new Achievement("oc.server", "oc.server",
10, 6, Items.get(Constants.ItemName.ServerTier1).createItemStack(1), Rack, Constants.ItemName.ServerTier1, Constants.ItemName.ServerTier2, Constants.ItemName.ServerTier3)
val Screen = new Achievement("oc.screen", "oc.screen",
6, 7, Items.get(Constants.BlockName.ScreenTier1).createItemStack(1), Microchip, Constants.BlockName.ScreenTier1, Constants.BlockName.ScreenTier2, Constants.BlockName.ScreenTier3)
val Keyboard = new Achievement("oc.keyboard", "oc.keyboard",
8, 7, Items.get(Constants.BlockName.Keyboard).createItemStack(1), Screen, Constants.BlockName.Keyboard)
val Hologram = new Achievement("oc.hologram", "oc.hologram",
8, 8, Items.get(Constants.BlockName.HologramTier1).createItemStack(1), Screen, Constants.BlockName.HologramTier1, Constants.BlockName.HologramTier2)
val DiskDrive = new Achievement("oc.diskDrive", "oc.diskDrive",
6, 9, Items.get(Constants.BlockName.DiskDrive).createItemStack(1), Microchip, Constants.BlockName.DiskDrive)
val Floppy = new Achievement("oc.floppy", "oc.floppy",
8, 9, Items.get(Constants.ItemName.Floppy).createItemStack(1), DiskDrive, Constants.ItemName.Floppy)
val OpenOS = new Achievement("oc.openOS", "oc.openOS",
10, 9, Items.createOpenOS(), Floppy)
val Raid = new Achievement("oc.raid", "oc.raid",
8, 10, Items.get(Constants.BlockName.Raid).createItemStack(1), DiskDrive, Constants.BlockName.Raid)
val Transistor = newAchievement("transistor").
at(2, 0).
whenCrafting(Constants.ItemName.Transistor).
add()
val Disassembler = newAchievement("disassembler").
at(2, 2).
whenCrafting(Constants.BlockName.Disassembler).
withParent(Transistor).
add()
val Microchip = newAchievement("chip").
at(4, 0).
withParent(Transistor).
whenCrafting(Constants.ItemName.ChipTier1).
whenCrafting(Constants.ItemName.ChipTier2).
whenCrafting(Constants.ItemName.ChipTier3).
add()
val Capacitor = newAchievement("capacitor").
at(6, -1).
withParent(Microchip).
whenCrafting(Constants.BlockName.Capacitor).
add()
val Assembler = newAchievement("assembler").
at(8, -2).
withParent(Capacitor).
whenCrafting(Constants.BlockName.Assembler).
add()
val Microcontroller = newAchievement("microcontroller").
at(10, -2).
withParent(Assembler).
whenAssembling(Constants.BlockName.Microcontroller).
add()
val Robot = newAchievement("robot").
at(10, -3).
withParent(Assembler).
whenAssembling(Constants.BlockName.Robot).
add()
val Drone = newAchievement("drone").
at(10, -4).
withParent(Assembler).
whenAssembling(Constants.ItemName.Drone).
add()
val Tablet = newAchievement("tablet").
at(10, -5).
withParent(Assembler).
whenAssembling(Constants.ItemName.Tablet).
add()
val Charger = newAchievement("charger").
at(8, -1).
withParent(Capacitor).
whenCrafting(Constants.BlockName.Charger).
add()
val CPU = newAchievement("cpu").
at(6, 0).
withParent(Microchip).
whenCrafting(Constants.ItemName.CPUTier1).
whenCrafting(Constants.ItemName.CPUTier2).
whenCrafting(Constants.ItemName.CPUTier3).
add()
val MotionSensor = newAchievement("motionSensor").
at(8, 0).
withParent(CPU).
whenCrafting(Constants.BlockName.MotionSensor).
add()
val Geolyzer = newAchievement("geolyzer").
at(8, 1).
withParent(CPU).
whenCrafting(Constants.BlockName.Geolyzer).
add()
val RedstoneIO = newAchievement("redstoneIO").
at(8, 2).
withParent(CPU).
whenCrafting(Constants.BlockName.Redstone).
add()
val EEPROM = newAchievement("eeprom").
at(6, 3).
withParent(Microchip).
whenCrafting(Constants.ItemName.EEPROM).
add()
val Memory = newAchievement("ram").
at(6, 4).
withParent(Microchip).
whenCrafting(Constants.ItemName.RAMTier1).
whenCrafting(Constants.ItemName.RAMTier2).
whenCrafting(Constants.ItemName.RAMTier3).
whenCrafting(Constants.ItemName.RAMTier4).
whenCrafting(Constants.ItemName.RAMTier5).
whenCrafting(Constants.ItemName.RAMTier6).
add()
val HDD = newAchievement("hdd").
at(6, 5).
withParent(Microchip).
whenCrafting(Constants.ItemName.HDDTier1).
whenCrafting(Constants.ItemName.HDDTier2).
whenCrafting(Constants.ItemName.HDDTier3).
add()
val Case = newAchievement("case").
at(6, 6).
withParent(Microchip).
whenCrafting(Constants.BlockName.CaseTier1).
whenCrafting(Constants.BlockName.CaseTier2).
whenCrafting(Constants.BlockName.CaseTier3).
add()
val Rack = newAchievement("rack").
at(8, 6).
withParent(Case).
whenCrafting(Constants.BlockName.ServerRack).
add()
val Server = newAchievement("server").
at(10, 6).
withParent(Rack).
whenCrafting(Constants.ItemName.ServerTier1).
whenCrafting(Constants.ItemName.ServerTier2).
whenCrafting(Constants.ItemName.ServerTier3).
add()
val Screen = newAchievement("screen").
at(6, 7).
withParent(Microchip).
whenCrafting(Constants.BlockName.ScreenTier1).
whenCrafting(Constants.BlockName.ScreenTier2).
whenCrafting(Constants.BlockName.ScreenTier3).
add()
val Keyboard = newAchievement("keyboard").
at(8, 7).
withParent(Screen).
whenCrafting(Constants.BlockName.Keyboard).
add()
val Hologram = newAchievement("hologram").
at(8, 8).
withParent(Screen).
whenCrafting(Constants.BlockName.HologramTier1).
whenCrafting(Constants.BlockName.HologramTier2).
add()
val DiskDrive = newAchievement("diskDrive").
at(6, 9).
withParent(Microchip).
whenCrafting(Constants.BlockName.DiskDrive).
add()
val Floppy = newAchievement("floppy").
at(8, 9).
withParent(DiskDrive).
whenCrafting(Constants.ItemName.Floppy).
add()
val OpenOS = newAchievement("openOS").
at(10, 9).
withParent(Floppy).
whenCrafting(Items.createOpenOS()).
add()
val Raid = newAchievement("raid").
at(8, 10).
withParent(DiskDrive).
whenCrafting(Constants.BlockName.Raid).
add()
val Card = new Achievement("oc.card", "oc.card",
0, -2, Items.get(Constants.ItemName.Card).createItemStack(1), null, Constants.ItemName.Card).setIndependent()
val RedstoneCard = new Achievement("oc.redstoneCard", "oc.redstoneCard",
-2, -4, Items.get(Constants.ItemName.RedstoneCardTier1).createItemStack(1), Card, Constants.ItemName.RedstoneCardTier1, Constants.ItemName.RedstoneCardTier2)
val GraphicsCard = new Achievement("oc.graphicsCard", "oc.graphicsCard",
0, -5, Items.get(Constants.ItemName.GraphicsCardTier1).createItemStack(1), Card, Constants.ItemName.GraphicsCardTier1, Constants.ItemName.GraphicsCardTier2, Constants.ItemName.GraphicsCardTier3)
val NetworkCard = new Achievement("oc.networkCard", "oc.networkCard",
2, -4, Items.get(Constants.ItemName.NetworkCard).createItemStack(1), Card, Constants.ItemName.NetworkCard)
val WirelessNetworkCard = new Achievement("oc.wirelessNetworkCard", "oc.wirelessNetworkCard",
2, -6, Items.get(Constants.ItemName.WirelessNetworkCard).createItemStack(1), NetworkCard, Constants.ItemName.WirelessNetworkCard)
val Card = newAchievement("card").
at(0, -2).
whenCrafting(Constants.ItemName.Card).
add()
val RedstoneCard = newAchievement("redstoneCard").
at(-2, -4).
withParent(Card).
whenCrafting(Constants.ItemName.RedstoneCardTier1).
whenCrafting(Constants.ItemName.RedstoneCardTier2).
add()
val GraphicsCard = newAchievement("graphicsCard").
at(0, -5).
withParent(Card).
whenCrafting(Constants.ItemName.GraphicsCardTier1).
whenCrafting(Constants.ItemName.GraphicsCardTier2).
whenCrafting(Constants.ItemName.GraphicsCardTier3).
add()
val NetworkCard = newAchievement("networkCard").
at(2, -4).
withParent(Card).
whenCrafting(Constants.ItemName.NetworkCard).
add()
val WirelessNetworkCard = newAchievement("wirelessNetworkCard").
at(2, -6).
withParent(NetworkCard).
whenCrafting(Constants.ItemName.WirelessNetworkCard).
add()
val Cable = new Achievement("oc.cable", "oc.cable",
-2, 0, Items.get(Constants.BlockName.Cable).createItemStack(1), null, Constants.BlockName.Cable).setIndependent()
val PowerDistributor = new Achievement("oc.powerDistributor", "oc.powerDistributor",
-4, -1, Items.get(Constants.BlockName.PowerDistributor).createItemStack(1), Cable, Constants.BlockName.PowerDistributor)
val Switch = new Achievement("oc.switch", "oc.switch",
-4, 0, Items.get(Constants.BlockName.Switch).createItemStack(1), Cable, "switch", Constants.BlockName.Switch)
val Adapter = new Achievement("oc.adapter", "oc.adapter",
-4, 1, Items.get(Constants.BlockName.Adapter).createItemStack(1), Cable, Constants.BlockName.Adapter)
val Cable = newAchievement("cable").
at(-2, 0).
whenCrafting(Constants.BlockName.Cable).
add()
val PowerDistributor = newAchievement("powerDistributor").
at(-4, -1).
withParent(Cable).
whenCrafting(Constants.BlockName.PowerDistributor).
add()
val Switch = newAchievement("switch").
at(-4, 0).
withParent(Cable).
whenCrafting(Constants.BlockName.Switch).
whenCrafting(Constants.BlockName.AccessPoint).
add()
val Adapter = newAchievement("adapter").
at(-4, 1).
withParent(Cable).
whenCrafting(Constants.BlockName.Adapter).
add()
def init() {
// Missing @Override causes ambiguity, so cast is required; still a virtual call,
// so Achievement.registerStat is still the method that's really being called.
All.foreach(_.asInstanceOf[StatBase].registerStat())
AchievementPage.registerAchievementPage(new AchievementPage("OpenComputers", All: _*))
AchievementPage.registerAchievementPage(new AchievementPage(OpenComputers.Name, All: _*))
}
def onAssemble(stack: ItemStack, player: EntityPlayer): Unit = {
val descriptor = Items.get(stack)
if (descriptor == Items.get(Constants.BlockName.Microcontroller)) player.addStat(Microcontroller, 1)
if (descriptor == Items.get(Constants.BlockName.Robot)) player.addStat(Robot, 1)
if (descriptor == Items.get(Constants.ItemName.Drone)) player.addStat(Drone, 1)
if (descriptor == Items.get(Constants.ItemName.Tablet)) player.addStat(Tablet, 1)
AssemblingMap.get(Items.get(stack)).foreach(player.addStat(_, 1))
}
def onCraft(stack: ItemStack, player: EntityPlayer): Unit = {
CraftingMap.get(Items.get(stack)).foreach(player.addStat(_, 1))
if (ItemStack.areItemStacksEqual(stack, Items.createOpenOS())) {
player.addStat(OpenOS, 1)
}
CustomCraftingMap.find(entry => ItemStack.areItemStacksEqual(stack, entry._1)).foreach(entry => player.addStat(entry._2, 1))
}
}
class Achievement(name: String, description: String, x: Int, y: Int, stack: ItemStack, parent: MCAchievement, requirements: String*) extends MCAchievement(name, description, x, y, stack, parent) {
Achievement.All += this
private def newAchievement(name: String) = new AchievementBuilder(name)
for (requirement <- requirements) {
val descriptor = Items.get(requirement)
if (descriptor != null) {
Achievement.CraftingMap += descriptor -> this
private class AchievementBuilder(val name: String) {
var x = 0
var y = 0
var stack = stackFromName(name)
var parent: Option[MCAchievement] = None
var crafting = mutable.Set.empty[String]
var customCrafting = mutable.Set.empty[ItemStack]
var assembling = mutable.Set.empty[String]
def at(x: Int, y: Int): AchievementBuilder = {
this.x = x
this.y = y
this
}
def withIconOf(stack: ItemStack): AchievementBuilder = {
this.stack = Option(stack)
this
}
def withParent(parent: MCAchievement): AchievementBuilder = {
this.parent = Option(parent)
this
}
def whenCrafting(name: String): AchievementBuilder = {
crafting += name
if (stack.isEmpty) stack = stackFromName(name)
this
}
def whenCrafting(stack: ItemStack): AchievementBuilder = {
customCrafting += stack
if (this.stack.isEmpty) this.stack = Option(stack)
this
}
def whenAssembling(name: String): AchievementBuilder = {
assembling += name
if (stack.isEmpty) stack = stackFromName(name)
this
}
def add(): MCAchievement = {
val achievement = new MCAchievement("oc." + name, "oc." + name, x, y, stack.orNull, parent.orNull)
if (parent.isEmpty) {
achievement.asInstanceOf[StatBase].initIndependentStat()
}
for (requirement <- crafting) {
val descriptor = Items.get(requirement)
if (descriptor != null) {
Achievement.CraftingMap += descriptor -> achievement
}
}
for (requirement <- customCrafting) {
if (requirement != null) {
Achievement.CustomCraftingMap += requirement -> achievement
}
}
for (requirement <- assembling) {
val descriptor = Items.get(requirement)
if (descriptor != null) {
Achievement.AssemblingMap += descriptor -> achievement
}
}
Achievement.All += achievement
achievement
}
private def stackFromName(name: String) = Option(Items.get(name)).map(_.createItemStack(1))
}
}
}

View File

@ -257,6 +257,13 @@ object EventHandler {
(month == Calendar.DECEMBER && dayOfMonth == 14)
}
def isItTime = {
val now = Calendar.getInstance()
val month = now.get(Calendar.MONTH)
val dayOfMonth = now.get(Calendar.DAY_OF_MONTH)
month == Calendar.APRIL && dayOfMonth == 1
}
private def recraft(e: ItemCraftedEvent, item: ItemInfo, callback: ItemStack => Option[ItemStack]): Boolean = {
if (api.Items.get(e.crafting) == item) {
for (slot <- 0 until e.craftMatrix.getSizeInventory) {

View File

@ -2,6 +2,7 @@ package li.cil.oc.common.block
import java.util
import li.cil.oc.Constants
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.client.KeyBindings
@ -76,7 +77,7 @@ class Microcontroller(protected implicit val tileTag: ClassTag[tileentity.Microc
}
true
}
else if (api.Items.get(player.getHeldItem) == api.Items.get("eeprom")) {
else if (api.Items.get(player.getHeldItem) == api.Items.get(Constants.ItemName.EEPROM)) {
if (!world.isRemote) {
world.getTileEntity(pos) match {
case mcu: tileentity.Microcontroller =>

View File

@ -159,10 +159,7 @@ object Items extends ItemAPI {
get(Constants.ItemName.RAMTier6).createItemStack(1)
)
val stack = get(Constants.ItemName.Drone).createItemStack(1)
data.save(stack)
stack
data.createItemStack()
}
def createConfiguredMicrocontroller() = {
@ -182,10 +179,7 @@ object Items extends ItemAPI {
get(Constants.ItemName.RAMTier6).createItemStack(1)
)
val stack = get(Constants.BlockName.Microcontroller).createItemStack(1)
data.save(stack)
stack
data.createItemStack()
}
def createConfiguredRobot() = {
@ -226,10 +220,7 @@ object Items extends ItemAPI {
get(Constants.BlockName.DiskDrive).createItemStack(1)
)
val stack = get(Constants.BlockName.Robot).createItemStack(1)
data.save(stack)
stack
data.createItemStack()
}
def createConfiguredTablet() = {

View File

@ -83,10 +83,11 @@ class Delegator extends Item {
override def isBookEnchantable(itemA: ItemStack, itemB: ItemStack): Boolean = false
override def getRarity(stack: ItemStack) = Delegator.subItem(stack) match {
case Some(subItem) => subItem.rarity(stack)
case _ => EnumRarity.COMMON
}
override def getRarity(stack: ItemStack) =
Delegator.subItem(stack) match {
case Some(subItem) => subItem.rarity(stack)
case _ => EnumRarity.COMMON
}
override def getColorFromItemStack(stack: ItemStack, pass: Int) =
Delegator.subItem(stack) match {

View File

@ -1,5 +1,6 @@
package li.cil.oc.common.item
import li.cil.oc.Constants
import li.cil.oc.api
import net.minecraft.item.ItemStack
@ -7,8 +8,8 @@ class InkCartridge(val parent: Delegator) extends Delegate {
override def maxStackSize = 1
override def getContainerItem(stack: ItemStack): ItemStack = {
if (api.Items.get(stack) == api.Items.get("inkCartridge"))
api.Items.get("inkCartridgeEmpty").createItemStack(1)
if (api.Items.get(stack) == api.Items.get(Constants.ItemName.InkCartridge))
api.Items.get(Constants.ItemName.InkCartridgeEmpty).createItemStack(1)
else
super.getContainerItem(stack)
}

View File

@ -30,7 +30,7 @@ class MicrocontrollerData extends ItemData {
// Reserve slot for EEPROM if necessary, avoids having to resize the
// components array in the MCU tile entity, which isn't possible currently.
if (!components.exists(stack => api.Items.get(stack) == api.Items.get("eeprom"))) {
if (!components.exists(stack => api.Items.get(stack) == api.Items.get(Constants.ItemName.EEPROM))) {
components :+= null
}
}

View File

@ -126,9 +126,9 @@ object PrintData {
private val inkPerCartridge = Settings.get.printInkValue
def materialValue(stack: ItemStack) = {
if (api.Items.get(stack) == api.Items.get("chamelium"))
if (api.Items.get(stack) == api.Items.get(Constants.ItemName.Chamelium))
materialPerItem
else if (api.Items.get(stack) == api.Items.get("print")) {
else if (api.Items.get(stack) == api.Items.get(Constants.BlockName.Print)) {
val data = new PrintData(stack)
computeCosts(data) match {
case Some((materialRequired, inkRequired)) => (materialRequired * Settings.get.printRecycleRate).toInt
@ -139,7 +139,7 @@ object PrintData {
}
def inkValue(stack: ItemStack) = {
if (api.Items.get(stack) == api.Items.get("inkCartridge"))
if (api.Items.get(stack) == api.Items.get(Constants.ItemName.InkCartridge))
inkPerCartridge
else if (Color.isDye(stack))
inkPerCartridge / 10

View File

@ -1,5 +1,6 @@
package li.cil.oc.common.tileentity
import li.cil.oc.Constants
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.internal
@ -235,7 +236,7 @@ class Microcontroller extends traits.PowerAcceptor with traits.Hub with traits.C
// For hotswapping EEPROMs.
def changeEEPROM(newEeprom: ItemStack) = {
val oldEepromIndex = info.components.indexWhere(api.Items.get(_) == api.Items.get("eeprom"))
val oldEepromIndex = info.components.indexWhere(api.Items.get(_) == api.Items.get(Constants.ItemName.EEPROM))
if (oldEepromIndex >= 0) {
val oldEeprom = info.components(oldEepromIndex)
super.setInventorySlotContents(oldEepromIndex, newEeprom)

View File

@ -4,9 +4,7 @@ import codechicken.lib.data.MCDataInput
import codechicken.lib.data.MCDataOutput
import codechicken.lib.vec.Cuboid6
import codechicken.lib.vec.Vector3
import codechicken.multipart._
import cpw.mods.fml.relauncher.Side
import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.Constants
import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.api.Items
@ -20,7 +18,6 @@ import li.cil.oc.common.block.Cable
import li.cil.oc.common.tileentity
import li.cil.oc.util.Color
import li.cil.oc.util.ExtendedNBT._
import net.minecraft.client.renderer.RenderBlocks
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
@ -55,9 +52,9 @@ class CablePart(val original: Option[tileentity.Cable] = None) extends SimpleBlo
// ----------------------------------------------------------------------- //
override def simpleBlock = Items.get("cable").block().asInstanceOf[Cable]
override def simpleBlock = Items.get(Constants.BlockName.Cable).block().asInstanceOf[Cable]
def getType = Settings.namespace + "cable"
def getType = Settings.namespace + Constants.BlockName.Cable
override def doesTick = false

View File

@ -4,8 +4,7 @@ import codechicken.lib.packet.PacketCustom
import codechicken.lib.raytracer.RayTracer
import codechicken.lib.vec.BlockCoord
import codechicken.lib.vec.Vector3
import codechicken.multipart.TileMultipart
import cpw.mods.fml.common.eventhandler.SubscribeEvent
import li.cil.oc.Constants
import li.cil.oc.Settings
import li.cil.oc.api.Items
import li.cil.oc.client.PacketSender
@ -51,10 +50,10 @@ object EventHandler {
case itemBlock: ItemBlock =>
itemBlock.field_150939_a match {
case simpleBlock: SimpleBlock =>
if (simpleBlock == Items.get("cable").block()) {
if (simpleBlock == Items.get(Constants.BlockName.Cable).block()) {
placeDelegatePart(player, hit, new CablePart())
}
else if (simpleBlock == Items.get("print").block()) {
else if (simpleBlock == Items.get(Constants.BlockName.Print).block()) {
val part = new PrintPart()
part.data.load(player.getHeldItem)
part.facing = yaw2Direction((player.rotationYaw / 360 * 4).round & 3).getOpposite

View File

@ -3,8 +3,7 @@ package li.cil.oc.integration.fmp
import java.util
import codechicken.lib.vec.BlockCoord
import codechicken.multipart.MultiPartRegistry
import codechicken.multipart.MultiPartRegistry.IPartConverter
import li.cil.oc.Constants
import li.cil.oc.api.Items
import li.cil.oc.common.tileentity.Cable
import li.cil.oc.common.tileentity.Print
@ -16,8 +15,8 @@ object MultipartConverter extends IPartConverter {
}
override def blockTypes = util.Arrays.asList(
Items.get("cable").block,
Items.get("print").block
Items.get(Constants.BlockName.Cable).block,
Items.get(Constants.BlockName.Print).block
)
override def convert(world: World, pos: BlockCoord) = {

View File

@ -7,6 +7,7 @@ import codechicken.lib.data.MCDataOutput
import codechicken.lib.raytracer.ExtendedMOP
import codechicken.lib.vec.Cuboid6
import codechicken.lib.vec.Vector3
import li.cil.oc.Constants
import li.cil.oc.Settings
import li.cil.oc.api.Items
import li.cil.oc.common.block.Print
@ -88,9 +89,9 @@ class PrintPart(val original: Option[tileentity.Print] = None) extends SimpleBlo
// ----------------------------------------------------------------------- //
override def simpleBlock = Items.get("print").block().asInstanceOf[Print]
override def simpleBlock = Items.get(Constants.BlockName.Print).block().asInstanceOf[Print]
def getType = Settings.namespace + "print"
def getType = Settings.namespace + Constants.BlockName.Print
override def doesTick = false

View File

@ -1,5 +1,6 @@
package li.cil.oc.integration.gc
import li.cil.oc.Constants
import li.cil.oc.api
import li.cil.oc.api.driver.EnvironmentAware
import li.cil.oc.api.driver.EnvironmentHost
@ -11,7 +12,7 @@ import net.minecraft.item.ItemStack
object DriverWorldSensorCard extends Item with HostAware with EnvironmentAware {
override def worksWith(stack: ItemStack) =
isOneOf(stack, api.Items.get("worldSensorCard"))
isOneOf(stack, api.Items.get(Constants.ItemName.WorldSensorCard))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (Mods.Galacticraft.isAvailable) new WorldSensorCard(host)

View File

@ -30,10 +30,11 @@ object DriverCPU extends Item with Processor {
case _ => Tier.One
}
override def supportedComponents(stack: ItemStack) = Delegator.subItem(stack) match {
case Some(cpu: item.CPU) => Settings.get.cpuComponentSupport(cpu.tier)
case _ => Tier.One
}
override def supportedComponents(stack: ItemStack) =
Delegator.subItem(stack) match {
case Some(cpu: item.CPU) => Settings.get.cpuComponentSupport(cpu.tier)
case _ => Tier.One
}
override def architecture(stack: ItemStack): Class[_ <: Architecture] = {
if (stack.hasTagCompound) {

View File

@ -21,15 +21,17 @@ object DriverComponentBus extends Item with Processor {
override def slot(stack: ItemStack) = Slot.ComponentBus
override def tier(stack: ItemStack) = Delegator.subItem(stack) match {
case Some(bus: item.ComponentBus) => bus.tier
case _ => Tier.One
}
override def tier(stack: ItemStack) =
Delegator.subItem(stack) match {
case Some(bus: item.ComponentBus) => bus.tier
case _ => Tier.One
}
override def supportedComponents(stack: ItemStack) = Delegator.subItem(stack) match {
case Some(bus: item.ComponentBus) => Settings.get.cpuComponentSupport(bus.tier)
case _ => Tier.One
}
override def supportedComponents(stack: ItemStack) =
Delegator.subItem(stack) match {
case Some(bus: item.ComponentBus) => Settings.get.cpuComponentSupport(bus.tier)
case _ => Tier.One
}
override def architecture(stack: ItemStack) = null
}

View File

@ -24,8 +24,9 @@ object DriverContainerCard extends Item with Container {
override def providedTier(stack: ItemStack) = tier(stack)
override def tier(stack: ItemStack) = Delegator.subItem(stack) match {
case Some(container: item.UpgradeContainerCard) => container.tier
case _ => Tier.One
}
override def tier(stack: ItemStack) =
Delegator.subItem(stack) match {
case Some(container: item.UpgradeContainerCard) => container.tier
case _ => Tier.One
}
}

View File

@ -24,8 +24,9 @@ object DriverContainerUpgrade extends Item with Container {
override def providedTier(stack: ItemStack) = tier(stack)
override def tier(stack: ItemStack) = Delegator.subItem(stack) match {
case Some(container: item.UpgradeContainerUpgrade) => container.tier
case _ => Tier.One
}
override def tier(stack: ItemStack) =
Delegator.subItem(stack) match {
case Some(container: item.UpgradeContainerUpgrade) => container.tier
case _ => Tier.One
}
}

View File

@ -22,22 +22,25 @@ object DriverFileSystem extends Item {
api.Items.get(Constants.ItemName.Floppy)) &&
(!stack.hasTagCompound || !stack.getTagCompound.hasKey(Settings.namespace + "lootPath"))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) = Delegator.subItem(stack) match {
case Some(hdd: HardDiskDrive) => createEnvironment(stack, hdd.kiloBytes * 1024, host)
case Some(disk: FloppyDisk) => createEnvironment(stack, Settings.get.floppySize * 1024, host)
case _ => null
}
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
Delegator.subItem(stack) match {
case Some(hdd: HardDiskDrive) => createEnvironment(stack, hdd.kiloBytes * 1024, host)
case Some(disk: FloppyDisk) => createEnvironment(stack, Settings.get.floppySize * 1024, host)
case _ => null
}
override def slot(stack: ItemStack) = Delegator.subItem(stack) match {
case Some(hdd: HardDiskDrive) => Slot.HDD
case Some(disk: FloppyDisk) => Slot.Floppy
case _ => throw new IllegalArgumentException()
}
override def slot(stack: ItemStack) =
Delegator.subItem(stack) match {
case Some(hdd: HardDiskDrive) => Slot.HDD
case Some(disk: FloppyDisk) => Slot.Floppy
case _ => throw new IllegalArgumentException()
}
override def tier(stack: ItemStack) = Delegator.subItem(stack) match {
case Some(hdd: HardDiskDrive) => hdd.tier
case _ => 0
}
override def tier(stack: ItemStack) =
Delegator.subItem(stack) match {
case Some(hdd: HardDiskDrive) => hdd.tier
case _ => 0
}
private def createEnvironment(stack: ItemStack, capacity: Int, host: EnvironmentHost) = if (DimensionManager.getWorld(0) != null) {
// We have a bit of a chicken-egg problem here, because we want to use the

View File

@ -28,10 +28,11 @@ object DriverGraphicsCard extends Item with HostAware with EnvironmentAware {
override def slot(stack: ItemStack) = Slot.Card
override def tier(stack: ItemStack) = Delegator.subItem(stack) match {
case Some(gpu: common.item.GraphicsCard) => gpu.tier
case _ => Tier.One
}
override def tier(stack: ItemStack) =
Delegator.subItem(stack) match {
case Some(gpu: common.item.GraphicsCard) => gpu.tier
case _ => Tier.One
}
override def providedEnvironment(stack: ItemStack) = classOf[component.GraphicsCard]
}

View File

@ -27,8 +27,9 @@ object DriverMemory extends Item with driver.item.Memory {
override def slot(stack: ItemStack) = Slot.Memory
override def tier(stack: ItemStack) = Delegator.subItem(stack) match {
case Some(memory: item.Memory) => memory.tier / 2
case _ => Tier.One
}
override def tier(stack: ItemStack) =
Delegator.subItem(stack) match {
case Some(memory: item.Memory) => memory.tier / 2
case _ => Tier.One
}
}

View File

@ -41,10 +41,11 @@ object DriverRedstoneCard extends Item with HostAware with EnvironmentAware {
override def slot(stack: ItemStack) = Slot.Card
override def tier(stack: ItemStack) = Delegator.subItem(stack) match {
case Some(card: item.RedstoneCard) => card.tier
case _ => Tier.One
}
override def tier(stack: ItemStack) =
Delegator.subItem(stack) match {
case Some(card: item.RedstoneCard) => card.tier
case _ => Tier.One
}
override def providedEnvironment(stack: ItemStack): Class[_ <: Environment] = {
val isAdvanced = tier(stack) == Tier.Two

View File

@ -21,8 +21,9 @@ object DriverUpgradeBattery extends Item with HostAware {
override def slot(stack: ItemStack) = Slot.Upgrade
override def tier(stack: ItemStack) = Delegator.subItem(stack) match {
case Some(battery: item.UpgradeBattery) => battery.tier
case _ => Tier.One
}
override def tier(stack: ItemStack) =
Delegator.subItem(stack) match {
case Some(battery: item.UpgradeBattery) => battery.tier
case _ => Tier.One
}
}

View File

@ -31,10 +31,11 @@ object DriverUpgradeDatabase extends Item with HostAware with EnvironmentAware {
override def slot(stack: ItemStack) = Slot.Upgrade
override def tier(stack: ItemStack) = Delegator.subItem(stack) match {
case Some(database: item.UpgradeDatabase) => database.tier
case _ => Tier.One
}
override def tier(stack: ItemStack) =
Delegator.subItem(stack) match {
case Some(database: item.UpgradeDatabase) => database.tier
case _ => Tier.One
}
override def providedEnvironment(stack: ItemStack) = classOf[component.UpgradeDatabase]
}

View File

@ -1,5 +1,6 @@
package li.cil.oc.integration.stargatetech2
import li.cil.oc.Constants
import li.cil.oc.api
import li.cil.oc.api.driver.EnvironmentAware
import li.cil.oc.api.driver.EnvironmentHost
@ -11,7 +12,7 @@ import net.minecraft.item.ItemStack
object DriverAbstractBusCard extends Item with HostAware with EnvironmentAware {
override def worksWith(stack: ItemStack) =
isOneOf(stack, api.Items.get("abstractBusCard"))
isOneOf(stack, api.Items.get(Constants.ItemName.AbstractBusCard))
override def worksWith(stack: ItemStack, host: Class[_ <: EnvironmentHost]) =
worksWith(stack) && (isComputer(host) || isRobot(host) || isServer(host) || isMicrocontroller(host))