Refactoring.

This commit is contained in:
Florian Nücke 2015-03-24 00:03:01 +01:00
parent bdc006d31e
commit d45cc724b5
13 changed files with 36 additions and 35 deletions

Binary file not shown.

View File

@ -44,6 +44,7 @@ item.oc.appengTunnel.name=P2P Tunnel - OpenComputers
item.oc.ArrowKeys.name=Arrow Keys item.oc.ArrowKeys.name=Arrow Keys
item.oc.ButtonGroup.name=Button Group item.oc.ButtonGroup.name=Button Group
item.oc.CardBase.name=Card Base item.oc.CardBase.name=Card Base
item.oc.Chamelium.name=Chamelium
item.oc.CircuitBoard.name=Circuit Board item.oc.CircuitBoard.name=Circuit Board
item.oc.ControlUnit.name=Control Unit (CU) item.oc.ControlUnit.name=Control Unit (CU)
item.oc.ComponentBus0.name=Component Bus (Tier 1) item.oc.ComponentBus0.name=Component Bus (Tier 1)
@ -88,7 +89,6 @@ item.oc.MicrocontrollerCase1.name=Microcontroller Case (Tier 2)
item.oc.MicrocontrollerCase3.name=Microcontroller Case (Creative) item.oc.MicrocontrollerCase3.name=Microcontroller Case (Creative)
item.oc.NetworkCard.name=Network Card item.oc.NetworkCard.name=Network Card
item.oc.NumPad.name=Numeric Keypad item.oc.NumPad.name=Numeric Keypad
item.oc.Plastic.name=Plastic
item.oc.Present.name=A little something... item.oc.Present.name=A little something...
item.oc.PrintedCircuitBoard.name=Printed Circuit Board (PCB) item.oc.PrintedCircuitBoard.name=Printed Circuit Board (PCB)
item.oc.RawCircuitBoard.name=Raw Circuit Board item.oc.RawCircuitBoard.name=Raw Circuit Board
@ -225,6 +225,7 @@ oc:tooltip.Cable=A cheap way of connecting blocks.
oc:tooltip.Capacitor=Stores energy for later use. Can be filled and emptied very quickly. oc:tooltip.Capacitor=Stores energy for later use. Can be filled and emptied very quickly.
oc:tooltip.CardBase=As the name indicates, this is the basic building block for all expansion cards. oc:tooltip.CardBase=As the name indicates, this is the basic building block for all expansion cards.
oc:tooltip.Case=The Computer Case is the basic building block for computers and houses the computer's §fextension cards§7, §fRAM§7 and §fhard disks§7.[nl] Slots: §f%s§7 oc:tooltip.Case=The Computer Case is the basic building block for computers and houses the computer's §fextension cards§7, §fRAM§7 and §fhard disks§7.[nl] Slots: §f%s§7
oc:tooltip.Chamelium=Raw material for 3D prints. Do not swallow. Not that you could even if you wanted to.
oc:tooltip.Charger=Transfers energy from capacitors into adjacent robots and drones. The transfer rate depends on the incoming §fredstone signal§7, where no signal means don't charge devices, and maximum strength means charge at full speed. Can also be used to charge tablets and access hard drives in tablets. oc:tooltip.Charger=Transfers energy from capacitors into adjacent robots and drones. The transfer rate depends on the incoming §fredstone signal§7, where no signal means don't charge devices, and maximum strength means charge at full speed. Can also be used to charge tablets and access hard drives in tablets.
oc:tooltip.CircuitBoard=Now we're getting somewhere. Can be etched to obtain a printed circuit board. 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.ControlUnit=This is the unit that... controls... stuff. You need it to build a CPU. So yeah, totally important.
@ -261,7 +262,6 @@ oc:tooltip.Microcontroller=Microcontrollers are computers boiled down to the ess
oc:tooltip.MicrocontrollerCase=Base component for building microcontrollers. Place it into an assembler to add further components and assemble a microcontroller. oc:tooltip.MicrocontrollerCase=Base component for building microcontrollers. Place it into an assembler to add further components and assemble a microcontroller.
oc:tooltip.MotionSensor=Can detect movement of nearby living beings. Requires clear line-of-sight. oc:tooltip.MotionSensor=Can detect movement of nearby living beings. Requires clear line-of-sight.
oc:tooltip.NetworkCard=Allows distant computers connected by other blocks (such as cable) to communicate by sending messages to each other. oc:tooltip.NetworkCard=Allows distant computers connected by other blocks (such as cable) to communicate by sending messages to each other.
oc:tooltip.Plastic=Raw material for 3D prints. Do not swallow. Not that you could even if you wanted to.
oc:tooltip.PowerAcceptor=Energy conversion speed: §f%s/t§7 oc:tooltip.PowerAcceptor=Energy conversion speed: §f%s/t§7
oc:tooltip.PowerConverter.BuildCraft=§fBuildCraft MJ§7: §a%s:%s§7 oc:tooltip.PowerConverter.BuildCraft=§fBuildCraft MJ§7: §a%s:%s§7
oc:tooltip.PowerConverter.Factorization=§fFactorization Charge§7: §a%s:%s§7 oc:tooltip.PowerConverter.Factorization=§fFactorization Charge§7: §a%s:%s§7
@ -271,7 +271,7 @@ oc:tooltip.PowerConverter.ThermalExpansion=§fThermal Expansion RF§7: §a%s:%s
oc:tooltip.PowerConverter.ResonantEngine=§fResonant Engine Coulombs§7: §a%s:%s§7 oc:tooltip.PowerConverter.ResonantEngine=§fResonant Engine Coulombs§7: §a%s:%s§7
oc:tooltip.PowerConverter=Converts power from other mods to the internal energy type. Conversion rates: oc:tooltip.PowerConverter=Converts power from other mods to the internal energy type. Conversion rates:
oc:tooltip.PowerDistributor=Distributes energy among different networks. This is useful for sharing power fed into your system from one converter among different sub-networks that should remain separate. oc:tooltip.PowerDistributor=Distributes energy among different networks. This is useful for sharing power fed into your system from one converter among different sub-networks that should remain separate.
oc:tooltip.Printer=Allows printing blocks of user-defined shapes using plastic and ink cartridges. Must be configured using a computer. Keep away from small children. Because reasons. oc:tooltip.Printer=Allows printing blocks of user-defined shapes using Chamelium and Ink Cartridges. Must be configured using a computer. Keep away from small children. Because reasons.
oc:tooltip.PrintedCircuitBoard=The basic building block for expansion cards and memory and such. oc:tooltip.PrintedCircuitBoard=The basic building block for expansion cards and memory and such.
oc:tooltip.Present=... for your troubles. Open this present for a chance to receive some §kphat lewt§7![nl]§8Craft OpenComputers items when the time is right for a chance to receive a present.§7 oc:tooltip.Present=... for your troubles. Open this present for a chance to receive some §kphat lewt§7![nl]§8Craft OpenComputers items when the time is right for a chance to receive a present.§7
oc:tooltip.Raid=Allows combining three hard drives into one larger file system that can be used by all connected computers. oc:tooltip.Raid=Allows combining three hard drives into one larger file system that can be used by all connected computers.

