From 7ee74d56a112f1d1f853d2d79ed7f0b4f9eaf0a1 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 5 Dec 2013 13:38:00 -0800 Subject: [PATCH] First Iteration of Gate Rewrite GateKind enum is gone, replaced with two enums: GateMaterial and GateLogic. Pulsars and Timers are abstracted into GateExpansions that can be applied to "upgrade" a gate. (Incomplete) GateExpansions will eventually be moved to the API so that other can define new expansions easily. GateExpansions are not currently serialized or synced to the client. This remains to be done. Legacy migration support is included, but untested. Currently only the base logic texture layer (white/black) are being rendered. Eventually the material and expansions will each render an additional texture layer onto the gate. --- .../textures/blocks/gate_iron_or_dark.png | Bin 163 -> 0 bytes .../textures/blocks/gate_iron_or_lit.png | Bin 137 -> 0 bytes .../gate_dark_and.png} | Bin .../textures/blocks/gates/gate_dark_or.png | Bin 0 -> 217 bytes .../{gate_lit.png => gates/gate_lit_and.png} | Bin .../textures/blocks/gates/gate_lit_or.png | Bin 0 -> 194 bytes .../blocks/gates/gate_material_diamond.png | Bin 0 -> 195 bytes .../blocks/gates/gate_material_gold.png | Bin 0 -> 196 bytes .../blocks/gates/gate_material_iron.png | Bin 0 -> 194 bytes .../textures/items/autarchic_gate.png | Bin 339 -> 0 bytes .../textures/items/gate_diamond_or.png | Bin 340 -> 0 bytes .../textures/items/gate_gold_or.png | Bin 340 -> 0 bytes .../textures/items/gate_iron_or.png | Bin 340 -> 0 bytes .../items/gates/gate_expansion_clock.png | Bin 0 -> 214 bytes .../items/gates/gate_expansion_pulsar.png | Bin 0 -> 222 bytes .../{gate.png => gates/gate_logic_and.png} | Bin .../textures/items/gates/gate_logic_or.png | Bin 0 -> 340 bytes .../items/gates/gate_material_diamond.png | Bin 0 -> 204 bytes .../items/gates/gate_material_gold.png | Bin 0 -> 204 bytes .../items/gates/gate_material_iron.png | Bin 0 -> 204 bytes .../lang/buildcraft/en_US.properties | 33 +- common/buildcraft/BuildCraftEnergy.java | 2 +- common/buildcraft/BuildCraftSilicon.java | 58 +-- common/buildcraft/BuildCraftTransport.java | 17 +- .../builders/TileBlueprintLibrary.java | 5 +- common/buildcraft/builders/TileBuilder.java | 5 +- common/buildcraft/core/fluids/FluidUtils.java | 7 +- .../buildcraft/core/inventory/InvUtils.java | 90 +++++ common/buildcraft/core/utils/Utils.java | 87 ----- common/buildcraft/energy/TileEngineIron.java | 3 +- common/buildcraft/energy/TileEngineStone.java | 3 +- .../{ => triggers}/TriggerEngineHeat.java | 11 +- common/buildcraft/factory/BlockTank.java | 7 +- .../buildcraft/factory/TileAutoWorkbench.java | 6 +- .../factory/gui/ContainerAutoWorkbench.java | 3 +- .../buildcraft/silicon/TileAssemblyTable.java | 5 +- .../transport/BlockGenericPipe.java | 35 +- common/buildcraft/transport/Gate.java | 179 ++++----- common/buildcraft/transport/GateVanilla.java | 360 ------------------ .../transport/IPipeRenderState.java | 12 - common/buildcraft/transport/ItemGate.java | 164 -------- common/buildcraft/transport/Pipe.java | 16 +- .../buildcraft/transport/PipeRenderState.java | 27 +- .../buildcraft/transport/TileGenericPipe.java | 63 ++- .../transport/blueprints/BptBlockPipe.java | 121 +++--- .../transport/gates/GateDefinition.java | 119 ++++++ .../gates/GateExpansionController.java | 60 +++ .../transport/gates/GateExpansionPulsar.java | 148 +++++++ .../transport/gates/GateExpansions.java | 28 ++ .../transport/gates/GateFactory.java | 91 +++++ .../transport/gates/IGateExpansion.java | 24 ++ .../buildcraft/transport/gates/ItemGate.java | 135 +++++++ .../transport/gui/ContainerGateInterface.java | 63 +-- .../transport/gui/GuiGateInterface.java | 34 +- .../transport/render/PipeRendererTESR.java | 108 ++++-- .../transport/render/PipeRendererWorld.java | 27 +- .../transport/triggers/ActionPipeColor.java | 2 +- .../triggers/TriggerPipeContents.java | 12 +- 58 files changed, 1112 insertions(+), 1058 deletions(-) delete mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gate_iron_or_dark.png delete mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gate_iron_or_lit.png rename buildcraft_resources/assets/buildcraft/textures/blocks/{gate_dark.png => gates/gate_dark_and.png} (100%) create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_dark_or.png rename buildcraft_resources/assets/buildcraft/textures/blocks/{gate_lit.png => gates/gate_lit_and.png} (100%) create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_lit_or.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_material_diamond.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_material_gold.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_material_iron.png delete mode 100644 buildcraft_resources/assets/buildcraft/textures/items/autarchic_gate.png delete mode 100644 buildcraft_resources/assets/buildcraft/textures/items/gate_diamond_or.png delete mode 100644 buildcraft_resources/assets/buildcraft/textures/items/gate_gold_or.png delete mode 100644 buildcraft_resources/assets/buildcraft/textures/items/gate_iron_or.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/gates/gate_expansion_clock.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/gates/gate_expansion_pulsar.png rename buildcraft_resources/assets/buildcraft/textures/items/{gate.png => gates/gate_logic_and.png} (100%) create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/gates/gate_logic_or.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/gates/gate_material_diamond.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/gates/gate_material_gold.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/gates/gate_material_iron.png rename common/buildcraft/energy/{ => triggers}/TriggerEngineHeat.java (86%) delete mode 100644 common/buildcraft/transport/GateVanilla.java delete mode 100644 common/buildcraft/transport/IPipeRenderState.java delete mode 100644 common/buildcraft/transport/ItemGate.java create mode 100644 common/buildcraft/transport/gates/GateDefinition.java create mode 100644 common/buildcraft/transport/gates/GateExpansionController.java create mode 100644 common/buildcraft/transport/gates/GateExpansionPulsar.java create mode 100644 common/buildcraft/transport/gates/GateExpansions.java create mode 100644 common/buildcraft/transport/gates/GateFactory.java create mode 100644 common/buildcraft/transport/gates/IGateExpansion.java create mode 100644 common/buildcraft/transport/gates/ItemGate.java diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gate_iron_or_dark.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gate_iron_or_dark.png deleted file mode 100644 index d12e5d653deb1dbbe9c2d56bb289e8956ff36316..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!S%6Q7>;M1%?E`%z7#O^O0t^gR z3=EkJ3{?yaVhjv+3=FzJ#S9GE3=A0z4Dk#Mehdtz3=Gx`3?-_;p&)}iT^vIsE+;1} zkW6S14w%%~IdS4gb7m0Wc4=Up&A?p7$m5*J#9%MNq@-{6?<`OcgQu&X%Q~loCIGe~ BAA|q^ diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gate_iron_or_lit.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gate_iron_or_lit.png deleted file mode 100644 index d71ab7b89e0b0566d6e1fe6c532859fb5adcfd62..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 137 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFv4DbnY{r~^JeW1@z28K@z3{M#t z{xdM#Vqnq|Kvf=|E{-7<{%=ojuLMeZ~Zo=@s;^~ z6*u|cWr?x5wQe_%ofC4#^TNdoo74{;^Ey9;<$SGxOU%OPi?M+p_b&vR$>8bg=d#Wz Gp$P!QNkfAG literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gate_lit.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_lit_and.png similarity index 100% rename from buildcraft_resources/assets/buildcraft/textures/blocks/gate_lit.png rename to buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_lit_and.png diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_lit_or.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_lit_or.png new file mode 100644 index 0000000000000000000000000000000000000000..c9c3ac1dbcaf81198c83901749130b8d4fb7387c GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKsLIaM z#WBRfKlz8hlEhU8MteyKJ3|AT)Px`WE)op0d3kuYOGs=pHn^h}$1ISmc#>_w-j{|IeVd@{U}>jT^UsCNX%r`njxgN@xNA&;m5{ literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_material_diamond.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_material_diamond.png new file mode 100644 index 0000000000000000000000000000000000000000..cf070f6c3a68ca585f5473e8b1d0c60d8be0c4b1 GIT binary patch literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKsLI~c z#WBRf|Luj1oD2#K%#QBGrR;^%R&3?}bt6iqQ9pQ+&B2TW69Xv;-kz;rEuU}8Id}-d g|KG`XtXh+K+owPC+cPWI1C3(vboFyt=akR{0CIRbUH||9 literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_material_gold.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_material_gold.png new file mode 100644 index 0000000000000000000000000000000000000000..c26d18544a56bbf6c045b7868671b10b58377c96 GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKsLH|9 z#WBRf|Luj1oD2#K%#PxP|0QG2s%5=xw%aD={^0Z!6@LRM3EmzyH|FI0(sMg?qc=eK h$Lbd~e~dfD;PvlM`hUIK^+2;2JYD@<);T3K0RV9(Ig9`R literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_material_iron.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_material_iron.png new file mode 100644 index 0000000000000000000000000000000000000000..69f899948dbcd4d1573fc5af9aded3e4250c2711 GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKsLIaM z#WBRf|Lp}sE(QgL!w&!d3p?JAC^cJf@ajX2lpN1bEQ=d29>_>AF}QZ`*__*(Sh*qm fKk8Nz@0ar2GyJQ6;PGi)ph*m#u6{1-oD!M)D@H6r-IaB z2IG(MqDU`R%^~<<8-fskKCprtHlY(%L4q|%z%Y!$1ejnPdO-)%&;b!}KtG6yU65f5 zmLUdH5CZXK9#Sv>VQ|6sD`HI}5cbs3vGQPKQSQ?I|i{r$12+OpVE~Rh&HK3ogZLnO9M2 z(&x;^?yM(W{T944=skguGL>H_w#T2Nm&u3lqTG;~L+LZq BQhERY diff --git a/buildcraft_resources/assets/buildcraft/textures/items/gate_diamond_or.png b/buildcraft_resources/assets/buildcraft/textures/items/gate_diamond_or.png deleted file mode 100644 index ca11adeb3f3541c06afa775fbcfa479c65dbd0a2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 340 zcmWlTPbhDLFVQ7qxPjpQpahr*Azy-*4J0JG7cw4WM;7B}K6EUnRw28(J!c1rEF( zzddM;yhaLQFwgCRA2wkM#-JNIzyoX04$B}x2%_KsH~63dhM)^-VH8X-3pTKTh)9AA z8?XrTFaiM(U8Z3hdSM3aumomsf)P$&P@KJ7e2RueD~c@Mg!djgg$ueQn_u^wP+QCT z0@aC+UnSnGxNGu-$iRdroL1Vl)Z2aMWB$!_v}1{V$8tIwr(>b$xc*R0<{Qg3RhQZL zji!|2RrB@PyOQx4qUq@5-OraUqui$!vJTZ~P4%1?)^o+>a(&&Cs&5jpxa_iY)gOrc E0aDgl2mk;8 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/gate_gold_or.png b/buildcraft_resources/assets/buildcraft/textures/items/gate_gold_or.png deleted file mode 100644 index 24ea397665449269c801f5a3d7dbf5b7b0a692b5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 340 zcmWlT&nts*0LDLYVJ4KrtSKqk#DSU6m}#>g)@yr>A!>3nqG(F8S^HsJl%^C~i3>TH zi+17W!kd(nl0QJXsKsHvo_e0A=kh#H+ABFKRazBL>2lg+;nn{vD;275s~Qz{;Pv?J zAxq>nQWW^Pt=|JbY{4`HpclHp1MAQU%V2{Qh=K#$;DaU@fgaGpI2d6LtY8K)kpu}g zVG-tG41yrO%)k!x!z|cg2~6Mw1DwDxWG(`toRU>p5;fud$8M2AE}PY_c}Xbk6$8QA z#K*53Z#16B|4!yRFZ{ewW{Va7r#-J zbG&A{K6{t5K7BMDox1=2)MVv{)I!do7%Zv2^WsLnR4p|&JS(~uF^kJC*{%kIu|GAv BT4MkJ diff --git a/buildcraft_resources/assets/buildcraft/textures/items/gate_iron_or.png b/buildcraft_resources/assets/buildcraft/textures/items/gate_iron_or.png deleted file mode 100644 index a90217d72f1b36838a74c825acd7db8cfc9bca89..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 340 zcmWlT&nts*0LDL2Vzy8Yvv!b@O&pjBjhQz4VZFB37@{V*7*W%dWV80exF}Hyt;9(V z=C%tr7v7|tl>7n8MNJO#_0;n`J(uTsvOdYFQR!5G#_h7p!fXFoSuWJjUNa`_$mb0> z!q(VptR!Idd-ov#+b{z`=!0(X!UlA~D%c?cad3hM{Ll=e&8qk1q@ zpZfTflWnr6p;(FyPkEzRxpPOkJ9Ir2-%KZamc&=0ptW%xjKnAP$4a``qE^*i<&(Fn zDo)qUHy7`6&ToikVMHDDemF C%~=!x diff --git a/buildcraft_resources/assets/buildcraft/textures/items/gates/gate_expansion_clock.png b/buildcraft_resources/assets/buildcraft/textures/items/gates/gate_expansion_clock.png new file mode 100644 index 0000000000000000000000000000000000000000..874a3b620465913aab5ab3112eebc6f6d7c2626a GIT binary patch literal 214 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKs4B?Q z#WBRfKl#MA^~*V$JF~z3KY6Tx`QLwa-p8g74$k%d? literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/gates/gate_expansion_pulsar.png b/buildcraft_resources/assets/buildcraft/textures/items/gates/gate_expansion_pulsar.png new file mode 100644 index 0000000000000000000000000000000000000000..a9983ebc5283293cf202bdae53e1a154d724621d GIT binary patch literal 222 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0gN_s>q|Kvlk;E{-7<{>dk{tzXX3+?oCL|H)$o%>VwY^9rXP2sXa=U!g~j?~sdR z13!NdbHPt>$-`GJ9AgOjAYjPwBtGV$(-g)Z25pQ_lDK$(oM&KIzPiIpb=3kBpur5D Lu6{1-oD!Mq|Kvjo5T^vI!{I^~>%f*-|a_r-Gt2er9YDGFl1eNYfcfIkLGPgA`Iq@l1 z%(UB;fBT=^m@C!1yl%7A=QA@OUwisMd;M|c4;%M#|7rgjfAFlO{SnDvp8yBG+>A3# z%+8W;0*=b5U%A+FOy`B+6c_Uv$9+1VJRFk6dL+G)JGr_f9K4ir3lcrJp4@-RCo8k@ zAeYqUgd-PZYR@c)jtOi!rZb`Y^s1s})~p*!-E1aljcYW;{af|#D!%p(bP0l+XkKeN=ub literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/gates/gate_material_diamond.png b/buildcraft_resources/assets/buildcraft/textures/items/gates/gate_material_diamond.png new file mode 100644 index 0000000000000000000000000000000000000000..04ceae02c38b99c6d7ecb0aa82e6a2ca94c7e002 GIT binary patch literal 204 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0gN_s>q|KvmYBE{-7<{>dk{tzXX3+?oCL|H)$o%>VwY^Cp`fc=#Yzp>?H%q|KvmYBE{-7<{>dk{tzXX3+?oCL|H)$o%>VwY^Cp`80y#N3J literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/gates/gate_material_iron.png b/buildcraft_resources/assets/buildcraft/textures/items/gates/gate_material_iron.png new file mode 100644 index 0000000000000000000000000000000000000000..61b4633817332eb0dcae7525f8d06f7a8066fad0 GIT binary patch literal 204 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0gN_s>q|KvmYBE{-7<{>dk{tzXX3+?oCL|H)$o%>VwY^Cp`nJiTS=z!hw0)VA_q s7K3KRm4=7e2M(yI6dAU%{YhtFNapP4TB*M{7-$TGr>mdKI;Vst0Er1cc>n+a literal 0 HcmV?d00001 diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties index e5cbceb6..0ec7fdc4 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -30,17 +30,28 @@ fillerpattern.box=Box fluid.oil=Oil fluid.fuel=Fuel -gate.pipe.empty=Pipe Empty -gate.pipe.containsItems=Items Traversing -gate.pipe.containsFluids=Fluid Traversing -gate.pipe.containsEnergy=Power Traversing -gate.pipe.requestsEnergy=Power Requested -gate.pipe.tooMuchEnergy=Power Overloaded -gate.engine.blue=Engine Blue -gate.engine.green=Engine Green -gate.engine.yellow=Engine Yellow -gate.engine.red=Engine Red -gate.pipe.item.color=Paint Items %s +gate.action.pipe.item.color=Paint Items %s + +gate.logic.and=AND +gate.logic.or=OR + +gate.material.iron=Iron +gate.material.gold=Gold +gate.material.diamond=Diamond + +gate.name=%s %s Gate +gate.name.basic=Gate + +gate.trigger.pipe.empty=Pipe Empty +gate.trigger.pipe.containsItems=Items Traversing +gate.trigger.pipe.containsFluids=Fluid Traversing +gate.trigger.pipe.containsEnergy=Power Traversing +gate.trigger.pipe.requestsEnergy=Power Requested +gate.trigger.pipe.tooMuchEnergy=Power Overloaded +gate.trigger.engine.blue=Engine Blue +gate.trigger.engine.green=Engine Green +gate.trigger.engine.yellow=Engine Yellow +gate.trigger.engine.red=Engine Red gui.building.resources=Building Resources gui.del=Del diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 0e6b9036..3ad675a6 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -29,7 +29,7 @@ import buildcraft.energy.ItemBucketBuildcraft; import buildcraft.energy.ItemEngine; import buildcraft.energy.BucketHandler; import buildcraft.energy.TileEngine.EnergyStage; -import buildcraft.energy.TriggerEngineHeat; +import buildcraft.energy.triggers.TriggerEngineHeat; import buildcraft.energy.worldgen.BiomeGenOilDesert; import buildcraft.energy.worldgen.BiomeGenOilOcean; import buildcraft.energy.worldgen.BiomeInitializer; diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index 0131f3a9..710ed384 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -146,28 +146,28 @@ public class BuildCraftSilicon { new ItemStack(BuildCraftTransport.pipeGate, 1, 8)}); // Iron - Autarchic - CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 2), new Object[]{new ItemStack(redstoneChipset, 1, 0), - new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 1)}); - CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 1), new Object[]{new ItemStack(redstoneChipset, 1, 0), - new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 2)}); - - // Gold - Autarchic - CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 4), new Object[]{new ItemStack(redstoneChipset, 1, 0), - new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 3)}); - CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 3), new Object[]{new ItemStack(redstoneChipset, 1, 0), - new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 4)}); - - // Diamond - Autarchic - CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 6), new Object[]{new ItemStack(redstoneChipset, 1, 0), - new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 5)}); - CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 5), new Object[]{new ItemStack(redstoneChipset, 1, 0), - new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 6)}); - - // Quartz - Autarchic - CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 8), new Object[]{new ItemStack(redstoneChipset, 1, 0), - new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 7)}); - CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 7), new Object[]{new ItemStack(redstoneChipset, 1, 0), - new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 8)}); +// CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 2), new Object[]{new ItemStack(redstoneChipset, 1, 0), +// new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 1)}); +// CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 1), new Object[]{new ItemStack(redstoneChipset, 1, 0), +// new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 2)}); +// +// // Gold - Autarchic +// CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 4), new Object[]{new ItemStack(redstoneChipset, 1, 0), +// new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 3)}); +// CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 3), new Object[]{new ItemStack(redstoneChipset, 1, 0), +// new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 4)}); +// +// // Diamond - Autarchic +// CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 6), new Object[]{new ItemStack(redstoneChipset, 1, 0), +// new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 5)}); +// CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 5), new Object[]{new ItemStack(redstoneChipset, 1, 0), +// new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 6)}); +// +// // Quartz - Autarchic +// CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 8), new Object[]{new ItemStack(redstoneChipset, 1, 0), +// new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 7)}); +// CoreProxy.proxy.addShapelessRecipe(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 7), new Object[]{new ItemStack(redstoneChipset, 1, 0), +// new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 8)}); // / REDSTONE CHIPSETS CoreProxy.proxy.addName(new ItemStack(redstoneChipset, 1, 0), "Redstone Chipset"); @@ -192,13 +192,13 @@ public class BuildCraftSilicon { CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 2), "Iron OR Gate"); CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 4), "Gold OR Gate"); CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGate, 1, 6), "Diamond OR Gate"); - CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 0), "Autarchic Gate"); - CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 1), "Autarchic Iron AND Gate"); - CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 3), "Autarchic Gold AND Gate"); - CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 5), "Autarchic Diamond AND Gate"); - CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 2), "Autarchic Iron OR Gate"); - CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 4), "Autarchic Gold OR Gate"); - CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 6), "Autarchic Diamond OR Gate"); +// CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 0), "Autarchic Gate"); +// CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 1), "Autarchic Iron AND Gate"); +// CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 3), "Autarchic Gold AND Gate"); +// CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 5), "Autarchic Diamond AND Gate"); +// CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 2), "Autarchic Iron OR Gate"); +// CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 4), "Autarchic Gold OR Gate"); +// CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 6), "Autarchic Diamond OR Gate"); // BuildcraftRecipes.assemblyTable.addRecipe(new ItemStack(BuildCraftTransport.pipeGate, 1, 0), 20000, new ItemStack(redstoneChipset, 1, 0)); diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index aa063e2e..6ec1bac7 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -8,10 +8,8 @@ package buildcraft; import buildcraft.api.core.IIconProvider; -import buildcraft.api.filler.IFillerPattern; import buildcraft.api.gates.ActionManager; import buildcraft.api.recipes.BuildcraftRecipes; -import buildcraft.core.recipes.AssemblyRecipeManager; import buildcraft.api.transport.IExtractionHandler; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.PipeManager; @@ -29,7 +27,7 @@ import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.GateIconProvider; import buildcraft.transport.GuiHandler; import buildcraft.transport.ItemFacade; -import buildcraft.transport.ItemGate; +import buildcraft.transport.gates.ItemGate; import buildcraft.transport.ItemPipe; import buildcraft.transport.ItemPlug; import buildcraft.transport.Pipe; @@ -42,6 +40,8 @@ import buildcraft.transport.blueprints.BptItemPipeDiamond; import buildcraft.transport.blueprints.BptItemPipeEmerald; import buildcraft.transport.blueprints.BptItemPipeIron; import buildcraft.transport.blueprints.BptItemPipeWooden; +import buildcraft.transport.gates.GateExpansionPulsar; +import buildcraft.transport.gates.GateExpansions; import buildcraft.transport.network.PacketHandlerTransport; import buildcraft.transport.pipes.PipeFluidsCobblestone; import buildcraft.transport.pipes.PipeFluidsEmerald; @@ -114,7 +114,6 @@ public class BuildCraftTransport { public static float pipeDurability; public static Item pipeWaterproof; public static Item pipeGate; - public static Item pipeGateAutarchic; public static Item redPipeWire; public static Item bluePipeWire; public static Item greenPipeWire; @@ -267,6 +266,8 @@ public class BuildCraftTransport { PipeManager.registerExtractionHandler(new ExtractionHandler(excludedItemBlocks, excludedFluidBlocks)); + GateExpansions.registerExpansion(GateExpansionPulsar.INSTANCE); + Property groupItemsTriggerProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "pipes.groupItemsTrigger", 32); groupItemsTriggerProp.comment = "when reaching this amount of objects in a pipes, items will be automatically grouped"; groupItemsTrigger = groupItemsTriggerProp.getInt(); @@ -347,16 +348,10 @@ public class BuildCraftTransport { CoreProxy.proxy.registerItem(yellowPipeWire); Property pipeGateId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeGate.id", DefaultProps.GATE_ID); - pipeGate = new ItemGate(pipeGateId.getInt(), 0); + pipeGate = new ItemGate(pipeGateId.getInt()); pipeGate.setUnlocalizedName("pipeGate"); CoreProxy.proxy.registerItem(pipeGate); - Property pipeGateAutarchicId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeGateAutarchic.id", - DefaultProps.GATE_AUTARCHIC_ID); - pipeGateAutarchic = new ItemGate(pipeGateAutarchicId.getInt(), 1); - pipeGateAutarchic.setUnlocalizedName("pipeGateAutarchic"); - CoreProxy.proxy.registerItem(pipeGateAutarchic); - Property pipeFacadeId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeFacade.id", DefaultProps.PIPE_FACADE_ID); facadeItem = new ItemFacade(pipeFacadeId.getInt()); facadeItem.setUnlocalizedName("pipeFacade"); diff --git a/common/buildcraft/builders/TileBlueprintLibrary.java b/common/buildcraft/builders/TileBlueprintLibrary.java index d5b87120..01af4e23 100644 --- a/common/buildcraft/builders/TileBlueprintLibrary.java +++ b/common/buildcraft/builders/TileBlueprintLibrary.java @@ -4,6 +4,7 @@ import buildcraft.BuildCraftBuilders; import buildcraft.core.TileBuildCraft; import buildcraft.core.blueprints.BptBase; import buildcraft.core.blueprints.BptPlayerIndex; +import buildcraft.core.inventory.InvUtils; import buildcraft.core.network.TileNetworkData; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; @@ -150,7 +151,7 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory { owner = nbttagcompound.getString("owner"); locked = nbttagcompound.getBoolean("locked"); - Utils.readStacksFromNBT(nbttagcompound, "stack", stack); + InvUtils.readStacksFromNBT(nbttagcompound, "stack", stack); } @Override @@ -160,7 +161,7 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory { nbttagcompound.setString("owner", owner); nbttagcompound.setBoolean("locked", locked); - Utils.writeStacksToNBT(nbttagcompound, "stack", stack); + InvUtils.writeStacksToNBT(nbttagcompound, "stack", stack); } @Override diff --git a/common/buildcraft/builders/TileBuilder.java b/common/buildcraft/builders/TileBuilder.java index fc2b84e1..2774ff84 100644 --- a/common/buildcraft/builders/TileBuilder.java +++ b/common/buildcraft/builders/TileBuilder.java @@ -29,6 +29,7 @@ import buildcraft.core.blueprints.BptBuilderBase; import buildcraft.core.blueprints.BptBuilderBlueprint; import buildcraft.core.blueprints.BptBuilderTemplate; import buildcraft.core.blueprints.BptContext; +import buildcraft.core.inventory.InvUtils; import buildcraft.core.network.PacketUpdate; import buildcraft.core.network.TileNetworkData; import buildcraft.core.proxy.CoreProxy; @@ -447,7 +448,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - Utils.readStacksFromNBT(nbttagcompound, "Items", items); + InvUtils.readStacksFromNBT(nbttagcompound, "Items", items); if (nbttagcompound.hasKey("box")) { box.initialize(nbttagcompound.getCompoundTag("box")); @@ -470,7 +471,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); - Utils.writeStacksToNBT(nbttagcompound, "Items", items); + InvUtils.writeStacksToNBT(nbttagcompound, "Items", items); if (box.isInitialized()) { NBTTagCompound boxStore = new NBTTagCompound(); diff --git a/common/buildcraft/core/fluids/FluidUtils.java b/common/buildcraft/core/fluids/FluidUtils.java index 143a95d8..2e0a535e 100644 --- a/common/buildcraft/core/fluids/FluidUtils.java +++ b/common/buildcraft/core/fluids/FluidUtils.java @@ -1,6 +1,7 @@ package buildcraft.core.fluids; import buildcraft.core.TileBuffer; +import buildcraft.core.inventory.InvUtils; import buildcraft.core.utils.Utils; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; @@ -34,7 +35,7 @@ public class FluidUtils { if (used > 0) { if (!player.capabilities.isCreativeMode) { - player.inventory.setInventorySlotContents(player.inventory.currentItem, Utils.consumeItem(current)); + player.inventory.setInventorySlotContents(player.inventory.currentItem, InvUtils.consumeItem(current)); } return true; } @@ -52,10 +53,10 @@ public class FluidUtils { if (!player.inventory.addItemStackToInventory(filled)) { return false; } else { - player.inventory.setInventorySlotContents(player.inventory.currentItem, Utils.consumeItem(current)); + player.inventory.setInventorySlotContents(player.inventory.currentItem, InvUtils.consumeItem(current)); } } else { - player.inventory.setInventorySlotContents(player.inventory.currentItem, Utils.consumeItem(current)); + player.inventory.setInventorySlotContents(player.inventory.currentItem, InvUtils.consumeItem(current)); player.inventory.setInventorySlotContents(player.inventory.currentItem, filled); } diff --git a/common/buildcraft/core/inventory/InvUtils.java b/common/buildcraft/core/inventory/InvUtils.java index 1942983d..6780c5bd 100644 --- a/common/buildcraft/core/inventory/InvUtils.java +++ b/common/buildcraft/core/inventory/InvUtils.java @@ -6,6 +6,9 @@ import buildcraft.core.inventory.filters.IStackFilter; import net.minecraft.entity.item.EntityItem; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; @@ -116,4 +119,91 @@ public class InvUtils { inv.setInventorySlotContents(slot, null); } } + + public static NBTTagCompound getItemData(ItemStack stack) { + NBTTagCompound nbt = stack.getTagCompound(); + if (nbt == null) { + nbt = new NBTTagCompound("tag"); + stack.setTagCompound(nbt); + } + return nbt; + } + + public static void addItemToolTip(ItemStack stack, String tag, String msg) { + NBTTagCompound nbt = getItemData(stack); + NBTTagCompound display = nbt.getCompoundTag("display"); + nbt.setCompoundTag("display", display); + NBTTagList lore = display.getTagList("Lore"); + display.setTag("Lore", lore); + lore.appendTag(new NBTTagString(tag, msg)); + } + + public static void writeInvToNBT(IInventory inv, String tag, NBTTagCompound data) { + NBTTagList list = new NBTTagList(); + for (byte slot = 0; slot < inv.getSizeInventory(); slot++) { + ItemStack stack = inv.getStackInSlot(slot); + if (stack != null) { + NBTTagCompound itemTag = new NBTTagCompound(); + itemTag.setByte("Slot", slot); + stack.writeToNBT(itemTag); + list.appendTag(itemTag); + } + } + data.setTag(tag, list); + } + + public static void readInvFromNBT(IInventory inv, String tag, NBTTagCompound data) { + NBTTagList list = data.getTagList(tag); + for (byte entry = 0; entry < list.tagCount(); entry++) { + NBTTagCompound itemTag = (NBTTagCompound) list.tagAt(entry); + int slot = itemTag.getByte("Slot"); + if (slot >= 0 && slot < inv.getSizeInventory()) { + ItemStack stack = ItemStack.loadItemStackFromNBT(itemTag); + inv.setInventorySlotContents(slot, stack); + } + } + } + + public static void readStacksFromNBT(NBTTagCompound nbt, String name, ItemStack[] stacks) { + NBTTagList nbttaglist = nbt.getTagList(name); + + for (int i = 0; i < stacks.length; ++i) { + if (i < nbttaglist.tagCount()) { + NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist.tagAt(i); + + stacks[i] = ItemStack.loadItemStackFromNBT(nbttagcompound2); + } else { + stacks[i] = null; + } + } + } + + public static void writeStacksToNBT(NBTTagCompound nbt, String name, ItemStack[] stacks) { + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < stacks.length; ++i) { + NBTTagCompound cpt = new NBTTagCompound(); + nbttaglist.appendTag(cpt); + if (stacks[i] != null) { + stacks[i].writeToNBT(cpt); + } + + } + + nbt.setTag(name, nbttaglist); + } + + public static ItemStack consumeItem(ItemStack stack) { + if (stack.stackSize == 1) { + if (stack.getItem().hasContainerItem()) { + return stack.getItem().getContainerItemStack(stack); + } else { + return null; + } + } else { + stack.splitStack(1); + + return stack; + } + } } diff --git a/common/buildcraft/core/utils/Utils.java b/common/buildcraft/core/utils/Utils.java index 435170de..f83bedbb 100644 --- a/common/buildcraft/core/utils/Utils.java +++ b/common/buildcraft/core/utils/Utils.java @@ -388,93 +388,6 @@ public class Utils { } - public static NBTTagCompound getItemData(ItemStack stack) { - NBTTagCompound nbt = stack.getTagCompound(); - if (nbt == null) { - nbt = new NBTTagCompound("tag"); - stack.setTagCompound(nbt); - } - return nbt; - } - - public static void addItemToolTip(ItemStack stack, String tag, String msg) { - NBTTagCompound nbt = getItemData(stack); - NBTTagCompound display = nbt.getCompoundTag("display"); - nbt.setCompoundTag("display", display); - NBTTagList lore = display.getTagList("Lore"); - display.setTag("Lore", lore); - lore.appendTag(new NBTTagString(tag, msg)); - } - - public static void writeInvToNBT(IInventory inv, String tag, NBTTagCompound data) { - NBTTagList list = new NBTTagList(); - for (byte slot = 0; slot < inv.getSizeInventory(); slot++) { - ItemStack stack = inv.getStackInSlot(slot); - if (stack != null) { - NBTTagCompound itemTag = new NBTTagCompound(); - itemTag.setByte("Slot", slot); - stack.writeToNBT(itemTag); - list.appendTag(itemTag); - } - } - data.setTag(tag, list); - } - - public static void readInvFromNBT(IInventory inv, String tag, NBTTagCompound data) { - NBTTagList list = data.getTagList(tag); - for (byte entry = 0; entry < list.tagCount(); entry++) { - NBTTagCompound itemTag = (NBTTagCompound) list.tagAt(entry); - int slot = itemTag.getByte("Slot"); - if (slot >= 0 && slot < inv.getSizeInventory()) { - ItemStack stack = ItemStack.loadItemStackFromNBT(itemTag); - inv.setInventorySlotContents(slot, stack); - } - } - } - - public static void readStacksFromNBT(NBTTagCompound nbt, String name, ItemStack[] stacks) { - NBTTagList nbttaglist = nbt.getTagList(name); - - for (int i = 0; i < stacks.length; ++i) { - if (i < nbttaglist.tagCount()) { - NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist.tagAt(i); - - stacks[i] = ItemStack.loadItemStackFromNBT(nbttagcompound2); - } else { - stacks[i] = null; - } - } - } - - public static void writeStacksToNBT(NBTTagCompound nbt, String name, ItemStack[] stacks) { - NBTTagList nbttaglist = new NBTTagList(); - - for (int i = 0; i < stacks.length; ++i) { - NBTTagCompound cpt = new NBTTagCompound(); - nbttaglist.appendTag(cpt); - if (stacks[i] != null) { - stacks[i].writeToNBT(cpt); - } - - } - - nbt.setTag(name, nbttaglist); - } - - public static ItemStack consumeItem(ItemStack stack) { - if (stack.stackSize == 1) { - if (stack.getItem().hasContainerItem()) { - return stack.getItem().getContainerItemStack(stack); - } else { - return null; - } - } else { - stack.splitStack(1); - - return stack; - } - } - public static T[] concat(T[] first, T[] second) { T[] result = Arrays.copyOf(first, first.length + second.length); System.arraycopy(second, 0, result, first.length, second.length); diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index fd05b1d6..276792d4 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -33,6 +33,7 @@ import buildcraft.core.IItemPipe; import buildcraft.core.fluids.FluidUtils; import buildcraft.core.fluids.Tank; import buildcraft.core.fluids.TankManager; +import buildcraft.core.inventory.InvUtils; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; import buildcraft.energy.gui.ContainerEngine; @@ -192,7 +193,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan if (liquid != null) { if (fill(ForgeDirection.UNKNOWN, liquid, false) == liquid.amount) { fill(ForgeDirection.UNKNOWN, liquid, true); - setInventorySlotContents(0, Utils.consumeItem(stack)); + setInventorySlotContents(0, InvUtils.consumeItem(stack)); } } } diff --git a/common/buildcraft/energy/TileEngineStone.java b/common/buildcraft/energy/TileEngineStone.java index 6f385d79..38ef563e 100644 --- a/common/buildcraft/energy/TileEngineStone.java +++ b/common/buildcraft/energy/TileEngineStone.java @@ -20,6 +20,7 @@ import buildcraft.BuildCraftCore; import buildcraft.BuildCraftEnergy; import buildcraft.api.gates.ITrigger; import buildcraft.core.GuiIds; +import buildcraft.core.inventory.InvUtils; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; import buildcraft.energy.gui.ContainerEngine; @@ -77,7 +78,7 @@ public class TileEngineStone extends TileEngineWithInventory { burnTime = totalBurnTime = getItemBurnTime(getStackInSlot(0)); if (burnTime > 0) { - setInventorySlotContents(0, Utils.consumeItem(getStackInSlot(0))); + setInventorySlotContents(0, InvUtils.consumeItem(getStackInSlot(0))); } } } diff --git a/common/buildcraft/energy/TriggerEngineHeat.java b/common/buildcraft/energy/triggers/TriggerEngineHeat.java similarity index 86% rename from common/buildcraft/energy/TriggerEngineHeat.java rename to common/buildcraft/energy/triggers/TriggerEngineHeat.java index 470c2930..4f527de3 100644 --- a/common/buildcraft/energy/TriggerEngineHeat.java +++ b/common/buildcraft/energy/triggers/TriggerEngineHeat.java @@ -5,11 +5,12 @@ * 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.energy; +package buildcraft.energy.triggers; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.triggers.BCTrigger; import buildcraft.core.utils.StringUtils; +import buildcraft.energy.TileEngine; import buildcraft.energy.TileEngine.EnergyStage; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -34,13 +35,13 @@ public class TriggerEngineHeat extends BCTrigger { public String getDescription() { switch (stage) { case BLUE: - return StringUtils.localize("gate.engine.blue"); + return StringUtils.localize("gate.trigger.engine.blue"); case GREEN: - return StringUtils.localize("gate.engine.green"); + return StringUtils.localize("gate.trigger.engine.green"); case YELLOW: - return StringUtils.localize("gate.engine.yellow"); + return StringUtils.localize("gate.trigger.engine.yellow"); default: - return StringUtils.localize("gate.engine.red"); + return StringUtils.localize("gate.trigger.engine.red"); } } diff --git a/common/buildcraft/factory/BlockTank.java b/common/buildcraft/factory/BlockTank.java index 75bbc95c..265e102a 100644 --- a/common/buildcraft/factory/BlockTank.java +++ b/common/buildcraft/factory/BlockTank.java @@ -9,6 +9,7 @@ package buildcraft.factory; import buildcraft.BuildCraftCore; import buildcraft.core.CreativeTabBuildCraft; +import buildcraft.core.inventory.InvUtils; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -101,7 +102,7 @@ public class BlockTank extends BlockContainer { int qty = tank.fill(ForgeDirection.UNKNOWN, liquid, true); if (qty != 0 && !BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) { - entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, Utils.consumeItem(current)); + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current)); } return true; @@ -121,10 +122,10 @@ public class BlockTank extends BlockContainer { if (!entityplayer.inventory.addItemStackToInventory(filled)) return false; else { - entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, Utils.consumeItem(current)); + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current)); } } else { - entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, Utils.consumeItem(current)); + entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current)); entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, filled); } } diff --git a/common/buildcraft/factory/TileAutoWorkbench.java b/common/buildcraft/factory/TileAutoWorkbench.java index adadee9f..2dfc0171 100644 --- a/common/buildcraft/factory/TileAutoWorkbench.java +++ b/common/buildcraft/factory/TileAutoWorkbench.java @@ -127,12 +127,12 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory public void readFromNBT(NBTTagCompound data) { super.readFromNBT(data); resultInv.readFromNBT(data); - Utils.readInvFromNBT(craftMatrix, "matrix", data); + InvUtils.readInvFromNBT(craftMatrix, "matrix", data); // Legacy Code if (data.hasKey("stackList")) { ItemStack[] stacks = new ItemStack[9]; - Utils.readStacksFromNBT(data, "stackList", stacks); + InvUtils.readStacksFromNBT(data, "stackList", stacks); for (int i = 0; i < 9; i++) { craftMatrix.setInventorySlotContents(i, stacks[i]); } @@ -143,7 +143,7 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory public void writeToNBT(NBTTagCompound data) { super.writeToNBT(data); resultInv.writeToNBT(data); - Utils.writeInvToNBT(craftMatrix, "matrix", data); + InvUtils.writeInvToNBT(craftMatrix, "matrix", data); } public ItemStack findRecipeOutput() { diff --git a/common/buildcraft/factory/gui/ContainerAutoWorkbench.java b/common/buildcraft/factory/gui/ContainerAutoWorkbench.java index 11804d59..27c407e3 100644 --- a/common/buildcraft/factory/gui/ContainerAutoWorkbench.java +++ b/common/buildcraft/factory/gui/ContainerAutoWorkbench.java @@ -11,6 +11,7 @@ import buildcraft.core.gui.BuildCraftContainer; import buildcraft.core.gui.slots.SlotOutput; import buildcraft.core.gui.slots.SlotUntouchable; import buildcraft.core.gui.slots.SlotWorkbench; +import buildcraft.core.inventory.InvUtils; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.Utils; @@ -39,7 +40,7 @@ public class ContainerAutoWorkbench extends BuildCraftContainer { public void setInventorySlotContents(int slot, ItemStack stack) { super.setInventorySlotContents(slot, stack); if (stack != null && tile.isLast() && CoreProxy.proxy.isRenderWorld(tile.worldObj)) { - Utils.addItemToolTip(stack, "tip", EnumChatFormatting.YELLOW + StringUtils.localize("gui.clickcraft")); + InvUtils.addItemToolTip(stack, "tip", EnumChatFormatting.YELLOW + StringUtils.localize("gui.clickcraft")); } } }; diff --git a/common/buildcraft/silicon/TileAssemblyTable.java b/common/buildcraft/silicon/TileAssemblyTable.java index 3c40745e..bf139edb 100644 --- a/common/buildcraft/silicon/TileAssemblyTable.java +++ b/common/buildcraft/silicon/TileAssemblyTable.java @@ -5,6 +5,7 @@ import buildcraft.api.power.ILaserTarget; import buildcraft.api.gates.IAction; import buildcraft.core.DefaultProps; import buildcraft.core.IMachine; +import buildcraft.core.inventory.InvUtils; import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketNBT; import buildcraft.core.proxy.CoreProxy; @@ -190,7 +191,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - Utils.readStacksFromNBT(nbt, "items", items); + InvUtils.readStacksFromNBT(nbt, "items", items); energyStored = nbt.getFloat("energyStored"); @@ -225,7 +226,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - Utils.writeStacksToNBT(nbt, "items", items); + InvUtils.writeStacksToNBT(nbt, "items", items); nbt.setFloat("energyStored", energyStored); diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index cd056b73..242f2c3a 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -7,6 +7,7 @@ */ package buildcraft.transport; +import buildcraft.transport.gates.ItemGate; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -44,6 +45,8 @@ import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.BCLog; import buildcraft.core.utils.Utils; import buildcraft.core.utils.MatrixTranformations; +import buildcraft.transport.gates.GateDefinition; +import buildcraft.transport.gates.GateFactory; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -726,7 +729,7 @@ public class BlockGenericPipe extends BlockBuildCraft { private boolean addGate(EntityPlayer player, Pipe pipe) { if (!pipe.hasGate()) { - pipe.gate = Gate.makeGate(pipe, player.getCurrentEquippedItem()); + pipe.gate = GateFactory.makeGate(pipe, player.getCurrentEquippedItem()); if (!player.capabilities.isCreativeMode) { player.getCurrentEquippedItem().splitStack(1); } @@ -885,26 +888,12 @@ public class BlockGenericPipe extends BlockBuildCraft { @SideOnly(Side.CLIENT) @Override public Icon getBlockTexture(IBlockAccess iblockaccess, int x, int y, int z, int side) { - TileEntity tile = iblockaccess.getBlockTileEntity(x, y, z); - if (!(tile instanceof IPipeRenderState)) + if (!(tile instanceof TileGenericPipe)) return null; - if (((IPipeRenderState) tile).getRenderState().textureArray != null) - return ((IPipeRenderState) tile).getRenderState().textureArray[side]; - return ((IPipeRenderState) tile).getRenderState().currentTexture; - - // Pipe pipe = getPipe(iblockaccess, i, j, k); - // if (!isValid(pipe)) { - // CoreProxy.BindTexture(DefaultProps.TEXTURE_BLOCKS); - // return 0; - // } - // int pipeTexture = pipe.getPipeTexture(); - // if (pipeTexture > 255) { - // CoreProxy.BindTexture(DefaultProps.TEXTURE_EXTERNAL); - // return pipeTexture - 256; - // } - // CoreProxy.BindTexture(DefaultProps.TEXTURE_BLOCKS); - // return pipeTexture; + if (((TileGenericPipe) tile).renderState.textureArray != null) + return ((TileGenericPipe) tile).renderState.textureArray[side]; + return ((TileGenericPipe) tile).renderState.currentTexture; } @Override @@ -1052,6 +1041,14 @@ public class BlockGenericPipe extends BlockBuildCraft { dummyPipe.getIconProvider().registerIcons(iconRegister); } } + + for (GateDefinition.GateMaterial material : GateDefinition.GateMaterial.VALUES) { + material.registerBlockIcon(iconRegister); + } + + for (GateDefinition.GateLogic logic : GateDefinition.GateLogic.VALUES) { + logic.registerBlockIcon(iconRegister); + } } @Override diff --git a/common/buildcraft/transport/Gate.java b/common/buildcraft/transport/Gate.java index d94b26f2..63de3e46 100644 --- a/common/buildcraft/transport/Gate.java +++ b/common/buildcraft/transport/Gate.java @@ -7,60 +7,34 @@ import buildcraft.api.gates.IActionReceptor; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.TriggerParameter; -import buildcraft.core.network.PacketPayload; -import buildcraft.core.network.PacketPayloadArrays; +import buildcraft.api.transport.IPipe; +import buildcraft.core.GuiIds; +import buildcraft.core.proxy.CoreProxy; import buildcraft.core.triggers.ActionRedstoneOutput; +import buildcraft.transport.gates.GateDefinition.GateLogic; +import buildcraft.transport.gates.GateDefinition.GateMaterial; +import buildcraft.transport.gates.GateExpansionController; +import buildcraft.transport.gates.ItemGate; import buildcraft.transport.triggers.ActionSignalOutput; import com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; import java.util.HashMap; -import java.util.LinkedList; +import java.util.HashSet; +import java.util.List; import java.util.Map; +import java.util.Set; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ForgeDirection; -public abstract class Gate { +public final class Gate { - public static enum GateKind { - - None, Single, AND_2, OR_2, AND_3, OR_3, AND_4, OR_4, AND_5, OR_5; - - public static GateKind getKindFromDamage(ItemStack itemstack) { - switch (itemstack.getItemDamage()) { - case 0: - return Single; - case 1: - return AND_2; - case 2: - return OR_2; - case 3: - return AND_3; - case 4: - return OR_3; - case 5: - return AND_4; - case 6: - return OR_4; - case 7: - return AND_5; - case 8: - return OR_5; - default: - return None; - } - } - } - - public static enum GateConditional { - - None, AND, OR - } - protected Pipe pipe; - public GateKind kind; + public final Pipe pipe; + public final GateMaterial material; + public final GateLogic logic; + public final Set expansions = new HashSet(); public ITrigger[] triggers = new ITrigger[8]; public ITriggerParameter[] triggerParameters = new ITriggerParameter[8]; public IAction[] actions = new IAction[8]; @@ -68,14 +42,10 @@ public abstract class Gate { public boolean broadcastRedstone = false; // / CONSTRUCTOR - public Gate(Pipe pipe) { + public Gate(Pipe pipe, GateMaterial material, GateLogic logic) { this.pipe = pipe; - } - - public Gate(Pipe pipe, ItemStack stack) { - - this.pipe = pipe; - kind = GateKind.getKindFromDamage(stack); + this.material = material; + this.logic = logic; } public void setTrigger(int position, ITrigger trigger) { @@ -104,7 +74,8 @@ public abstract class Gate { // / SAVING & LOADING public void writeToNBT(NBTTagCompound data) { - data.setInteger("Kind", kind.ordinal()); + data.setString("material", material.name()); + data.setString("logic", logic.name()); for (int i = 0; i < 8; ++i) { if (triggers[i] != null) @@ -125,8 +96,6 @@ public abstract class Gate { } public void readFromNBT(NBTTagCompound data) { - kind = Gate.GateKind.values()[data.getInteger("Kind")]; - for (int i = 0; i < 8; ++i) { if (data.hasKey("trigger[" + i + "]")) triggers[i] = ActionManager.triggers.get(data.getString("trigger[" + i + "]")); @@ -144,20 +113,23 @@ public abstract class Gate { broadcastRedstone = data.getBoolean("redstoneState"); } - // / SMP - public PacketPayload toPayload() { - PacketPayloadArrays payload = new PacketPayloadArrays(1, 0, 0); - payload.intPayload[0] = kind.ordinal(); - return payload; + // GUI + public void openGui(EntityPlayer player) { + if (!CoreProxy.proxy.isRenderWorld(player.worldObj)) { + player.openGui(BuildCraftTransport.instance, GuiIds.GATES, pipe.container.worldObj, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); + } } - // GUI - public abstract void openGui(EntityPlayer player); - // / UPDATING - public abstract void update(); + public void tick() { + for (GateExpansionController expansion : expansions) { + expansion.tick(); + } + } - public abstract ItemStack getGateItem(); + public ItemStack getGateItem() { + return ItemGate.makeGateItem(this); + } public void dropGate() { pipe.dropItem(getGateItem()); @@ -170,11 +142,6 @@ public abstract class Gate { } } - // / INFORMATION - public abstract String getName(); - - public abstract GateConditional getConditional(); - public boolean isGateActive() { for (boolean b : broadcastSignal) { if (b) @@ -187,7 +154,11 @@ public abstract class Gate { return broadcastRedstone; } - public abstract void startResolution(); + public void startResolution() { + for (GateExpansionController expansion : expansions) { + expansion.startResolution(); + } + } public void resolveActions() { boolean oldBroadcastRedstone = broadcastRedstone; @@ -212,7 +183,7 @@ public abstract class Gate { actionCount.add(action); if (!activeActions.containsKey(action)) { activeActions.put(action, isNearbyTriggerActive(trigger, parameter)); - } else if (getConditional() == GateConditional.AND) { + } else if (logic == GateLogic.AND) { activeActions.put(action, activeActions.get(action) && isNearbyTriggerActive(trigger, parameter)); } else { activeActions.put(action, activeActions.get(action) || isNearbyTriggerActive(trigger, parameter)); @@ -262,7 +233,13 @@ public abstract class Gate { } } - public abstract boolean resolveAction(IAction action, int count); + public boolean resolveAction(IAction action, int count) { + for (GateExpansionController expansion : expansions) { + if (expansion.resolveAction(action, count)) + return true; + } + return false; + } public boolean isNearbyTriggerActive(ITrigger trigger, ITriggerParameter parameter) { if (trigger instanceof ITriggerPipe) @@ -282,31 +259,57 @@ public abstract class Gate { } // / TRIGGERS - public abstract void addTrigger(LinkedList list); + public void addTrigger(List list) { + + if (pipe.wireSet[IPipe.WireColor.Red.ordinal()] && material == GateMaterial.IRON) { + list.add(BuildCraftTransport.triggerRedSignalActive); + list.add(BuildCraftTransport.triggerRedSignalInactive); + } + + if (pipe.wireSet[IPipe.WireColor.Blue.ordinal()] && material == GateMaterial.IRON) { + list.add(BuildCraftTransport.triggerBlueSignalActive); + list.add(BuildCraftTransport.triggerBlueSignalInactive); + } + + if (pipe.wireSet[IPipe.WireColor.Green.ordinal()] && material == GateMaterial.GOLD) { + list.add(BuildCraftTransport.triggerGreenSignalActive); + list.add(BuildCraftTransport.triggerGreenSignalInactive); + } + + if (pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] && material == GateMaterial.DIAMOND) { + list.add(BuildCraftTransport.triggerYellowSignalActive); + list.add(BuildCraftTransport.triggerYellowSignalInactive); + } + + for (GateExpansionController expansion : expansions) { + expansion.addTriggers(list); + } + +// if (pipe.gate.kind == GateKind.AND_5 || pipe.gate.kind == GateKind.OR_5) { +// list.add(BuildCraftTransport.triggerTimerShort); +// list.add(BuildCraftTransport.triggerTimerMedium); +// list.add(BuildCraftTransport.triggerTimerLong); +// } + + } // / ACTIONS - public abstract void addActions(LinkedList list); + public void addActions(List list) { + if (pipe.wireSet[IPipe.WireColor.Red.ordinal()] && material == GateMaterial.IRON) + list.add(BuildCraftTransport.actionRedSignal); - // / TEXTURES - public abstract int getTextureIconIndex(boolean isSignalActive); + if (pipe.wireSet[IPipe.WireColor.Blue.ordinal()] && material == GateMaterial.IRON) + list.add(BuildCraftTransport.actionBlueSignal); - public abstract ResourceLocation getGuiFile(); + if (pipe.wireSet[IPipe.WireColor.Green.ordinal()] && material == GateMaterial.GOLD) + list.add(BuildCraftTransport.actionGreenSignal); - public int getGuiHeight() { - return 207; - } + if (pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] && material == GateMaterial.DIAMOND) + list.add(BuildCraftTransport.actionYellowSignal); - public static boolean isGateItem(ItemStack stack) { - return stack.itemID == BuildCraftTransport.pipeGate.itemID || stack.itemID == BuildCraftTransport.pipeGateAutarchic.itemID; - } - public static Gate makeGate(Pipe pipe, NBTTagCompound data) { - Gate gate = new GateVanilla(pipe); - gate.readFromNBT(data); - return gate; - } - - public static Gate makeGate(Pipe pipe, ItemStack stack) { - return new GateVanilla(pipe, stack); + for (GateExpansionController expansion : expansions) { + expansion.addActions(list); + } } } diff --git a/common/buildcraft/transport/GateVanilla.java b/common/buildcraft/transport/GateVanilla.java deleted file mode 100644 index 066530a3..00000000 --- a/common/buildcraft/transport/GateVanilla.java +++ /dev/null @@ -1,360 +0,0 @@ -package buildcraft.transport; - -import buildcraft.BuildCraftTransport; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.power.IPowerReceptor; -import buildcraft.api.transport.IPipe; -import buildcraft.core.DefaultProps; -import buildcraft.core.GuiIds; -import buildcraft.core.proxy.CoreProxy; -import buildcraft.core.utils.StringUtils; -import buildcraft.transport.pipes.PipePowerWood; -import buildcraft.transport.triggers.ActionEnergyPulser; -import buildcraft.transport.triggers.ActionSingleEnergyPulse; -import java.util.LinkedList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; - -public class GateVanilla extends Gate { - - private EnergyPulser pulser; - - public GateVanilla(Pipe pipe) { - super(pipe); - } - - public GateVanilla(Pipe pipe, ItemStack stack) { - super(pipe, stack); - - if (stack.itemID == BuildCraftTransport.pipeGateAutarchic.itemID) { - addEnergyPulser(pipe); - } - } - - // / SAVING & LOADING - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - super.writeToNBT(nbttagcompound); - - if (pulser != null) { - NBTTagCompound nbttagcompoundC = new NBTTagCompound(); - pulser.writeToNBT(nbttagcompoundC); - nbttagcompound.setTag("Pulser", nbttagcompoundC); - } - } - - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - super.readFromNBT(nbttagcompound); - - // Load pulser if any - if (nbttagcompound.hasKey("Pulser")) { - NBTTagCompound nbttagcompoundP = nbttagcompound.getCompoundTag("Pulser"); - addEnergyPulser(pipe); - pulser.readFromNBT(nbttagcompoundP); - } - - } - - // GUI - @Override - public void openGui(EntityPlayer player) { - if (!CoreProxy.proxy.isRenderWorld(player.worldObj)) { - player.openGui(BuildCraftTransport.instance, GuiIds.GATES, pipe.container.worldObj, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); - } - } - - // / UPDATING - @Override - public void update() { - if (hasPulser()) { - pulser.update(); - } - } - - // / INFORMATION - public boolean hasPulser() { - return pulser != null; - } - - @Override - public String getName() { - switch (kind) { - case Single: - return StringUtils.localize("item.pipeGate.0"); - case AND_2: - return StringUtils.localize("item.pipeGate.1"); - case OR_2: - return StringUtils.localize("item.pipeGate.2"); - case AND_3: - return StringUtils.localize("item.pipeGate.3"); - case OR_3: - return StringUtils.localize("item.pipeGate.4"); - case AND_4: - return StringUtils.localize("item.pipeGate.5"); - case OR_4: - return StringUtils.localize("item.pipeGate.6"); - case AND_5: - return StringUtils.localize("item.pipeGate.7"); - case OR_5: - return StringUtils.localize("item.pipeGate.8"); - default: - return ""; - } - - } - - @Override - public GateConditional getConditional() { - if (kind == GateKind.OR_2 || kind == GateKind.OR_3 || kind == GateKind.OR_4 || kind == GateKind.OR_5) - return GateConditional.OR; - else if (kind == GateKind.AND_2 || kind == GateKind.AND_3 || kind == GateKind.AND_4 || kind == GateKind.AND_5) - return GateConditional.AND; - else - return GateConditional.None; - } - - /** - * Tries to add an energy pulser to gates that accept energy. - * - * @param pipe - * @return - */ - private boolean addEnergyPulser(Pipe pipe) { - if (!(pipe instanceof IPowerReceptor) || pipe instanceof PipePowerWood) { - pulser = new EnergyPulser(null); - return false; - } - pulser = new EnergyPulser((IPowerReceptor) pipe); - - return true; - } - - /** - * Drops a gate item of the specified kind. - * - * @param kind - * @param world - * @param i - * @param j - * @param k - */ - @Override - public ItemStack getGateItem() { - - int gateDamage; - switch (kind) { - case Single: - gateDamage = 0; - break; - case AND_2: - gateDamage = 1; - break; - case OR_2: - gateDamage = 2; - break; - case AND_3: - gateDamage = 3; - break; - case OR_3: - gateDamage = 4; - break; - case AND_4: - gateDamage = 5; - break; - case OR_4: - gateDamage = 6; - case AND_5: - gateDamage = 7; - break; - default: - gateDamage = 8; - break; - } - - Item gateItem; - if (hasPulser()) { - gateItem = BuildCraftTransport.pipeGateAutarchic; - } else { - gateItem = BuildCraftTransport.pipeGate; - } - - return new ItemStack(gateItem, 1, gateDamage); - - } - - // / ACTIONS - @Override - public void addActions(LinkedList list) { - - if (pipe.wireSet[IPipe.WireColor.Red.ordinal()] && kind.ordinal() >= Gate.GateKind.AND_2.ordinal()) { - list.add(BuildCraftTransport.actionRedSignal); - } - - if (pipe.wireSet[IPipe.WireColor.Blue.ordinal()] && kind.ordinal() >= Gate.GateKind.AND_3.ordinal()) { - list.add(BuildCraftTransport.actionBlueSignal); - } - - if (pipe.wireSet[IPipe.WireColor.Green.ordinal()] && kind.ordinal() >= Gate.GateKind.AND_4.ordinal()) { - list.add(BuildCraftTransport.actionGreenSignal); - } - - if (pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] && kind.ordinal() >= Gate.GateKind.AND_4.ordinal()) { - list.add(BuildCraftTransport.actionYellowSignal); - } - - if (hasPulser()) { - list.add(BuildCraftTransport.actionEnergyPulser); - list.add(BuildCraftTransport.actionSingleEnergyPulse); - } - - } - - @Override - public void startResolution() { - if (hasPulser() && pulser.isActive()) { - pulser.disablePulse(); - pipe.container.scheduleRenderUpdate(); - } - } - - @Override - public boolean resolveAction(IAction action, int count) { - - if (action instanceof ActionEnergyPulser) { - pulser.enablePulse(count); - pipe.container.scheduleRenderUpdate(); - return true; - } else if (action instanceof ActionSingleEnergyPulse) { - pulser.enableSinglePulse(count); - pipe.container.scheduleRenderUpdate(); - return true; - } - return false; - } - - // / TRIGGERS - @Override - public void addTrigger(LinkedList list) { - - if (pipe.wireSet[IPipe.WireColor.Red.ordinal()] && kind.ordinal() >= Gate.GateKind.AND_2.ordinal()) { - list.add(BuildCraftTransport.triggerRedSignalActive); - list.add(BuildCraftTransport.triggerRedSignalInactive); - } - - if (pipe.wireSet[IPipe.WireColor.Blue.ordinal()] && kind.ordinal() >= Gate.GateKind.AND_3.ordinal()) { - list.add(BuildCraftTransport.triggerBlueSignalActive); - list.add(BuildCraftTransport.triggerBlueSignalInactive); - } - - if (pipe.wireSet[IPipe.WireColor.Green.ordinal()] && kind.ordinal() >= Gate.GateKind.AND_4.ordinal()) { - list.add(BuildCraftTransport.triggerGreenSignalActive); - list.add(BuildCraftTransport.triggerGreenSignalInactive); - } - - if (pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] && kind.ordinal() >= Gate.GateKind.AND_4.ordinal()) { - list.add(BuildCraftTransport.triggerYellowSignalActive); - list.add(BuildCraftTransport.triggerYellowSignalInactive); - } - - if (pipe.gate.kind == GateKind.AND_5 || pipe.gate.kind == GateKind.OR_5) { - list.add(BuildCraftTransport.triggerTimerShort); - list.add(BuildCraftTransport.triggerTimerMedium); - list.add(BuildCraftTransport.triggerTimerLong); - } - - } - - // / ICONS - @Override - public final int getTextureIconIndex(boolean isSignalActive) { - - boolean isGateActive = isSignalActive; - if (hasPulser() && pulser.isActive()) { - isGateActive = true; - } - - if (!hasPulser()) { - switch (kind) { - case None: - return 0; - case Single: - return isGateActive ? GateIconProvider.Gate_Lit : GateIconProvider.Gate_Dark; - case AND_2: - return isGateActive ? GateIconProvider.Gate_Iron_And_Lit : GateIconProvider.Gate_Iron_And_Dark; - case OR_2: - return isGateActive ? GateIconProvider.Gate_Iron_Or_Lit : GateIconProvider.Gate_Iron_Or_Dark; - case AND_3: - return isGateActive ? GateIconProvider.Gate_Gold_And_Lit : GateIconProvider.Gate_Gold_And_Dark; - case OR_3: - return isGateActive ? GateIconProvider.Gate_Gold_Or_Lit : GateIconProvider.Gate_Gold_Or_Dark; - case AND_4: - return isGateActive ? GateIconProvider.Gate_Diamond_And_Lit : GateIconProvider.Gate_Diamond_And_Dark; - case OR_4: - return isGateActive ? GateIconProvider.Gate_Diamond_Or_Lit : GateIconProvider.Gate_Diamond_Or_Dark; - case AND_5: - return isGateActive ? GateIconProvider.Gate_Quartz_And_Lit : GateIconProvider.Gate_Quartz_And_Dark; - case OR_5: - return isGateActive ? GateIconProvider.Gate_Quartz_Or_Lit : GateIconProvider.Gate_Quartz_Or_Dark; - } - } else { - switch (kind) { - case None: - return 0; - case Single: - return isGateActive ? GateIconProvider.Gate_Autarchic_Lit : GateIconProvider.Gate_Autarchic_Dark; - case AND_2: - return isGateActive ? GateIconProvider.Gate_Autarchic_Iron_And_Lit : GateIconProvider.Gate_Autarchic_Iron_And_Dark; - case OR_2: - return isGateActive ? GateIconProvider.Gate_Autarchic_Iron_Or_Lit : GateIconProvider.Gate_Autarchic_Iron_Or_Dark; - case AND_3: - return isGateActive ? GateIconProvider.Gate_Autarchic_Gold_And_Lit : GateIconProvider.Gate_Autarchic_Gold_And_Dark; - case OR_3: - return isGateActive ? GateIconProvider.Gate_Autarchic_Gold_Or_Lit : GateIconProvider.Gate_Autarchic_Gold_Or_Dark; - case AND_4: - return isGateActive ? GateIconProvider.Gate_Autarchic_Diamond_And_Lit : GateIconProvider.Gate_Autarchic_Diamond_And_Dark; - case OR_4: - return isGateActive ? GateIconProvider.Gate_Autarchic_Diamond_Or_Lit : GateIconProvider.Gate_Autarchic_Diamond_Or_Dark; - case AND_5: - return isGateActive ? GateIconProvider.Gate_Autarchic_Quartz_And_Lit : GateIconProvider.Gate_Autarchic_Quartz_And_Dark; - case OR_5: - return isGateActive ? GateIconProvider.Gate_Autarchic_Quartz_Or_Lit : GateIconProvider.Gate_Autarchic_Quartz_Or_Dark; - } - } - - return 0; - } - private static final ResourceLocation TEXTURE1 = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/gate_interface_1.png"); - private static final ResourceLocation TEXTURE2 = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/gate_interface_2.png"); - private static final ResourceLocation TEXTURE3 = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/gate_interface_3.png"); - private static final ResourceLocation TEXTURE4 = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/gate_interface_4.png"); - - @Override - public ResourceLocation getGuiFile() { - if (kind == GateKind.Single) - return TEXTURE1; - else if (kind == GateKind.AND_2 || kind == GateKind.OR_2) - return TEXTURE2; - else if (kind == GateKind.AND_3 || kind == GateKind.OR_3 || kind == GateKind.AND_5 || kind == GateKind.OR_5) - return TEXTURE3; - else - return TEXTURE4; - } - - @Override - public int getGuiHeight() { - switch (kind) { - case Single: - return 146; - case AND_2: - case OR_2: - return 164; - default: - return 200; - } - } -} diff --git a/common/buildcraft/transport/IPipeRenderState.java b/common/buildcraft/transport/IPipeRenderState.java deleted file mode 100644 index 3170b31c..00000000 --- a/common/buildcraft/transport/IPipeRenderState.java +++ /dev/null @@ -1,12 +0,0 @@ -package buildcraft.transport; - -import buildcraft.api.core.IIconProvider; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public interface IPipeRenderState { - public PipeRenderState getRenderState(); - - @SideOnly(Side.CLIENT) - public IIconProvider getPipeIcons(); -} diff --git a/common/buildcraft/transport/ItemGate.java b/common/buildcraft/transport/ItemGate.java deleted file mode 100644 index 91be27e5..00000000 --- a/common/buildcraft/transport/ItemGate.java +++ /dev/null @@ -1,164 +0,0 @@ -package buildcraft.transport; - -import buildcraft.api.gates.ActionManager; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.ITrigger; -import buildcraft.core.ItemBuildCraft; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import java.util.List; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; - -public class ItemGate extends ItemBuildCraft { - - public static final int Gate = 0; - public static final int Gate_Iron_And = 1; - public static final int Gate_Iron_Or = 2; - public static final int Gate_Gold_And = 3; - public static final int Gate_Gold_Or = 4; - public static final int Gate_Diamond_And = 5; - public static final int Gate_Diamond_Or = 6; - - public static final int Autarchic_Gate = 7; - public static final int Autarchic_Gate_Iron_And = 8; - public static final int Autarchic_Gate_Iron_Or = 9; - public static final int Autarchic_Gate_Gold_And = 10; - public static final int Autarchic_Gate_Gold_Or = 11; - public static final int Autarchic_Gate_Diamond_And = 12; - public static final int Autarchic_Gate_Diamond_Or = 13; - - public static final int Gate_Quartz_And = 14; - public static final int Gate_Quartz_Or = 15; - - public static final int Autarchic_Gate_Quartz_And = 16; - public static final int Autarchic_Gate_Quartz_Or = 17; - - public static final int MAX = 18; - - private int series; - - @SideOnly(Side.CLIENT) - private Icon[] icons; - - public ItemGate(int i, int series) { - super(i); - - this.series = series; - - setHasSubtypes(true); - setMaxDamage(0); - setPassSneakClick(true); - } - - @SuppressWarnings({ "all" }) - @Override - @SideOnly(Side.CLIENT) - public Icon getIconFromDamage(int i) { - if (series == 0){ //Normal Gates - switch (i) { - case 0: - return icons[ItemGate.Gate]; - case 1: - return icons[ItemGate.Gate_Iron_And]; - case 2: - return icons[ItemGate.Gate_Iron_Or]; - case 3: - return icons[ItemGate.Gate_Gold_And]; - case 4: - return icons[ItemGate.Gate_Gold_Or]; - case 5: - return icons[ItemGate.Gate_Diamond_And]; - case 6: - return icons[ItemGate.Gate_Diamond_Or]; - case 7: - return icons[ItemGate.Gate_Quartz_And]; - default: - return icons[ItemGate.Gate_Quartz_Or]; - } - } else if (series == 1){ - switch (i) { - case 0: - return icons[ItemGate.Autarchic_Gate]; - case 1: - return icons[ItemGate.Autarchic_Gate_Iron_And]; - case 2: - return icons[ItemGate.Autarchic_Gate_Iron_Or]; - case 3: - return icons[ItemGate.Autarchic_Gate_Gold_And]; - case 4: - return icons[ItemGate.Autarchic_Gate_Gold_Or]; - case 5: - return icons[ItemGate.Autarchic_Gate_Diamond_And]; - case 6: - return icons[ItemGate.Autarchic_Gate_Diamond_Or]; - case 7: - return icons[ItemGate.Autarchic_Gate_Quartz_And]; - default: - return icons[ItemGate.Autarchic_Gate_Quartz_Or]; - } - } - return null; - } - - @Override - public String getUnlocalizedName(ItemStack itemstack) { - return (new StringBuilder()).append(super.getUnlocalizedName()).append(".").append(itemstack.getItemDamage()).toString(); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List itemList) { - itemList.add(new ItemStack(this, 1, 0)); - itemList.add(new ItemStack(this, 1, 1)); - itemList.add(new ItemStack(this, 1, 2)); - itemList.add(new ItemStack(this, 1, 3)); - itemList.add(new ItemStack(this, 1, 4)); - itemList.add(new ItemStack(this, 1, 5)); - itemList.add(new ItemStack(this, 1, 6)); - itemList.add(new ItemStack(this, 1, 7)); - itemList.add(new ItemStack(this, 1, 8)); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) - { - - for (IAction action : ActionManager.actions.values()){ - action.registerIcons(iconRegister); - } - - for (ITrigger trigger : ActionManager.triggers.values()){ - trigger.registerIcons(iconRegister); - } - - icons = new Icon[ItemGate.MAX]; - icons[ItemGate.Gate] = iconRegister.registerIcon("buildcraft:gate"); - icons[ItemGate.Gate_Iron_And] = iconRegister.registerIcon("buildcraft:gate_iron_and"); - icons[ItemGate.Gate_Iron_Or] = iconRegister.registerIcon("buildcraft:gate_iron_or"); - icons[ItemGate.Gate_Gold_And] = iconRegister.registerIcon("buildcraft:gate_gold_and"); - icons[ItemGate.Gate_Gold_Or] = iconRegister.registerIcon("buildcraft:gate_gold_or"); - icons[ItemGate.Gate_Diamond_And] = iconRegister.registerIcon("buildcraft:gate_diamond_and"); - icons[ItemGate.Gate_Diamond_Or] = iconRegister.registerIcon("buildcraft:gate_diamond_or"); - - icons[ItemGate.Autarchic_Gate] = iconRegister.registerIcon("buildcraft:autarchic_gate"); - icons[ItemGate.Autarchic_Gate_Iron_And] = iconRegister.registerIcon("buildcraft:autarchic_gate_iron_and"); - icons[ItemGate.Autarchic_Gate_Iron_Or] = iconRegister.registerIcon("buildcraft:autarchic_gate_iron_or"); - icons[ItemGate.Autarchic_Gate_Gold_And] = iconRegister.registerIcon("buildcraft:autarchic_gate_gold_and"); - icons[ItemGate.Autarchic_Gate_Gold_Or] = iconRegister.registerIcon("buildcraft:autarchic_gate_gold_or"); - icons[ItemGate.Autarchic_Gate_Diamond_And] = iconRegister.registerIcon("buildcraft:autarchic_gate_diamond_and"); - icons[ItemGate.Autarchic_Gate_Diamond_Or] = iconRegister.registerIcon("buildcraft:autarchic_gate_diamond_or"); - - icons[ItemGate.Gate_Quartz_And] = iconRegister.registerIcon("buildcraft:gate_quartz_and"); - icons[ItemGate.Gate_Quartz_Or] = iconRegister.registerIcon("buildcraft:gate_quartz_or"); - - icons[ItemGate.Autarchic_Gate_Quartz_And] = iconRegister.registerIcon("buildcraft:autarchic_gate_quartz_and"); - icons[ItemGate.Autarchic_Gate_Quartz_Or] = iconRegister.registerIcon("buildcraft:autarchic_gate_quartz_or"); - - - } -} diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index ad45c878..fb48bb1f 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -19,6 +19,7 @@ import buildcraft.core.IDropControlInventory; import buildcraft.core.inventory.InvUtils; import buildcraft.core.network.TilePacketWrapper; import buildcraft.core.utils.Utils; +import buildcraft.transport.gates.GateFactory; import buildcraft.transport.pipes.events.PipeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -189,7 +190,7 @@ public abstract class Pipe implements IPipe, IDropContr // Update the gate if we have any if (gate != null) { gate.resolveActions(); - gate.update(); + gate.tick(); } } @@ -200,7 +201,7 @@ public abstract class Pipe implements IPipe, IDropContr public void writeToNBT(NBTTagCompound data) { transport.writeToNBT(data); - // Save pulser if any + // Save gate if any if (gate != null) { NBTTagCompound gateNBT = new NBTTagCompound(); gate.writeToNBT(gateNBT); @@ -215,17 +216,10 @@ public abstract class Pipe implements IPipe, IDropContr public void readFromNBT(NBTTagCompound data) { transport.readFromNBT(data); - // Load pulser if any + // Load gate if any if (data.hasKey("Gate")) { NBTTagCompound gateNBT = data.getCompoundTag("Gate"); - gate = Gate.makeGate(this, gateNBT); - } else if (data.hasKey("gateKind")) { - // Legacy implementation - Gate.GateKind kind = Gate.GateKind.values()[data.getInteger("gateKind")]; - if (kind != Gate.GateKind.None) { - gate = new GateVanilla(this); - gate.kind = kind; - } + gate = GateFactory.makeGate(this, gateNBT); } for (int i = 0; i < 4; ++i) { diff --git a/common/buildcraft/transport/PipeRenderState.java b/common/buildcraft/transport/PipeRenderState.java index 4727da75..0eb23c21 100644 --- a/common/buildcraft/transport/PipeRenderState.java +++ b/common/buildcraft/transport/PipeRenderState.java @@ -14,7 +14,7 @@ import net.minecraft.util.Icon; public class PipeRenderState implements IClientState { - private boolean hasGate = false; + private boolean isGateLit = false; private int gateIconIndex = 0; public final ConnectionMatrix pipeConnectionMatrix = new ConnectionMatrix(); public final TextureMatrix textureMatrix = new TextureMatrix(); @@ -31,26 +31,15 @@ public class PipeRenderState implements IClientState { @SideOnly(Side.CLIENT) public Icon[] textureArray; - public void setHasGate(boolean value) { - if (hasGate != value) { - hasGate = value; + public void setIsGateLit(boolean value) { + if (isGateLit != value) { + isGateLit = value; dirty = true; } } - public boolean hasGate() { - return hasGate; - } - - public void setGateIconIndex(int value) { - if (gateIconIndex != value) { - gateIconIndex = value; - dirty = true; - } - } - - public int getGateIconIndex() { - return gateIconIndex; + public boolean isGateLit() { + return isGateLit; } public void clean() { @@ -72,7 +61,7 @@ public class PipeRenderState implements IClientState { @Override public void writeData(DataOutputStream data) throws IOException { - data.writeBoolean(hasGate); + data.writeBoolean(isGateLit); data.writeInt(gateIconIndex); pipeConnectionMatrix.writeData(data); textureMatrix.writeData(data); @@ -83,7 +72,7 @@ public class PipeRenderState implements IClientState { @Override public void readData(DataInputStream data) throws IOException { - hasGate = data.readBoolean(); + isGateLit = data.readBoolean(); gateIconIndex = data.readInt(); pipeConnectionMatrix.readData(data); textureMatrix.readData(data); diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 6736099f..6c31f1f7 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -49,37 +49,38 @@ import buildcraft.core.network.IGuiReturnHandler; import buildcraft.core.network.ISyncedTile; import buildcraft.core.network.PacketTileState; import buildcraft.core.utils.BCLog; -import buildcraft.transport.Gate.GateKind; +import buildcraft.transport.gates.GateDefinition; +import buildcraft.transport.gates.GateFactory; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.server.management.PlayerInstance; import net.minecraft.world.WorldServer; public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFluidHandler, IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder, - IDropControlInventory, IPipeRenderState, ISyncedTile, ISolidSideTile, IGuiReturnHandler { + IDropControlInventory, ISyncedTile, ISolidSideTile, IGuiReturnHandler { - private class CoreState implements IClientState { + public class CoreState implements IClientState { public int pipeId = -1; - public int gateKind = 0; - public boolean pulser = false; + public int gateMaterial = -1; + public int gateLogic = -1; @Override public void writeData(DataOutputStream data) throws IOException { data.writeInt(pipeId); - data.writeInt(gateKind); - data.writeBoolean(pulser); + data.writeByte(gateMaterial); + data.writeByte(gateLogic); } @Override public void readData(DataInputStream data) throws IOException { pipeId = data.readInt(); - gateKind = data.readInt(); - pulser = data.readBoolean(); + gateMaterial = data.readByte(); + gateLogic = data.readByte(); } } - private PipeRenderState renderState = new PipeRenderState(); - private CoreState coreState = new CoreState(); + public final PipeRenderState renderState = new PipeRenderState(); + public final CoreState coreState = new CoreState(); private boolean deletePipe = false; private TileBuffer[] tileBuffer; public boolean[] pipeConnectionsBuffer = new boolean[6]; @@ -120,7 +121,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); redstonePowered = nbt.getBoolean("redstonePowered"); - + coreState.pipeId = nbt.getInteger("pipeId"); pipe = BlockGenericPipe.createPipe(coreState.pipeId); @@ -249,8 +250,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } // Gate Textures - renderState.setHasGate(pipe.hasGate()); - renderState.setGateIconIndex(!pipe.hasGate() ? 0 : pipe.gate.getTextureIconIndex(pipe.gate.isGateActive())); + renderState.setIsGateLit(pipe.gate != null ? pipe.gate.isGateActive() : false); // Facades for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { @@ -369,11 +369,11 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui PacketTileState packet = new PacketTileState(this.xCoord, this.yCoord, this.zCoord); if (pipe != null && pipe.gate != null) { - coreState.gateKind = pipe.gate.kind.ordinal(); - coreState.pulser = pipe.gate instanceof GateVanilla && ((GateVanilla)pipe.gate).hasPulser() ? true : false; + coreState.gateMaterial = pipe.gate.material.ordinal(); + coreState.gateLogic = pipe.gate.logic.ordinal(); } else { - coreState.gateKind = 0; - coreState.pulser = false; + coreState.gateMaterial = -1; + coreState.gateLogic = -1; } if (pipe != null && pipe.transport != null) @@ -604,15 +604,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui return true; } - /** - * IPipeRenderState implementation * - */ - @Override - public PipeRenderState getRenderState() { - return renderState; - } - - @Override @SideOnly(Side.CLIENT) public IIconProvider getPipeIcons() { if (pipe == null) @@ -643,16 +634,14 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui if (pipe == null && coreState.pipeId != 0) initialize(BlockGenericPipe.createPipe(coreState.pipeId)); - if (pipe != null && coreState.gateKind != GateKind.None.ordinal()) { - if (pipe.gate == null) { - if (coreState.pulser) { - pipe.gate = new GateVanilla(pipe, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, coreState.gateKind)); - } else { - pipe.gate = new GateVanilla(pipe); - } - } - pipe.gate.kind = GateKind.values()[coreState.gateKind]; - } + if (pipe == null) + break; + + if (coreState.gateMaterial == -1) + pipe.gate = null; + else if (pipe.gate == null) + pipe.gate = GateFactory.makeGate(pipe, GateDefinition.GateMaterial.fromOrdinal(coreState.gateMaterial), GateDefinition.GateLogic.fromOrdinal(coreState.gateLogic)); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); break; case 1: { diff --git a/common/buildcraft/transport/blueprints/BptBlockPipe.java b/common/buildcraft/transport/blueprints/BptBlockPipe.java index 428bd55e..b40ca219 100644 --- a/common/buildcraft/transport/blueprints/BptBlockPipe.java +++ b/common/buildcraft/transport/blueprints/BptBlockPipe.java @@ -19,7 +19,6 @@ import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.TriggerParameter; import buildcraft.core.Version; import buildcraft.transport.BlockGenericPipe; -import buildcraft.transport.GateVanilla; import buildcraft.transport.Pipe; import java.util.LinkedList; import net.minecraft.block.Block; @@ -55,14 +54,14 @@ public class BptBlockPipe extends BptBlock { requirements.add(new ItemStack(BuildCraftTransport.yellowPipeWire)); } - if (slot.cpt.hasKey("gate")) { - int gateId = slot.cpt.getInteger("gate"); - if (slot.cpt.hasKey("hasPulser") && slot.cpt.getBoolean("hasPulser")) { - requirements.add(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, gateId - 1)); - } else { - requirements.add(new ItemStack(BuildCraftTransport.pipeGate, 1, gateId - 1)); - } - } +// if (slot.cpt.hasKey("gate")) { +// int gateId = slot.cpt.getInteger("gate"); +// if (slot.cpt.hasKey("hasPulser") && slot.cpt.getBoolean("hasPulser")) { +// requirements.add(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, gateId - 1)); +// } else { +// requirements.add(new ItemStack(BuildCraftTransport.pipeGate, 1, gateId - 1)); +// } +// } if (BuildCraftCore.itemBptProps[pipeId] != null) { BuildCraftCore.itemBptProps[pipeId].addRequirements(slot, requirements); @@ -99,36 +98,36 @@ public class BptBlockPipe extends BptBlock { pipe.wireSet[i] = true; } - if (slot.cpt.hasKey("gate")) { - // / TODO: Does not save/load custom gates - int gateId = slot.cpt.getInteger("gate"); - GateVanilla newGate; - if (slot.cpt.hasKey("hasPulser") && slot.cpt.getBoolean("hasPulser")) { - newGate = new GateVanilla(pipe, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, gateId - 1)); - } else { - newGate = new GateVanilla(pipe, new ItemStack(BuildCraftTransport.pipeGate, 1, gateId - 1)); - } - pipe.gate = newGate; - - for (int i = 0; i < 8; ++i) { - if (slot.cpt.hasKey("trigger" + i)) { -// pipe.gate.actions[i] = ActionManager.triggers[slot.cpt.getInteger("trigger" + i)]; - } - - if (slot.cpt.hasKey("triggerParameter" + i)) { - ItemStack s = ItemStack.loadItemStackFromNBT((NBTTagCompound) slot.cpt.getTag("triggerParameter" + i)); - - if (s != null) { -// pipe.triggerParameters[i] = new TriggerParameter(); -// pipe.triggerParameters[i].set(s); - } - } - - if (slot.cpt.hasKey("action" + i)) { -// pipe.activatedActions[i] = ActionManager.actions[slot.cpt.getInteger("action" + i)]; - } - } - } +// if (slot.cpt.hasKey("gate")) { +// // / TODO: Does not save/load custom gates +// int gateId = slot.cpt.getInteger("gate"); +// GateVanilla newGate; +// if (slot.cpt.hasKey("hasPulser") && slot.cpt.getBoolean("hasPulser")) { +// newGate = new GateVanilla(pipe, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, gateId - 1)); +// } else { +// newGate = new GateVanilla(pipe, new ItemStack(BuildCraftTransport.pipeGate, 1, gateId - 1)); +// } +// pipe.gate = newGate; +// +// for (int i = 0; i < 8; ++i) { +// if (slot.cpt.hasKey("trigger" + i)) { +//// pipe.gate.actions[i] = ActionManager.triggers[slot.cpt.getInteger("trigger" + i)]; +// } +// +// if (slot.cpt.hasKey("triggerParameter" + i)) { +// ItemStack s = ItemStack.loadItemStackFromNBT((NBTTagCompound) slot.cpt.getTag("triggerParameter" + i)); +// +// if (s != null) { +//// pipe.triggerParameters[i] = new TriggerParameter(); +//// pipe.triggerParameters[i].set(s); +// } +// } +// +// if (slot.cpt.hasKey("action" + i)) { +//// pipe.activatedActions[i] = ActionManager.actions[slot.cpt.getInteger("action" + i)]; +// } +// } +// } BlockGenericPipe.placePipe(pipe, context.world(), slot.x, slot.y, slot.z, slot.blockId, slot.meta); @@ -150,29 +149,29 @@ public class BptBlockPipe extends BptBlock { } // / TODO: Does not save/load custom gates - if (pipe.hasGate()) { - bptSlot.cpt.setInteger("gate", pipe.gate.kind.ordinal()); - if (pipe.gate instanceof GateVanilla) { - bptSlot.cpt.setBoolean("hasPulser", ((GateVanilla) pipe.gate).hasPulser()); - } - - for (int i = 0; i < 8; ++i) { -// if (pipe.activatedTriggers[i] != null) { -// bptSlot.cpt.setInteger("trigger" + i, pipe.activatedTriggers[i].getId()); -// } +// if (pipe.hasGate()) { +// bptSlot.cpt.setInteger("gate", pipe.gate.kind.ordinal()); +// if (pipe.gate instanceof GateVanilla) { +// bptSlot.cpt.setBoolean("hasPulser", ((GateVanilla) pipe.gate).hasPulser()); +// } // -// if (pipe.triggerParameters[i] != null) { -// NBTTagCompound subCpt = new NBTTagCompound(); -// pipe.triggerParameters[i].getItemStack().writeToNBT(subCpt); -// -// bptSlot.cpt.setTag("triggerParameter" + i, subCpt); -// } -// -// if (pipe.activatedActions[i] != null) { -// bptSlot.cpt.setInteger("action" + i, pipe.activatedActions[i].getId()); -// } - } - } +// for (int i = 0; i < 8; ++i) { +//// if (pipe.activatedTriggers[i] != null) { +//// bptSlot.cpt.setInteger("trigger" + i, pipe.activatedTriggers[i].getId()); +//// } +//// +//// if (pipe.triggerParameters[i] != null) { +//// NBTTagCompound subCpt = new NBTTagCompound(); +//// pipe.triggerParameters[i].getItemStack().writeToNBT(subCpt); +//// +//// bptSlot.cpt.setTag("triggerParameter" + i, subCpt); +//// } +//// +//// if (pipe.activatedActions[i] != null) { +//// bptSlot.cpt.setInteger("action" + i, pipe.activatedActions[i].getId()); +//// } +// } +// } if (BuildCraftCore.itemBptProps[pipe.itemID] != null) { BuildCraftCore.itemBptProps[pipe.itemID].initializeFromWorld(bptSlot, context, x, y, z); diff --git a/common/buildcraft/transport/gates/GateDefinition.java b/common/buildcraft/transport/gates/GateDefinition.java new file mode 100644 index 00000000..0d94acfc --- /dev/null +++ b/common/buildcraft/transport/gates/GateDefinition.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.transport.gates; + +import buildcraft.core.DefaultProps; +import buildcraft.core.utils.StringUtils; +import java.util.Locale; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.util.Icon; +import net.minecraft.util.ResourceLocation; + +/** + * + * @author CovertJaguar + */ +public final class GateDefinition { + + private GateDefinition() { + } + + public static String getLocalizedName(GateMaterial material, GateLogic logic) { + if (material == GateMaterial.REDSTONE) + return StringUtils.localize("gate.name.basic"); + return String.format(StringUtils.localize("gate.name"), StringUtils.localize("gate.material." + material.getTag()), StringUtils.localize("gate.logic." + logic.getTag())); + } + + public static enum GateMaterial { + + REDSTONE("gate_interface_1.png", 146, 1, false), IRON("gate_interface_2.png", 164, 2, true), GOLD("gate_interface_3.png", 200, 4, true), DIAMOND("gate_interface_4.png", 200, 8, true); + public static final GateMaterial[] VALUES = values(); + public final ResourceLocation guiFile; + public final int guiHeight; + public final int numSlots; + public final boolean hasParameterSlot; + private Icon iconBlock; + private Icon iconItem; + + public Icon getIconBlock() { + return iconBlock; + } + + public Icon getIconItem() { + return iconItem; + } + + public String getTag() { + return name().toLowerCase(Locale.ENGLISH); + } + + public void registerBlockIcon(IconRegister iconRegister) { + if (this != REDSTONE) + iconBlock = iconRegister.registerIcon("buildcraft:gates/gate_material_" + getTag()); + } + + public void registerItemIcon(IconRegister iconRegister) { + if (this != REDSTONE) + iconItem = iconRegister.registerIcon("buildcraft:gates/gate_material_" + getTag()); + } + + private GateMaterial(String guiFile, int guiHeight, int numSlots, boolean hasParamterSlot) { + this.guiFile = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/" + guiFile); + this.guiHeight = guiHeight; + this.numSlots = numSlots; + this.hasParameterSlot = hasParamterSlot; + } + + public static GateMaterial fromOrdinal(int ordinal) { + if (ordinal < 0 || ordinal >= VALUES.length) + return REDSTONE; + return VALUES[ordinal]; + } + } + + public static enum GateLogic { + + AND, OR; + public static final GateLogic[] VALUES = values(); + private Icon iconLit; + private Icon iconDark; + private Icon iconItem; + + public Icon getIconLit() { + return iconLit; + } + + public Icon getIconDark() { + return iconDark; + } + + public Icon getIconItem() { + return iconItem; + } + + public String getTag() { + return name().toLowerCase(Locale.ENGLISH); + } + + public void registerBlockIcon(IconRegister iconRegister) { + iconLit = iconRegister.registerIcon("buildcraft:gates/gate_lit_" + getTag()); + iconDark = iconRegister.registerIcon("buildcraft:gates/gate_dark_" + getTag()); + } + + public void registerItemIcon(IconRegister iconRegister) { + iconItem = iconRegister.registerIcon("buildcraft:gates/gate_logic_" + getTag()); + } + + public static GateLogic fromOrdinal(int ordinal) { + if (ordinal < 0 || ordinal >= VALUES.length) + return AND; + return VALUES[ordinal]; + } + } +} diff --git a/common/buildcraft/transport/gates/GateExpansionController.java b/common/buildcraft/transport/gates/GateExpansionController.java new file mode 100644 index 00000000..e595641c --- /dev/null +++ b/common/buildcraft/transport/gates/GateExpansionController.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.transport.gates; + +import buildcraft.api.gates.IAction; +import buildcraft.api.gates.ITrigger; +import java.util.List; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +/** + * + * @author CovertJaguar + */ +public abstract class GateExpansionController { + + public final IGateExpansion type; + public final TileEntity pipeTile; + + public GateExpansionController(IGateExpansion type, TileEntity pipeTile) { + this.pipeTile = pipeTile; + this.type = type; + } + + public IGateExpansion getType() { + return type; + } + + public boolean isActive() { + return false; + } + + public void tick() { + } + + public void startResolution() { + } + + public boolean resolveAction(IAction action, int count) { + return false; + } + + public void addTriggers(List list) { + } + + public void addActions(List list) { + } + + public void writeToNBT(NBTTagCompound nbt) { + } + + public void readFromNBT(NBTTagCompound nbt) { + } +} diff --git a/common/buildcraft/transport/gates/GateExpansionPulsar.java b/common/buildcraft/transport/gates/GateExpansionPulsar.java new file mode 100644 index 00000000..29b0561d --- /dev/null +++ b/common/buildcraft/transport/gates/GateExpansionPulsar.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.transport.gates; + +import buildcraft.BuildCraftTransport; +import buildcraft.api.gates.IAction; +import buildcraft.api.power.IPowerReceptor; +import buildcraft.api.power.PowerHandler; +import buildcraft.api.power.PowerHandler.Type; +import buildcraft.core.utils.StringUtils; +import buildcraft.transport.triggers.ActionEnergyPulser; +import buildcraft.transport.triggers.ActionSingleEnergyPulse; +import java.util.List; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.ForgeDirection; + +/** + * + * @author CovertJaguar + */ +public class GateExpansionPulsar implements IGateExpansion { + + public static GateExpansionPulsar INSTANCE = new GateExpansionPulsar(); + + private GateExpansionPulsar() { + } + + @Override + public String getUniqueIdentifier() { + return "buildcraft:pulsar"; + } + + @Override + public String getDisplayName() { + return StringUtils.localize("gate.expansion.pulsar"); + } + + @Override + public GateExpansionController makeController(TileEntity pipeTile) { + return new GateExpansionControllerPulsar(pipeTile); + } + + private class GateExpansionControllerPulsar extends GateExpansionController { + + private boolean isActive; + private boolean singlePulse; + private boolean hasPulsed; + private int pulseCount; + private int tick; + + public GateExpansionControllerPulsar(TileEntity pipeTile) { + super(GateExpansionPulsar.this, pipeTile); + } + + @Override + public void startResolution() { + if (isActive()) { + disablePulse(); + } + } + + @Override + public boolean resolveAction(IAction action, int count) { + + if (action instanceof ActionEnergyPulser) { + enablePulse(count); + return true; + } else if (action instanceof ActionSingleEnergyPulse) { + enableSinglePulse(count); + return true; + } + return false; + } + + @Override + public void addActions(List list) { + super.addActions(list); + list.add(BuildCraftTransport.actionEnergyPulser); + list.add(BuildCraftTransport.actionSingleEnergyPulse); + } + + @Override + public void tick() { + if (!isActive && hasPulsed) + hasPulsed = false; + + PowerHandler.PowerReceiver powerReceptor = ((IPowerReceptor) pipeTile).getPowerReceiver(ForgeDirection.UNKNOWN); + + if (powerReceptor == null || !isActive || tick++ % 10 != 0) + return; + + if (!singlePulse || !hasPulsed) { + powerReceptor.receiveEnergy(Type.GATE, Math.min(1 << (pulseCount - 1), 64) * 1.01f, ForgeDirection.WEST); + hasPulsed = true; + } + } + + private void enableSinglePulse(int count) { + singlePulse = true; + isActive = true; + pulseCount = count; + } + + private void enablePulse(int count) { + isActive = true; + singlePulse = false; + pulseCount = count; + } + + private void disablePulse() { + if (!isActive) { + hasPulsed = false; + } + isActive = false; + pulseCount = 0; + } + + @Override + public boolean isActive() { + return isActive; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + nbt.setBoolean("singlePulse", singlePulse); + nbt.setBoolean("isActive", isActive); + nbt.setBoolean("hasPulsed", hasPulsed); + nbt.setInteger("pulseCount", pulseCount); + nbt.setInteger("tick", tick); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + isActive = nbt.getBoolean("isActive"); + singlePulse = nbt.getBoolean("singlePulse"); + hasPulsed = nbt.getBoolean("hasPulsed"); + pulseCount = nbt.getInteger("pulseCount"); + tick = nbt.getInteger("tick"); + } + } +} diff --git a/common/buildcraft/transport/gates/GateExpansions.java b/common/buildcraft/transport/gates/GateExpansions.java new file mode 100644 index 00000000..ab509898 --- /dev/null +++ b/common/buildcraft/transport/gates/GateExpansions.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.transport.gates; + +import java.util.HashMap; +import java.util.Map; + +/** + * + * @author CovertJaguar + */ +public final class GateExpansions { + + public static final Map expansions = new HashMap(); + + private GateExpansions() { + } + + public static void registerExpansion(IGateExpansion expansion) { + expansions.put(expansion.getUniqueIdentifier(), expansion); + } +} diff --git a/common/buildcraft/transport/gates/GateFactory.java b/common/buildcraft/transport/gates/GateFactory.java new file mode 100644 index 00000000..79dafabc --- /dev/null +++ b/common/buildcraft/transport/gates/GateFactory.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.transport.gates; + +import buildcraft.transport.Gate; +import buildcraft.transport.Pipe; +import buildcraft.transport.gates.GateDefinition.GateLogic; +import buildcraft.transport.gates.GateDefinition.GateMaterial; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/** + * + * @author CovertJaguar + */ +public class GateFactory { + + public static Gate makeGate(Pipe pipe, GateMaterial material, GateLogic logic) { + return new Gate(pipe, material, logic); + } + + public static Gate makeGate(Pipe pipe, ItemStack stack) { + if (stack == null || stack.stackSize <= 0 || !(stack.getItem() instanceof ItemGate)) + return null; + + return makeGate(pipe, ItemGate.getMaterial(stack), ItemGate.getLogic(stack)); + } + + public static Gate makeGate(Pipe pipe, NBTTagCompound nbt) { + GateMaterial material = GateMaterial.REDSTONE; + GateLogic logic = GateLogic.AND; + + // Legacy Support + if (nbt.hasKey("Kind")) { + int kind = nbt.getInteger("Kind"); + switch (kind) { + case 1: + case 2: + material = GateMaterial.IRON; + break; + case 3: + case 4: + material = GateMaterial.GOLD; + break; + case 5: + case 6: + material = GateMaterial.DIAMOND; + break; + } + switch (kind) { + case 2: + case 4: + case 6: + logic = GateLogic.OR; + break; + } + } + + if (nbt.hasKey("material")) { + try { + material = GateMaterial.valueOf(nbt.getString("material")); + } catch (IllegalArgumentException ex) { + return null; + } + } + if (nbt.hasKey("logic")) { + try { + logic = GateLogic.valueOf(nbt.getString("logic")); + } catch (IllegalArgumentException ex) { + return null; + } + } + + Gate gate = makeGate(pipe, material, logic); + + if (nbt.hasKey("Pulser")) { + NBTTagCompound pulsarTag = nbt.getCompoundTag("Pulser"); + GateExpansionController pulsarCon = GateExpansionPulsar.INSTANCE.makeController(pipe.container); + pulsarCon.readFromNBT(pulsarTag); + gate.expansions.add(pulsarCon); + } + + return gate; + } +} diff --git a/common/buildcraft/transport/gates/IGateExpansion.java b/common/buildcraft/transport/gates/IGateExpansion.java new file mode 100644 index 00000000..eaea02e9 --- /dev/null +++ b/common/buildcraft/transport/gates/IGateExpansion.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.transport.gates; + +import net.minecraft.tileentity.TileEntity; + +/** + * + * @author CovertJaguar + */ +public interface IGateExpansion { + + String getUniqueIdentifier(); + + String getDisplayName(); + + GateExpansionController makeController(TileEntity pipeTile); +} diff --git a/common/buildcraft/transport/gates/ItemGate.java b/common/buildcraft/transport/gates/ItemGate.java new file mode 100644 index 00000000..7054d513 --- /dev/null +++ b/common/buildcraft/transport/gates/ItemGate.java @@ -0,0 +1,135 @@ +package buildcraft.transport.gates; + +import buildcraft.BuildCraftTransport; +import buildcraft.api.gates.ActionManager; +import buildcraft.api.gates.IAction; +import buildcraft.api.gates.ITrigger; +import buildcraft.core.ItemBuildCraft; +import buildcraft.core.inventory.InvUtils; +import buildcraft.transport.Gate; +import buildcraft.transport.gates.GateDefinition.GateLogic; +import buildcraft.transport.gates.GateDefinition.GateMaterial; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.Icon; + +public class ItemGate extends ItemBuildCraft { + + @SideOnly(Side.CLIENT) + private Icon[] icons; + + public ItemGate(int id) { + super(id); + setHasSubtypes(false); + setMaxDamage(0); + setPassSneakClick(true); + } + + private static NBTTagCompound getNBT(ItemStack stack) { + if (stack == null || !(stack.getItem() instanceof ItemGate)) + return null; + return InvUtils.getItemData(stack); + } + + public static GateMaterial getMaterial(ItemStack stack) { + NBTTagCompound nbt = getNBT(stack); + if (nbt == null) + return GateMaterial.REDSTONE; + return GateMaterial.fromOrdinal(nbt.getByte("material")); + } + + public static GateLogic getLogic(ItemStack stack) { + NBTTagCompound nbt = getNBT(stack); + if (nbt == null) + return GateLogic.AND; + return GateLogic.fromOrdinal(nbt.getByte("logic")); + } + + public static void addGateExpansion(ItemStack stack, IGateExpansion expansion) { + NBTTagCompound nbt = getNBT(stack); + if (nbt == null) + return; + nbt.setBoolean(expansion.getUniqueIdentifier(), true); + } + + public static boolean hasGateExpansion(ItemStack stack, IGateExpansion expansion) { + NBTTagCompound nbt = getNBT(stack); + if (nbt == null) + return false; + return nbt.getBoolean(expansion.getUniqueIdentifier()); + } + + public static ItemStack makeGateItem(GateMaterial material, GateLogic logic) { + ItemStack stack = new ItemStack(BuildCraftTransport.pipeGate); + NBTTagCompound nbt = InvUtils.getItemData(stack); + nbt.setByte("material", (byte) material.ordinal()); + nbt.setByte("logic", (byte) logic.ordinal()); + return stack; + } + + public static ItemStack makeGateItem(Gate gate) { + ItemStack stack = new ItemStack(BuildCraftTransport.pipeGate); + NBTTagCompound nbt = InvUtils.getItemData(stack); + nbt.setByte("material", (byte) gate.material.ordinal()); + nbt.setByte("logic", (byte) gate.logic.ordinal()); + return stack; + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return GateDefinition.getLocalizedName(getMaterial(stack), getLogic(stack)); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(int id, CreativeTabs tab, List itemList) { + for (GateMaterial material : GateMaterial.VALUES) { + for (GateLogic logic : GateLogic.VALUES) { + if (material == GateMaterial.REDSTONE && logic == GateLogic.OR) + continue; + ItemStack stack = makeGateItem(material, logic); + for (IGateExpansion exp : GateExpansions.expansions.values()) { + addGateExpansion(stack, exp); + } + itemList.add(stack); + } + } + } + + @Override + public Icon getIconIndex(ItemStack stack) { + return getIcon(stack, 0); + } + + @Override + public Icon getIcon(ItemStack stack, int pass) { + return getLogic(stack).getIconItem(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister iconRegister) { + + for (GateDefinition.GateMaterial material : GateDefinition.GateMaterial.VALUES) { + material.registerItemIcon(iconRegister); + } + + for (GateDefinition.GateLogic logic : GateDefinition.GateLogic.VALUES) { + logic.registerItemIcon(iconRegister); + } + + for (IAction action : ActionManager.actions.values()) { + action.registerIcons(iconRegister); + } + + for (ITrigger trigger : ActionManager.triggers.values()) { + trigger.registerIcons(iconRegister); + } + } +} diff --git a/common/buildcraft/transport/gui/ContainerGateInterface.java b/common/buildcraft/transport/gui/ContainerGateInterface.java index 3b13bf46..4a74ec28 100644 --- a/common/buildcraft/transport/gui/ContainerGateInterface.java +++ b/common/buildcraft/transport/gui/ContainerGateInterface.java @@ -21,9 +21,8 @@ import buildcraft.core.network.PacketPayloadArrays; import buildcraft.core.network.PacketPayloadStream; import buildcraft.core.network.PacketUpdate; import buildcraft.core.proxy.CoreProxy; -import buildcraft.core.utils.BCLog; -import buildcraft.transport.Gate; import buildcraft.transport.Pipe; +import buildcraft.transport.gates.GateDefinition; import java.io.DataInputStream; import java.io.DataOutputStream; @@ -71,12 +70,12 @@ public class ContainerGateInterface extends BuildCraftContainer { for (int y = 0; y < 3; y++) { for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(playerInventory, x + y * 9 + 9, 8 + x * 18, pipe.gate.getGuiHeight() - 84 + y * 18)); + addSlotToContainer(new Slot(playerInventory, x + y * 9 + 9, 8 + x * 18, pipe.gate.material.guiHeight - 84 + y * 18)); } } for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(playerInventory, x, 8 + x * 18, pipe.gate.getGuiHeight() - 26)); + addSlotToContainer(new Slot(playerInventory, x, 8 + x * 18, pipe.gate.material.guiHeight - 26)); } this.pipe = pipe; @@ -99,16 +98,12 @@ public class ContainerGateInterface extends BuildCraftContainer { _potentialActions.addAll(ActionManager.getNeighborActions(block, tile)); } - if (getGateOrdinal() < Gate.GateKind.AND_3.ordinal()) { + if (!pipe.gate.material.hasParameterSlot) { Iterator it = _potentialTriggers.iterator(); while (it.hasNext()) { ITrigger trigger = it.next(); - try { - if (trigger.requiresParameter()) - it.remove(); - } catch (Throwable error) { - BCLog.logErrorAPI("Buildcraft", error, trigger.getClass()); - } + if (trigger.requiresParameter()) + it.remove(); } } } @@ -169,31 +164,31 @@ public class ContainerGateInterface extends BuildCraftContainer { try { PacketPayloadStream payload = (PacketPayloadStream) packet.payload; DataInputStream data = payload.stream; - + int position = data.readInt(); - + setTrigger(position, ActionManager.triggers.get(data.readUTF()), notify); setAction(position, ActionManager.actions.get(data.readUTF()), notify); - + ItemStack parameter = Packet.readItemStack(data); - if(parameter != null) { + if (parameter != null) { ITriggerParameter param = new TriggerParameter(); param.set(parameter); setTriggerParameter(position, param, notify); } else { setTriggerParameter(position, null, notify); } - } catch(IOException e) { + } catch (IOException e) { e.printStackTrace(); } } - + private PacketPayload getSelectionPayload(final int position) { PacketPayloadStream payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { @Override public void writeData(DataOutputStream data) throws IOException { data.writeInt(position); - + if (pipe.gate.triggers[position] != null) { data.writeUTF(pipe.gate.triggers[position].getUniqueTag()); } else { @@ -338,29 +333,7 @@ public class ContainerGateInterface extends BuildCraftContainer { public void sendSelection(EntityPlayer player) { if (pipe == null || pipe.gate == null) return; - int positions = 0; - switch (pipe.gate.kind) { - case Single: - positions = 1; - break; - case AND_2: - case OR_2: - positions = 2; - break; - case AND_3: - case OR_3: - case AND_5: - case OR_5: - positions = 4; - break; - case OR_4: - case AND_4: - default: - positions = 8; - break; - } - - for (int position = 0; position < positions; position++) { + for (int position = 0; position < pipe.gate.material.numSlots; position++) { CoreProxy.proxy.sendToPlayer(player, new PacketUpdate(PacketIds.GATE_SELECTION, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, getSelectionPayload(position))); } @@ -442,14 +415,10 @@ public class ContainerGateInterface extends BuildCraftContainer { * GATE INFORMATION * */ public ResourceLocation getGateGuiFile() { - return pipe.gate.getGuiFile(); - } - - public final int getGateOrdinal() { - return pipe.gate.kind.ordinal(); + return pipe.gate.material.guiFile; } public String getGateName() { - return pipe.gate.getName(); + return GateDefinition.getLocalizedName(pipe.gate.material, pipe.gate.logic); } } diff --git a/common/buildcraft/transport/gui/GuiGateInterface.java b/common/buildcraft/transport/gui/GuiGateInterface.java index 65a9d07b..e81d3752 100644 --- a/common/buildcraft/transport/gui/GuiGateInterface.java +++ b/common/buildcraft/transport/gui/GuiGateInterface.java @@ -13,7 +13,6 @@ import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.gui.GuiAdvancedInterface; import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.StringUtils; -import buildcraft.transport.Gate.GateKind; import buildcraft.transport.Pipe; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -29,7 +28,8 @@ public class GuiGateInterface extends GuiAdvancedInterface { IInventory playerInventory; private final ContainerGateInterface _container; - private int nbEntries; + private final Pipe pipe; + private int numSlots; class TriggerSlot extends AdvancedSlot { @@ -159,31 +159,27 @@ public class GuiGateInterface extends GuiAdvancedInterface { super(new ContainerGateInterface(playerInventory, pipe), null, null); _container = (ContainerGateInterface) this.inventorySlots; + this.pipe = pipe; this.playerInventory = playerInventory; xSize = 176; - ySize = pipe.gate.getGuiHeight(); + ySize = pipe.gate.material.guiHeight; int position = 0; + numSlots = pipe.gate.material.numSlots; - if (pipe.gate.kind == GateKind.Single) { - nbEntries = 1; - + if (numSlots == 1) { slots = new AdvancedSlot[2]; slots[0] = new TriggerSlot(62, 26, pipe, 0); slots[1] = new ActionSlot(98, 26, pipe, 0); - } else if (pipe.gate.kind == GateKind.AND_2 || pipe.gate.kind == GateKind.OR_2) { - nbEntries = 2; - + } else if (numSlots == 2) { slots = new AdvancedSlot[4]; slots[0] = new TriggerSlot(62, 26, pipe, 0); slots[1] = new TriggerSlot(62, 44, pipe, 1); slots[2] = new ActionSlot(98, 26, pipe, 0); slots[3] = new ActionSlot(98, 44, pipe, 1); - } else if (pipe.gate.kind == GateKind.AND_3 || pipe.gate.kind == GateKind.OR_3 || pipe.gate.kind == GateKind.AND_5 || pipe.gate.kind == GateKind.OR_5) { - nbEntries = 4; - + } else if (numSlots == 4) { slots = new AdvancedSlot[12]; for (int k = 0; k < 4; ++k) { @@ -201,9 +197,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { position++; } - } else if (pipe.gate.kind == GateKind.AND_4 || pipe.gate.kind == GateKind.OR_4) { - nbEntries = 8; - + } else if (numSlots == 8) { slots = new AdvancedSlot[24]; for (int k = 0; k < 4; ++k) { @@ -261,7 +255,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { if (slot instanceof TriggerSlot) { ITrigger trigger = ((TriggerSlot) slot).getTrigger(); - if (_container.getGateOrdinal() >= GateKind.AND_3.ordinal()) { + if (pipe.gate.material.hasParameterSlot) { if (_container.triggerState[triggerTracker++]) { mc.renderEngine.bindTexture(texture); @@ -333,7 +327,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { _container.setTrigger(position, changed, true); - if (_container.getGateOrdinal() >= GateKind.AND_3.ordinal()) { + if (pipe.gate.material.hasParameterSlot) { _container.setTriggerParameter(position, null, true); } } else if (slot instanceof ActionSlot) { @@ -366,16 +360,16 @@ public class GuiGateInterface extends GuiAdvancedInterface { } } - _container.setAction(position - nbEntries, changed, true); + _container.setAction(position - numSlots, changed, true); } else if (slot instanceof TriggerParameterSlot) { - TriggerSlot trigger = (TriggerSlot) slots[position - nbEntries * 2]; + TriggerSlot trigger = (TriggerSlot) slots[position - numSlots * 2]; if (trigger.isDefined() && trigger.getTrigger().hasParameter()) { ITriggerParameter param = trigger.getTrigger().createParameter(); if (param != null) { param.set(mc.thePlayer.inventory.getItemStack()); - _container.setTriggerParameter(position - nbEntries * 2, param, true); + _container.setTriggerParameter(position - numSlots * 2, param, true); } } } diff --git a/common/buildcraft/transport/render/PipeRendererTESR.java b/common/buildcraft/transport/render/PipeRendererTESR.java index f8d90d0d..3681ec03 100644 --- a/common/buildcraft/transport/render/PipeRendererTESR.java +++ b/common/buildcraft/transport/render/PipeRendererTESR.java @@ -13,10 +13,10 @@ import buildcraft.BuildCraftTransport; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.IPipe.WireColor; import buildcraft.core.CoreConstants; -import buildcraft.core.render.FluidRenderer; import buildcraft.core.render.RenderEntityBlock; import buildcraft.core.render.RenderEntityBlock.RenderInfo; import buildcraft.core.utils.EnumColor; +import buildcraft.core.utils.MatrixTranformations; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeRenderState; @@ -37,6 +37,7 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.Fluid; @@ -270,7 +271,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { } private void renderGatesWires(TileGenericPipe pipe, double x, double y, double z) { - PipeRenderState state = pipe.getRenderState(); + PipeRenderState state = pipe.renderState; if (state.wireMatrix.hasWire(WireColor.Red)) { pipeWireRender(pipe, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MIN_POS, IPipe.WireColor.Red, x, y, z); @@ -288,14 +289,14 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { pipeWireRender(pipe, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, IPipe.WireColor.Yellow, x, y, z); } - if (state.hasGate()) { + if (pipe.pipe.gate != null) { pipeGateRender(pipe, x, y, z); } } private void pipeWireRender(TileGenericPipe pipe, float cx, float cy, float cz, IPipe.WireColor color, double x, double y, double z) { - PipeRenderState state = pipe.getRenderState(); + PipeRenderState state = pipe.renderState; float minX = CoreConstants.PIPE_MIN_POS; float minY = CoreConstants.PIPE_MIN_POS; @@ -454,43 +455,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { bindTexture(TextureMap.locationBlocksTexture); - PipeRenderState state = pipe.getRenderState(); - - float min = CoreConstants.PIPE_MIN_POS + 0.05F; - float max = CoreConstants.PIPE_MAX_POS - 0.05F; - - RenderInfo box = new RenderInfo(); - box.texture = BuildCraftTransport.instance.gateIconProvider.getIcon(state.getGateIconIndex()); - - if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) { - box.setBounds(CoreConstants.PIPE_MIN_POS - 0.10F, min, min, CoreConstants.PIPE_MIN_POS + 0.001F, max, max); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); - } - - if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) { - box.setBounds(CoreConstants.PIPE_MAX_POS + 0.001F, min, min, CoreConstants.PIPE_MAX_POS + 0.10F, max, max); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); - } - - if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) { - box.setBounds(min, CoreConstants.PIPE_MIN_POS - 0.10F, min, max, CoreConstants.PIPE_MIN_POS + 0.001F, max); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); - } - - if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) { - box.setBounds(min, CoreConstants.PIPE_MAX_POS + 0.001F, min, max, CoreConstants.PIPE_MAX_POS + 0.10F, max); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); - } - - if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) { - box.setBounds(min, min, CoreConstants.PIPE_MIN_POS - 0.10F, max, max, CoreConstants.PIPE_MIN_POS + 0.001F); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); - } - - if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) { - box.setBounds(min, min, CoreConstants.PIPE_MAX_POS + 0.001F, max, max, CoreConstants.PIPE_MAX_POS + 0.10F); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); - } + renderGate(pipe, pipe.pipe.gate.logic.getIconDark()); RenderHelper.enableStandardItemLighting(); @@ -498,6 +463,67 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { GL11.glPopMatrix(); } + private void renderGate(TileGenericPipe tile, Icon icon) { + float min = CoreConstants.PIPE_MIN_POS + 0.05F; + float max = CoreConstants.PIPE_MAX_POS - 0.05F; + + PipeRenderState state = tile.renderState; + + RenderInfo box = new RenderInfo(); + box.texture = icon; + + float[][] zeroState = new float[3][2]; + // X START - END + zeroState[0][0] = min; + zeroState[0][1] = max; + // Y START - END + zeroState[1][0] = CoreConstants.PIPE_MIN_POS - 0.10F; + zeroState[1][1] = CoreConstants.PIPE_MIN_POS + 0.001F; + // Z START - END + zeroState[2][0] = min; + zeroState[2][1] = max; + + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + if (shouldRenderNormalPipeSide(state, direction)) { + float[][] rotated = MatrixTranformations.deepClone(zeroState); + MatrixTranformations.transform(rotated, direction); + + box.setBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); + RenderEntityBlock.INSTANCE.renderBlock(box, tile.worldObj, 0, 0, 0, tile.xCoord, tile.yCoord, tile.zCoord, true, true); + } + } + +// if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) { +// box.setBounds(CoreConstants.PIPE_MIN_POS - 0.10F, min, min, CoreConstants.PIPE_MIN_POS + 0.001F, max, max); +// RenderEntityBlock.INSTANCE.renderBlock(box, tile.worldObj, 0, 0, 0, tile.xCoord, tile.yCoord, tile.zCoord, true, true); +// } +// +// if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) { +// box.setBounds(CoreConstants.PIPE_MAX_POS + 0.001F, min, min, CoreConstants.PIPE_MAX_POS + 0.10F, max, max); +// RenderEntityBlock.INSTANCE.renderBlock(box, tile.worldObj, 0, 0, 0, tile.xCoord, tile.yCoord, tile.zCoord, true, true); +// } +// +// if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) { +// box.setBounds(min, CoreConstants.PIPE_MIN_POS - 0.10F, min, max, CoreConstants.PIPE_MIN_POS + 0.001F, max); +// RenderEntityBlock.INSTANCE.renderBlock(box, tile.worldObj, 0, 0, 0, tile.xCoord, tile.yCoord, tile.zCoord, true, true); +// } +// +// if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) { +// box.setBounds(min, CoreConstants.PIPE_MAX_POS + 0.001F, min, max, CoreConstants.PIPE_MAX_POS + 0.10F, max); +// RenderEntityBlock.INSTANCE.renderBlock(box, tile.worldObj, 0, 0, 0, tile.xCoord, tile.yCoord, tile.zCoord, true, true); +// } +// +// if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) { +// box.setBounds(min, min, CoreConstants.PIPE_MIN_POS - 0.10F, max, max, CoreConstants.PIPE_MIN_POS + 0.001F); +// RenderEntityBlock.INSTANCE.renderBlock(box, tile.worldObj, 0, 0, 0, tile.xCoord, tile.yCoord, tile.zCoord, true, true); +// } +// +// if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) { +// box.setBounds(min, min, CoreConstants.PIPE_MAX_POS + 0.001F, max, max, CoreConstants.PIPE_MAX_POS + 0.10F); +// RenderEntityBlock.INSTANCE.renderBlock(box, tile.worldObj, 0, 0, 0, tile.xCoord, tile.yCoord, tile.zCoord, true, true); +// } + } + private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction) { return !state.pipeConnectionMatrix.isConnected(direction) && state.facadeMatrix.getFacadeBlockId(direction) == 0 && !state.plugMatrix.isConnected(direction) && !isOpenOrientation(state, direction); } diff --git a/common/buildcraft/transport/render/PipeRendererWorld.java b/common/buildcraft/transport/render/PipeRendererWorld.java index bddbb397..7e17074b 100644 --- a/common/buildcraft/transport/render/PipeRendererWorld.java +++ b/common/buildcraft/transport/render/PipeRendererWorld.java @@ -4,11 +4,11 @@ import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.core.CoreConstants; import buildcraft.transport.BlockGenericPipe; -import buildcraft.transport.IPipeRenderState; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeRenderState; import buildcraft.transport.TransportProxy; import buildcraft.core.utils.MatrixTranformations; +import buildcraft.transport.TileGenericPipe; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; @@ -20,9 +20,10 @@ import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.ForgeDirection; public class PipeRendererWorld implements ISimpleBlockRenderingHandler { - public void renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, BlockGenericPipe block, IPipeRenderState renderState, int x, int y, int z) { - PipeRenderState state = renderState.getRenderState(); - IIconProvider icons = renderState.getPipeIcons(); + + public void renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, BlockGenericPipe block, TileGenericPipe tile, int x, int y, int z) { + PipeRenderState state = tile.renderState; + IIconProvider icons = tile.getPipeIcons(); if (icons == null) return; @@ -42,7 +43,8 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { for (int dir = 0; dir < 6; dir++) { int mask = 1 << dir; - if ((connectivity & mask) == 0) continue; // no connection towards dir + if ((connectivity & mask) == 0) + continue; // no connection towards dir // center piece offsets resetToCenterDimensions(dim); @@ -67,12 +69,17 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { } private void resetToCenterDimensions(float[] dim) { - for (int i = 0; i < 3; i++) dim[i] = CoreConstants.PIPE_MIN_POS; - for (int i = 3; i < 6; i++) dim[i] = CoreConstants.PIPE_MAX_POS; + for (int i = 0; i < 3; i++) { + dim[i] = CoreConstants.PIPE_MIN_POS; + } + for (int i = 3; i < 6; i++) { + dim[i] = CoreConstants.PIPE_MAX_POS; + } } /** - * Render a block with normal and inverted vertex order so back face culling doesn't have any effect. + * Render a block with normal and inverted vertex order so back face culling + * doesn't have any effect. */ private void renderTwoWayBlock(RenderBlocks renderblocks, BlockGenericPipe block, int x, int y, int z, float[] dim, int mask) { assert mask != 0; @@ -149,8 +156,8 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { TileEntity tile = world.getBlockTileEntity(x, y, z); - if (tile instanceof IPipeRenderState) { - IPipeRenderState pipeTile = (IPipeRenderState) tile; + if (tile instanceof TileGenericPipe) { + TileGenericPipe pipeTile = (TileGenericPipe) tile; renderPipe(renderer, world, (BlockGenericPipe) block, pipeTile, x, y, z); } return true; diff --git a/common/buildcraft/transport/triggers/ActionPipeColor.java b/common/buildcraft/transport/triggers/ActionPipeColor.java index 6f9add53..9f873c0c 100644 --- a/common/buildcraft/transport/triggers/ActionPipeColor.java +++ b/common/buildcraft/transport/triggers/ActionPipeColor.java @@ -27,7 +27,7 @@ public class ActionPipeColor extends BCAction { @Override public String getDescription() { - return String.format(StringUtils.localize("gate.pipe.item.color"), color.getLocalizedName()); + return String.format(StringUtils.localize("gate.action.pipe.item.color"), color.getLocalizedName()); } @Override diff --git a/common/buildcraft/transport/triggers/TriggerPipeContents.java b/common/buildcraft/transport/triggers/TriggerPipeContents.java index afa4d353..fc718918 100644 --- a/common/buildcraft/transport/triggers/TriggerPipeContents.java +++ b/common/buildcraft/transport/triggers/TriggerPipeContents.java @@ -66,17 +66,17 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe { switch (kind) { case Empty: - return StringUtils.localize("gate.pipe.empty"); + return StringUtils.localize("gate.trigger.pipe.empty"); case ContainsItems: - return StringUtils.localize("gate.pipe.containsItems"); + return StringUtils.localize("gate.trigger.pipe.containsItems"); case ContainsFluids: - return StringUtils.localize("gate.pipe.containsFluids"); + return StringUtils.localize("gate.trigger.pipe.containsFluids"); case ContainsEnergy: - return StringUtils.localize("gate.pipe.containsEnergy"); + return StringUtils.localize("gate.trigger.pipe.containsEnergy"); case RequestsEnergy: - return StringUtils.localize("gate.pipe.requestsEnergy"); + return StringUtils.localize("gate.trigger.pipe.requestsEnergy"); case TooMuchEnergy: - return StringUtils.localize("gate.pipe.tooMuchEnergy"); + return StringUtils.localize("gate.trigger.pipe.tooMuchEnergy"); } return "";