diff --git a/src/main/resources/assets/opencomputers/lang/de_DE.lang b/src/main/resources/assets/opencomputers/lang/de_DE.lang index 999e05b04..029e38e05 100644 --- a/src/main/resources/assets/opencomputers/lang/de_DE.lang +++ b/src/main/resources/assets/opencomputers/lang/de_DE.lang @@ -20,6 +20,7 @@ oc:tile.PowerDistributor.name=Stromverteiler oc:tile.Redstone.name=Redstone-I/O oc:tile.Robot.name=Roboter oc:tile.RobotAfterimage.name=Roboter +oc:tile.RobotAssembler.name=Roboter-Werkbank oc:tile.Router.name=Switch oc:tile.Screen0.name=Bildschirm (Stufe 1) oc:tile.Screen1.name=Bildschirm (Stufe 2) @@ -117,9 +118,10 @@ oc:gui.Error.OutOfMemory=Nicht genug Arbeitsspeicher. oc:gui.Robot.Power=Energie oc:gui.Robot.TurnOff=Ausschalten oc:gui.Robot.TurnOn=Einschalten +oc:gui.RobotAssembler.CollectRobot=Roboter entnehmen oc:gui.RobotAssembler.Complexity=Komplexität: %s/%s oc:gui.RobotAssembler.InsertCase=Computergehäuse einlegen -oc:gui.RobotAssembler.Run=Bauen +oc:gui.RobotAssembler.Run=Zusammenbauen oc:gui.ServerRack.None=Keine oc:gui.ServerRack.Back=Hinten oc:gui.ServerRack.Bottom=Unten @@ -188,6 +190,7 @@ oc:tooltip.Robot=Im Gegensatz zu normalen Computern können sich Roboter in der # The underscore makes sure this isn't hidden with the rest of the tooltip. oc:tooltip.Robot_Level=§fStufe§7: §a%s§7. oc:tooltip.Robot_StoredEnergy=§fGespeicherte Energie§7: §a%s§7. +oc:tooltip.RobotAssembler=Erlaubt das Bauen von Robotern aus diversen anderen Computerteilen. oc:tooltip.Router=Erlaubt es, mehrere Netzwerke miteinander zu verbinden. Leitet ausschließlich Netzwerknachrichten weiter, Komponenten "hinter" dem Switch sind nicht sichtbar. Nützlich, um Netzwerke zu trennen, jedoch nach wie vor Kommunikation zwischen den Netzwerken zu erlauben, z.b. mittels Netzwerkkarten. oc:tooltip.Screen=Zeigt Text an, gesteuert von Grafikkarten in Computern.[nl] Höchstauflösung: §f%sx%s§7.[nl] Maximale Farbtiefe: §f%s§7. oc:tooltip.Server=Ein Server kann wie ein gewöhnliches Computergehäuse mit Komponenten verbessert werden. Um den Server zu starten, muss er in einem Servergehäuse installiert werden.[nl] Anzahl unterstützter Fernbedienungen: §f%s§7. diff --git a/src/main/resources/assets/opencomputers/lang/en_US.lang b/src/main/resources/assets/opencomputers/lang/en_US.lang index 1f4a1a56f..263ec9e8d 100644 --- a/src/main/resources/assets/opencomputers/lang/en_US.lang +++ b/src/main/resources/assets/opencomputers/lang/en_US.lang @@ -20,6 +20,7 @@ oc:tile.PowerDistributor.name=Power Distributor oc:tile.Redstone.name=Redstone I/O oc:tile.Robot.name=Robot oc:tile.RobotAfterimage.name=Robot +oc:tile.RobotAssembler.name=Robot Assembler oc:tile.Router.name=Switch oc:tile.Screen0.name=Screen (Tier 1) oc:tile.Screen1.name=Screen (Tier 2) @@ -117,6 +118,7 @@ oc:gui.Error.OutOfMemory=Out of memory. oc:gui.Robot.Power=Energy oc:gui.Robot.TurnOff=Turn off oc:gui.Robot.TurnOn=Turn on +oc:gui.RobotAssembler.CollectRobot=Collect robot oc:gui.RobotAssembler.Complexity=Complexity: %s/%s oc:gui.RobotAssembler.InsertCase=Insert a Computer Case oc:gui.RobotAssembler.Run=Assemble @@ -188,6 +190,7 @@ oc:tooltip.Robot=Unlike computers, robots can move around and interact with the # The underscore makes sure this isn't hidden with the rest of the tooltip. oc:tooltip.Robot_Level=§fLevel§7: §a%s§7. oc:tooltip.Robot_StoredEnergy=§fStored energy§7: §a%s§7. +oc:tooltip.RobotAssembler=Allows constructing robots from a number of different computer parts. oc:tooltip.Router=Allows connecting different networks to each other. Only network messages will be passed along, components will not be visible through this. Use this to separate networks while still allowing communication using Network Cards, for example. oc:tooltip.Screen=Display text, controlled by a Graphics Card in a Case.[nl] Maximum resolution: §f%sx%s§7.[nl] Maximum color depth: §f%s§7. oc:tooltip.Server=This is a server, there are many like it, but this one can be upgraded with components much like a computer case can be. It can be run by inserting it into a server rack.[nl] Number of supported terminals: §f%s§7. diff --git a/src/main/resources/assets/opencomputers/recipes/default.recipes b/src/main/resources/assets/opencomputers/recipes/default.recipes index aea44390a..1154ff97b 100644 --- a/src/main/resources/assets/opencomputers/recipes/default.recipes +++ b/src/main/resources/assets/opencomputers/recipes/default.recipes @@ -370,11 +370,6 @@ redstone { [blockRedstone, "oc:redstoneCard", blockRedstone] [ingotIron, "oc:materialCircuitBoardPrinted", ingotIron]] } -robot { - input: [["oc:screen1", "oc:graphicsCard1", "oc:diskDrive"] - [dispenser, "oc:case1", "oc:ram1"] - ["oc:capacitor", minecartHopper, "oc:capacitor"]] -} robotAssembler { input: [[ingotIron, workbench, ingotIron] [craftingPiston, "oc:circuitChip2", craftingPiston] diff --git a/src/main/resources/assets/opencomputers/recipes/gregtech.recipes b/src/main/resources/assets/opencomputers/recipes/gregtech.recipes index 0d5e91e70..dcd2a5555 100644 --- a/src/main/resources/assets/opencomputers/recipes/gregtech.recipes +++ b/src/main/resources/assets/opencomputers/recipes/gregtech.recipes @@ -286,11 +286,6 @@ redstone { [{block=BlockMetaID_Machine, subID=69}, craftingRawMachineTier02, "oc:redstoneCard"] ["oc:circuitChip2", "oc:materialCircuitBoardPrinted", "oc:circuitChip2"]] } -robot { - input: [["oc:screen1", "oc:graphicsCard1", "oc:diskDrive"] - [{block=BlockMetaID_Machine, subID=46}, craftingRawMachineTier02, "oc:ram1"] - [{item=Electric, subID=7}, craftingToolWrench, {item=Electric, subID=7}]] -} switch { input: [["", "oc:lanCard", ""] ["oc:cable", craftingRawMachineTier02, "oc:cable"] diff --git a/src/main/resources/assets/opencomputers/recipes/hardmode.recipes b/src/main/resources/assets/opencomputers/recipes/hardmode.recipes index 7b625e477..9a1ecd99a 100644 --- a/src/main/resources/assets/opencomputers/recipes/hardmode.recipes +++ b/src/main/resources/assets/opencomputers/recipes/hardmode.recipes @@ -302,11 +302,6 @@ redstone { [blockRedstone, "oc:redstoneCard", blockRedstone] [ingotIron, "oc:materialCircuitBoardPrinted", ingotIron]] } -robot { - input: [["oc:screen1", "oc:graphicsCard1", "oc:diskDrive"] - [dispenser, "oc:case1", "oc:ram1"] - ["oc:capacitor", minecartHopper, "oc:capacitor"]] -} switch { input: [[ingotIron, "oc:cable", ingotIron] ["oc:cable", "oc:lanCard", "oc:cable"] diff --git a/src/main/scala/li/cil/oc/Blocks.scala b/src/main/scala/li/cil/oc/Blocks.scala index 5c30d5c46..b653f5e10 100644 --- a/src/main/scala/li/cil/oc/Blocks.scala +++ b/src/main/scala/li/cil/oc/Blocks.scala @@ -3,8 +3,6 @@ package li.cil.oc import cpw.mods.fml.common.registry.GameRegistry import li.cil.oc.common.block._ import li.cil.oc.common.tileentity -import net.minecraft.item.ItemStack -import net.minecraft.nbt.NBTTagCompound import li.cil.oc.common.recipe.Recipes object Blocks { @@ -13,24 +11,14 @@ object Blocks { var blockSpecial: SpecialDelegator = _ var blockSpecialWithRedstone: SpecialDelegator = _ - var cable: Cable = _ var robotProxy: RobotProxy = _ var robotAfterimage: RobotAfterimage = _ - var screen1, screen2, screen3: Screen = _ def init() { blockSimple = new SimpleDelegator(Settings.get.blockId1) blockSimpleWithRedstone = new SimpleRedstoneDelegator(Settings.get.blockId2) blockSpecial = new SpecialDelegator(Settings.get.blockId3) - blockSpecialWithRedstone = new SpecialRedstoneDelegator(Settings.get.blockId4) { - override def subBlockItemStacks() = super.subBlockItemStacks() ++ Iterable({ - val stack = new ItemStack(this, 1, robotProxy.blockId) - stack.setTagCompound(new NBTTagCompound("tag")) - stack.getTagCompound.setDouble(Settings.namespace + "xp", Settings.get.baseXpToLevel + math.pow(30.0001 * Settings.get.constantXpGrowth, Settings.get.exponentialXpGrowth)) - stack.getTagCompound.setInteger(Settings.namespace + "storedEnergy", (Settings.get.bufferRobot + Settings.get.bufferPerLevel * 30).toInt) - stack - }) - } + blockSpecialWithRedstone = new SpecialRedstoneDelegator(Settings.get.blockId4) GameRegistry.registerBlock(blockSimple, classOf[Item], Settings.namespace + "simple") GameRegistry.registerBlock(blockSimpleWithRedstone, classOf[Item], Settings.namespace + "simple_redstone") @@ -59,44 +47,40 @@ object Blocks { // IMPORTANT: the multi block must come first, since the sub blocks will // try to register with it. Also, the order the sub blocks are created in // must not be changed since that order determines their actual IDs. - Recipes.addBlockDelegate(new Adapter(blockSimple), "adapter", "oc:adapter") - cable = Recipes.addBlockDelegate(new Cable(blockSpecial), "cable", "oc:cable") - Recipes.addBlockDelegate(new Capacitor(blockSimple), "capacitor", "oc:capacitor") - Recipes.addBlockDelegate(new Case.Tier1(blockSimpleWithRedstone), "case1", "oc:case1") - Recipes.addBlockDelegate(new Case.Tier2(blockSimpleWithRedstone), "case2", "oc:case2") - Recipes.addBlockDelegate(new Case.Tier3(blockSimpleWithRedstone), "case3", "oc:case3") - Recipes.addBlockDelegate(new Charger(blockSimpleWithRedstone), "charger", "oc:charger") - Recipes.addBlockDelegate(new DiskDrive(blockSimple), "diskDrive", "oc:diskDrive") - Recipes.addBlockDelegate(new Keyboard(blockSpecial), "keyboard", "oc:keyboard") - Recipes.addBlockDelegate(new PowerDistributor(blockSimple), "powerDistributor", "oc:powerDistributor") - Recipes.addBlockDelegate(new PowerConverter(blockSimple), "powerConverter", "oc:powerConverter") - Recipes.addBlockDelegate(new Redstone(blockSimpleWithRedstone), "redstone", "oc:redstone") + Recipes.addBlock(new Adapter(blockSimple), "adapter", "oc:adapter") + Recipes.addBlock(new Cable(blockSpecial), "cable", "oc:cable") + Recipes.addBlock(new Capacitor(blockSimple), "capacitor", "oc:capacitor") + Recipes.addBlock(new Case.Tier1(blockSimpleWithRedstone), "case1", "oc:case1") + Recipes.addBlock(new Case.Tier2(blockSimpleWithRedstone), "case2", "oc:case2") + Recipes.addBlock(new Case.Tier3(blockSimpleWithRedstone), "case3", "oc:case3") + Recipes.addBlock(new Charger(blockSimpleWithRedstone), "charger", "oc:charger") + Recipes.addBlock(new DiskDrive(blockSimple), "diskDrive", "oc:diskDrive") + Recipes.addBlock(new Keyboard(blockSpecial), "keyboard", "oc:keyboard") + Recipes.addBlock(new PowerDistributor(blockSimple), "powerDistributor", "oc:powerDistributor") + Recipes.addBlock(new PowerConverter(blockSimple), "powerConverter", "oc:powerConverter") + Recipes.addBlock(new Redstone(blockSimpleWithRedstone), "redstone", "oc:redstone") robotAfterimage = new RobotAfterimage(blockSpecial) - robotProxy = Recipes.addBlockDelegate(new RobotProxy(blockSpecialWithRedstone), "robot", "oc:robot") - Recipes.addBlockDelegate(new Switch(blockSimple), "switch", "oc:switch") - screen1 = Recipes.addBlockDelegate(new Screen.Tier1(blockSimpleWithRedstone), "screen1", "oc:screen1") - screen2 = Recipes.addBlockDelegate(new Screen.Tier2(blockSimpleWithRedstone), "screen2", "oc:screen2") - screen3 = Recipes.addBlockDelegate(new Screen.Tier3(blockSimpleWithRedstone), "screen3", "oc:screen3") - - // For automatic conversion from old format (when screens did not take - // redstone inputs) to keep save format compatible. - blockSimple.subBlocks += screen1 - blockSimple.subBlocks += screen2 - blockSimple.subBlocks += screen3 + robotProxy = Items.registerBlock(new RobotProxy(blockSpecialWithRedstone), "robot") + Recipes.addBlock(new Switch(blockSimple), "switch", "oc:switch") + // Copied to simple block for automatic conversion from old format (when + // screens did not take redstone inputs) to keep save format compatible. + blockSimple.subBlocks += Recipes.addBlock(new Screen.Tier1(blockSimpleWithRedstone), "screen1", "oc:screen1") + blockSimple.subBlocks += Recipes.addBlock(new Screen.Tier2(blockSimpleWithRedstone), "screen2", "oc:screen2") + blockSimple.subBlocks += Recipes.addBlock(new Screen.Tier3(blockSimpleWithRedstone), "screen3", "oc:screen3") // v1.2.0 - Recipes.addBlockDelegate(new Rack(blockSpecialWithRedstone), "rack", "oc:rack") + Recipes.addBlock(new Rack(blockSpecialWithRedstone), "rack", "oc:rack") // v1.2.2 - Recipes.addBlockDelegate(new Hologram.Tier1(blockSpecial), "hologram1", "oc:hologram1") - Recipes.addBlockDelegate(new AccessPoint(blockSimple), "accessPoint", "oc:accessPoint") + Recipes.addBlock(new Hologram.Tier1(blockSpecial), "hologram1", "oc:hologram1") + Recipes.addBlock(new AccessPoint(blockSimple), "accessPoint", "oc:accessPoint") // v1.2.6 new Case.TierCreative(blockSimpleWithRedstone) // v1.3.0 - Recipes.addBlockDelegate(new Hologram.Tier2(blockSpecial), "hologram2", "oc:hologram2") - Recipes.addBlockDelegate(new Geolyzer(blockSimple), "geolyzer", "oc:geolyzer") - Recipes.addBlockDelegate(new RobotAssembler(blockSpecial), "robotAssembler", "oc:robotAssembler") + Recipes.addBlock(new Hologram.Tier2(blockSpecial), "hologram2", "oc:hologram2") + Recipes.addBlock(new Geolyzer(blockSimple), "geolyzer", "oc:geolyzer") + Recipes.addBlock(new RobotAssembler(blockSpecial), "robotAssembler", "oc:robotAssembler") } } \ No newline at end of file diff --git a/src/main/scala/li/cil/oc/Items.scala b/src/main/scala/li/cil/oc/Items.scala index 414c9e9f0..4fff8f2f9 100644 --- a/src/main/scala/li/cil/oc/Items.scala +++ b/src/main/scala/li/cil/oc/Items.scala @@ -21,7 +21,7 @@ object Items extends ItemAPI { case _ => null } - def register(delegate: common.block.Delegate, name: String) { + def registerBlock[T <: common.block.Delegate](delegate: T, name: String) = { descriptors += name -> new ItemInfo { override def block = delegate.parent @@ -30,9 +30,10 @@ object Items extends ItemAPI { override def createItemStack(size: Int) = delegate.createItemStack(size) } names += delegate -> name + delegate } - def register(instance: Block, name: String) { + def registerBlock(instance: Block, name: String) = { descriptors += name -> new ItemInfo { override def block = instance @@ -41,9 +42,10 @@ object Items extends ItemAPI { override def createItemStack(size: Int) = new ItemStack(instance, size) } names += instance -> name + instance } - def register(delegate: common.item.Delegate, name: String) { + def registerItem[T <: common.item.Delegate](delegate: T, name: String) = { descriptors += name -> new ItemInfo { override def block = null @@ -52,9 +54,10 @@ object Items extends ItemAPI { override def createItemStack(size: Int) = delegate.createItemStack(size) } names += delegate -> name + delegate } - def register(instance: Item, name: String) { + def registerItem(instance: Item, name: String) = { descriptors += name -> new ItemInfo { override def block = null @@ -63,6 +66,7 @@ object Items extends ItemAPI { override def createItemStack(size: Int) = new ItemStack(instance, size) } names += instance -> name + instance } private def getBlockOrItem(stack: ItemStack): Any = if (stack == null) null else { @@ -93,92 +97,92 @@ object Items extends ItemAPI { GameRegistry.registerItem(multi, Settings.namespace + "item") - Recipes.addItemDelegate(new item.Analyzer(multi), "analyzer", "oc:analyzer") + Recipes.addItem(new item.Analyzer(multi), "analyzer", "oc:analyzer") - Recipes.addItemDelegate(new item.Memory(multi, 0), "ram1", "oc:ram1") - Recipes.addItemDelegate(new item.Memory(multi, 2), "ram3", "oc:ram3") - Recipes.addItemDelegate(new item.Memory(multi, 3), "ram4", "oc:ram4") + Recipes.addItem(new item.Memory(multi, 0), "ram1", "oc:ram1") + Recipes.addItem(new item.Memory(multi, 2), "ram3", "oc:ram3") + Recipes.addItem(new item.Memory(multi, 3), "ram4", "oc:ram4") - Recipes.addItemDelegate(new item.FloppyDisk(multi), "floppy", "oc:floppy") - Recipes.addItemDelegate(new item.HardDiskDrive(multi, 0), "hdd1", "oc:hdd1") - Recipes.addItemDelegate(new item.HardDiskDrive(multi, 1), "hdd2", "oc:hdd2") - Recipes.addItemDelegate(new item.HardDiskDrive(multi, 2), "hdd3", "oc:hdd3") + Recipes.addItem(new item.FloppyDisk(multi), "floppy", "oc:floppy") + Recipes.addItem(new item.HardDiskDrive(multi, 0), "hdd1", "oc:hdd1") + Recipes.addItem(new item.HardDiskDrive(multi, 1), "hdd2", "oc:hdd2") + Recipes.addItem(new item.HardDiskDrive(multi, 2), "hdd3", "oc:hdd3") - Recipes.addItemDelegate(new item.GraphicsCard(multi, 0), "graphicsCard1", "oc:graphicsCard1") - Recipes.addItemDelegate(new item.GraphicsCard(multi, 1), "graphicsCard2", "oc:graphicsCard2") - Recipes.addItemDelegate(new item.GraphicsCard(multi, 2), "graphicsCard3", "oc:graphicsCard3") - Recipes.addItemDelegate(new item.NetworkCard(multi), "lanCard", "oc:lanCard") - Recipes.addItemDelegate(new item.RedstoneCard(multi), "redstoneCard", "oc:redstoneCard") - Recipes.addItemDelegate(new item.WirelessNetworkCard(multi), "wlanCard", "oc:wlanCard") + Recipes.addItem(new item.GraphicsCard(multi, 0), "graphicsCard1", "oc:graphicsCard1") + Recipes.addItem(new item.GraphicsCard(multi, 1), "graphicsCard2", "oc:graphicsCard2") + Recipes.addItem(new item.GraphicsCard(multi, 2), "graphicsCard3", "oc:graphicsCard3") + Recipes.addItem(new item.NetworkCard(multi), "lanCard", "oc:lanCard") + Recipes.addItem(new item.RedstoneCard(multi), "redstoneCard", "oc:redstoneCard") + Recipes.addItem(new item.WirelessNetworkCard(multi), "wlanCard", "oc:wlanCard") - Recipes.addItemDelegate(new item.UpgradeCrafting(multi), "craftingUpgrade", "oc:craftingUpgrade") - Recipes.addItemDelegate(new item.UpgradeGenerator(multi), "generatorUpgrade", "oc:generatorUpgrade") + Recipes.addItem(new item.UpgradeCrafting(multi), "craftingUpgrade", "oc:craftingUpgrade") + Recipes.addItem(new item.UpgradeGenerator(multi), "generatorUpgrade", "oc:generatorUpgrade") ironNugget = new item.IronNugget(multi) - Recipes.addItemDelegate(new item.CuttingWire(multi), "cuttingWire", "oc:materialCuttingWire") - Recipes.addItemDelegate(new item.Acid(multi), "acid", "oc:materialAcid") - Recipes.addItemDelegate(new item.Disk(multi), "disk", "oc:materialDisk") + Recipes.addItem(new item.CuttingWire(multi), "cuttingWire", "oc:materialCuttingWire") + Recipes.addItem(new item.Acid(multi), "acid", "oc:materialAcid") + Recipes.addItem(new item.Disk(multi), "disk", "oc:materialDisk") - Recipes.addItemDelegate(new item.ButtonGroup(multi), "buttonGroup", "oc:materialButtonGroup") - Recipes.addItemDelegate(new item.ArrowKeys(multi), "arrowKeys", "oc:materialArrowKey") - Recipes.addItemDelegate(new item.NumPad(multi), "numPad", "oc:materialNumPad") + Recipes.addItem(new item.ButtonGroup(multi), "buttonGroup", "oc:materialButtonGroup") + Recipes.addItem(new item.ArrowKeys(multi), "arrowKeys", "oc:materialArrowKey") + Recipes.addItem(new item.NumPad(multi), "numPad", "oc:materialNumPad") - Recipes.addItemDelegate(new item.Transistor(multi), "transistor", "oc:materialTransistor") - Recipes.addItemDelegate(new item.Microchip(multi, 0), "chip1", "oc:circuitChip1") - Recipes.addItemDelegate(new item.Microchip(multi, 1), "chip2", "oc:circuitChip2") - Recipes.addItemDelegate(new item.Microchip(multi, 2), "chip3", "oc:circuitChip3") - Recipes.addItemDelegate(new item.ALU(multi), "alu", "oc:materialALU") - Recipes.addItemDelegate(new item.ControlUnit(multi), "cu", "oc:materialCU") - Recipes.addItemDelegate(new item.CPU(multi, 0), "cpu1", "oc:cpu1") + Recipes.addItem(new item.Transistor(multi), "transistor", "oc:materialTransistor") + Recipes.addItem(new item.Microchip(multi, 0), "chip1", "oc:circuitChip1") + Recipes.addItem(new item.Microchip(multi, 1), "chip2", "oc:circuitChip2") + Recipes.addItem(new item.Microchip(multi, 2), "chip3", "oc:circuitChip3") + Recipes.addItem(new item.ALU(multi), "alu", "oc:materialALU") + Recipes.addItem(new item.ControlUnit(multi), "cu", "oc:materialCU") + Recipes.addItem(new item.CPU(multi, 0), "cpu1", "oc:cpu1") - Recipes.addItemDelegate(new item.RawCircuitBoard(multi), "rawCircuitBoard", "oc:materialCircuitBoardRaw") - Recipes.addItemDelegate(new item.CircuitBoard(multi), "circuitBoard", "oc:materialCircuitBoard") - Recipes.addItemDelegate(new item.PrintedCircuitBoard(multi), "printedCircuitBoard", "oc:materialCircuitBoardPrinted") - Recipes.addItemDelegate(new item.CardBase(multi), "card", "oc:materialCard") + Recipes.addItem(new item.RawCircuitBoard(multi), "rawCircuitBoard", "oc:materialCircuitBoardRaw") + Recipes.addItem(new item.CircuitBoard(multi), "circuitBoard", "oc:materialCircuitBoard") + Recipes.addItem(new item.PrintedCircuitBoard(multi), "printedCircuitBoard", "oc:materialCircuitBoardPrinted") + Recipes.addItem(new item.CardBase(multi), "card", "oc:materialCard") // v1.1.0 - Recipes.addItemDelegate(new item.UpgradeSolarGenerator(multi), "solarGeneratorUpgrade", "oc:solarGeneratorUpgrade") - Recipes.addItemDelegate(new item.UpgradeSign(multi), "signUpgrade", "oc:signUpgrade") - Recipes.addItemDelegate(new item.UpgradeNavigation(multi), "navigationUpgrade", "oc:navigationUpgrade") + Recipes.addItem(new item.UpgradeSolarGenerator(multi), "solarGeneratorUpgrade", "oc:solarGeneratorUpgrade") + Recipes.addItem(new item.UpgradeSign(multi), "signUpgrade", "oc:signUpgrade") + Recipes.addItem(new item.UpgradeNavigation(multi), "navigationUpgrade", "oc:navigationUpgrade") // Always create, to avoid shifting IDs. val abstractBus = new item.AbstractBusCard(multi) if (Mods.StargateTech2.isAvailable) { - Recipes.addItemDelegate(abstractBus, "abstractBusCard", "oc:abstractBusCard") + Recipes.addItem(abstractBus, "abstractBusCard", "oc:abstractBusCard") } - Recipes.addItemDelegate(new item.Memory(multi, 4), "ram5", "oc:ram5") - Recipes.addItemDelegate(new item.Memory(multi, 5), "ram6", "oc:ram6") + Recipes.addItem(new item.Memory(multi, 4), "ram5", "oc:ram5") + Recipes.addItem(new item.Memory(multi, 5), "ram6", "oc:ram6") // v1.2.0 - Recipes.addItemDelegate(new item.Server(multi, 2), "server3", "oc:server3") - Recipes.addItemDelegate(new item.Terminal(multi), "terminal", "oc:terminal") - Recipes.addItemDelegate(new item.CPU(multi, 1), "cpu2", "oc:cpu2") - Recipes.addItemDelegate(new item.CPU(multi, 2), "cpu3", "oc:cpu3") - Recipes.addItemDelegate(new item.InternetCard(multi), "internetCard", "oc:internetCard") - Recipes.addItemDelegate(new item.Server(multi, 0), "server1", "oc:server1") - Recipes.addItemDelegate(new item.Server(multi, 1), "server2", "oc:server2") + Recipes.addItem(new item.Server(multi, 2), "server3", "oc:server3") + Recipes.addItem(new item.Terminal(multi), "terminal", "oc:terminal") + Recipes.addItem(new item.CPU(multi, 1), "cpu2", "oc:cpu2") + Recipes.addItem(new item.CPU(multi, 2), "cpu3", "oc:cpu3") + Recipes.addItem(new item.InternetCard(multi), "internetCard", "oc:internetCard") + Recipes.addItem(new item.Server(multi, 0), "server1", "oc:server1") + Recipes.addItem(new item.Server(multi, 1), "server2", "oc:server2") // v1.2.3 - register(new item.FloppyDisk(multi) { + registerItem(new item.FloppyDisk(multi) { showInItemList = false }, "lootDisk") // v1.2.6 - Recipes.addItemDelegate(new item.Interweb(multi), "interweb", "oc:materialInterweb") - Recipes.addItemDelegate(new item.UpgradeAngel(multi), "angelUpgrade", "oc:angelUpgrade") - Recipes.addItemDelegate(new item.Memory(multi, 1), "ram2", "oc:ram2") + Recipes.addItem(new item.Interweb(multi), "interweb", "oc:materialInterweb") + Recipes.addItem(new item.UpgradeAngel(multi), "angelUpgrade", "oc:angelUpgrade") + Recipes.addItem(new item.Memory(multi, 1), "ram2", "oc:ram2") // v1.3.0 - Recipes.addItemDelegate(new item.LinkedCard(multi), "linkedCard", "oc:linkedCard") - Recipes.addItemDelegate(new item.UpgradeExperience(multi), "experienceUpgrade", "oc:experienceUpgrade") - Recipes.addItemDelegate(new item.UpgradeInventory(multi), "inventoryUpgrade", "oc:inventoryUpgrade") - Recipes.addItemDelegate(new item.UpgradeContainerUpgrade(multi, 0), "upgradeContainer1", "oc:upgradeContainer1") - Recipes.addItemDelegate(new item.UpgradeContainerUpgrade(multi, 1), "upgradeContainer2", "oc:upgradeContainer2") - Recipes.addItemDelegate(new item.UpgradeContainerUpgrade(multi, 2), "upgradeContainer3", "oc:upgradeContainer3") - Recipes.addItemDelegate(new item.UpgradeContainerCard(multi, 0), "cardContainer1", "oc:cardContainer1") - Recipes.addItemDelegate(new item.UpgradeContainerCard(multi, 1), "cardContainer2", "oc:cardContainer2") - Recipes.addItemDelegate(new item.UpgradeContainerCard(multi, 2), "cardContainer3", "oc:cardContainer3") + Recipes.addItem(new item.LinkedCard(multi), "linkedCard", "oc:linkedCard") + Recipes.addItem(new item.UpgradeExperience(multi), "experienceUpgrade", "oc:experienceUpgrade") + Recipes.addItem(new item.UpgradeInventory(multi), "inventoryUpgrade", "oc:inventoryUpgrade") + Recipes.addItem(new item.UpgradeContainerUpgrade(multi, 0), "upgradeContainer1", "oc:upgradeContainer1") + Recipes.addItem(new item.UpgradeContainerUpgrade(multi, 1), "upgradeContainer2", "oc:upgradeContainer2") + Recipes.addItem(new item.UpgradeContainerUpgrade(multi, 2), "upgradeContainer3", "oc:upgradeContainer3") + Recipes.addItem(new item.UpgradeContainerCard(multi, 0), "cardContainer1", "oc:cardContainer1") + Recipes.addItem(new item.UpgradeContainerCard(multi, 1), "cardContainer2", "oc:cardContainer2") + Recipes.addItem(new item.UpgradeContainerCard(multi, 2), "cardContainer3", "oc:cardContainer3") } } \ No newline at end of file diff --git a/src/main/scala/li/cil/oc/common/Proxy.scala b/src/main/scala/li/cil/oc/common/Proxy.scala index 659c7e30e..8520e705f 100644 --- a/src/main/scala/li/cil/oc/common/Proxy.scala +++ b/src/main/scala/li/cil/oc/common/Proxy.scala @@ -34,17 +34,10 @@ class Proxy { registerExclusive("nuggetIron", Items.ironNugget.createItemStack()) if (OreDictionary.getOres("nuggetIron").exists(Items.ironNugget.createItemStack().isItemEqual)) { - Recipes.addItemDelegate(Items.ironNugget, "nuggetIron") + Recipes.addItem(Items.ironNugget, "nuggetIron") Recipes.addItem(Item.ingotIron, "ingotIron") } - if (Mods.ForgeMultipart.isAvailable) { - MultiPart.init() - } - if (Mods.ComputerCraft16.isAvailable) { - ComputerCraft16.init() - } - api.CreativeTab.instance = CreativeTab api.Driver.instance = driver.Registry api.FileSystem.instance = fs.FileSystem @@ -54,6 +47,13 @@ class Proxy { if (LuaStateFactory.isAvailable) classOf[NativeLuaArchitecture] else classOf[LuaJLuaArchitecture] api.Network.instance = network.Network + + if (Mods.ForgeMultipart.isAvailable) { + MultiPart.init() + } + if (Mods.ComputerCraft16.isAvailable) { + ComputerCraft16.init() + } } def init(e: FMLInitializationEvent) { diff --git a/src/main/scala/li/cil/oc/common/multipart/CablePart.scala b/src/main/scala/li/cil/oc/common/multipart/CablePart.scala index f8ef065d1..f2dac7fb4 100644 --- a/src/main/scala/li/cil/oc/common/multipart/CablePart.scala +++ b/src/main/scala/li/cil/oc/common/multipart/CablePart.scala @@ -3,13 +3,13 @@ package li.cil.oc.common.multipart import codechicken.lib.vec.{Vector3, Cuboid6} import codechicken.multipart._ import cpw.mods.fml.relauncher.{Side, SideOnly} -import li.cil.oc.api.network +import li.cil.oc.api.{Items, network} import li.cil.oc.api.network.{Message, Node, Visibility} import li.cil.oc.client.renderer.tileentity.CableRenderer -import li.cil.oc.common.block.Cable +import li.cil.oc.common.block.{Delegator, Cable} import li.cil.oc.server.TickHandler import li.cil.oc.util.ExtendedNBT._ -import li.cil.oc.{Blocks, Settings, api} +import li.cil.oc.{Settings, api} import net.minecraft.nbt.NBTTagCompound import net.minecraft.util.AxisAlignedBB import org.lwjgl.opengl.GL11 @@ -19,7 +19,7 @@ import scala.collection.convert.WrapAsScala._ class CablePart(val original: Option[Node] = None) extends DelegatePart with TCuboidPart with TNormalOcclusion with network.Environment { val node = api.Network.newNode(this, Visibility.None).create() - override def delegate = Blocks.cable + override def delegate = Delegator.subBlock(Items.get("cable").createItemStack(1)).get def getType = Settings.namespace + "cable" diff --git a/src/main/scala/li/cil/oc/common/multipart/EventHandler.scala b/src/main/scala/li/cil/oc/common/multipart/EventHandler.scala index 2751e4e37..28104a725 100644 --- a/src/main/scala/li/cil/oc/common/multipart/EventHandler.scala +++ b/src/main/scala/li/cil/oc/common/multipart/EventHandler.scala @@ -4,7 +4,6 @@ import codechicken.lib.packet.PacketCustom import codechicken.lib.raytracer.RayTracer import codechicken.lib.vec.{Vector3, BlockCoord} import codechicken.multipart.TileMultipart -import li.cil.oc.Blocks import li.cil.oc.client.PacketSender import li.cil.oc.common.block.Delegator import net.minecraft.block.Block @@ -15,6 +14,7 @@ import net.minecraftforge.common.MinecraftForge import net.minecraftforge.event.ForgeSubscribe import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action import net.minecraftforge.event.entity.player.{PlayerDestroyItemEvent, PlayerInteractEvent} +import li.cil.oc.api.Items object EventHandler { @ForgeSubscribe @@ -31,7 +31,7 @@ object EventHandler { val world = player.getEntityWorld val hit = RayTracer.reTrace(world, player) if (hit != null) Delegator.subBlock(player.getHeldItem) match { - case Some(subBlock) if subBlock == Blocks.cable => placeDelegatePart(player, hit, new CablePart()) + case Some(subBlock) if subBlock == Delegator.subBlock(Items.get("cable").createItemStack(1)).get => placeDelegatePart(player, hit, new CablePart()) case _ => false } else false diff --git a/src/main/scala/li/cil/oc/common/multipart/MultiPart.scala b/src/main/scala/li/cil/oc/common/multipart/MultiPart.scala index 6c15c6dcb..2935c48ac 100644 --- a/src/main/scala/li/cil/oc/common/multipart/MultiPart.scala +++ b/src/main/scala/li/cil/oc/common/multipart/MultiPart.scala @@ -4,9 +4,10 @@ import codechicken.lib.vec.BlockCoord import codechicken.multipart.MultiPartRegistry.{IPartConverter, IPartFactory} import codechicken.multipart.{TMultiPart, MultiPartRegistry} import li.cil.oc.common.tileentity.Cable -import li.cil.oc.{Settings, Blocks} +import li.cil.oc.Settings import net.minecraft.world.World import net.minecraftforge.common.MinecraftForge +import li.cil.oc.api.Items object MultiPart extends IPartFactory with IPartConverter { def init() { @@ -22,7 +23,7 @@ object MultiPart extends IPartFactory with IPartConverter { } override def canConvert(blockID: Int): Boolean = { - blockID == Blocks.cable.parent.blockID + blockID == Items.get("cable").block.blockID } override def convert(world: World, pos: BlockCoord) = { diff --git a/src/main/scala/li/cil/oc/common/recipe/Recipes.scala b/src/main/scala/li/cil/oc/common/recipe/Recipes.scala index 24da08699..ba4a56474 100644 --- a/src/main/scala/li/cil/oc/common/recipe/Recipes.scala +++ b/src/main/scala/li/cil/oc/common/recipe/Recipes.scala @@ -20,22 +20,22 @@ import scala.collection.mutable object Recipes { val list = mutable.LinkedHashMap.empty[ItemStack, String] - def addBlockDelegate[T <: common.block.Delegate](delegate: T, name: String, oreDict: String = null) = { - Items.register(delegate, name) + def addBlock[T <: common.block.Delegate](delegate: T, name: String, oreDict: String = null) = { + Items.registerBlock(delegate, name) list += delegate.createItemStack() -> name register(oreDict, delegate.createItemStack()) delegate } - def addItemDelegate[T <: common.item.Delegate](delegate: T, name: String, oreDict: String = null) = { - Items.register(delegate, name) + def addItem[T <: common.item.Delegate](delegate: T, name: String, oreDict: String = null) = { + Items.registerItem(delegate, name) list += delegate.createItemStack() -> name register(oreDict, delegate.createItemStack()) delegate } def addItem(instance: Item, name: String) = { - Items.register(instance, name) + Items.registerItem(instance, name) list += new ItemStack(instance) -> name instance } diff --git a/src/main/scala/li/cil/oc/server/component/machine/Machine.scala b/src/main/scala/li/cil/oc/server/component/machine/Machine.scala index 87c56d447..ab849eca0 100644 --- a/src/main/scala/li/cil/oc/server/component/machine/Machine.scala +++ b/src/main/scala/li/cil/oc/server/component/machine/Machine.scala @@ -46,7 +46,7 @@ class Machine(val owner: Owner, constructor: Constructor[_ <: Architecture]) ext private val signals = mutable.Queue.empty[Machine.Signal] - private val callCounts = mutable.Map.empty[String, mutable.Map[String, Int]] + private val callCounts = mutable.Map.empty[Any, mutable.Map[String, Int]] // ----------------------------------------------------------------------- // @@ -240,9 +240,14 @@ class Machine(val owner: Owner, constructor: Constructor[_ <: Architecture]) ext override def invoke(value: Value, method: String, args: Array[AnyRef]): Array[AnyRef] = Callbacks(value).get(method) match { case Some(callback) => val direct = callback.direct - if (direct && architecture.isInitialized) { + if (direct && architecture.isInitialized) callCounts.synchronized { val limit = callback.limit - // TODO callcount limit + val counts = callCounts.getOrElseUpdate(value, mutable.Map.empty[String, Int]) + val count = counts.getOrElseUpdate(method, 0) + if (count >= limit) { + throw new LimitReachedException() + } + counts(method) += 1 } Registry.convert(callback(value, this, new ArgumentsImpl(Seq(args: _*)))) case _ => throw new NoSuchMethodException() diff --git a/src/main/scala/li/cil/oc/server/network/Callbacks.scala b/src/main/scala/li/cil/oc/server/network/Callbacks.scala index 3f4d98ef5..a20bddd70 100644 --- a/src/main/scala/li/cil/oc/server/network/Callbacks.scala +++ b/src/main/scala/li/cil/oc/server/network/Callbacks.scala @@ -4,7 +4,7 @@ import java.lang.reflect.{InvocationTargetException, Method, Modifier} import li.cil.oc.api.driver.MethodWhitelist import li.cil.oc.api.machine.Robot import li.cil.oc.api.network -import li.cil.oc.api.network.{Environment, Context, ManagedPeripheral} +import li.cil.oc.api.network.{Context, ManagedPeripheral} import li.cil.oc.OpenComputers import li.cil.oc.server.driver.CompoundBlockEnvironment import scala.collection.{immutable, mutable} diff --git a/src/main/scala/li/cil/oc/util/ItemCosts.scala b/src/main/scala/li/cil/oc/util/ItemCosts.scala index b79fa5233..8f506a351 100644 --- a/src/main/scala/li/cil/oc/util/ItemCosts.scala +++ b/src/main/scala/li/cil/oc/util/ItemCosts.scala @@ -48,7 +48,7 @@ object ItemCosts { def hasCosts(stack: ItemStack) = { val ingredients = computeIngredients(stack) - ingredients.size > 0 && (ingredients.size > 1 || !ItemStack.areItemStacksEqual(ingredients.head._1, stack)) + ingredients.size > 0 && (ingredients.size > 1 || !ingredients.head._1.isItemEqual(stack)) } def addTooltip(stack: ItemStack, tooltip: util.List[String]) { diff --git a/src/main/scala/li/cil/oc/util/ItemUtils.scala b/src/main/scala/li/cil/oc/util/ItemUtils.scala index 70ad2ae0b..6dd0b1150 100644 --- a/src/main/scala/li/cil/oc/util/ItemUtils.scala +++ b/src/main/scala/li/cil/oc/util/ItemUtils.scala @@ -69,7 +69,7 @@ object ItemUtils { api.Items.get("keyboard").createItemStack(1), api.Items.get("inventoryUpgrade").createItemStack(1), api.Items.get("experienceUpgrade").createItemStack(1), - api.Items.get("gpu1").createItemStack(1), + api.Items.get("graphicsCard1").createItemStack(1), api.Items.get("cpu1").createItemStack(1), api.Items.get("ram2").createItemStack(1) )