View File

@ -318,7 +318,7 @@ disk {
[nuggetIron, "", nuggetIron] [nuggetIron, "", nuggetIron]
["", nuggetIron, ""]] ["", nuggetIron, ""]]
} }
plastic { chamelium {
input: [[gravel, redstone, gravel], input: [[gravel, redstone, gravel],
[redstone, {item=coal, subID=1}, redstone], [redstone, {item=coal, subID=1}, redstone],
[gravel, water_bucket, gravel]] [gravel, water_bucket, gravel]]

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

View File

@ -27,7 +27,7 @@ object Textures {
val guiKeyboardMissing = new ResourceLocation(Settings.resourceDomain, "textures/gui/keyboard_missing.png") val guiKeyboardMissing = new ResourceLocation(Settings.resourceDomain, "textures/gui/keyboard_missing.png")
val guiPrinter = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer.png") val guiPrinter = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer.png")
val guiPrinterInk = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer_ink.png") val guiPrinterInk = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer_ink.png")
val guiPrinterPlastic = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer_plastic.png") val guiPrinterMaterial = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer_material.png")
val guiPrinterProgress = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer_progress.png") val guiPrinterProgress = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer_progress.png")
val guiRaid = new ResourceLocation(Settings.resourceDomain, "textures/gui/raid.png") val guiRaid = new ResourceLocation(Settings.resourceDomain, "textures/gui/raid.png")
val guiRange = new ResourceLocation(Settings.resourceDomain, "textures/gui/range.png") val guiRange = new ResourceLocation(Settings.resourceDomain, "textures/gui/range.png")

