From d45cc724b53a9bdd34883ff4d74e8762ce88b02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 24 Mar 2015 00:03:01 +0100 Subject: [PATCH] Refactoring. --- assets/items.psd | Bin 583622 -> 584048 bytes .../assets/opencomputers/lang/en_US.lang | 6 ++-- .../opencomputers/recipes/default.recipes | 2 +- ...inter_plastic.png => printer_material.png} | Bin .../textures/items/Chamelium.png | Bin 0 -> 313 bytes .../opencomputers/textures/items/Plastic.png | Bin 316 -> 0 bytes .../scala/li/cil/oc/client/Textures.scala | 2 +- .../scala/li/cil/oc/client/gui/Printer.scala | 10 +++--- .../li/cil/oc/common/container/Printer.scala | 10 +++--- .../scala/li/cil/oc/common/init/Items.scala | 2 +- .../li/cil/oc/common/item/Chamelium.scala | 3 ++ .../scala/li/cil/oc/common/item/Plastic.scala | 3 -- .../li/cil/oc/common/tileentity/Printer.scala | 33 +++++++++--------- 13 files changed, 36 insertions(+), 35 deletions(-) rename src/main/resources/assets/opencomputers/textures/gui/{printer_plastic.png => printer_material.png} (100%) create mode 100644 src/main/resources/assets/opencomputers/textures/items/Chamelium.png delete mode 100644 src/main/resources/assets/opencomputers/textures/items/Plastic.png create mode 100644 src/main/scala/li/cil/oc/common/item/Chamelium.scala delete mode 100644 src/main/scala/li/cil/oc/common/item/Plastic.scala diff --git a/assets/items.psd b/assets/items.psd index 9eaa421ece300068932778eed3f24445ca692638..3ac63c947e14d403369751e7070c0a1e4c9698e9 100644 GIT binary patch delta 2426 zcmZvbeN+=y8pdZP$=rb^1f(u!cT1zeGHcrYhzlrYPy^XS+=b>266q^ zDrlf-v2L}s#N)*eu(XG=c1>+b%h)3F&$b6YLSWspR*$7>6wx+x&rwv?%ngH!|qdM52&bPB;iB@e;9;C@0ntPMF%?c7(c~-K%!~Lh;V)q!vEDh)Rj+Um;3nx&NxDbpO`7%>sF3vTxPRd%Y^7fM{Zn%Cr4sE)kC$yQjo zj7lSCh;J^VR;XRVrk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~iOcj8KNGdH<@ z;C+qx$A2rBS^ef`CzhW4kvZQx(bB(HMjveGnRp_Wd-^=OF26B!EvI$V=3aigYFn#3 z`Rcl?50n1j%0%?BedpqF|J?s=%p8KTlwEWtL-2R`AlF@jue^%4l;nusipbCQ027Q7R zy)#U|XoyLmf~;ufm=$pe+LI<>Ytl?uWix4&P;Y`ROp}sU3~#U)meAi5^nx^ru}W&M zH7SXyr|5`dnpC&!nj+P2WTr@MnbG5NITTXYj7(()kaD*pSEPpwOd5f5^-jVcT_v{A0*W2I*?N5uCkiNX! zE4#I8yk57vRxU@iiJw#ptylfZ~kBc6&1@Rf5IHap=*I0xF2{`)?h=yD{#?IE*={QoAe`qs$r5 z;gA9fREtGvgFXv~%EBrrP(fBSV~j)bFw+E}xTKNbWFyH*sHl^%0x1r|8!QH-f}JWU zPLh;f4oDsBWPa1Ad8MHN)m>(CwJj7x4*m2pQ>MF{HK!AeTxRN1oto*Gp`t6ywsa>B z5NgCIh!{G0g$brVkT6s^4s0F@*oASX`&$8f;VKkULeV?KweQ-H2AGW~Y(8qmjlU8*n Z`pzDsy$d{Qv)d{iBNUKof*Yg8YJkTvWjDX#aj8plr3Li(^Q| zt(fzXLPr!hST49ZT+EsLJHBj|#mZAh^nX8OvWVyY{_OH^VV9KoMUCIueF@v+W|6 s&TQT&^346U<_~$k3jgZ$>lv6C=BjapJg+UE4Ri*Br>mdKI;Vst0J3p?tpET3 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/opencomputers/textures/items/Plastic.png b/src/main/resources/assets/opencomputers/textures/items/Plastic.png deleted file mode 100644 index 914588f6b48eb3be3830a4a60542384f5862057d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 316 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!fo%K)DcS4$&ZJq_jJyo7`pzwlsJPd6J^CySK$fV!%j_-Mb- zK-btvpTgXv#2CMcea&r6WgTs`E0@pz|NsBq{(JdALxf9${DOg8G{CT__6`S7y2{hV zF{I*F%=yK%i(##NymOIXTXVmmhPKCL- 0 || isActive) && Option(getStackInSlot(slotOutput)).fold(true)(stack => { stack.stackSize < stack.getMaxStackSize && output.fold(true)(ItemStack.areItemStackTagsEqual(stack, _)) - }) + }) && (output.isDefined || (amountMaterial > 0 && amountInk > 0)) def progress = (1 - requiredEnergy / totalRequiredEnergy) * 100 @@ -190,23 +190,24 @@ class Printer extends traits.Environment with traits.Inventory with traits.Rotat override def 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 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 if (totalVolume == 0) { isActive = false + data = new PrintData() } else { - val plasticRequired = totalVolume + val materialRequired = totalVolume val inkRequired = (totalSurface / 6) max 1 totalRequiredEnergy = totalShapes * Settings.get.printShapeCost requiredEnergy = totalRequiredEnergy - if (amountPlastic >= plasticRequired && amountInk >= inkRequired) { - amountPlastic -= plasticRequired + if (amountMaterial >= materialRequired && amountInk >= inkRequired) { + amountMaterial -= materialRequired amountInk -= inkRequired output = Option(data.createItemStack()) 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) } - if (maxAmountPlastic - amountPlastic >= plasticPerItem) { - val plastic = decrStackSize(slotPlastic, 1) - if (plastic != null) { - amountPlastic += plasticPerItem + if (maxAmountMaterial - amountMaterial >= materialPerItem) { + val material = decrStackSize(slotMaterial, 1) + if (material != null) { + amountMaterial += materialPerItem } } @@ -255,7 +256,7 @@ class Printer extends traits.Environment with traits.Inventory with traits.Rotat override def readFromNBTForServer(nbt: NBTTagCompound) { super.readFromNBTForServer(nbt) - amountPlastic = nbt.getInteger(Settings.namespace + "amountPlastic") + amountMaterial = nbt.getInteger(Settings.namespace + "amountMaterial") amountInk = nbt.getInteger(Settings.namespace + "amountInk") data.load(nbt.getCompoundTag(Settings.namespace + "data")) 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) { super.writeToNBTForServer(nbt) - nbt.setInteger(Settings.namespace + "amountPlastic", amountPlastic) + nbt.setInteger(Settings.namespace + "amountMaterial", amountMaterial) nbt.setInteger(Settings.namespace + "amountInk", amountInk) nbt.setNewCompoundTag(Settings.namespace + "data", data.save) 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) = if (slot == 0) - api.Items.get(stack) == api.Items.get("plastic") + api.Items.get(stack) == api.Items.get("chamelium") else if (slot == 1) api.Items.get(stack) == api.Items.get("inkCartridge") else false