diff --git a/assets/opencomputers/lang/de_DE.lang b/assets/opencomputers/lang/de_DE.lang index 1eeb6bc8e..b33690b6a 100644 --- a/assets/opencomputers/lang/de_DE.lang +++ b/assets/opencomputers/lang/de_DE.lang @@ -27,11 +27,9 @@ oc:item.CardBase.name=Kartenbasis oc:item.CircuitBoard.name=Leiterplatte oc:item.ControlUnit.name=Steuerwerk (CU) oc:item.CPU.name=Hauptprozessor (CPU) -oc:item.Crafting.name=Crafting Upgrade oc:item.CuttingWire.name=Schneidedraht oc:item.Disk.name=Platte oc:item.Floppy.name=Diskette -oc:item.Generator.name=Generator Upgrade oc:item.GraphicsCard0.name=Einfache Grafikkarte oc:item.GraphicsCard1.name=Hochwertige Grafikkarte oc:item.GraphicsCard2.name=Ausgezeichnete Grafikkarte @@ -47,6 +45,11 @@ oc:item.PrintedCircuitBoard.name=Gedruckte Leiterplatte (PCB) oc:item.RawCircuitBoard.name=Leiterplattenrohling oc:item.RedstoneCard.name=Redstonekarte oc:item.Transistor.name=Transistor +oc:item.UpgradeCrafting.name=Crafting Upgrade +oc:item.UpgradeGenerator.name=Generator Upgrade +oc:item.UpgradeNavigation.name=Navigationsupgrade +oc:item.UpgradeSign.name=Schild-E/A Upgrade +oc:item.UpgradeSolarGenerator.name=Solar Generator Upgrade oc:item.WirelessNetworkCard.name=Drahtlosnetzwerkkarte # GUI @@ -81,14 +84,12 @@ oc:tooltip.Charger=Lädt Roboter mit Energie aus Kondensatoren auf. Die Ladegesc oc:tooltip.CircuitBoard=Mühselig vermehrt sich das Eichhörnchen. Wenn es groß wird, wird es mal eine gedruckte Leiterplatte. oc:tooltip.ControlUnit=Klingt wichtig, ist es auch. Man baut daraus immerhin CPUs. Wie könnte es da nicht wichtig sein. oc:tooltip.CPU=Kernstück eines jeden Computers. Die Taktrate hat einen leichten Schatten, aber was kann man von einer Taschensonnenuhr schon erwarten? -oc:tooltip.Crafting=Ermöglicht Robotern in dem oberen linken Bereich ihres Inventars zu craften. Gegenstände müssen so angeordnet sein wie sie es in einer Werkbank wären. oc:tooltip.CuttingWire=Wird gebraucht um Tonblöcke in Leiterplattenform zu bekommen. Vermutlich das ineffizienteste Werkzeug in der Geschichte der Menschheit, da es nach einer Verwendung kaputt geht. oc:tooltip.Disk=Sehr einfaches Speichermedium das verwendet werden kann um Disketten und Festplatten bauen. oc:tooltip.DiskDrive.CC=ComputerCraft Disketten werden §aunterstützt§7. oc:tooltip.DiskDrive=Erlaubt es Disketten zu lesen und zu beschreiben. -oc:tooltip.Generator=Kann verwendet werden um unterwegs Energie aus Brennstoffen zu erzeugen. Verbraucht Gegenstände über einen ihrem Brennwert gemäßen Zeitraum.[nl] §fEffizienz§7: §a%s%%§7 oc:tooltip.GraphicsCard=Erlaubt es den angezeigten Inhalt von Bildschirmen zu ändern.[nl] Höchstauflösung: §f%sx%s§7.[nl] Maximale Farbtiefe: §f%s§7.[nl] Operationen/Tick: §f%s§7. -oc:tooltip.IronNugget=Ein Nugget das aus Eisen besteht, drum wird es ja auch Eisennugget genannt... +oc:tooltip.IronNugget=Ein Nugget das aus Eisen besteht, darum wird es ja auch Eisennugget genannt, duh... oc:tooltip.Keyboard=Kann an Bildschirmen befestigt werden um auf ihnen zu tippen. oc:tooltip.Memory=Braucht ein jeder Computer um zu starten. Je mehr vorhanden, desto komplexere Programme können ausgeführt werden. oc:tooltip.Microchip=Tritt auch unter dem Alias Integrierter Schaltkreis auf. Keine Ahnung warum das auch mit Redstone klappt, aber es funktioniert. @@ -112,4 +113,9 @@ oc:tooltip.Router=Erlaubt es mehrere Netzwerke miteinander zu verbinden. Leitet 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.TooLong=Shift gedrückt halten für mehr Infos. oc:tooltip.Transistor=Elementarer Baustein der meisten Computerkomponenten. Nicht zu verwechseln mit Steinelementaren. +oc:tooltip.UpgradeCrafting=Ermöglicht Robotern in dem oberen linken Bereich ihres Inventars zu craften. Gegenstände müssen so angeordnet sein wie sie es in einer Werkbank wären. +oc:tooltip.UpgradeGenerator=Kann verwendet werden um unterwegs Energie aus Brennstoffen zu erzeugen. Verbraucht Gegenstände über einen ihrem Brennwert gemäßen Zeitraum.[nl] §fEffizienz§7: §a%s%%§7 +oc:tooltip.UpgradeNavigation=Erlaubt es Robotern ihre Position und Ausrichtung zu bestimmen. Die Position ist relativ zur Mitte der Karte, die in diesem Upgrade verbaut wurde. +oc:tooltip.UpgradeSign=Erlaubt das Lesen und Schreiben von Text auf Schildern. +oc:tooltip.UpgradeSolarGenerator=Kann verwendet werden um unterwegs Energie aus Sonnenlicht zu generieren. Benötigt eine ungehinderte Sicht zum Himmel über dem Roboter. Generiert Energie mit %s%% der Geschwindigkeit einer Stirling Engine. oc:tooltip.WirelessNetworkCard=Erlaubt das drahtlose Senden von Netzwerknachrichten, zusätzlich zu normalen. Drahtlose Nachrichten werden nur gesendet, wenn eine §fSignalstärke§7 festgelegt wurde! \ No newline at end of file diff --git a/assets/opencomputers/lang/en_US.lang b/assets/opencomputers/lang/en_US.lang index e0793552d..1e8933334 100644 --- a/assets/opencomputers/lang/en_US.lang +++ b/assets/opencomputers/lang/en_US.lang @@ -23,6 +23,7 @@ oc:block.Screen1.name=Advanced Screen oc:block.Screen2.name=Superior Screen # Items +oc:item.Acid.name=Grog oc:item.ALU.name=Arithmetic Logic Unit (ALU) oc:item.Analyzer.name=Analyzer oc:item.ArrowKeys.name=Arrow Keys @@ -31,15 +32,12 @@ oc:item.CardBase.name=Card Base oc:item.CircuitBoard.name=Circuit Board oc:item.ControlUnit.name=Control Unit (CU) oc:item.CPU.name=Central Processing Unit (CPU) -oc:item.Crafting.name=Crafting Upgrade oc:item.CuttingWire.name=Cutting Wire oc:item.Disk.name=Disk Platter oc:item.FloppyDisk.name=Floppy Disk -oc:item.Generator.name=Generator Upgrade oc:item.GraphicsCard0.name=Basic Graphics Card oc:item.GraphicsCard1.name=Advanced Graphics Card oc:item.GraphicsCard2.name=Superior Graphics Card -oc:item.Acid.name=Grog oc:item.HardDiskDrive.name=Hard Disk Drive oc:item.IronNugget.name=Iron Nugget oc:item.Memory.name=Memory @@ -52,6 +50,11 @@ oc:item.PrintedCircuitBoard.name=Printed Circuit Board (PCB) oc:item.RawCircuitBoard.name=Raw Circuit Board oc:item.RedstoneCard.name=Redstone Card oc:item.Transistor.name=Transistor +oc:item.UpgradeCrafting.name=Crafting Upgrade +oc:item.UpgradeGenerator.name=Generator Upgrade +oc:item.UpgradeNavigation.name=Navigation Upgrade +oc:item.UpgradeSign.name=Sign I/O Upgrade +oc:item.UpgradeSolarGenerator.name=Solar Generator Upgrade oc:item.WirelessNetworkCard.name=Wireless Network Card # GUI @@ -86,14 +89,12 @@ oc:tooltip.Charger=Transfers energy from capacitors into adjacent robots. The tr oc:tooltip.CircuitBoard=Now we're getting somewhere. Can be etched to obtain a printed circuit board. oc:tooltip.ControlUnit=This is the unit that... controls... stuff. You need it to build a CPU. So yeah, totally important. oc:tooltip.CPU=An essential component of all computers. The clock rate is a bit unreliable, but what do you expect when it runs on a pocket sundial? -oc:tooltip.Crafting=Enables robots to use the top left area of their inventory for crafting objects. Items have to be aligned as they would be in a crafting table. oc:tooltip.CuttingWire=Used to cut clay blocks into circuit board shape. Breaks after one use, which probably makes it the most inefficient tool ever. oc:tooltip.Disk=Primitive medium that can be used to build persistent storage devices. oc:tooltip.DiskDrive.CC=ComputerCraft floppies are §asupported§7. oc:tooltip.DiskDrive=Allows reading and writing floppies. -oc:tooltip.Generator=Can be used to generate energy from fuel on the go. Burns items to generate energy over time, based on their fuel value.[nl] §fEfficiency§7: §a%s%%§7 oc:tooltip.GraphicsCard=Used to change what's displayed on screens.[nl] Maximum resolution: §f%sx%s§7.[nl] Maximum color depth: §f%s§7.[nl] Operations/tick: §f%s§7. -oc:tooltip.IronNugget=A nugget made of iron, that's why it's called a Iron Nugget, stupid... +oc:tooltip.IronNugget=A nugget made of iron, that's why it's called an Iron Nugget, duh... oc:tooltip.Keyboard=Can be attached to screens to allow typing on them. oc:tooltip.Memory=Required to get computers to run. The more you have, the more complex the programs you can run. oc:tooltip.Microchip=The chip formerly known as Integrated Circuit. I have no idea why this works with redstone, but it does. @@ -118,4 +119,9 @@ oc:tooltip.Router=Allows connecting different networks to each other. Only netwo 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.TooLong=Hold shift for a detailed tooltip. oc:tooltip.Transistor=A basic element in most other computer parts. It's a bit twisted, but it does the job. +oc:tooltip.UpgradeCrafting=Enables robots to use the top left area of their inventory for crafting objects. Items have to be aligned as they would be in a crafting table. +oc:tooltip.UpgradeGenerator=Can be used to generate energy from fuel on the go. Burns items to generate energy over time, based on their fuel value.[nl] §fEfficiency§7: §a%s%%§7 +oc:tooltip.UpgradeNavigation=Can be used to determine the position and orientation of the robot. The position is relative to the center of the map that was used to craft this upgrade. +oc:tooltip.UpgradeSign=Allows reading text on and writing text to signs. +oc:tooltip.UpgradeSolarGenerator=Can be used to generate energy from sunlight on the go. Requires a clear line of sight to the sky above the robot. Generates energy at %s%% of the speed of a Stirling Engine. oc:tooltip.WirelessNetworkCard=Allows wireless sending of network messages in addition to normal ones. Make sure to set the §fsignal strength§7 or no wireless packet will be sent! \ No newline at end of file diff --git a/assets/opencomputers/lang/zh_CN.lang b/assets/opencomputers/lang/zh_CN.lang index 013775c2e..4668a57b2 100644 --- a/assets/opencomputers/lang/zh_CN.lang +++ b/assets/opencomputers/lang/zh_CN.lang @@ -23,6 +23,7 @@ oc:block.Screen1.name=高级屏幕 oc:block.Screen2.name=超级屏幕 # Items +oc:item.Acid.name=蚀刻药水 oc:item.ALU.name=算逻运算单元(ALU) oc:item.Analyzer.name=分析器 oc:item.ArrowKeys.name=方向键 @@ -31,15 +32,12 @@ oc:item.CardBase.name=主板 oc:item.CircuitBoard.name=电路板 oc:item.ControlUnit.name=控制单元(CU) oc:item.CPU.name=中央处理器(CPU) -oc:item.Crafting.name=合成升级 oc:item.CuttingWire.name=切割线 oc:item.Disk.name=磁盘 oc:item.FloppyDisk.name=软盘 -oc:item.Generator.name=发电机升级 oc:item.GraphicsCard0.name=基础显卡 oc:item.GraphicsCard1.name=高级显卡 oc:item.GraphicsCard2.name=超级显卡 -oc:item.Acid.name=蚀刻药水 oc:item.HardDiskDrive.name=硬盘驱动 oc:item.IronNugget.name=铁粒 oc:item.Memory.name=内存 @@ -52,6 +50,8 @@ oc:item.PrintedCircuitBoard.name=印制板(PCB) oc:item.RawCircuitBoard.name=电路板材料 oc:item.RedstoneCard.name=红石卡 oc:item.Transistor.name=晶体管 +oc:item.UpgradeCrafting.name=合成升级 +oc:item.UpgradeGenerator.name=发电机升级 oc:item.WirelessNetworkCard.name=无线网卡 # GUI @@ -85,12 +85,10 @@ oc:tooltip.Charger=将电容器的能量传输给相邻机器人.[nl]传输效 oc:tooltip.CircuitBoard=现在我们已经取得一些进展.[nl]可以通过蚀刻来得到印制板. oc:tooltip.ControlUnit=用来控制...控制东西...的单元.[nl]你需要这玩意儿来做CPU.所以反正啦,这个非常重要. oc:tooltip.CPU=所有计算机最核心的组件,它的时钟频率有点不可靠,[nl]但是你考虑到它是靠便携日晷来运行的你还能指望啥呢? -oc:tooltip.Crafting=使得机器人能够将其物品栏的左上区域作为合成网格来制做物品.[nl]物品栏内物品摆放必须与工作台中一致. oc:tooltip.CuttingWire=用于将粘土块切割成电路板的形状.[nl]使用一次就会坏掉,这可能使得成为历来最低效的工具. oc:tooltip.Disk=用于制造持久存储设备的原始媒介材料. oc:tooltip.DiskDrive.CC=已经§a支持§7使用另一个电脑模组(ComputerCraft)的软盘. oc:tooltip.DiskDrive=用来读写软盘. -oc:tooltip.Generator=用来不断地消耗燃料发电,燃烧物品并基于它们的燃烧值随着时间推移产生电力.[nl] §f效率§7: §a%s%%§7. oc:tooltip.GraphicsCard=用来改变屏幕显示内容.[nl]最高分辨率:§f%sx%s§7.[nl] 最大色深: §f%s§7. oc:tooltip.IronNugget=颗粒状的铁,所以叫铁粒啦,蠢蠢的感觉... oc:tooltip.Keyboard=可以连接屏幕,能够输入显示文本. @@ -116,4 +114,6 @@ oc:tooltip.Router=允许设备相互连接不同的网络.[nl]仅能传递网络 oc:tooltip.Screen=由机箱内的显卡控制来显示文本.[nl]最高分辨率:§f%sx%s§7.[nl] 最大色深: §f%s§7. oc:tooltip.TooLong=按住潜行键(shift)以查看详细提示信息. oc:tooltip.Transistor=在多数其他计算机的零件中都很基础的元件.[nl]引脚有点弯了,但还能用. +oc:tooltip.UpgradeCrafting=使得机器人能够将其物品栏的左上区域作为合成网格来制做物品.[nl]物品栏内物品摆放必须与工作台中一致. +oc:tooltip.UpgradeGenerator=用来不断地消耗燃料发电,燃烧物品并基于它们的燃烧值随着时间推移产生电力.[nl] §f效率§7: §a%s%%§7. oc:tooltip.WirelessNetworkCard=允许在发送正常信息外无线发送网络信息.[nl]请确保已设置好§f信号强度§7否则不会发出无线数据包. diff --git a/assets/opencomputers/recipes/default.recipes b/assets/opencomputers/recipes/default.recipes new file mode 100644 index 000000000..69a17a2a7 --- /dev/null +++ b/assets/opencomputers/recipes/default.recipes @@ -0,0 +1,264 @@ +# Do not change this file, it is rewritten each time you start the game. +# Instead, use the custom.conf file to edit recipes by redefining them there. + +analyzer { + input: [["", torchRedstoneActive, ""] + [craftingTransistor, circuitBasic, nuggetGold] + [craftingTransistor, craftingCircuitBoardAdvanced, nuggetGold]] +} + +ram1 { + input: [[circuitBasic, circuitBasic, circuitBasic] + [craftingCircuitBoardAdvanced, craftingCircuitBoardAdvanced, craftingCircuitBoardAdvanced]] +} +ram2 { + input: [[circuitAdvanced, circuitAdvanced, circuitAdvanced] + [craftingRAMBasic, craftingCircuitBoardAdvanced, craftingRAMBasic]] +} +ram3 { + input: [[circuitElite, circuitElite, circuitElite] + [craftingRAMAdvanced, craftingCircuitBoardAdvanced, craftingRAMAdvanced]] +} + +floppy { + input: [[nuggetIron, lever, nuggetIron] + [craftingCircuitBoardBasic, "oc:craftingDisk", craftingCircuitBoardBasic] + [nuggetIron, paper, nuggetIron]] +} +hdd1 { + input: [[circuitBasic, "oc:craftingDisk", ingotIron] + [craftingCircuitBoardAdvanced, "oc:craftingDisk", pistonBase] + [circuitBasic, "oc:craftingDisk", ingotIron]] +} +hdd2 { + input: [[ingotGold, craftingHDDBasic, ingotGold] + [circuitAdvanced, craftingCircuitBoardAdvanced, circuitAdvanced] + [ingotGold, craftingHDDBasic, ingotGold]] +} +hdd3 { + input: [[circuitElite, craftingHDDAdvanced, circuitElite] + [craftingRAMBasic, craftingCircuitBoardAdvanced, craftingRAMBasic] + [circuitElite, craftingHDDAdvanced, circuitElite]] +} + +graphicsCard1 { + input: [[circuitBasic, craftingALU, craftingRAMBasic] + ["", craftingCircuitBoardBasic, ""]] +} +graphicsCard2 { + input: [[circuitAdvanced, circuitAdvanced, craftingRAMAdvanced] + ["", craftingGPUBasic, ""]] +} +graphicsCard3 { + input: [[circuitElite, circuitElite, craftingRAMElite] + ["", craftingGPUAdvanced, ""]] +} +redstoneCard { + input: [[torchRedstoneActive, circuitBasic, ""] + ["", craftingCircuitBoardBasic, ""]] +} +lanCard { + input: [[craftingWireCopper, circuitBasic, ""] + ["", craftingGPUBasic, ""]] +} +wlanCard { + input: [[enderPearl, circuitAdvanced, ""] + ["", componentCardLan, ""]] +} + +craftingUpgrade { + input: [[ingotIron, pistonBase, ingotIron] + [circuitBasic, workbench, circuitBasic] + [ingotIron, craftingCircuitBoardAdvanced, ingotIron]] +} +generatorUpgrade { + input: [[ingotIron, "", ingotIron] + [circuitBasic, pistonBase, circuitBasic] + [craftingCircuitBoardAdvanced, ingotIron, craftingCircuitBoardAdvanced]] +} +navigationUpgrade { + input: [[ingotGold, compass, ingotGold] + [circuitElite, {item=map, subID=32767}, circuitElite] + [ingotGold, potion, ingotGold]] +} +signUpgrade { + input: [[ingotIron, dyePowder, ingotIron] + [circuitAdvanced, stickWood, circuitAdvanced] + [ingotIron, pistonStickyBase, ingotIron]] +} +solarGeneratorUpgrade { + input: [[glass, glass, glass] + [circuitAdvanced, "oc:craftingGenerator", circuitAdvanced]] +} + +nuggetIron { + type: shapeless + input: ingotIron + count: 9 +} +cuttingWire { + input: [[stickWood, nuggetIron, stickWood]] +} +acid { + type: shapeless + input: [bucketWater, sugar, slimeball, spiderEye, bone, {item=dyePowder, subID=1}] +} +disk { + input: [["", nuggetIron, ""] + [nuggetIron, "", nuggetIron] + ["", nuggetIron, ""]] +} + +buttonGroup { + input: [[button, button, button] + [button, button, button]] +} +arrowKeys { + input: [["", button, ""] + [button, button, button]] +} +numPad { + input: [[button, button, button] + [button, button, button] + [button, button, button]] +} + +transistor { + input: [[nuggetIron, nuggetIron, nuggetIron] + [nuggetGold, redstone, nuggetGold] + ["", torchRedstoneActive, ""]] +} +chip1 { + input: [[nuggetIron, fenceIron, nuggetIron] + [redstone, craftingTransistor, redstone] + [nuggetIron, fenceIron, nuggetIron]] +} +chip2 { + input: [[nuggetGold, {item=dyePowder, subID=4} , nuggetGold] + [circuitBasic, diamond, circuitBasic] + [nuggetGold, {item=dyePowder, subID=4}, nuggetGold]] +} +chip3 { + input: [[yellowDust, comparator, yellowDust] + [circuitAdvanced, emerald, circuitAdvanced] + [yellowDust, comparator, yellowDust]] +} +alu { + input: [[diode, torchRedstoneActive, diode] + [craftingTransistor, craftingTransistor, craftingTransistor] + [nuggetIron, redstone, nuggetIron]] +} +cpu { + input: [[circuitBasic, redstone, circuitBasic] + [fenceIron, craftingControlUnit, fenceIron] + [circuitBasic, craftingALU, circuitBasic]] +} +cu { + input: [[nuggetGold, torchRedstoneActive, nuggetGold] + [craftingTransistor, clock, craftingTransistor] + [nuggetGold, redstone, nuggetGold]] +} + +rawCircuitBoard { + type: shapeless + input: ["oc:craftingWire", clay, {item=dyePowder, subID=2}] +} +circuitBoard { + type: furnace + input: "oc:craftingCircuitBoardRaw" +} +printedCircuitBoard { + type: shapeless + input: [craftingCircuitBoardBasic, nuggetGold, "oc:craftingAcid"] +} +card { + input: [[nuggetIron, circuitBasic, craftingTransistor] + [nuggetIron, craftingCircuitBoardAdvanced, craftingCircuitBoardAdvanced] + [nuggetIron, nuggetGold, nuggetGold]] +} + +adapter { + input: [[ingotIron, craftingWireCopper, ingotIron] + [craftingWireCopper, circuitBasic, craftingWireCopper] + [ingotIron, craftingCircuitBoardAdvanced, ingotIron]] +} +cable { + input: [["", nuggetIron, ""] + [nuggetIron, redstone, nuggetIron] + ["", nuggetIron, ""]] + output: 4 +} +capacitor { + input: [[ingotIron, craftingTransistor, ingotIron] + [nuggetGold, paper, nuggetGold] + [ingotIron, craftingCircuitBoardAdvanced, ingotIron]] +} +charger { + input: [[ingotIron, ingotGold, ingotIron] + [craftingCapacitor, circuitAdvanced, craftingCapacitor] + [ingotIron, craftingCircuitBoardAdvanced, ingotIron]] +} +case1 { + input: [[ingotIron, craftingCircuitBoardAdvanced, ingotIron] + [fenceIron, craftingCPU, fenceIron] + [ingotIron, circuitBasic, ingotIron]] +} +case2 { + input: [[ingotGold, craftingCircuitBoardAdvanced, ingotGold] + [circuitAdvanced, craftingRawMachineBasic, circuitAdvanced] + [ingotGold, circuitAdvanced, ingotGold]] +} +case3 { + input: [[circuitElite, craftingCircuitBoardAdvanced, circuitElite] + [diamond, craftingRawMachineAdvanced, diamond] + [circuitElite, craftingCircuitBoardAdvanced, circuitElite]] +} +diskDrive { + input: [[ingotIron, circuitBasic, ingotIron] + [pistonBase, stickWood, ""] + [ingotIron, circuitBasic, ingotIron]] +} +keyboard { + input: [["oc:craftingButtonGroup", "oc:craftingButtonGroup", "oc:craftingButtonGroup"] + ["oc:craftingButtonGroup", "oc:craftingArrowKey", "oc:craftingNumPad"]] +} +powerConverter { + input: [[ingotIron, craftingWireCopper, ingotIron] + [ingotGold, circuitBasic, ingotGold] + [ingotIron, craftingCircuitBoardAdvanced, ingotIron]] +} +powerDistributor { + input: [[ingotIron, ingotGold, ingotIron] + [craftingWireCopper, circuitBasic, craftingWireCopper] + [ingotIron, craftingCircuitBoardAdvanced, ingotIron]] +} +redstone { + input: [[ingotIron, blockRedstone, ingotIron] + [blockRedstone, componentCardRedstone, blockRedstone] + [ingotIron, craftingCircuitBoardAdvanced, ingotIron]] +} +robot { + input: [[craftingMonitorBasic, craftingGPUBasic, craftingDiskDrive] + [dispenser, craftingRawMachineBasic, craftingRAMBasic] + [craftingCapacitor, minecartHopper, craftingCapacitor]] +} +router { + input: [[ingotIron, craftingWireCopper, ingotIron] + [craftingWireCopper, componentCardLan, craftingWireCopper] + [ingotIron, craftingCircuitBoardAdvanced, ingotIron]] +} +screen1 { + input: [[ingotIron, ingotIron, glass] + [redstone, craftingTransistor, glass] + [ingotIron, ingotIron, glass]] +} +screen2 { + input: [[ingotGold, {item=dyePowder, subID=1}, ingotGold] + [circuitAdvanced, {item=dyePowder, subID=2}, craftingMonitorBasic] + [ingotGold, {item=dyePowder, subID=4}, ingotGold]] +} +screen3 { + input: [[obsidian, craftingCircuitBoardAdvanced, circuitElite] + [blazeRod, netherquartz, craftingMonitorAdvanced] + [obsidian, craftingCircuitBoardAdvanced, circuitElite]] +} \ No newline at end of file diff --git a/assets/opencomputers/recipes/user.recipes b/assets/opencomputers/recipes/user.recipes new file mode 100644 index 000000000..79b5d4581 --- /dev/null +++ b/assets/opencomputers/recipes/user.recipes @@ -0,0 +1,14 @@ +# To use different sets of recipes, include other recipe files in the order of +# priority to use the recipes defined in them. The last include has the highest +# priority (i.e. included recipes simply replace the current definition for all +# already known recipes). + +include file("default.recipes") +#include file("buildcraft.recipes") +#include file("gregtech.recipes") +#include file("your_custom.recipes") + +# You can also specify custom recipes in this file directly. Have a look at the +# default.recipes file to get an idea how recipes have to be structured. You'll +# want to define your recipes after all includes, to avoid those overwriting +# your recipes. \ No newline at end of file diff --git a/assets/opencomputers/textures/items/upgrade_navigation.png b/assets/opencomputers/textures/items/upgrade_navigation.png new file mode 100644 index 000000000..5c7975af0 Binary files /dev/null and b/assets/opencomputers/textures/items/upgrade_navigation.png differ diff --git a/assets/opencomputers/textures/items/upgrade_sign.png b/assets/opencomputers/textures/items/upgrade_sign.png new file mode 100644 index 000000000..4cc5ef007 Binary files /dev/null and b/assets/opencomputers/textures/items/upgrade_sign.png differ diff --git a/assets/opencomputers/textures/items/upgrade_solar_generator.png b/assets/opencomputers/textures/items/upgrade_solar_generator.png new file mode 100644 index 000000000..e2f471cd5 Binary files /dev/null and b/assets/opencomputers/textures/items/upgrade_solar_generator.png differ diff --git a/li/cil/oc/Blocks.scala b/li/cil/oc/Blocks.scala index b32efe904..c0ffd6fad 100644 --- a/li/cil/oc/Blocks.scala +++ b/li/cil/oc/Blocks.scala @@ -3,6 +3,9 @@ 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.block.Block +import net.minecraft.item.ItemStack +import net.minecraftforge.oredict.OreDictionary object Blocks { var blockSimple: SimpleDelegator = _ @@ -17,8 +20,8 @@ object Blocks { var case1, case2, case3: Case = _ var diskDrive: DiskDrive = _ var keyboard: Keyboard = _ - var powerDistributor: PowerDistributor = _ var powerConverter: PowerConverter = _ + var powerDistributor: PowerDistributor = _ var redstone: Redstone = _ var robotProxy: RobotProxy = _ var robotAfterimage: RobotAfterimage = _ @@ -72,5 +75,23 @@ object Blocks { screen3 = new Screen.Tier3(blockSimple) redstone = new Redstone(blockSimpleWithRedstone) + + register("craftingWireCopper", cable.createItemStack()) + register("craftingCapacitor", capacitor.createItemStack()) + register("craftingRawMachineBasic", case1.createItemStack()) + register("craftingRawMachineAdvanced", case2.createItemStack()) + register("craftingRawMachineElite", case3.createItemStack()) + register("craftingDiskDrive", diskDrive.createItemStack()) + register("craftingMonitorBasic", screen1.createItemStack()) + register("craftingMonitorAdvanced", screen2.createItemStack()) + register("craftingMonitorElite", screen3.createItemStack()) + + register("torchRedstoneActive", new ItemStack(Block.torchRedstoneActive, 1, 0)) + } + + private def register(name: String, item: ItemStack) { + if (!OreDictionary.getOres(name).contains(item)) { + OreDictionary.registerOre(name, item) + } } } \ No newline at end of file diff --git a/li/cil/oc/CraftingHandler.scala b/li/cil/oc/CraftingHandler.scala index 0cae3fa15..b96960f99 100644 --- a/li/cil/oc/CraftingHandler.scala +++ b/li/cil/oc/CraftingHandler.scala @@ -1,9 +1,11 @@ package li.cil.oc import cpw.mods.fml.common.ICraftingHandler +import li.cil.oc.server.driver.Registry +import li.cil.oc.util.ExtendedNBT._ import net.minecraft.entity.player.EntityPlayer import net.minecraft.inventory.IInventory -import net.minecraft.item.{Item, ItemStack} +import net.minecraft.item.{ItemMap, Item, ItemStack} object CraftingHandler extends ICraftingHandler { override def onCrafting(player: EntityPlayer, craftedStack: ItemStack, inventory: IInventory) = { @@ -28,6 +30,40 @@ object CraftingHandler extends ICraftingHandler { } } } + + if (craftedStack.isItemEqual(Items.upgradeNavigation.createItemStack())) { + Registry.driverFor(craftedStack) match { + case Some(driver) => + var oldMap = None: Option[ItemStack] + for (i <- 0 to inventory.getSizeInventory) { + val stack = inventory.getStackInSlot(i) + if (stack != null) { + if (stack.isItemEqual(Items.upgradeNavigation.createItemStack())) { + // Restore the map currently used in the upgrade. + val nbt = driver.dataTag(stack) + oldMap = Option(ItemStack.loadItemStackFromNBT(nbt.getCompoundTag(Settings.namespace + "map"))) + } + else if (stack.getItem == Item.map) { + // Store information of the map used for crafting in the result. + val nbt = driver.dataTag(craftedStack) + val map = stack.getItem.asInstanceOf[ItemMap] + val info = map.getMapData(stack, player.getEntityWorld) + nbt.setInteger(Settings.namespace + "xCenter", info.xCenter) + nbt.setInteger(Settings.namespace + "zCenter", info.zCenter) + nbt.setInteger(Settings.namespace + "scale", 128 * (1 << info.scale)) + nbt.setNewCompoundTag(Settings.namespace + "map", stack.writeToNBT) + } + } + } + if (oldMap.isDefined) { + val map = oldMap.get + if (!player.inventory.addItemStackToInventory(map)) { + player.dropPlayerItemWithRandomChoice(map, false) + } + } + case _ => + } + } } override def onSmelting(player: EntityPlayer, item: ItemStack) {} diff --git a/li/cil/oc/Items.scala b/li/cil/oc/Items.scala index 6f91cfdbc..9a8185846 100644 --- a/li/cil/oc/Items.scala +++ b/li/cil/oc/Items.scala @@ -2,6 +2,7 @@ package li.cil.oc import cpw.mods.fml.common.registry.GameRegistry import li.cil.oc.common.item +import net.minecraft.item.ItemStack import net.minecraftforge.oredict.OreDictionary object Items { @@ -29,8 +30,11 @@ object Items { // ----------------------------------------------------------------------- // // Upgrades - var crafting: item.Crafting = null - var generator: item.Generator = null + var upgradeCrafting: item.UpgradeCrafting = null + var upgradeGenerator: item.UpgradeGenerator = null + var upgradeNavigation: item.UpgradeNavigation = null + var upgradeSign: item.UpgradeSign = null + var upgradeSolarGenerator: item.UpgradeSolarGenerator = null // ----------------------------------------------------------------------- // // Crafting @@ -77,8 +81,8 @@ object Items { rs = new item.RedstoneCard(multi) wlan = new item.WirelessNetworkCard(multi) - crafting = new item.Crafting(multi) - generator = new item.Generator(multi) + upgradeCrafting = new item.UpgradeCrafting(multi) + upgradeGenerator = new item.UpgradeGenerator(multi) ironNugget = new item.IronNugget(multi) cuttingWire = new item.CuttingWire(multi) @@ -102,6 +106,53 @@ object Items { pcb = new item.PrintedCircuitBoard(multi) card = new item.CardBase(multi) - OreDictionary.registerOre("nuggetIron", ironNugget.createItemStack()) + // v1.1.0 + upgradeSolarGenerator = new item.UpgradeSolarGenerator(multi) + upgradeSign = new item.UpgradeSign(multi) + upgradeNavigation = new item.UpgradeNavigation(multi) + + // ----------------------------------------------------------------------- // + + registerExclusive("nuggetIron", ironNugget.createItemStack()) + register("oc:craftingCircuitBoardRaw", rawCircuitBoard.createItemStack()) + register("craftingCircuitBoardBasic", circuitBoard.createItemStack()) + register("craftingCircuitBoardAdvanced", pcb.createItemStack()) + register("oc:craftingWire", cuttingWire.createItemStack()) + register("circuitBasic", chip1.createItemStack()) + register("circuitAdvanced", chip2.createItemStack()) + register("circuitElite", chip3.createItemStack()) + register("craftingTransistor", transistor.createItemStack()) + register("craftingControlUnit", cu.createItemStack()) + register("craftingALU", alu.createItemStack()) + register("craftingCPU", cpu.createItemStack()) + register("componentCardRedstone", rs.createItemStack()) + register("componentCardLan", lan.createItemStack()) + register("craftingGPUBasic", gpu1.createItemStack()) + register("craftingGPUAdvanced", gpu2.createItemStack()) + register("craftingGPUElite", gpu3.createItemStack()) + register("craftingRAMBasic", ram1.createItemStack()) + register("craftingRAMAdvanced", ram2.createItemStack()) + register("craftingRAMElite", ram3.createItemStack()) + register("craftingHDDBasic", hdd1.createItemStack()) + register("craftingHDDAdvanced", hdd2.createItemStack()) + register("craftingHDDElite", hdd3.createItemStack()) + register("oc:craftingButtonGroup", buttonGroup.createItemStack()) + register("oc:craftingArrowKey", arrowKeys.createItemStack()) + register("oc:craftingNumPad", numPad.createItemStack()) + register("oc:craftingDisk", disk.createItemStack()) + register("oc:craftingAcid", acid.createItemStack()) + register("oc:craftingGenerator", upgradeGenerator.createItemStack()) + } + + def register(name: String, item: ItemStack) { + if (!OreDictionary.getOres(name).contains(item)) { + OreDictionary.registerOre(name, item) + } + } + + def registerExclusive(name: String, item: ItemStack) { + if (OreDictionary.getOres(name).isEmpty) { + OreDictionary.registerOre(name, item) + } } } \ No newline at end of file diff --git a/li/cil/oc/Recipes.scala b/li/cil/oc/Recipes.scala index d47ede97f..7e19ab86d 100644 --- a/li/cil/oc/Recipes.scala +++ b/li/cil/oc/Recipes.scala @@ -1,492 +1,288 @@ package li.cil.oc +import com.typesafe.config._ import cpw.mods.fml.common.Loader import cpw.mods.fml.common.registry.GameRegistry +import java.io.{FileReader, File} +import java.util.logging.Level import net.minecraft.block.Block import net.minecraft.item.crafting.FurnaceRecipes -import net.minecraft.item.{Item, ItemStack} -import net.minecraftforge.oredict.{ShapelessOreRecipe, ShapedOreRecipe} +import net.minecraft.item.{ItemStack, Item} +import net.minecraftforge.oredict.{OreDictionary, ShapelessOreRecipe, ShapedOreRecipe} +import org.apache.commons.io.FileUtils +import scala.Some +import scala.collection.convert.wrapAsScala._ +import scala.collection.mutable.ArrayBuffer object Recipes { def init() { - val blazeRod = new ItemStack(Item.blazeRod) - val boneMeal = new ItemStack(Item.dyePowder, 1, 15) - val cactusGreen = new ItemStack(Item.dyePowder, 1, 2) - val clock = new ItemStack(Item.pocketSundial) - val comparator = new ItemStack(Item.comparator) - val craftingTable = new ItemStack(Block.workbench) - val diamond = new ItemStack(Item.diamond) - val dispenser = new ItemStack(Block.dispenser) - val emerald = new ItemStack(Item.emerald) - val enderPearl = new ItemStack(Item.enderPearl) - val glass = new ItemStack(Block.glass) - val glowstoneDust = new ItemStack(Item.glowstone) - val goldIngot = new ItemStack(Item.ingotGold) - val goldNugget = new ItemStack(Item.goldNugget) - val ironBars = new ItemStack(Block.fenceIron) - val ironIngot = new ItemStack(Item.ingotIron) - val lapis = new ItemStack(Item.dyePowder, 1, 4) - val lever = new ItemStack(Block.lever) - val minecartHopper = new ItemStack(Item.minecartHopper) - val netherQuartz = new ItemStack(Item.netherQuartz) - val obsidian = new ItemStack(Block.obsidian) - val paper = new ItemStack(Item.paper) - val piston = new ItemStack(Block.pistonBase) - val redstoneBlock = new ItemStack(Block.blockRedstone) - val redstoneDust = new ItemStack(Item.redstone) - val redstoneTorch = new ItemStack(Block.torchRedstoneActive) - val repeater = new ItemStack(Item.redstoneRepeater) - val roseRed = new ItemStack(Item.dyePowder, 1, 1) - val slimeBall = new ItemStack(Item.slimeBall) - val spiderEye = new ItemStack(Item.spiderEye) - val stick = new ItemStack(Item.stick) - val sugar = new ItemStack(Item.sugar) + try { + val defaultRecipes = new File(Loader.instance.getConfigDir + File.separator + "opencomputers" + File.separator + "default.recipes") + val userRecipes = new File(Loader.instance.getConfigDir + File.separator + "opencomputers" + File.separator + "user.recipes") - val acid = Items.acid.createItemStack() - val alu = Items.alu.createItemStack() - val cable = Blocks.cable.createItemStack() - val card = Items.card.createItemStack() - val chip1 = Items.chip1.createItemStack() - val chip2 = Items.chip2.createItemStack() - val chip3 = Items.chip3.createItemStack() - val board = Items.circuitBoard.createItemStack() - val cpu = Items.cpu.createItemStack() - val cu = Items.cu.createItemStack() - val disk = Items.disk.createItemStack() - val floppy = Items.floppyDisk.createItemStack() - val gpu1 = Items.gpu1.createItemStack() - val gpu2 = Items.gpu2.createItemStack() - val gpu3 = Items.gpu3.createItemStack() - val hdd1 = Items.hdd1.createItemStack() - val hdd2 = Items.hdd2.createItemStack() - val hdd3 = Items.hdd3.createItemStack() - val lanCard = Items.lan.createItemStack() - val pcb = Items.pcb.createItemStack() - val ram1 = Items.ram1.createItemStack() - val ram2 = Items.ram2.createItemStack() - val ram3 = Items.ram3.createItemStack() - val rawBoard = Items.rawCircuitBoard.createItemStack() - val redstoneCard = Items.rs.createItemStack() - val transistor = Items.transistor.createItemStack() - val wlanCard = Items.wlan.createItemStack() + defaultRecipes.getParentFile.mkdirs() + FileUtils.copyURLToFile(getClass.getResource("/assets/opencomputers/recipes/default.recipes"), defaultRecipes) + if (!userRecipes.exists()) { + FileUtils.copyURLToFile(getClass.getResource("/assets/opencomputers/recipes/user.recipes"), userRecipes) + } + val config = ConfigParseOptions.defaults. + setSyntax(ConfigSyntax.CONF). + setIncluder(new ConfigIncluder with ConfigIncluderFile { + var fallback: ConfigIncluder = _ - // ----------------------------------------------------------------------- // + def withFallback(fallback: ConfigIncluder) = { + this.fallback = fallback + this + } - if (!Loader.isModLoaded("gregtech_addon")) { - GameRegistry.addRecipe(new ShapelessOreRecipe(Items.ironNugget.createItemStack(9), ironIngot)) + def include(context: ConfigIncludeContext, what: String) = fallback.include(context, what) + + def includeFile(context: ConfigIncludeContext, what: File) = { + val in = if (what.isAbsolute) new FileReader(what) else new FileReader(new File(userRecipes.getParentFile, what.getPath)) + val result = ConfigFactory.parseReader(in) + in.close() + result.root() + } + }) + val recipes = ConfigFactory.parseFile(userRecipes, config) + + // Try to keep this in the same order as the fields in the Items class + // to make it easier to match them and check if anything is missing. + addRecipe(Items.analyzer.createItemStack(), recipes, "analyzer") + + addRecipe(Items.ram1.createItemStack(), recipes, "ram1") + addRecipe(Items.ram2.createItemStack(), recipes, "ram2") + addRecipe(Items.ram3.createItemStack(), recipes, "ram3") + + addRecipe(Items.floppyDisk.createItemStack(), recipes, "floppy") + addRecipe(Items.hdd1.createItemStack(), recipes, "hdd1") + addRecipe(Items.hdd2.createItemStack(), recipes, "hdd2") + addRecipe(Items.hdd3.createItemStack(), recipes, "hdd3") + + addRecipe(Items.gpu1.createItemStack(), recipes, "graphicsCard1") + addRecipe(Items.gpu2.createItemStack(), recipes, "graphicsCard2") + addRecipe(Items.gpu3.createItemStack(), recipes, "graphicsCard3") + addRecipe(Items.lan.createItemStack(), recipes, "lanCard") + addRecipe(Items.rs.createItemStack(), recipes, "redstoneCard") + addRecipe(Items.wlan.createItemStack(), recipes, "wlanCard") + + addRecipe(Items.upgradeCrafting.createItemStack(), recipes, "craftingUpgrade") + addRecipe(Items.upgradeGenerator.createItemStack(), recipes, "generatorUpgrade") + addRecipe(Items.upgradeNavigation.createItemStack(), recipes, "navigationUpgrade") + addRecipe(Items.upgradeSign.createItemStack(), recipes, "signUpgrade") + addRecipe(Items.upgradeSolarGenerator.createItemStack(), recipes, "solarGeneratorUpgrade") + + if (OreDictionary.getOres("nuggetIron").contains(Items.ironNugget.createItemStack())) { + addRecipe(Items.ironNugget.createItemStack(), recipes, "nuggetIron") + } + addRecipe(Items.cuttingWire.createItemStack(), recipes, "cuttingWire") + addRecipe(Items.acid.createItemStack(), recipes, "acid") + addRecipe(Items.disk.createItemStack(), recipes, "disk") + + addRecipe(Items.buttonGroup.createItemStack(), recipes, "buttonGroup") + addRecipe(Items.arrowKeys.createItemStack(), recipes, "arrowKeys") + addRecipe(Items.numPad.createItemStack(), recipes, "numPad") + + addRecipe(Items.transistor.createItemStack(), recipes, "transistor") + addRecipe(Items.chip1.createItemStack(), recipes, "chip1") + addRecipe(Items.chip2.createItemStack(), recipes, "chip2") + addRecipe(Items.chip3.createItemStack(), recipes, "chip3") + addRecipe(Items.alu.createItemStack(), recipes, "alu") + addRecipe(Items.cpu.createItemStack(), recipes, "cpu") + addRecipe(Items.cu.createItemStack(), recipes, "cu") + + addRecipe(Items.rawCircuitBoard.createItemStack(), recipes, "rawCircuitBoard") + addRecipe(Items.circuitBoard.createItemStack(), recipes, "circuitBoard") + addRecipe(Items.pcb.createItemStack(), recipes, "printedCircuitBoard") + addRecipe(Items.card.createItemStack(), recipes, "card") + + // Try to keep this in the same order as the fields in the Blocks class + // to make it easier to match them and check if anything is missing. + addRecipe(Blocks.adapter.createItemStack(), recipes, "adapter") + addRecipe(Blocks.cable.createItemStack(), recipes, "cable") + addRecipe(Blocks.capacitor.createItemStack(), recipes, "capacitor") + addRecipe(Blocks.charger.createItemStack(), recipes, "charger") + addRecipe(Blocks.case1.createItemStack(), recipes, "case1") + addRecipe(Blocks.case2.createItemStack(), recipes, "case2") + addRecipe(Blocks.case3.createItemStack(), recipes, "case3") + addRecipe(Blocks.diskDrive.createItemStack(), recipes, "diskDrive") + addRecipe(Blocks.keyboard.createItemStack(), recipes, "keyboard") + addRecipe(Blocks.powerConverter.createItemStack(), recipes, "powerConverter") + addRecipe(Blocks.powerDistributor.createItemStack(), recipes, "powerDistributor") + addRecipe(Blocks.redstone.createItemStack(), recipes, "redstone") + addRecipe(Blocks.robotProxy.createItemStack(), recipes, "robot") + addRecipe(Blocks.router.createItemStack(), recipes, "router") + addRecipe(Blocks.screen1.createItemStack(), recipes, "screen1") + addRecipe(Blocks.screen2.createItemStack(), recipes, "screen2") + addRecipe(Blocks.screen3.createItemStack(), recipes, "screen3") + + // Navigation upgrade recrafting. + GameRegistry.addRecipe(new ShapelessOreRecipe(Items.upgradeNavigation.createItemStack(), Items.upgradeNavigation.createItemStack(), new ItemStack(Item.map, 1, OreDictionary.WILDCARD_VALUE))) + } + catch { + case e: Throwable => OpenComputers.log.log(Level.SEVERE, "Error parsing recipes, you may not be able to craft any items from this mod!", e) } - GameRegistry.addShapelessRecipe(rawBoard, Items.cuttingWire.createItemStack(), new ItemStack(Block.blockClay), cactusGreen) - FurnaceRecipes.smelting().addSmelting(rawBoard.itemID, rawBoard.getItemDamage, board, 0) - GameRegistry.addRecipe(new ShapelessOreRecipe(acid, Item.bucketWater, sugar, roseRed, slimeBall, spiderEye, boneMeal)) - GameRegistry.addRecipe(new ShapelessOreRecipe(pcb, acid, Item.goldNugget, board)) - - addRecipe(ironIngot, - "xxx", - "xxx", - "xxx", - 'x', "nuggetIron") - - addRecipe(disk, - " i ", - "i i", - " i ", - 'i', "nuggetIron") - - addRecipe(transistor, - "iii", - "grg", - " t ", - 'i', "nuggetIron", - 'g', goldNugget, - 'r', redstoneDust, - 't', redstoneTorch) - - addRecipe(chip1, - "ibi", - "rtr", - "ibi", - 'i', "nuggetIron", - 'b', ironBars, - 'r', redstoneDust, - 't', transistor) - - addRecipe(chip2, - "glg", - "cdc", - "glg", - 'g', goldNugget, - 'l', lapis, - 'c', chip1, - 'd', diamond) - - addRecipe(chip3, - "dmd", - "cec", - "dmd", - 'd', glowstoneDust, - 'm', comparator, - 'c', chip2, - 'e', emerald) - - addRecipe(alu, - "rtr", - "sss", - "idi", - 'r', repeater, - 's', transistor, - 't', redstoneTorch, - 'i', "nuggetIron", - 'd', redstoneDust) - - addRecipe(cu, - "gtg", - "scs", - "gdg", - 'g', goldNugget, - 't', redstoneTorch, - 's', transistor, - 'c', clock, - 'd', redstoneDust) - - addRecipe(cpu, - "cdc", - "bub", - "cac", - 'c', chip1, - 'd', redstoneDust, - 'b', ironBars, - 'u', cu, - 'a', alu) - - addRecipe(card, - "ict", - "ibb", - "igg", - 'i', "nuggetIron", - 'c', chip1, - 't', transistor, - 'b', pcb, - 'g', goldNugget) - - addRecipe(Items.buttonGroup.createItemStack(), - "bbb", - "bbb", - 'b', new ItemStack(Block.stoneButton)) - - addRecipe(Items.arrowKeys.createItemStack(), - " b ", - "bbb", - 'b', new ItemStack(Block.stoneButton)) - - addRecipe(Items.numPad.createItemStack(), - "bbb", - "bbb", - "bbb", - 'b', new ItemStack(Block.stoneButton)) - - // ----------------------------------------------------------------------- // - - addRecipe(Blocks.case1.createItemStack(), - "ipi", - "bcb", - "imi", - 'i', ironIngot, - 'p', pcb, - 'b', ironBars, - 'c', cpu, - 'm', chip1) - - addRecipe(Blocks.case2.createItemStack(), - "gpg", - "mcm", - "gpg", - 'g', goldIngot, - 'p', pcb, - 'm', chip2, - 'c', Blocks.case1.createItemStack()) - - addRecipe(Blocks.case3.createItemStack(), - "mpm", - "dcd", - "mpm", - 'm', chip3, - 'p', pcb, - 'd', diamond, - 'c', Blocks.case2.createItemStack()) - - addRecipe(Blocks.screen1.createItemStack(), - "iig", - "rtg", - "iig", - 'i', ironIngot, - 'g', glass, - 'r', redstoneDust, - 't', transistor) - - addRecipe(Blocks.screen2.createItemStack(), - "iri", - "cgs", - "ibi", - 'i', goldIngot, - 'r', roseRed, - 'c', chip2, - 'g', cactusGreen, - 's', Blocks.screen1.createItemStack(), - 'b', lapis) - - addRecipe(Blocks.screen3.createItemStack(), - "opc", - "bqs", - "opc", - 'o', obsidian, - 'p', pcb, - 'c', chip3, - 'b', blazeRod, - 'q', netherQuartz, - 's', Blocks.screen2.createItemStack()) - - addRecipe(Blocks.capacitor.createItemStack(), - "iti", - "gpg", - "ibi", - 'i', ironIngot, - 't', transistor, - 'g', goldNugget, - 'p', paper, - 'b', pcb) - - addRecipe(Blocks.powerConverter.createItemStack(), - "iwi", - "gcg", - "ibi", - 'i', ironIngot, - 'c', chip1, - 'w', cable, - 'g', goldIngot, - 'b', pcb) - - addRecipe(Blocks.diskDrive.createItemStack(), - "ici", - "ps ", - "ici", - 'i', ironIngot, - 'c', chip1, - 'p', piston, - 's', stick) - - addRecipe(Blocks.adapter.createItemStack(), - "iwi", - "wcw", - "ibi", - 'i', ironIngot, - 'w', cable, - 'c', chip1, - 'b', pcb) - - addRecipe(Blocks.redstone.createItemStack(), - "iri", - "rcr", - "ibi", - 'i', ironIngot, - 'r', redstoneBlock, - 'c', redstoneCard, - 'b', pcb) - - addRecipe(Blocks.powerDistributor.createItemStack(), - "igi", - "wcw", - "ibi", - 'i', ironIngot, - 'g', goldIngot, - 'w', cable, - 'c', chip1, - 'b', pcb) - - addRecipe(Blocks.router.createItemStack(), - "iwi", - "wnw", - "ibi", - 'i', ironIngot, - 'w', cable, - 'n', lanCard, - 'b', pcb) - - addRecipe(Blocks.charger.createItemStack(), - "igi", - "pcp", - "ibi", - 'i', ironIngot, - 'g', goldIngot, - 'p', Blocks.capacitor.createItemStack(), - 'c', chip2, - 'b', pcb) - - addRecipe(Blocks.robotProxy.createItemStack(), - "sgf", - "dcr", - "bmb", - 's', Blocks.screen1.createItemStack(), - 'g', gpu1, - 'f', Blocks.diskDrive.createItemStack(), - 'd', dispenser, - 'c', Blocks.case1.createItemStack(), - 'r', ram1, - 'b', Blocks.capacitor.createItemStack(), - 'm', minecartHopper) - - addRecipe(Blocks.keyboard.createItemStack(), - "ggg", - "gan", - 'g', Items.buttonGroup.createItemStack(), - 'a', Items.arrowKeys.createItemStack(), - 'n', Items.numPad.createItemStack()) - - addRecipe(Blocks.cable.createItemStack(4), - " i ", - "iri", - " i ", - 'i', "nuggetIron", - 'r', redstoneDust) - - // ----------------------------------------------------------------------- // - - addRecipe(Items.cuttingWire.createItemStack(), - "sis", - 's', stick, - 'i', "nuggetIron") - - addRecipe(Items.analyzer.createItemStack(), - " r ", - "tcg", - "tpg", - 'r', redstoneTorch, - 't', transistor, - 'c', chip1, - 'g', goldNugget, - 'p', pcb) - - addRecipe(ram1, - "ccc", - "bbb", - 'c', chip1, - 'b', pcb) - - addRecipe(ram2, - "ccc", - "rbr", - 'c', chip2, - 'r', ram1, - 'b', pcb) - - addRecipe(ram3, - "ccc", - "rbr", - 'c', chip3, - 'r', ram2, - 'b', pcb) - - addRecipe(floppy, - "ili", - "bdb", - "ipi", - 'i', "nuggetIron", - 'l', lever, - 'b', board, - 'd', disk, - 'p', paper) - - addRecipe(hdd1, - "cdi", - "bdp", - "cdi", - 'c', chip1, - 'd', disk, - 'i', ironIngot, - 'b', pcb, - 'p', piston) - - addRecipe(hdd2, - "gdg", - "cbc", - "gdg", - 'g', goldIngot, - 'd', hdd1, - 'c', chip2, - 'b', pcb) - - addRecipe(hdd3, - "cdc", - "rbr", - "cdc", - 'c', chip3, - 'd', hdd2, - 'r', ram1, - 'b', pcb) - - addRecipe(gpu1, - "car", - " b ", - 'c', chip1, - 'a', alu, - 'r', ram1, - 'b', card) - - addRecipe(gpu2, - "ccr", - " g ", - 'c', chip2, - 'r', ram2, - 'g', gpu1) - - addRecipe(gpu3, - "ccr", - " g ", - 'c', chip3, - 'r', ram3, - 'g', gpu2) - - addRecipe(redstoneCard, - "tc ", - " b ", - 't', redstoneTorch, - 'c', chip1, - 'b', card) - - addRecipe(lanCard, - "wc ", - " b ", - 'w', cable, - 'c', chip1, - 'b', card) - - addRecipe(wlanCard, - "pc ", - " b ", - 'p', enderPearl, - 'c', chip2, - 'b', lanCard) - - addRecipe(Items.generator.createItemStack(), - "i i", - "cpc", - "bib", - 'i', ironIngot, - 'c', chip1, - 'p', piston, - 'b', pcb) - - addRecipe(Items.crafting.createItemStack(), - "ipi", - "cwc", - "ibi", - 'i', ironIngot, - 'p', piston, - 'c', chip1, - 'w', craftingTable, - 'b', pcb) } - private def addRecipe(output: ItemStack, args: Any*) = { - GameRegistry.addRecipe(new ShapedOreRecipe(output, args.map(_.asInstanceOf[AnyRef]): _*)) + def addRecipe(output: ItemStack, list: Config, name: String) = try { + if (list.hasPath(name)) { + val recipe = list.getConfig(name) + tryGetType(recipe) match { + case "shaped" => addShapedRecipe(output, recipe) + case "shapeless" => addShapelessRecipe(output, recipe) + case "furnace" => addFurnaceRecipe(output, recipe) + case other => throw new RecipeException("Invalid recipe type '" + other + "'.") + } + } + else { + OpenComputers.log.info("No recipe for '" + name + "', you will not be able to craft this item.") + } } + catch { + case e: RecipeException => OpenComputers.log.warning("Failed adding recipe for '" + name + "', you will not be able to craft this item! The error was: " + e.getMessage) + case e: Throwable => OpenComputers.log.log(Level.SEVERE, "Failed adding recipe for '" + name + "', you will not be able to craft this item!", e) + } + + private def addShapedRecipe(stack: ItemStack, recipe: Config) { + val rows = recipe.getList("input").unwrapped().map { + case row: java.util.List[Object] => row.map(parseIngredient).padTo(3, null) + case other => throw new RecipeException("Invalid row entry for shaped recipe (not a list: " + other + ").") + } + + var number = -1 + var shape = ArrayBuffer.empty[String] + val input = ArrayBuffer.empty[AnyRef] + for (row <- rows) { + val (pattern, ingredients) = row.foldLeft((new StringBuilder, Seq.empty[AnyRef]))((acc, ingredient) => { + val (pattern, ingredients) = acc + ingredient match { + case _@(_: ItemStack | _: String) => + number += 1 + (pattern.append(('a' + number).toChar), ingredients ++ Seq(Char.box(('a' + number).toChar), ingredient)) + case _ => (pattern.append(' '), ingredients) + } + }) + shape += pattern.toString + input ++= ingredients + } + + val output = stack.copy() + output.stackSize = tryGetCount(recipe) + + GameRegistry.addRecipe(new ShapedOreRecipe(output, shape ++ input: _*)) + } + + private def addShapelessRecipe(stack: ItemStack, recipe: Config) { + val input = recipe.getValue("input").unwrapped() match { + case list: java.util.List[Object] => list.map(parseIngredient) + case other => Seq(parseIngredient(other)) + } + + val output = stack.copy() + output.stackSize = tryGetCount(recipe) + + if (input.size > 0 && output.stackSize > 0) { + GameRegistry.addRecipe(new ShapelessOreRecipe(output, input: _*)) + } + } + + private def addFurnaceRecipe(stack: ItemStack, recipe: Config) { + val input = parseIngredient(recipe.getValue("input").unwrapped()) + + val output = stack.copy() + output.stackSize = tryGetCount(recipe) + + input match { + case stack: ItemStack => + FurnaceRecipes.smelting().addSmelting(stack.itemID, stack.getItemDamage, output, 0) + case name: String => + for (stack <- OreDictionary.getOres(name)) { + FurnaceRecipes.smelting().addSmelting(stack.itemID, stack.getItemDamage, output, 0) + } + case _ => + } + } + + private def parseIngredient(entry: AnyRef) = entry match { + case map: java.util.HashMap[String, _] => + if (map.contains("oreDict")) { + map.get("oreDict") match { + case value: String => value + case other => throw new RecipeException("Invalid name in recipe (not a string: " + other + ").") + } + } + else if (map.contains("item")) { + map.get("item") match { + case name: String => + Item.itemsList.find(itemNameEquals(_, name)) match { + case Some(item) => new ItemStack(item, 1, tryGetId(map)) + case _ => throw new RecipeException("No item found with name '" + name + "'.") + } + case id: Number => new ItemStack(validateItemId(id), 1, tryGetId(map)) + case other => throw new RecipeException("Invalid item name in recipe (not a string: " + other + ").") + } + } + else if (map.contains("block")) { + map.get("block") match { + case name: String => + Block.blocksList.find(blockNameEquals(_, name)) match { + case Some(block) => new ItemStack(block, 1, tryGetId(map)) + case _ => throw new RecipeException("No block found with name '" + name + "'.") + } + case id: Number => new ItemStack(validateBlockId(id), 1, tryGetId(map)) + case other => throw new RecipeException("Invalid block name (not a string: " + other + ").") + } + } + else throw new RecipeException("Invalid ingredient type (no oreDict, item or block entry).") + case name: String => + if (name == null || name.trim.isEmpty) null + else if (OreDictionary.getOres(name) != null && !OreDictionary.getOres(name).isEmpty) name + else { + Item.itemsList.find(itemNameEquals(_, name)) match { + case Some(item) => new ItemStack(item, 1, 0) + case _ => Block.blocksList.find(blockNameEquals(_, name)) match { + case Some(block) => new ItemStack(block, 1, 0) + case _ => throw new RecipeException("No ore dictionary entry, item or block found for ingredient with name '" + name + "'.") + } + } + } + case _ => throw new RecipeException("Invalid ingredient type (not a map or string).") + } + + private def itemNameEquals(item: Item, name: String) = + item != null && (item.getUnlocalizedName == name || item.getUnlocalizedName == "item." + name) + + private def blockNameEquals(block: Block, name: String) = + block != null && (block.getUnlocalizedName == name || block.getUnlocalizedName == "tile." + name) + + private def tryGetType(recipe: Config) = if (recipe.hasPath("type")) recipe.getString("type") else "shaped" + + private def tryGetCount(recipe: Config) = if (recipe.hasPath("output")) recipe.getInt("output") else 1 + + private def tryGetId(ingredient: java.util.HashMap[String, _]): Int = + if (ingredient.contains("subID")) ingredient.get("subID") match { + case id: Number => id.intValue + case id: String => Integer.valueOf(id) + case _ => 0 + } else 0 + + private def validateBlockId(id: Number) = { + val index = id.intValue + if (index < 1 || index >= Block.blocksList.length || Block.blocksList(index) == null) throw new RecipeException("Invalid block ID: " + index) + Block.blocksList(index) + } + + private def validateItemId(id: Number) = { + val index = id.intValue + if (index < 0 || index >= Item.itemsList.length || Item.itemsList(index) == null) throw new RecipeException("Invalid item ID: " + index) + Item.itemsList(index) + } + + private def cartesianProduct[T](xss: List[List[T]]): List[List[T]] = xss match { + case Nil => List(Nil) + case h :: t => for (xh <- h; xt <- cartesianProduct(t)) yield xh :: xt + } + + private class RecipeException(message: String) extends RuntimeException(message) + } diff --git a/li/cil/oc/Settings.scala b/li/cil/oc/Settings.scala index cbb2c0cbf..26c9a16b9 100644 --- a/li/cil/oc/Settings.scala +++ b/li/cil/oc/Settings.scala @@ -91,6 +91,7 @@ class Settings(config: Config) { val ratioThermalExpansion = config.getDouble("power.ratioThermalExpansion").toFloat val chargeRate = config.getDouble("power.chargerChargeRate") val generatorEfficiency = config.getDouble("power.generatorEfficiency") + val solarGeneratorEfficiency = config.getDouble("power.solarGeneratorEfficiency") // power.buffer val bufferCapacitor = config.getDouble("power.buffer.capacitor") max 0 diff --git a/li/cil/oc/client/renderer/item/UpgradeRenderer.scala b/li/cil/oc/client/renderer/item/UpgradeRenderer.scala index c838323ce..4c9f3090a 100644 --- a/li/cil/oc/client/renderer/item/UpgradeRenderer.scala +++ b/li/cil/oc/client/renderer/item/UpgradeRenderer.scala @@ -13,7 +13,7 @@ import org.lwjgl.opengl.GL11 object UpgradeRenderer extends IItemRenderer { def handleRenderType(item: ItemStack, renderType: ItemRenderType) = { Items.multi.subItem(item) match { - case Some(subItem) if subItem == Items.generator || subItem == Items.crafting => renderType == ItemRenderType.EQUIPPED + case Some(subItem) if subItem == Items.upgradeGenerator || subItem == Items.upgradeCrafting => renderType == ItemRenderType.EQUIPPED case _ => false } } @@ -31,7 +31,7 @@ object UpgradeRenderer extends IItemRenderer { GL11.glTranslatef(0.5f, 0.5f, 0.5f) Items.multi.subItem(stack) match { - case Some(subItem) if subItem == Items.crafting => + case Some(subItem) if subItem == Items.upgradeCrafting => // TODO display list? val b = AxisAlignedBB.getAABBPool.getAABB(0.4, 0.2, 0.64, 0.6, 0.4, 0.84) tm.bindTexture(new ResourceLocation(Settings.resourceDomain, "textures/items/upgrade_crafting_equipped.png")) @@ -71,7 +71,7 @@ object UpgradeRenderer extends IItemRenderer { t.addVertexWithUV(b.minX, b.minY, b.minZ, 0.5, 1) t.setNormal(-1, 0, 0) t.draw() - case Some(subItem) if subItem == Items.generator => + case Some(subItem) if subItem == Items.upgradeGenerator => // TODO display lists? val onOffset = if (Item.dataTag(stack).getInteger("remainingTicks") > 0) 0.5 else 0 val b = AxisAlignedBB.getAABBPool.getAABB(0.4, 0.2, 0.16, 0.6, 0.4, 0.36) diff --git a/li/cil/oc/common/Proxy.scala b/li/cil/oc/common/Proxy.scala index 934037ec1..01a18804f 100644 --- a/li/cil/oc/common/Proxy.scala +++ b/li/cil/oc/common/Proxy.scala @@ -27,12 +27,15 @@ class Proxy { api.Driver.add(driver.block.CommandBlock) api.Driver.add(driver.block.NoteBlock) - api.Driver.add(driver.item.Crafting) + api.Driver.add(driver.item.UpgradeCrafting) api.Driver.add(driver.item.FileSystem) - api.Driver.add(driver.item.Generator) + api.Driver.add(driver.item.UpgradeGenerator) + api.Driver.add(driver.item.SolarGenerator) api.Driver.add(driver.item.GraphicsCard) + api.Driver.add(driver.item.UpgradeNavigation) api.Driver.add(driver.item.Memory) api.Driver.add(driver.item.NetworkCard) + api.Driver.add(driver.item.UpgradeSign) api.Driver.add(driver.item.RedstoneCard) api.Driver.add(driver.item.WirelessNetworkCard) diff --git a/li/cil/oc/common/item/IronNugget.scala b/li/cil/oc/common/item/IronNugget.scala index f6974fa62..e93d79685 100644 --- a/li/cil/oc/common/item/IronNugget.scala +++ b/li/cil/oc/common/item/IronNugget.scala @@ -1,14 +1,23 @@ package li.cil.oc.common.item import cpw.mods.fml.common.Loader +import java.util import li.cil.oc.Settings +import li.cil.oc.util.Tooltip import net.minecraft.client.renderer.texture.IconRegister +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.item.ItemStack class IronNugget(val parent: Delegator) extends Delegate { val unlocalizedName = "IronNugget" override val showInItemList = !Loader.isModLoaded("gregtech_addon") + override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) { + tooltip.addAll(Tooltip.get(unlocalizedName)) + super.tooltipLines(stack, player, tooltip, advanced) + } + override def registerIcons(iconRegister: IconRegister) = { super.registerIcons(iconRegister) diff --git a/li/cil/oc/common/item/Crafting.scala b/li/cil/oc/common/item/UpgradeCrafting.scala similarity index 87% rename from li/cil/oc/common/item/Crafting.scala rename to li/cil/oc/common/item/UpgradeCrafting.scala index 3248a4658..c3e1d6bc5 100644 --- a/li/cil/oc/common/item/Crafting.scala +++ b/li/cil/oc/common/item/UpgradeCrafting.scala @@ -7,8 +7,8 @@ import net.minecraft.client.renderer.texture.IconRegister import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.{EnumRarity, ItemStack} -class Crafting(val parent: Delegator) extends Delegate { - val unlocalizedName = "Crafting" +class UpgradeCrafting(val parent: Delegator) extends Delegate { + val unlocalizedName = "UpgradeCrafting" override def rarity = EnumRarity.epic diff --git a/li/cil/oc/common/item/Generator.scala b/li/cil/oc/common/item/UpgradeGenerator.scala similarity index 87% rename from li/cil/oc/common/item/Generator.scala rename to li/cil/oc/common/item/UpgradeGenerator.scala index 8a31922ed..0c93f36db 100644 --- a/li/cil/oc/common/item/Generator.scala +++ b/li/cil/oc/common/item/UpgradeGenerator.scala @@ -7,8 +7,8 @@ import net.minecraft.client.renderer.texture.IconRegister import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.{EnumRarity, ItemStack} -class Generator(val parent: Delegator) extends Delegate { - val unlocalizedName = "Generator" +class UpgradeGenerator(val parent: Delegator) extends Delegate { + val unlocalizedName = "UpgradeGenerator" override def rarity = EnumRarity.epic diff --git a/li/cil/oc/common/item/UpgradeNavigation.scala b/li/cil/oc/common/item/UpgradeNavigation.scala new file mode 100644 index 000000000..cf8cff80a --- /dev/null +++ b/li/cil/oc/common/item/UpgradeNavigation.scala @@ -0,0 +1,25 @@ +package li.cil.oc.common.item + +import java.util +import li.cil.oc.Settings +import li.cil.oc.util.Tooltip +import net.minecraft.client.renderer.texture.IconRegister +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.item.{EnumRarity, ItemStack} + +class UpgradeNavigation(val parent: Delegator) extends Delegate { + val unlocalizedName = "UpgradeNavigation" + + override def rarity = EnumRarity.epic + + override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) { + tooltip.addAll(Tooltip.get(unlocalizedName)) + super.tooltipLines(stack, player, tooltip, advanced) + } + + override def registerIcons(iconRegister: IconRegister) = { + super.registerIcons(iconRegister) + + icon = iconRegister.registerIcon(Settings.resourceDomain + ":upgrade_navigation") + } +} diff --git a/li/cil/oc/common/item/UpgradeSign.scala b/li/cil/oc/common/item/UpgradeSign.scala new file mode 100644 index 000000000..5add8bfb1 --- /dev/null +++ b/li/cil/oc/common/item/UpgradeSign.scala @@ -0,0 +1,25 @@ +package li.cil.oc.common.item + +import java.util +import li.cil.oc.Settings +import li.cil.oc.util.Tooltip +import net.minecraft.client.renderer.texture.IconRegister +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.item.{EnumRarity, ItemStack} + +class UpgradeSign(val parent: Delegator) extends Delegate { + val unlocalizedName = "UpgradeSign" + + override def rarity = EnumRarity.epic + + override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) { + tooltip.addAll(Tooltip.get(unlocalizedName)) + super.tooltipLines(stack, player, tooltip, advanced) + } + + override def registerIcons(iconRegister: IconRegister) = { + super.registerIcons(iconRegister) + + icon = iconRegister.registerIcon(Settings.resourceDomain + ":upgrade_sign") + } +} diff --git a/li/cil/oc/common/item/UpgradeSolarGenerator.scala b/li/cil/oc/common/item/UpgradeSolarGenerator.scala new file mode 100644 index 000000000..6f529cc62 --- /dev/null +++ b/li/cil/oc/common/item/UpgradeSolarGenerator.scala @@ -0,0 +1,25 @@ +package li.cil.oc.common.item + +import java.util +import li.cil.oc.Settings +import li.cil.oc.util.Tooltip +import net.minecraft.client.renderer.texture.IconRegister +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.item.{EnumRarity, ItemStack} + +class UpgradeSolarGenerator(val parent: Delegator) extends Delegate { + val unlocalizedName = "UpgradeSolarGenerator" + + override def rarity = EnumRarity.epic + + override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) { + tooltip.addAll(Tooltip.get(unlocalizedName, (Settings.get.solarGeneratorEfficiency * 100).toInt)) + super.tooltipLines(stack, player, tooltip, advanced) + } + + override def registerIcons(iconRegister: IconRegister) = { + super.registerIcons(iconRegister) + + icon = iconRegister.registerIcon(Settings.resourceDomain + ":upgrade_solar_generator") + } +} diff --git a/li/cil/oc/server/component/Crafting.scala b/li/cil/oc/server/component/UpgradeCrafting.scala similarity index 97% rename from li/cil/oc/server/component/Crafting.scala rename to li/cil/oc/server/component/UpgradeCrafting.scala index a17fbdd4e..232f9d56a 100644 --- a/li/cil/oc/server/component/Crafting.scala +++ b/li/cil/oc/server/component/UpgradeCrafting.scala @@ -12,7 +12,7 @@ import net.minecraftforge.common.MinecraftForge import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent import scala.collection.mutable -class Crafting(val owner: MCTileEntity) extends ManagedComponent { +class UpgradeCrafting(val owner: MCTileEntity) extends ManagedComponent { val node = api.Network.newNode(this, Visibility.Network). withComponent("crafting"). create() diff --git a/li/cil/oc/server/component/Generator.scala b/li/cil/oc/server/component/UpgradeGenerator.scala similarity index 98% rename from li/cil/oc/server/component/Generator.scala rename to li/cil/oc/server/component/UpgradeGenerator.scala index adf26d90e..ed4e5aa09 100644 --- a/li/cil/oc/server/component/Generator.scala +++ b/li/cil/oc/server/component/UpgradeGenerator.scala @@ -9,7 +9,7 @@ import net.minecraft.nbt.NBTTagCompound import net.minecraft.tileentity.{TileEntity => MCTileEntity, TileEntityFurnace} import scala.Some -class Generator(val owner: MCTileEntity) extends ManagedComponent { +class UpgradeGenerator(val owner: MCTileEntity) extends ManagedComponent { val node = api.Network.newNode(this, Visibility.Network). withComponent("generator", Visibility.Neighbors). withConnector(). diff --git a/li/cil/oc/server/component/UpgradeNavigation.scala b/li/cil/oc/server/component/UpgradeNavigation.scala new file mode 100644 index 000000000..bc9bb1820 --- /dev/null +++ b/li/cil/oc/server/component/UpgradeNavigation.scala @@ -0,0 +1,33 @@ +package li.cil.oc.server.component + +import li.cil.oc.api +import li.cil.oc.api.network._ +import li.cil.oc.util.RotationHelper +import net.minecraft.tileentity.{TileEntity => MCTileEntity} + +class UpgradeNavigation(val owner: MCTileEntity, val xCenter: Int, val zCenter: Int, val size: Int) extends ManagedComponent { + val node = api.Network.newNode(this, Visibility.Network). + withComponent("navigation", Visibility.Neighbors). + create() + + // ----------------------------------------------------------------------- // + + @LuaCallback("getPosition") + def getPosition(context: RobotContext, args: Arguments): Array[AnyRef] = { + val x = owner.xCoord + val z = owner.zCoord + val y = owner.yCoord + val relativeX = x - xCenter + val relativeY = z - zCenter + + if (math.abs(relativeX) <= size / 2 && math.abs(relativeY) <= size / 2) + result(relativeX, relativeY, y) + else + result(Unit, "out of range") + } + + @LuaCallback("getFacing") + def getFacing(context: RobotContext, args: Arguments): Array[AnyRef] = { + result(RotationHelper.fromYaw(context.player().rotationYaw).ordinal()) + } +} diff --git a/li/cil/oc/server/component/UpgradeSign.scala b/li/cil/oc/server/component/UpgradeSign.scala new file mode 100644 index 000000000..bfda34d2c --- /dev/null +++ b/li/cil/oc/server/component/UpgradeSign.scala @@ -0,0 +1,40 @@ +package li.cil.oc.server.component + +import li.cil.oc.api +import li.cil.oc.api.network._ +import li.cil.oc.util.RotationHelper +import net.minecraft.tileentity.{TileEntity => MCTileEntity, TileEntitySign} + +class UpgradeSign(val owner: MCTileEntity) extends ManagedComponent { + val node = api.Network.newNode(this, Visibility.Network). + withComponent("sign", Visibility.Neighbors). + withConnector(). + create() + + // ----------------------------------------------------------------------- // + + @LuaCallback("getValue") + def read(context: RobotContext, args: Arguments): Array[AnyRef] = { + val player = context.player() + val facing = RotationHelper.fromYaw(player.rotationYaw) + owner.getWorldObj.getBlockTileEntity(owner.xCoord + facing.offsetX, owner.yCoord + facing.offsetY, owner.zCoord + facing.offsetZ) match { + case sign: TileEntitySign => result(sign.signText.mkString("\n")) + case _ => result(Unit, "no sign") + } + } + + @LuaCallback("setValue") + def write(context: RobotContext, args: Arguments): Array[AnyRef] = { + val text = args.checkString(0).lines.padTo(4, "").map(line => if (line.size > 15) line.substring(0, 15) else line) + val player = context.player() + val facing = RotationHelper.fromYaw(player.rotationYaw) + val (sx, sy, sz) = (owner.xCoord + facing.offsetX, owner.yCoord + facing.offsetY, owner.zCoord + facing.offsetZ) + owner.getWorldObj.getBlockTileEntity(sx, sy, sz) match { + case sign: TileEntitySign => + text.copyToArray(sign.signText) + owner.getWorldObj.markBlockForUpdate(sx, sy, sz) + result(sign.signText.mkString("\n")) + case _ => result(Unit, "no sign") + } + } +} diff --git a/li/cil/oc/server/component/UpgradeSolarGenerator.scala b/li/cil/oc/server/component/UpgradeSolarGenerator.scala new file mode 100644 index 000000000..021b9f8b8 --- /dev/null +++ b/li/cil/oc/server/component/UpgradeSolarGenerator.scala @@ -0,0 +1,44 @@ +package li.cil.oc.server.component + +import li.cil.oc.api.network.Visibility +import li.cil.oc.{Settings, api} +import net.minecraft.tileentity.{TileEntity => MCTileEntity} +import net.minecraft.world.World +import net.minecraft.world.biome.BiomeGenDesert + +class UpgradeSolarGenerator(val owner: MCTileEntity) extends ManagedComponent { + val node = api.Network.newNode(this, Visibility.Network). + withConnector(). + create() + + var ticksUntilCheck = 0 + + var isSunShining = false + + // ----------------------------------------------------------------------- // + + override val canUpdate = true + + override def update() { + super.update() + + ticksUntilCheck -= 1 + if (ticksUntilCheck <= 0) { + ticksUntilCheck = 100 + val world = owner.getWorldObj + val x = owner.xCoord + val y = owner.yCoord + val z = owner.zCoord + isSunShining = isSunVisible(world, x, y + 1, z) + } + if (isSunShining) { + node.changeBuffer(Settings.get.ratioBuildCraft * Settings.get.solarGeneratorEfficiency) + } + } + + private def isSunVisible(world: World, x: Int, y: Int, z: Int): Boolean = + world.isDaytime && + (!world.provider.hasNoSky) && + world.canBlockSeeTheSky(x, y, z) && + (world.getWorldChunkManager.getBiomeGenAt(x, z).isInstanceOf[BiomeGenDesert] || (!world.isRaining && !world.isThundering)) +} diff --git a/li/cil/oc/server/driver/item/SolarGenerator.scala b/li/cil/oc/server/driver/item/SolarGenerator.scala new file mode 100644 index 000000000..0998fe1f7 --- /dev/null +++ b/li/cil/oc/server/driver/item/SolarGenerator.scala @@ -0,0 +1,15 @@ +package li.cil.oc.server.driver.item + +import li.cil.oc.Items +import li.cil.oc.api.driver.Slot +import li.cil.oc.server.component +import net.minecraft.item.ItemStack +import net.minecraft.tileentity.{TileEntity => MCTileEntity} + +object SolarGenerator extends Item { + override def worksWith(stack: ItemStack) = isOneOf(stack, Items.upgradeSolarGenerator) + + override def createEnvironment(stack: ItemStack, container: MCTileEntity) = new component.UpgradeSolarGenerator(container) + + override def slot(stack: ItemStack) = Slot.Upgrade +} diff --git a/li/cil/oc/server/driver/item/Generator.scala b/li/cil/oc/server/driver/item/UpgradeCrafting.scala similarity index 78% rename from li/cil/oc/server/driver/item/Generator.scala rename to li/cil/oc/server/driver/item/UpgradeCrafting.scala index be2959d75..c07201912 100644 --- a/li/cil/oc/server/driver/item/Generator.scala +++ b/li/cil/oc/server/driver/item/UpgradeCrafting.scala @@ -6,10 +6,10 @@ import li.cil.oc.server.component import net.minecraft.item.ItemStack import net.minecraft.tileentity.{TileEntity => MCTileEntity} -object Generator extends Item { - override def worksWith(stack: ItemStack) = isOneOf(stack, Items.generator) +object UpgradeCrafting extends Item { + override def worksWith(stack: ItemStack) = isOneOf(stack, Items.upgradeCrafting) - override def createEnvironment(stack: ItemStack, container: MCTileEntity) = new component.Generator(container) + override def createEnvironment(stack: ItemStack, container: MCTileEntity) = new component.UpgradeCrafting(container) override def slot(stack: ItemStack) = Slot.Upgrade } diff --git a/li/cil/oc/server/driver/item/UpgradeGenerator.scala b/li/cil/oc/server/driver/item/UpgradeGenerator.scala new file mode 100644 index 000000000..02c337736 --- /dev/null +++ b/li/cil/oc/server/driver/item/UpgradeGenerator.scala @@ -0,0 +1,15 @@ +package li.cil.oc.server.driver.item + +import li.cil.oc.Items +import li.cil.oc.api.driver.Slot +import li.cil.oc.server.component +import net.minecraft.item.ItemStack +import net.minecraft.tileentity.{TileEntity => MCTileEntity} + +object UpgradeGenerator extends Item { + override def worksWith(stack: ItemStack) = isOneOf(stack, Items.upgradeGenerator) + + override def createEnvironment(stack: ItemStack, container: MCTileEntity) = new component.UpgradeGenerator(container) + + override def slot(stack: ItemStack) = Slot.Upgrade +} diff --git a/li/cil/oc/server/driver/item/UpgradeNavigation.scala b/li/cil/oc/server/driver/item/UpgradeNavigation.scala new file mode 100644 index 000000000..2cc558c4a --- /dev/null +++ b/li/cil/oc/server/driver/item/UpgradeNavigation.scala @@ -0,0 +1,25 @@ +package li.cil.oc.server.driver.item + +import li.cil.oc.api.driver.Slot +import li.cil.oc.server.component +import li.cil.oc.server.driver.Registry +import li.cil.oc.{Settings, Items} +import net.minecraft.item.ItemStack +import net.minecraft.tileentity.{TileEntity => MCTileEntity} + +object UpgradeNavigation extends Item { + override def worksWith(stack: ItemStack) = isOneOf(stack, Items.upgradeNavigation) + + override def createEnvironment(stack: ItemStack, container: MCTileEntity) = { + val nbt = Registry.driverFor(stack) match { + case Some(driver) => driver.dataTag(stack) + case _ => null + } + val x = if (nbt.hasKey(Settings.namespace + "xCenter")) nbt.getInteger(Settings.namespace + "xCenter") else container.xCoord + val z = if (nbt.hasKey(Settings.namespace + "zCenter")) nbt.getInteger(Settings.namespace + "zCenter") else container.zCoord + val size = if (nbt.hasKey(Settings.namespace + "scale")) nbt.getInteger(Settings.namespace + "scale") else 512 + new component.UpgradeNavigation(container, x, z, size) + } + + override def slot(stack: ItemStack) = Slot.Upgrade +} diff --git a/li/cil/oc/server/driver/item/Crafting.scala b/li/cil/oc/server/driver/item/UpgradeSign.scala similarity index 80% rename from li/cil/oc/server/driver/item/Crafting.scala rename to li/cil/oc/server/driver/item/UpgradeSign.scala index 6ffc40ded..d55afeecf 100644 --- a/li/cil/oc/server/driver/item/Crafting.scala +++ b/li/cil/oc/server/driver/item/UpgradeSign.scala @@ -6,10 +6,10 @@ import li.cil.oc.server.component import net.minecraft.item.ItemStack import net.minecraft.tileentity.{TileEntity => MCTileEntity} -object Crafting extends Item { - override def worksWith(stack: ItemStack) = isOneOf(stack, Items.crafting) +object UpgradeSign extends Item { + override def worksWith(stack: ItemStack) = isOneOf(stack, Items.upgradeSign) - override def createEnvironment(stack: ItemStack, container: MCTileEntity) = new component.Crafting(container) + override def createEnvironment(stack: ItemStack, container: MCTileEntity) = new component.UpgradeSign(container) override def slot(stack: ItemStack) = Slot.Upgrade } diff --git a/li/cil/oc/util/RotationHelper.scala b/li/cil/oc/util/RotationHelper.scala new file mode 100644 index 000000000..848041fb4 --- /dev/null +++ b/li/cil/oc/util/RotationHelper.scala @@ -0,0 +1,14 @@ +package li.cil.oc.util + +import net.minecraftforge.common.ForgeDirection + +object RotationHelper { + def fromYaw(yaw: Float) = { + (yaw / 360 * 4).round & 3 match { + case 0 => ForgeDirection.SOUTH + case 1 => ForgeDirection.WEST + case 2 => ForgeDirection.NORTH + case 3 => ForgeDirection.EAST + } + } +} diff --git a/reference.conf b/reference.conf index 957cda471..429f1c0fb 100644 --- a/reference.conf +++ b/reference.conf @@ -363,6 +363,12 @@ opencomputers { # default. generatorEfficiency: 0.8 + # The energy efficiency of the solar generator upgrade. At 1.0 this will + # generate as much energy as you'd get by burning fuel in a BuildCraft + # Stirling Engine . To discourage fully autonomous robots the efficiency + # of solar generators is greatly reduced by default. + solarGeneratorEfficiency: 0.2 + # Default "buffer" sizes, i.e. how much energy certain blocks can store. buffer { # The amount of energy a single capacitor can store.