View File

@ -13,12 +13,12 @@ class Printer(playerInventory: InventoryPlayer, val printer: tileentity.Printer)
xSize = 176 xSize = 176
ySize = 166 ySize = 166
private val plasticBar = addWidget(new ProgressBar(40, 21) { private val materialBar = addWidget(new ProgressBar(40, 21) {
override def width = 62 override def width = 62
override def height = 12 override def height = 12
override def barTexture = Textures.guiPrinterPlastic override def barTexture = Textures.guiPrinterMaterial
}) })
private val inkBar = addWidget(new ProgressBar(40, 53) { private val inkBar = addWidget(new ProgressBar(40, 53) {
override def width = 62 override def width = 62
@ -47,9 +47,9 @@ class Printer(playerInventory: InventoryPlayer, val printer: tileentity.Printer)
Localization.localizeImmediately(printer.getInventoryName), Localization.localizeImmediately(printer.getInventoryName),
8, 6, 0x404040) 8, 6, 0x404040)
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) // Me lazy... prevents NEI render glitch. GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) // Me lazy... prevents NEI render glitch.
if (func_146978_c(plasticBar.x, plasticBar.y, plasticBar.width, plasticBar.height, mouseX, mouseY)) { if (func_146978_c(materialBar.x, materialBar.y, materialBar.width, materialBar.height, mouseX, mouseY)) {
val tooltip = new java.util.ArrayList[String] val tooltip = new java.util.ArrayList[String]
tooltip.add(printerContainer.amountPlastic + "/" + printer.maxAmountPlastic) tooltip.add(printerContainer.amountMaterial + "/" + printer.maxAmountMaterial)
copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj) copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj)
} }
if (func_146978_c(inkBar.x, inkBar.y, inkBar.width, inkBar.height, mouseX, mouseY)) { if (func_146978_c(inkBar.x, inkBar.y, inkBar.width, inkBar.height, mouseX, mouseY)) {
@ -64,7 +64,7 @@ class Printer(playerInventory: InventoryPlayer, val printer: tileentity.Printer)
GL11.glColor3f(1, 1, 1) // Required under Linux. GL11.glColor3f(1, 1, 1) // Required under Linux.
mc.renderEngine.bindTexture(Textures.guiPrinter) mc.renderEngine.bindTexture(Textures.guiPrinter)
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize)
plasticBar.level = printerContainer.amountPlastic / printer.maxAmountPlastic.toDouble materialBar.level = printerContainer.amountMaterial / printer.maxAmountMaterial.toDouble
inkBar.level = printerContainer.amountInk / printer.maxAmountInk.toDouble inkBar.level = printerContainer.amountInk / printer.maxAmountInk.toDouble
if (printerContainer.isPrinting) progressBar.level = (System.currentTimeMillis() % 3000) / 3000.0 if (printerContainer.isPrinting) progressBar.level = (System.currentTimeMillis() % 3000) / 3000.0
else progressBar.level = 0 else progressBar.level = 0

View File

@ -16,7 +16,7 @@ class Printer(playerInventory: InventoryPlayer, val printer: tileentity.Printer)
addPlayerInventorySlots(8, 84) addPlayerInventorySlots(8, 84)
var isPrinting = false var isPrinting = false
var amountPlastic = 0 var amountMaterial = 0
var amountInk = 0 var amountInk = 0
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -27,7 +27,7 @@ class Printer(playerInventory: InventoryPlayer, val printer: tileentity.Printer)
} }
if (id == 1) { if (id == 1) {
amountPlastic = value amountMaterial = value
} }
if (id == 2) { if (id == 2) {
@ -42,9 +42,9 @@ class Printer(playerInventory: InventoryPlayer, val printer: tileentity.Printer)
isPrinting = printer.isPrinting isPrinting = printer.isPrinting
sendProgressBarUpdate(0, if (isPrinting) 1 else 0) sendProgressBarUpdate(0, if (isPrinting) 1 else 0)
} }
if (amountPlastic != printer.amountPlastic) { if (amountMaterial != printer.amountMaterial) {
amountPlastic = printer.amountPlastic amountMaterial = printer.amountMaterial
sendProgressBarUpdate(1, amountPlastic) sendProgressBarUpdate(1, amountMaterial)
} }
if (amountInk != printer.amountInk) { if (amountInk != printer.amountInk) {
amountInk = printer.amountInk amountInk = printer.amountInk

View File

@ -474,6 +474,6 @@ object Items extends ItemAPI {
// 1.5.4 // 1.5.4
Recipes.addMultiItem(new item.InkCartridgeEmpty(multi), "inkCartridgeEmpty", "oc:inkCartridgeEmpty") Recipes.addMultiItem(new item.InkCartridgeEmpty(multi), "inkCartridgeEmpty", "oc:inkCartridgeEmpty")
Recipes.addMultiItem(new item.InkCartridge(multi), "inkCartridge", "oc:inkCartridge") Recipes.addMultiItem(new item.InkCartridge(multi), "inkCartridge", "oc:inkCartridge")
Recipes.addMultiItem(new item.Plastic(multi), "plastic", "oc:plastic") Recipes.addMultiItem(new item.Chamelium(multi), "chamelium", "oc:chamelium")
} }
} }

View File

@ -0,0 +1,3 @@
package li.cil.oc.common.item
class Chamelium(val parent: Delegator) extends Delegate

View File

@ -1,3 +0,0 @@
package li.cil.oc.common.item
class Plastic(val parent: Delegator) extends Delegate

View File

@ -26,8 +26,8 @@ class Printer extends traits.Environment with traits.Inventory with traits.Rotat
withConnector(Settings.get.bufferConverter). withConnector(Settings.get.bufferConverter).
create() create()
val maxAmountPlastic = 256000 val maxAmountMaterial = 256000
var amountPlastic = 0 var amountMaterial = 0
val maxAmountInk = 100000 val maxAmountInk = 100000
var amountInk = 0 var amountInk = 0
@ -37,10 +37,10 @@ class Printer extends traits.Environment with traits.Inventory with traits.Rotat
var totalRequiredEnergy = 0.0 var totalRequiredEnergy = 0.0
var requiredEnergy = 0.0 var requiredEnergy = 0.0
val plasticPerItem = 2000 val materialPerItem = 2000
val inkPerCartridge = 50000 val inkPerCartridge = 50000
val slotPlastic = 0 val slotMaterial = 0
val slotInk = 1 val slotInk = 1
val slotOutput = 2 val slotOutput = 2
@ -63,7 +63,7 @@ class Printer extends traits.Environment with traits.Inventory with traits.Rotat
def isPrinting = (requiredEnergy > 0 || isActive) && Option(getStackInSlot(slotOutput)).fold(true)(stack => { def isPrinting = (requiredEnergy > 0 || isActive) && Option(getStackInSlot(slotOutput)).fold(true)(stack => {
stack.stackSize < stack.getMaxStackSize && output.fold(true)(ItemStack.areItemStackTagsEqual(stack, _)) stack.stackSize < stack.getMaxStackSize && output.fold(true)(ItemStack.areItemStackTagsEqual(stack, _))
}) }) && (output.isDefined || (amountMaterial > 0 && amountInk > 0))
def progress = (1 - requiredEnergy / totalRequiredEnergy) * 100 def progress = (1 - requiredEnergy / totalRequiredEnergy) * 100
@ -190,23 +190,24 @@ class Printer extends traits.Environment with traits.Inventory with traits.Rotat
override def updateEntity() { override def updateEntity() {
super.updateEntity() super.updateEntity()
if (isActive && output.isEmpty) { if (isActive && output.isEmpty && Option(getStackInSlot(slotOutput)).fold(true)(stack => stack.stackSize < stack.getMaxStackSize)) {
val totalVolume = data.stateOn.foldLeft(0)((acc, shape) => acc + shape.bounds.volume) + data.stateOff.foldLeft(0)((acc, shape) => acc + shape.bounds.volume) val totalVolume = data.stateOn.foldLeft(0)((acc, shape) => acc + shape.bounds.volume) + data.stateOff.foldLeft(0)((acc, shape) => acc + shape.bounds.volume)
val totalSurface = data.stateOn.foldLeft(0)((acc, shape) => acc + shape.bounds.surface) + data.stateOff.foldLeft(0)((acc, shape) => acc + shape.bounds.surface) val totalSurface = data.stateOn.foldLeft(0)((acc, shape) => acc + shape.bounds.surface) + data.stateOff.foldLeft(0)((acc, shape) => acc + shape.bounds.surface)
val totalShapes = data.stateOn.size + data.stateOff.size val totalShapes = data.stateOn.size + data.stateOff.size
if (totalVolume == 0) { if (totalVolume == 0) {
isActive = false isActive = false
data = new PrintData()
} }
else { else {
val plasticRequired = totalVolume val materialRequired = totalVolume
val inkRequired = (totalSurface / 6) max 1 val inkRequired = (totalSurface / 6) max 1
totalRequiredEnergy = totalShapes * Settings.get.printShapeCost totalRequiredEnergy = totalShapes * Settings.get.printShapeCost
requiredEnergy = totalRequiredEnergy requiredEnergy = totalRequiredEnergy
if (amountPlastic >= plasticRequired && amountInk >= inkRequired) { if (amountMaterial >= materialRequired && amountInk >= inkRequired) {
amountPlastic -= plasticRequired amountMaterial -= materialRequired
amountInk -= inkRequired amountInk -= inkRequired
output = Option(data.createItemStack()) output = Option(data.createItemStack())
ServerPacketSender.sendPrinting(this, printing = true) ServerPacketSender.sendPrinting(this, printing = true)
@ -238,10 +239,10 @@ class Printer extends traits.Environment with traits.Inventory with traits.Rotat
ServerPacketSender.sendPrinting(this, success && output.isDefined) ServerPacketSender.sendPrinting(this, success && output.isDefined)
} }
if (maxAmountPlastic - amountPlastic >= plasticPerItem) { if (maxAmountMaterial - amountMaterial >= materialPerItem) {
val plastic = decrStackSize(slotPlastic, 1) val material = decrStackSize(slotMaterial, 1)
if (plastic != null) { if (material != null) {
amountPlastic += plasticPerItem amountMaterial += materialPerItem
} }
} }
@ -255,7 +256,7 @@ class Printer extends traits.Environment with traits.Inventory with traits.Rotat
override def readFromNBTForServer(nbt: NBTTagCompound) { override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt) super.readFromNBTForServer(nbt)
amountPlastic = nbt.getInteger(Settings.namespace + "amountPlastic") amountMaterial = nbt.getInteger(Settings.namespace + "amountMaterial")
amountInk = nbt.getInteger(Settings.namespace + "amountInk") amountInk = nbt.getInteger(Settings.namespace + "amountInk")
data.load(nbt.getCompoundTag(Settings.namespace + "data")) data.load(nbt.getCompoundTag(Settings.namespace + "data"))
isActive = nbt.getBoolean(Settings.namespace + "active") isActive = nbt.getBoolean(Settings.namespace + "active")
@ -268,7 +269,7 @@ class Printer extends traits.Environment with traits.Inventory with traits.Rotat
override def writeToNBTForServer(nbt: NBTTagCompound) { override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt) super.writeToNBTForServer(nbt)
nbt.setInteger(Settings.namespace + "amountPlastic", amountPlastic) nbt.setInteger(Settings.namespace + "amountMaterial", amountMaterial)
nbt.setInteger(Settings.namespace + "amountInk", amountInk) nbt.setInteger(Settings.namespace + "amountInk", amountInk)
nbt.setNewCompoundTag(Settings.namespace + "data", data.save) nbt.setNewCompoundTag(Settings.namespace + "data", data.save)
nbt.setBoolean(Settings.namespace + "active", isActive) nbt.setBoolean(Settings.namespace + "active", isActive)
@ -296,7 +297,7 @@ class Printer extends traits.Environment with traits.Inventory with traits.Rotat
override def isItemValidForSlot(slot: Int, stack: ItemStack) = override def isItemValidForSlot(slot: Int, stack: ItemStack) =
if (slot == 0) if (slot == 0)
api.Items.get(stack) == api.Items.get("plastic") api.Items.get(stack) == api.Items.get("chamelium")
else if (slot == 1) else if (slot == 1)
api.Items.get(stack) == api.Items.get("inkCartridge") api.Items.get(stack) == api.Items.get("inkCartridge")
else false else false