From 5150d016720f972337e6e17582edbf0a1577d402 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 27 Dec 2013 08:40:44 -0800 Subject: [PATCH] Add Redstone Fader Exp + major cleanup --- .../blocks/gates/gate_expansion_fader.png | Bin 0 -> 577 bytes .../gates/gate_expansion_fader.png.mcmeta | 5 ++ .../items/gates/gate_expansion_fader.png | Bin 0 -> 663 bytes .../gates/gate_expansion_fader.png.mcmeta | 5 ++ .../textures/items/triggers/redstone_01.png | Bin 0 -> 317 bytes .../textures/items/triggers/redstone_02.png | Bin 0 -> 331 bytes .../textures/items/triggers/redstone_03.png | Bin 0 -> 325 bytes .../textures/items/triggers/redstone_04.png | Bin 0 -> 325 bytes .../textures/items/triggers/redstone_05.png | Bin 0 -> 332 bytes .../textures/items/triggers/redstone_06.png | Bin 0 -> 331 bytes .../textures/items/triggers/redstone_07.png | Bin 0 -> 319 bytes .../textures/items/triggers/redstone_08.png | Bin 0 -> 341 bytes .../textures/items/triggers/redstone_09.png | Bin 0 -> 329 bytes .../textures/items/triggers/redstone_10.png | Bin 0 -> 341 bytes .../textures/items/triggers/redstone_11.png | Bin 0 -> 315 bytes .../textures/items/triggers/redstone_12.png | Bin 0 -> 345 bytes .../textures/items/triggers/redstone_13.png | Bin 0 -> 343 bytes .../textures/items/triggers/redstone_14.png | Bin 0 -> 330 bytes .../textures/items/triggers/redstone_15.png | Bin 0 -> 344 bytes ...> trigger_pipecontents_containsfluids.png} | Bin .../lang/buildcraft/en_US.properties | 33 ++++++-- common/buildcraft/BuildCraftCore.java | 34 ++++---- common/buildcraft/BuildCraftEnergy.java | 8 +- common/buildcraft/BuildCraftTransport.java | 53 ++++++------ .../buildcraft/api/gates/ActionManager.java | 40 +++------ common/buildcraft/api/gates/IAction.java | 6 -- common/buildcraft/api/gates/ITrigger.java | 8 +- common/buildcraft/api/gates/package-info.java | 2 +- common/buildcraft/api/transport/PipeWire.java | 1 + .../builders/triggers/ActionFiller.java | 2 +- common/buildcraft/core/DefaultProps.java | 43 ---------- .../core/triggers/ActionMachineControl.java | 39 ++++----- .../core/triggers/ActionRedstoneOutput.java | 13 ++- common/buildcraft/core/triggers/BCAction.java | 28 +++---- .../buildcraft/core/triggers/BCTrigger.java | 22 ++--- .../core/triggers/TriggerFluidContainer.java | 16 +--- .../core/triggers/TriggerInventory.java | 24 ++---- .../core/triggers/TriggerInventoryLevel.java | 37 +++------ .../core/triggers/TriggerMachine.java | 10 +-- .../core/triggers/TriggerRedstoneInput.java | 44 ++++++++++ common/buildcraft/energy/TileEngine.java | 5 +- .../energy/triggers/TriggerEngineHeat.java | 34 ++------ .../transport/BlockGenericPipe.java | 2 +- common/buildcraft/transport/Gate.java | 77 ++++++------------ common/buildcraft/transport/Pipe.java | 20 +---- .../transport/PipeTriggerProvider.java | 18 ++-- .../buildcraft/transport/TileGenericPipe.java | 6 +- .../transport/gates/GateDefinition.java | 2 +- .../transport/gates/GateExpansionPulsar.java | 4 +- .../gates/GateExpansionRedstoneFader.java | 58 +++++++++++++ .../transport/gates/GateFactory.java | 1 + .../transport/pipes/PipeLogicIron.java | 3 +- ...rgyPulser.java => ActionEnergyPulsar.java} | 9 +- .../triggers/ActionExtractionPreset.java | 2 +- .../transport/triggers/ActionPipeColor.java | 2 +- .../triggers/ActionPipeDirection.java | 2 +- .../triggers/ActionPowerLimiter.java | 2 +- .../triggers/ActionRedstoneFaderOutput.java | 45 ++++++++++ .../triggers/ActionSignalOutput.java | 45 ++++------ .../triggers/ActionSingleEnergyPulse.java | 11 +-- .../transport/triggers/TriggerClockTimer.java | 15 +--- .../triggers/TriggerPipeContents.java | 77 ++++++------------ .../transport/triggers/TriggerPipeSignal.java | 32 ++------ ...ut.java => TriggerRedstoneFaderInput.java} | 34 +++----- 64 files changed, 462 insertions(+), 517 deletions(-) create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_expansion_fader.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_expansion_fader.png.mcmeta create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/gates/gate_expansion_fader.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/gates/gate_expansion_fader.png.mcmeta create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_01.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_02.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_03.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_04.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_05.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_06.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_07.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_08.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_09.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_10.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_11.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_12.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_13.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_14.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_15.png rename buildcraft_resources/assets/buildcraft/textures/items/triggers/{trigger_pipecontents_containsliquid.png => trigger_pipecontents_containsfluids.png} (100%) create mode 100644 common/buildcraft/core/triggers/TriggerRedstoneInput.java create mode 100644 common/buildcraft/transport/gates/GateExpansionRedstoneFader.java rename common/buildcraft/transport/triggers/{ActionEnergyPulser.java => ActionEnergyPulsar.java} (54%) create mode 100644 common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java rename common/buildcraft/transport/triggers/{TriggerRedstoneInput.java => TriggerRedstoneFaderInput.java} (53%) diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_expansion_fader.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_expansion_fader.png new file mode 100644 index 0000000000000000000000000000000000000000..9d30454c9f7fbf74fffa01c858e8e7cbc25cd53b GIT binary patch literal 577 zcmeAS@N?(olHy`uVBq!ia0vp^0ziC#gAF8d_OTz3Qb_g)@?~JCQe|LhXl7ve`5#EX zU|KPike|9owU|?M6>EalY;r#ZdA)jNSfLq}2`-^U|xh$@l zQNg)Cc*jL8zvBHj56W!I{mq$tFv38rhc)@&kAk@;Z)+cG+L)jt!Htb7e?D{XTkKL` z^);olg!B19MnO$Pr|M=Hf3e19GTgeWh3EDdf?b2I7b-}E5vh2M_>ty!VLl#D-1!^7 z?0zDa5GXv;vJY3ta33=i{)Ic>j{CfT`w*;Z|906tjae5r{!2RD3XD<)Pgg&ebxsLQ E0KWjzvH$=8 literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_expansion_fader.png.mcmeta b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_expansion_fader.png.mcmeta new file mode 100644 index 00000000..7e77c648 --- /dev/null +++ b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_expansion_fader.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 2 + } +} \ No newline at end of file diff --git a/buildcraft_resources/assets/buildcraft/textures/items/gates/gate_expansion_fader.png b/buildcraft_resources/assets/buildcraft/textures/items/gates/gate_expansion_fader.png new file mode 100644 index 0000000000000000000000000000000000000000..482e0bcc19c8ca6a13abaa59e13a70e40442f4fc GIT binary patch literal 663 zcmeAS@N?(olHy`uVBq!ia0vp^0ziC#gAF8d_OTz3Qb_g)@?~JCQe|LhXl7ve`5#EX zU|=~ zJ=@~J?p3d>Psz7)G0AWFd4efJ`+!N~l}`-QDjYYNF<$8GGPU{Osr*+!^0nWCUbFd; z4ePiJd=IqGdy{Q%148;9*VGuS0yjS6 zm~-K1%K0M4!s%OzTyN#HIEX)*e>soYqZ4LV?QtQ7zX8FFQVrj>fACuW_00P1cJFv= zEKEL*kw8iqX%KP2DbomoH#Z|I} z8Ro8tV4WfU;Mk43bGOKcGuwwLgw&xJBAOs~fVcO9utajadV$02yS}c!3**%!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v&`cgSUo)fj}Xt64!{5;QX|b^2DN4hJeJ(yb?V> z*ARs=V?9$nLqqq^PUb*W%RF5iLoEE0fBgS%?<%ocK@*7Wcvu{`I{VKkvR%H`u-`$C zL%Dll@*K7X(|Zh$>i)DnFn{pBMB$(R1J%$ra5-Qw9!xP-Rw zFD_U%ZP(v&qfjQJK+%VXHRk;M%J^TlN3_8w#Px>(S9;Y>_S85JexpD6*$Uh#i?j~4 z2U-|w+5C@w?a4fIMc0Q!5xx_w&!QeVsI5}E^TVE*At&RG<=U+mg@G<+@O1TaS?83{ F1OVDJZixT@ literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_02.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_02.png new file mode 100644 index 0000000000000000000000000000000000000000..0abf5bb7521e4cfb8e9f5f0a6d22a14a2ee67451 GIT binary patch literal 331 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v&`caS!VyRzM-C64!{5;QX|b^2DN4hJeJ(yb?V> z*ARs=V?9$nLqqq^PUb*WTRdGHLoEE0fBgS%?<%ocK@*7ecvuvedLAYjuxZZ7VNTfg z*yMr!1nxs8l1@lOD#!2~W60jac;xR6-o~4KIRY_4i!!YQ{vUtMRnl{aF*C-$DNVrb zp^skK&-}&u%qfes4z&kb1bg58XFXGkapsDy4~Zh@{`_kA&v%T=L2Z>%jYO;Q-aE}k z`b*d)|7|y&z-kmI`tY#E97)l6|JQz9(&!W7`on;W{RvaCZlQv3s9@fo`HT!6>n^w+ T5dT^WbU%ZqtDnm{r-UW|6QXeL literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_03.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_03.png new file mode 100644 index 0000000000000000000000000000000000000000..0360bf40fb54ccfc388b95e0450ee12137429e09 GIT binary patch literal 325 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v&_hrmW@H#DGFlC9V-A!TD(=<%vb93;~Imc_n&& zt|1C##(JiDhKBB+oy>u%)_J-(hFJI~|M>sk-c@3?f+i5_@vtZ`^*l^6VAGtD!uqDXl-wD=dQI8zdRw>>2Vb9DEG4FzFDx+T+(B%xC Lu6{1-oD!M!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v&_hv4UErY@m=-iEBhjaDG}zd16s2LqK9?UWuNc zYluRbv7V`(p`rU{Cv%{xb)GJcAr}70KmPx>ca>PJpb5l!JS+}ej?Fg>*bHZAu^ljo z;W@_eaKD2dhjMq~;Rs%a>^+P}{24pAr=3&Uz^Nk6e#-eu!hV8?lW7DH2Q?N?)X^G#$f7q#c>s*VFJ+Q N44$rjF6*2UngEhOa4rA< literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_05.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_05.png new file mode 100644 index 0000000000000000000000000000000000000000..bf4a40903d94e542064da78e621c64b3cf9ff594 GIT binary patch literal 332 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v&_hwXh{d$ALmpC9V-A!TD(=<%vb93;~Imc_n&& zt|1C##(JiDhKBB+oy>u%wtBiahFJI~|M>sk-c@3?f+i5_@vtZ`^*l^6U^A46RF2_^ zWsq;X*_R{G)wJJ1k3+dT@o)q$L-roVBY$`BHs0*J-SGc%;}845bq$Fkd>)UhgiM+Z zxYCO@p01a!l~fQ86}0O)G&AbexBDkUI8V5Qw(u`5cy^urPq{%DgHfR9!^0YLUOttZ zQmJTr;=}&6jXD!LS8>R@Jv_7G!=L=M>bxn7v<|fgS}2Im$nIpGxuUD!@qZo$k98MZ U*Z!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v&_hlcloG{Xik964!{5;QX|b^2DN4hJeJ(yb?V> z*ARs=V?9$nLqqq^PUb*WTRdGHLoEE0fBgS%?<%ocK@*7ecvu{`e0gFSG;^eaaHybN&!L%t4}ac|@|QZ{657JQxWGZr;JOgIQK0CmdKI;Vst01LiwRsaA1 literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_07.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_07.png new file mode 100644 index 0000000000000000000000000000000000000000..524eec2359ad445a568e2c80f8397664e02cc716 GIT binary patch literal 319 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v&`McIIosH-JJ?C9V-A!TD(=<%vb93;~Imc_n&& zt|1C##(JiDhKBB+oy>u%R(QHNhFJI~|M>sk-c@3?f+i5_@vtZ`^*l^6VAGsY#`cG` z$WbDaNBUS6L&RfVg?H*X9C^(D{MjGT3 literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_08.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_08.png new file mode 100644 index 0000000000000000000000000000000000000000..4279fcbbcd2082496352dbc06741d3433e54511f GIT binary patch literal 341 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v&`Mp*-&I#y}yd64!{5;QX|b^2DN4hJeJ(yb?V> z*ARs=V?9$nLqqq^PUb*W`#fD7LoEE0fBgS%?<%ocK@*7ecvuvedLAYjuo+4$*|>G< zR3qjD2|c#th7a)y;w=-8PB8RHE-yDPV?H32&roQe=j%U>cOfC!l8n8J%?t-%YV3kFoN-fOK1!K z;(}$!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v&`Mg=Ke^Z3YTSmAFQf1m~xflqVLYG6W=M=9TFA zxrQi|8S9zq85+8Ob}|R5+T`it7-Hd{{Nw+Bdsm6o3YtKy$HSt))blXOfXz^1*+eDg z1PML1owfrx$8!(-f9ddNzDD=~11|O@g|?it93@(f zciwoqzjq(cgw9nQ@@@}(bW4A~Pg%v1vPkPtd!WVV*UbN{CA1l4uIT!ZD01#g5&x+@ z6Xa5U+`r}^cETmJg@18DT1dse?bjx=83l?yJggxzf&0wXBaJ>Gt~)-~voXlEoO90) RISdLS22WQ%mvv4FO#pzLbvFP2 literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_10.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_10.png new file mode 100644 index 0000000000000000000000000000000000000000..d3aff5a538209bbaefbbe96245397323067b11ae GIT binary patch literal 341 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v&`MgWcKNt^XWh7azEp#-ybp0`5~ZncxukFPmx{?f9@P=YKq=7J)$hY;=Py=r*wc` zWWbI$$}{yL)z4*}Q$iB}J*I!0 literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_11.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_11.png new file mode 100644 index 0000000000000000000000000000000000000000..c479a1c5f7b6107252b77479fc371827adee7243 GIT binary patch literal 315 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v&_>&hyT>GC(1z64!{5;QX|b^2DN4hJeJ(yb?V> z*ARs=V?9$nLqqq^PUb*WOFUg1LoEE0fBgS%?<%ocK@*6L*q9Vr+xyQPY!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v)6pfml|#tw15E64!{5;QX|b^2DN4hJeJ(yb?V> z*ARs=V?9$nLqqq^PUb*Whdf;zLoEE0fBgS%?<%ocK@*6L*q9Vr6Al~1@EkkPI#D!P z*m>fCwm=c)n+81M&4vy?^e1p1I+3K&b@9o8Bm=gH$Gi&f+)Y{TGDx&_ACwUAz1;Z2 zzD@f>q6nYI<0>JOW&^JDqK&8PrE4V>ghK`GdJfHudiCx8$q>#HE}<>_iwmAzXa7@f z5XN8>DEjcQ#+;W=<)&0B+Mf8Ze{G}Agw9nQ@@@~$toZOJf2}%i$|9{p?SU2w;xn>4 inP;x(DtP>#hrvwqn17@C(KkTfFnGH9xvX!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v)63z00aoZvus+N?apKg7ec#$`gxH83GbB^Gfvm zTtgJfjP*?Q3=Q2sJDCGj9q@E<46*QE+HcEs$U&r~n44Sl$fZN_E;>C5N{i-JaPliG zn(Mw{f`E1ZgVH@cHtAEhzkBe^(c^*geV;VvNgW=li&7;QrE=)qsayBMZ)rz?%*(9SeSG7&>GPZY3m#6tAOTeIv|5Ax(|1uZkvj+7I}h`5UH|KJDUSJ+ zGB?-FM9t5E(jeCN&u(dl#iqE6iF|sz>X!bSZOk*j%?^-@4A?REn$gQ^3vD(nc(5!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v&_>-Omo4XMsXeC9V-A!TD(=<%vb93;~Imc_n&& zt|1C##(JiDhKBB+oy>u%Hha1_hFJI~|M>sk-c@3?f+i3fu`wyMo^lgxHY`XKIeNu_ zq3vOk0UO7E)*?rVNS;VTGs7JU5s!Hl-npB$m@xnIXMglxV%>rEKnsQ5*Pa)64r$Ce zc~tLz?w8aCpAgp{23+Y`D{t4U2dgRwhYH&D9GV#~|Ka|@2*wjGp)LH23zki<4tUo3 zMd9%OZETwy)K)3gNVFO+KJc literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_15.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/redstone_15.png new file mode 100644 index 0000000000000000000000000000000000000000..a74ff1d7dad92d11704f15349f49bf368a15ebb5 GIT binary patch literal 344 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=G^tAk28_ZrvZCAbW|YuPggq9v)6rqeIJmfg%i2C9V-A!TD(=<%vb93;~Imc_n&& zt|1C##(JiDhKBB+oy>u%4tlychFJJ7?YHGRg%*`!&PwKIC4(8LRMe-eB{%$*4dvFR6b11Z@a1L>9Ry*W~!jkX#tyxzcC-@ddZpa-6<~= z6pml;!|&)vr;?Ufi*v7Pep>!uN#ECUtl((5)_rHq3H#S?Snz<)j!UL2V8@$hM(?gH zu-UYr;I4j(S%y<(isQq&sMA~SH+(wL>D>sS+`PtLe&t;ucLK6V%KYb saturationStored = new TreeMap(); - public static BCTrigger triggerBlueEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_BLUE_ENGINE_HEAT, EnergyStage.BLUE, "buildcraft.engine.stage.blue"); - public static BCTrigger triggerGreenEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_GREEN_ENGINE_HEAT, EnergyStage.GREEN, "buildcraft.engine.stage.green"); - public static BCTrigger triggerYellowEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_YELLOW_ENGINE_HEAT, EnergyStage.YELLOW, "buildcraft.engine.stage.yellow"); - public static BCTrigger triggerRedEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_RED_ENGINE_HEAT, EnergyStage.RED, "buildcraft.engine.stage.red"); + public static BCTrigger triggerBlueEngineHeat = new TriggerEngineHeat(EnergyStage.BLUE); + public static BCTrigger triggerGreenEngineHeat = new TriggerEngineHeat(EnergyStage.GREEN); + public static BCTrigger triggerYellowEngineHeat = new TriggerEngineHeat(EnergyStage.YELLOW); + public static BCTrigger triggerRedEngineHeat = new TriggerEngineHeat(EnergyStage.RED); @Instance("BuildCraft|Energy") public static BuildCraftEnergy instance; diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 2a739909..4b4404aa 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -41,6 +41,7 @@ import buildcraft.transport.blueprints.BptItemPipeWooden; import buildcraft.transport.gates.GateExpansionPulsar; import buildcraft.api.gates.GateExpansions; import buildcraft.api.transport.PipeWire; +import buildcraft.transport.gates.GateExpansionRedstoneFader; import buildcraft.transport.gates.GateExpansionTimer; import buildcraft.transport.network.PacketHandlerTransport; import buildcraft.transport.network.TransportConnectionHandler; @@ -75,7 +76,7 @@ import buildcraft.transport.pipes.PipePowerQuartz; import buildcraft.transport.pipes.PipePowerStone; import buildcraft.transport.pipes.PipePowerWood; import buildcraft.transport.pipes.PipeStructureCobblestone; -import buildcraft.transport.triggers.ActionEnergyPulser; +import buildcraft.transport.triggers.ActionEnergyPulsar; import buildcraft.transport.triggers.ActionExtractionPreset; import buildcraft.transport.triggers.ActionPipeColor; import buildcraft.transport.triggers.ActionPipeDirection; @@ -85,8 +86,10 @@ import buildcraft.transport.triggers.ActionSingleEnergyPulse; import buildcraft.transport.triggers.TriggerPipeContents; import buildcraft.transport.triggers.TriggerClockTimer; import buildcraft.transport.triggers.TriggerClockTimer.Time; -import buildcraft.transport.triggers.TriggerPipeContents.Kind; +import buildcraft.transport.triggers.TriggerPipeContents.PipeContents; import buildcraft.transport.triggers.TriggerPipeSignal; +import buildcraft.transport.triggers.TriggerRedstoneFaderInput; +import buildcraft.transport.triggers.ActionRedstoneFaderOutput; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; @@ -155,30 +158,18 @@ public class BuildCraftTransport { // public static Item pipeItemsStipes; public static Item pipeStructureCobblestone; public static int groupItemsTrigger; - public static BCTrigger triggerPipeEmpty = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_EMPTY, Kind.Empty); - public static BCTrigger triggerPipeItems = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_ITEMS, Kind.ContainsItems); - public static BCTrigger triggerPipeFluids = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_LIQUIDS, Kind.ContainsFluids); - public static BCTrigger triggerPipeContainsEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_CONTAINS_ENERGY, Kind.ContainsEnergy); - public static BCTrigger triggerPipeRequestsEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_REQUESTS_ENERGY, Kind.RequestsEnergy); - public static BCTrigger triggerPipeTooMuchEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_TOO_MUCH_ENERGY, Kind.TooMuchEnergy); - public static BCTrigger triggerRedSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_RED_SIGNAL_ACTIVE, true, PipeWire.Red); - public static BCTrigger triggerRedSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_RED_SIGNAL_INACTIVE, false, PipeWire.Red); - public static BCTrigger triggerBlueSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_BLUE_SIGNAL_ACTIVE, true, PipeWire.Blue); - public static BCTrigger triggerBlueSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_BLUE_SIGNAL_INACTIVE, false, PipeWire.Blue); - public static BCTrigger triggerGreenSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_GREEN_SIGNAL_ACTIVE, true, PipeWire.Green); - public static BCTrigger triggerGreenSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_GREEN_SIGNAL_INACTIVE, false, PipeWire.Green); - public static BCTrigger triggerYellowSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_YELLOW_SIGNAL_ACTIVE, true, PipeWire.Yellow); - public static BCTrigger triggerYellowSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_YELLOW_SIGNAL_INACTIVE, false, PipeWire.Yellow); - public static BCTrigger[] triggerTimer = new TriggerClockTimer[TriggerClockTimer.Time.VALUES.length]; - public static BCAction actionRedSignal = new ActionSignalOutput(DefaultProps.ACTION_RED_SIGNAL, PipeWire.Red); - public static BCAction actionBlueSignal = new ActionSignalOutput(DefaultProps.ACTION_BLUE_SIGNAL, PipeWire.Blue); - public static BCAction actionGreenSignal = new ActionSignalOutput(DefaultProps.ACTION_GREEN_SIGNAL, PipeWire.Green); - public static BCAction actionYellowSignal = new ActionSignalOutput(DefaultProps.ACTION_YELLOW_SIGNAL, PipeWire.Yellow); - public static BCAction actionEnergyPulser = new ActionEnergyPulser(DefaultProps.ACTION_ENERGY_PULSER); - public static BCAction actionSingleEnergyPulse = new ActionSingleEnergyPulse(DefaultProps.ACTION_SINGLE_ENERGY_PULSE); + public static BCTrigger[] triggerPipe = new BCTrigger[PipeContents.values().length]; + public static BCTrigger[] triggerPipeWireActive = new BCTrigger[PipeWire.values().length]; + public static BCTrigger[] triggerPipeWireInactive = new BCTrigger[PipeWire.values().length]; + public static BCTrigger[] triggerTimer = new BCTrigger[TriggerClockTimer.Time.VALUES.length]; + public static BCTrigger[] triggerRedstoneLevel = new BCTrigger[15]; + public static BCAction[] actionPipeWire = new ActionSignalOutput[PipeWire.values().length]; + public static BCAction actionEnergyPulser = new ActionEnergyPulsar(); + public static BCAction actionSingleEnergyPulse = new ActionSingleEnergyPulse(); public static BCAction[] actionPipeColor = new BCAction[16]; public static BCAction[] actionPipeDirection = new BCAction[16]; public static BCAction[] actionPowerLimiter = new BCAction[7]; + public static BCAction[] actionRedstoneLevel = new BCAction[15]; public static BCAction actionExtractionPresetRed = new ActionExtractionPreset(EnumColor.RED); public static BCAction actionExtractionPresetBlue = new ActionExtractionPreset(EnumColor.BLUE); public static BCAction actionExtractionPresetGreen = new ActionExtractionPreset(EnumColor.GREEN); @@ -267,6 +258,7 @@ public class BuildCraftTransport { GateExpansions.registerExpansion(GateExpansionPulsar.INSTANCE); GateExpansions.registerExpansion(GateExpansionTimer.INSTANCE); + GateExpansions.registerExpansion(GateExpansionRedstoneFader.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"; @@ -413,10 +405,25 @@ public class BuildCraftTransport { public void postInit(FMLPostInitializationEvent evt) { ItemFacade.initialize(); + for (PipeContents kind : PipeContents.values()) { + triggerPipe[kind.ordinal()] = new TriggerPipeContents(kind); + } + + for (PipeWire wire : PipeWire.values()) { + triggerPipeWireActive[wire.ordinal()] = new TriggerPipeSignal(true, wire); + triggerPipeWireInactive[wire.ordinal()] = new TriggerPipeSignal(false, wire); + actionPipeWire[wire.ordinal()] = new ActionSignalOutput(wire); + } + for (Time time : TriggerClockTimer.Time.VALUES) { triggerTimer[time.ordinal()] = new TriggerClockTimer(time); } + for (int level = 0; level < triggerRedstoneLevel.length; level++) { + triggerRedstoneLevel[level] = new TriggerRedstoneFaderInput(level + 1); + actionRedstoneLevel[level] = new ActionRedstoneFaderOutput(level + 1); + } + for (EnumColor color : EnumColor.VALUES) { actionPipeColor[color.ordinal()] = new ActionPipeColor(color); } diff --git a/common/buildcraft/api/gates/ActionManager.java b/common/buildcraft/api/gates/ActionManager.java index 84e10c03..a4b3a5ba 100644 --- a/common/buildcraft/api/gates/ActionManager.java +++ b/common/buildcraft/api/gates/ActionManager.java @@ -3,6 +3,7 @@ package buildcraft.api.gates; import buildcraft.api.transport.IPipeTile; import java.util.HashMap; import java.util.LinkedList; +import java.util.List; import java.util.Map; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; @@ -11,8 +12,8 @@ public class ActionManager { public static Map triggers = new HashMap(); public static Map actions = new HashMap(); - private static LinkedList triggerProviders = new LinkedList(); - private static LinkedList actionProviders = new LinkedList(); + private static List triggerProviders = new LinkedList(); + private static List actionProviders = new LinkedList(); public static void registerTriggerProvider(ITriggerProvider provider) { if (provider != null && !triggerProviders.contains(provider)) { @@ -28,11 +29,11 @@ public class ActionManager { actions.put(action.getUniqueTag(), action); } - public static LinkedList getNeighborTriggers(Block block, TileEntity entity) { - LinkedList triggers = new LinkedList(); + public static List getNeighborTriggers(Block block, TileEntity entity) { + List triggers = new LinkedList(); for (ITriggerProvider provider : triggerProviders) { - LinkedList toAdd = provider.getNeighborTriggers(block, entity); + List toAdd = provider.getNeighborTriggers(block, entity); if (toAdd != null) { for (ITrigger t : toAdd) { @@ -52,12 +53,11 @@ public class ActionManager { } } - //TODO: Use sets not lists - public static LinkedList getNeighborActions(Block block, TileEntity entity) { - LinkedList actions = new LinkedList(); + public static List getNeighborActions(Block block, TileEntity entity) { + List actions = new LinkedList(); for (IActionProvider provider : actionProviders) { - LinkedList toAdd = provider.getNeighborActions(block, entity); + List toAdd = provider.getNeighborActions(block, entity); if (toAdd != null) { for (IAction t : toAdd) { @@ -71,11 +71,11 @@ public class ActionManager { return actions; } - public static LinkedList getPipeTriggers(IPipeTile pipe) { - LinkedList triggers = new LinkedList(); + public static List getPipeTriggers(IPipeTile pipe) { + List triggers = new LinkedList(); for (ITriggerProvider provider : triggerProviders) { - LinkedList toAdd = provider.getPipeTriggers(pipe); + List toAdd = provider.getPipeTriggers(pipe); if (toAdd != null) { for (ITrigger t : toAdd) { @@ -88,20 +88,4 @@ public class ActionManager { return triggers; } - - public static ITrigger getTriggerFromLegacyId(int legacyId) { - for (ITrigger trigger : triggers.values()) { - if (trigger.getLegacyId() == legacyId) - return trigger; - } - return null; - } - - public static IAction getActionFromLegacyId(int legacyId) { - for (IAction action : actions.values()) { - if (action.getLegacyId() == legacyId) - return action; - } - return null; - } } diff --git a/common/buildcraft/api/gates/IAction.java b/common/buildcraft/api/gates/IAction.java index 90547d58..689d22a9 100644 --- a/common/buildcraft/api/gates/IAction.java +++ b/common/buildcraft/api/gates/IAction.java @@ -7,12 +7,6 @@ import net.minecraft.util.Icon; public interface IAction { - /** - * Return your ID from the old API here, this is only used to convert old - * saves to the new format. - */ - int getLegacyId(); - String getUniqueTag(); @SideOnly(Side.CLIENT) diff --git a/common/buildcraft/api/gates/ITrigger.java b/common/buildcraft/api/gates/ITrigger.java index 87a333e5..e3b15d82 100644 --- a/common/buildcraft/api/gates/ITrigger.java +++ b/common/buildcraft/api/gates/ITrigger.java @@ -8,11 +8,11 @@ import net.minecraft.util.Icon; public interface ITrigger { /** - * Return your ID from the old API here, this is only used to convert old - * saves to the new format. + * Every trigger needs a unique tag, it should be in the format of + * ":". + * + * @return the unique id */ - int getLegacyId(); - String getUniqueTag(); @SideOnly(Side.CLIENT) diff --git a/common/buildcraft/api/gates/package-info.java b/common/buildcraft/api/gates/package-info.java index ff77cbac..01c1a66a 100644 --- a/common/buildcraft/api/gates/package-info.java +++ b/common/buildcraft/api/gates/package-info.java @@ -1,3 +1,3 @@ -@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|gates") +@API(apiVersion="2.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|gates") package buildcraft.api.gates; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/transport/PipeWire.java b/common/buildcraft/api/transport/PipeWire.java index 23b1b2f7..8f2a54a7 100644 --- a/common/buildcraft/api/transport/PipeWire.java +++ b/common/buildcraft/api/transport/PipeWire.java @@ -14,6 +14,7 @@ package buildcraft.api.transport; */ public enum PipeWire { Red, Blue, Green, Yellow; + public static final PipeWire[] VALUES = values(); public PipeWire reverse() { switch (this) { diff --git a/common/buildcraft/builders/triggers/ActionFiller.java b/common/buildcraft/builders/triggers/ActionFiller.java index af28dfc7..05be1a8f 100644 --- a/common/buildcraft/builders/triggers/ActionFiller.java +++ b/common/buildcraft/builders/triggers/ActionFiller.java @@ -16,7 +16,7 @@ public class ActionFiller extends BCAction { public final IFillerPattern pattern; public ActionFiller(IFillerPattern pattern) { - super(0, "filler:" + pattern.getUniqueTag()); + super("filler:" + pattern.getUniqueTag()); this.pattern = pattern; } diff --git a/common/buildcraft/core/DefaultProps.java b/common/buildcraft/core/DefaultProps.java index 8a79ef0a..725c0e59 100644 --- a/common/buildcraft/core/DefaultProps.java +++ b/common/buildcraft/core/DefaultProps.java @@ -128,49 +128,6 @@ public class DefaultProps { public static final int FILLER_LIFESPAN_TOUGH = 20; public static final int FILLER_LIFESPAN_NORMAL = 6000; - // These are only till here for Legacy support, new Triggers/Action don't need them - public static int TRIGGER_REDSTONE_ACTIVE = 1; - public static int TRIGGER_REDSTONE_INACTIVE = 2; - public static int TRIGGER_MACHINE_ACTIVE = 3; - public static int TRIGGER_MACHINE_INACTIVE = 4; - public static int TRIGGER_EMPTY_INVENTORY = 5; - public static int TRIGGER_CONTAINS_INVENTORY = 6; - public static int TRIGGER_SPACE_INVENTORY = 7; - public static int TRIGGER_FULL_INVENTORY = 8; - public static int TRIGGER_EMPTY_LIQUID = 9; - public static int TRIGGER_CONTAINS_LIQUID = 10; - public static int TRIGGER_SPACE_LIQUID = 11; - public static int TRIGGER_FULL_LIQUID = 12; - public static int TRIGGER_PIPE_EMPTY = 13; - public static int TRIGGER_PIPE_ITEMS = 14; - public static int TRIGGER_PIPE_LIQUIDS = 15; - public static int TRIGGER_PIPE_CONTAINS_ENERGY = 16; - public static int TRIGGER_RED_SIGNAL_ACTIVE = 17; - public static int TRIGGER_RED_SIGNAL_INACTIVE = 18; - public static int TRIGGER_BLUE_SIGNAL_ACTIVE = 19; - public static int TRIGGER_BLUE_SIGNAL_INACTIVE = 20; - public static int TRIGGER_GREEN_SIGNAL_ACTIVE = 21; - public static int TRIGGER_GREEN_SIGNAL_INACTIVE = 22; - public static int TRIGGER_YELLOW_SIGNAL_ACTIVE = 23; - public static int TRIGGER_YELLOW_SIGNAL_INACTIVE = 24; - public static int TRIGGER_BLUE_ENGINE_HEAT = 25; - public static int TRIGGER_GREEN_ENGINE_HEAT = 26; - public static int TRIGGER_YELLOW_ENGINE_HEAT = 27; - public static int TRIGGER_RED_ENGINE_HEAT = 28; - public static int TRIGGER_PIPE_REQUESTS_ENERGY = 29; - public static int TRIGGER_PIPE_TOO_MUCH_ENERGY = 30; - - public static int ACTION_REDSTONE = 1; - public static int ACTION_RED_SIGNAL = 2; - public static int ACTION_BLUE_SIGNAL = 3; - public static int ACTION_GREEN_SIGNAL = 4; - public static int ACTION_YELLOW_SIGNAL = 5; - public static int ACTION_ON = 6; - public static int ACTION_OFF = 7; - public static int ACTION_LOOP = 8; - public static int ACTION_ENERGY_PULSER = 9; - public static int ACTION_SINGLE_ENERGY_PULSE = 10; - public static int BIOME_OIL_OCEAN = 160; public static int BIOME_OIL_DESERT = 161; } diff --git a/common/buildcraft/core/triggers/ActionMachineControl.java b/common/buildcraft/core/triggers/ActionMachineControl.java index 80f4753a..b9c6f3ef 100644 --- a/common/buildcraft/core/triggers/ActionMachineControl.java +++ b/common/buildcraft/core/triggers/ActionMachineControl.java @@ -1,46 +1,37 @@ package buildcraft.core.triggers; +import buildcraft.core.utils.StringUtils; import java.util.Locale; - public class ActionMachineControl extends BCAction { public enum Mode { + Unknown, On, Off, Loop }; + public final Mode mode; - Mode mode; - - public ActionMachineControl(int legacyId, Mode mode) { - super(legacyId, "buildcraft.machine." + mode.name().toLowerCase(Locale.ENGLISH)); + public ActionMachineControl(Mode mode) { + super("buildcraft:machine." + mode.name().toLowerCase(Locale.ENGLISH), "buildcraft.machine." + mode.name().toLowerCase(Locale.ENGLISH)); this.mode = mode; } @Override public String getDescription() { - switch (mode) { - case On: - return "On"; - case Off: - return "Off"; - case Loop: - return "Loop"; - default: - return ""; - } + return StringUtils.localize("gate.action.machine." + mode.name().toLowerCase(Locale.ENGLISH)); } - + @Override public int getIconIndex() { switch (mode) { - case On: - return ActionTriggerIconProvider.Action_MachineControl_On; - case Off: - return ActionTriggerIconProvider.Action_MachineControl_Off; - case Loop: - default: - return ActionTriggerIconProvider.Action_MachineControl_Loop; - } + case On: + return ActionTriggerIconProvider.Action_MachineControl_On; + case Off: + return ActionTriggerIconProvider.Action_MachineControl_Off; + case Loop: + default: + return ActionTriggerIconProvider.Action_MachineControl_Loop; + } } } diff --git a/common/buildcraft/core/triggers/ActionRedstoneOutput.java b/common/buildcraft/core/triggers/ActionRedstoneOutput.java index d620fea7..ec43af46 100644 --- a/common/buildcraft/core/triggers/ActionRedstoneOutput.java +++ b/common/buildcraft/core/triggers/ActionRedstoneOutput.java @@ -1,19 +1,16 @@ /** - * Copyright (c) SpaceToad, 2011 - * http://www.mod-buildcraft.com + * Copyright (c) SpaceToad, 2011 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 + * 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.core.triggers; - public class ActionRedstoneOutput extends BCAction { - public ActionRedstoneOutput(int legacyId) { - super(legacyId, "buildcraft.redstone.output"); + public ActionRedstoneOutput() { + super("buildcraft:redstone.output", "buildcraft.redstone.output"); } @Override diff --git a/common/buildcraft/core/triggers/BCAction.java b/common/buildcraft/core/triggers/BCAction.java index b71e28fc..5b2d916a 100644 --- a/common/buildcraft/core/triggers/BCAction.java +++ b/common/buildcraft/core/triggers/BCAction.java @@ -8,6 +8,7 @@ package buildcraft.core.triggers; import buildcraft.api.gates.ActionManager; +import static buildcraft.api.gates.ActionManager.actions; import buildcraft.api.gates.IAction; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -16,22 +17,20 @@ import net.minecraft.util.Icon; public abstract class BCAction implements IAction { - protected final int legacyId; protected final String uniqueTag; - public BCAction(String uniqueTag) { - this(-1, uniqueTag); - } - /** - * - * @param legacyId this should be -1 for new Actions - * @param uniqueTag + * UniqueTag accepts multiple possible tags, use this feature to migrate to + * more standardized tags if needed, otherwise just pass a single string. + * The first passed string will be the one used when saved to disk. + * + * @param uniqueTag */ - public BCAction(int legacyId, String uniqueTag) { - this.legacyId = legacyId; - this.uniqueTag = uniqueTag; - ActionManager.registerAction(this); + public BCAction(String... uniqueTag) { + this.uniqueTag = uniqueTag[0]; + for (String tag : uniqueTag) { + ActionManager.actions.put(tag, this); + } } @Override @@ -39,11 +38,6 @@ public abstract class BCAction implements IAction { return uniqueTag; } - @Override - public int getLegacyId() { - return this.legacyId; - } - public int getIconIndex() { return 0; } diff --git a/common/buildcraft/core/triggers/BCTrigger.java b/common/buildcraft/core/triggers/BCTrigger.java index f4b6be6a..c8205d93 100644 --- a/common/buildcraft/core/triggers/BCTrigger.java +++ b/common/buildcraft/core/triggers/BCTrigger.java @@ -23,13 +23,20 @@ import net.minecraft.util.Icon; */ public abstract class BCTrigger implements ITrigger { - protected final int legacyId; protected final String uniqueTag; - public BCTrigger(int legacyId, String uniqueTag) { - this.legacyId = legacyId; - this.uniqueTag = uniqueTag; - ActionManager.registerTrigger(this); + /** + * UniqueTag accepts multiple possible tags, use this feature to migrate to + * more standardized tags if needed, otherwise just pass a single string. + * The first passed string will be the one used when saved to disk. + * + * @param uniqueTag + */ + public BCTrigger(String... uniqueTag) { + this.uniqueTag = uniqueTag[0]; + for (String tag : uniqueTag) { + ActionManager.triggers.put(tag, this); + } } @Override @@ -37,11 +44,6 @@ public abstract class BCTrigger implements ITrigger { return uniqueTag; } - @Override - public int getLegacyId() { - return this.legacyId; - } - public int getIconIndex() { return 0; } diff --git a/common/buildcraft/core/triggers/TriggerFluidContainer.java b/common/buildcraft/core/triggers/TriggerFluidContainer.java index 7f6b2ba0..8aff2fd6 100644 --- a/common/buildcraft/core/triggers/TriggerFluidContainer.java +++ b/common/buildcraft/core/triggers/TriggerFluidContainer.java @@ -9,6 +9,7 @@ package buildcraft.core.triggers; import buildcraft.api.gates.ITileTrigger; import buildcraft.api.gates.ITriggerParameter; +import buildcraft.core.utils.StringUtils; import java.util.Locale; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; @@ -25,8 +26,8 @@ public class TriggerFluidContainer extends BCTrigger implements ITileTrigger { }; public State state; - public TriggerFluidContainer(int legacyId, State state) { - super(legacyId, "buildcraft.fluid." + state.name().toLowerCase(Locale.ENGLISH)); + public TriggerFluidContainer(State state) { + super("buildcraft:fluid." + state.name().toLowerCase(Locale.ENGLISH), "buildcraft.fluid." + state.name().toLowerCase(Locale.ENGLISH)); this.state = state; } @@ -40,16 +41,7 @@ public class TriggerFluidContainer extends BCTrigger implements ITileTrigger { @Override public String getDescription() { - switch (state) { - case Empty: - return "Tank Empty"; - case Contains: - return "Fluid in Tank"; - case Space: - return "Space for Fluid"; - default: - return "Tank Full"; - } + return StringUtils.localize("gate.trigger.fluid." + state.name().toLowerCase(Locale.ENGLISH)); } @Override diff --git a/common/buildcraft/core/triggers/TriggerInventory.java b/common/buildcraft/core/triggers/TriggerInventory.java index cfa16bed..db7af481 100644 --- a/common/buildcraft/core/triggers/TriggerInventory.java +++ b/common/buildcraft/core/triggers/TriggerInventory.java @@ -13,6 +13,7 @@ import buildcraft.api.inventory.ISpecialInventory; import buildcraft.core.inventory.InventoryIterator; import buildcraft.core.inventory.InventoryIterator.IInvSlot; import buildcraft.core.inventory.StackHelper; +import buildcraft.core.utils.StringUtils; import java.util.Locale; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -27,8 +28,8 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger { }; public State state; - public TriggerInventory(int legacyId, State state) { - super(legacyId, "buildcraft.inventory." + state.name().toLowerCase(Locale.ENGLISH)); + public TriggerInventory(State state) { + super("buildcraft:inventory." + state.name().toLowerCase(Locale.ENGLISH), "buildcraft.inventory." + state.name().toLowerCase(Locale.ENGLISH)); this.state = state; } @@ -43,16 +44,7 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger { @Override public String getDescription() { - switch (state) { - case Empty: - return "Inventory Empty"; - case Contains: - return "Items in Inventory"; - case Space: - return "Space in Inventory"; - default: - return "Inventory Full"; - } + return StringUtils.localize("gate.trigger.inventory." + state.name().toLowerCase(Locale.ENGLISH)); } @Override @@ -91,13 +83,13 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger { for (IInvSlot slot : InventoryIterator.getIterable((IInventory) tile, side)) { hasSlots = true; ItemStack stack = slot.getStackInSlot(); - + foundItems |= stack != null && (searchedStack == null || StackHelper.instance().canStacksMerge(stack, searchedStack)); - foundSpace |= (stack == null || (StackHelper.instance().canStacksMerge(stack, searchedStack) && stack.stackSize < stack.getMaxStackSize())) + foundSpace |= (stack == null || (StackHelper.instance().canStacksMerge(stack, searchedStack) && stack.stackSize < stack.getMaxStackSize())) && (searchedStack == null || slot.canPutStackInSlot(searchedStack)); } - - if(!hasSlots) + + if (!hasSlots) return false; switch (state) { diff --git a/common/buildcraft/core/triggers/TriggerInventoryLevel.java b/common/buildcraft/core/triggers/TriggerInventoryLevel.java index 399a1bdd..cae03387 100644 --- a/common/buildcraft/core/triggers/TriggerInventoryLevel.java +++ b/common/buildcraft/core/triggers/TriggerInventoryLevel.java @@ -7,32 +7,36 @@ */ package buildcraft.core.triggers; -import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.ITileTrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.inventory.InventoryIterator; import buildcraft.core.inventory.InventoryIterator.IInvSlot; import buildcraft.core.inventory.StackHelper; +import buildcraft.core.utils.StringUtils; import java.util.Locale; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; -public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger{ +public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger { public enum TriggerType { - BELOW_25, BELOW_50, BELOW_75 + BELOW_25(0.25F), BELOW_50(0.5F), BELOW_75(0.75F); + public final float level; + + private TriggerType(float level) { + this.level = level; + } }; public TriggerType type; public TriggerInventoryLevel(TriggerType type) { - super(0, "buildcraft.inventorylevel." + type.name().toLowerCase(Locale.ENGLISH)); + super("buildcraft:inventorylevel." + type.name().toLowerCase(Locale.ENGLISH), + "buildcraft.inventorylevel." + type.name().toLowerCase(Locale.ENGLISH), + "buildcraft.filteredBuffer." + type.name().toLowerCase(Locale.ENGLISH)); this.type = type; - - // Legacy migration code - ActionManager.triggers.put("buildcraft.filteredBuffer." + type.name().toLowerCase(Locale.ENGLISH), this); } @Override @@ -47,14 +51,7 @@ public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger{ @Override public String getDescription() { - switch (type) { - case BELOW_25: - return "Contains < 25%"; - case BELOW_50: - return "Contains < 50%"; - default: - return "Contains < 75%"; - } + return String.format(StringUtils.localize("gate.trigger.inventorylevel.below"), (int) (type.level * 100)); } @Override @@ -80,15 +77,7 @@ public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger{ if (stackSpace > 0) { float percentage = (float) foundItems / ((float) stackSpace * (float) searchStack.getMaxStackSize()); - - switch (type) { - case BELOW_25: - return percentage < 0.25f; - case BELOW_50: - return percentage < 0.5f; - default: - return percentage < 0.75f; - } + return percentage < type.level; } } diff --git a/common/buildcraft/core/triggers/TriggerMachine.java b/common/buildcraft/core/triggers/TriggerMachine.java index 0520e4c8..e2eecfe9 100644 --- a/common/buildcraft/core/triggers/TriggerMachine.java +++ b/common/buildcraft/core/triggers/TriggerMachine.java @@ -10,6 +10,7 @@ package buildcraft.core.triggers; import buildcraft.api.gates.ITileTrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.IMachine; +import buildcraft.core.utils.StringUtils; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; @@ -17,18 +18,15 @@ public class TriggerMachine extends BCTrigger implements ITileTrigger { boolean active; - public TriggerMachine(int legacyId, boolean active) { - super(legacyId, "buildcraft.work." + (active ? "scheduled" : "done")); + public TriggerMachine(boolean active) { + super("buildcraft:work." + (active ? "scheduled" : "done"), "buildcraft.work." + (active ? "scheduled" : "done")); this.active = active; } @Override public String getDescription() { - if (active) - return "Work Scheduled"; - else - return "Work Done"; + return StringUtils.localize("gate.trigger.machine." + (active ? "scheduled" : "done")); } @Override diff --git a/common/buildcraft/core/triggers/TriggerRedstoneInput.java b/common/buildcraft/core/triggers/TriggerRedstoneInput.java new file mode 100644 index 00000000..a5d1d654 --- /dev/null +++ b/common/buildcraft/core/triggers/TriggerRedstoneInput.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) SpaceToad, 2011 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.core.triggers; + +import buildcraft.api.gates.ITriggerParameter; +import buildcraft.core.utils.StringUtils; +import buildcraft.transport.IPipeTrigger; +import buildcraft.transport.Pipe; + +public class TriggerRedstoneInput extends BCTrigger implements IPipeTrigger { + + boolean active; + + public TriggerRedstoneInput(boolean active) { + super("buildcraft:redstone.input." + (active ? "active" : "inactive"), active ? "buildcraft.redtone.input.active" : "buildcraft.redtone.input.inactive"); + this.active = active; + } + + @Override + public String getDescription() { + return StringUtils.localize("gate.trigger.redstone.input." + (active ? "active" : "inactive")); + } + + @Override + public boolean isTriggerActive(Pipe pipe, ITriggerParameter parameter) { + if (active) + return isBeingPowered(pipe); + return !isBeingPowered(pipe); + } + + private boolean isBeingPowered(Pipe pipe) { + return pipe.container.redstoneInput > 0; + } + + @Override + public int getIconIndex() { + return active ? ActionTriggerIconProvider.Trigger_RedstoneInput_Active : ActionTriggerIconProvider.Trigger_RedstoneInput_Inactive; + } +} diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index 0c769870..8ac75275 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -43,7 +43,8 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public enum EnergyStage { - BLUE, GREEN, YELLOW, RED, OVERHEAT + BLUE, GREEN, YELLOW, RED, OVERHEAT; + public static final EnergyStage[] VALUES = values(); } public static final float MIN_HEAT = 20; public static final float IDEAL_HEAT = 100; @@ -174,7 +175,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto if (!isOrientationValid()) switchOrientation(true); } - + if (!isRedstonePowered) if (energy > 1) energy--; diff --git a/common/buildcraft/energy/triggers/TriggerEngineHeat.java b/common/buildcraft/energy/triggers/TriggerEngineHeat.java index 2d79c743..8e8f5006 100644 --- a/common/buildcraft/energy/triggers/TriggerEngineHeat.java +++ b/common/buildcraft/energy/triggers/TriggerEngineHeat.java @@ -15,6 +15,7 @@ import buildcraft.energy.TileEngine; import buildcraft.energy.TileEngine.EnergyStage; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.Locale; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; @@ -24,26 +25,17 @@ public class TriggerEngineHeat extends BCTrigger implements ITileTrigger { public EnergyStage stage; @SideOnly(Side.CLIENT) - private Icon iconBlue, iconGreen, iconYellow, iconRed; + private Icon icon; - public TriggerEngineHeat(int id, EnergyStage stage, String uniqueTag) { - super(id, uniqueTag); + public TriggerEngineHeat(EnergyStage stage) { + super("buildcraft:engine.stage." + stage.name().toLowerCase(Locale.ENGLISH), "buildcraft.engine.stage." + stage.name().toLowerCase(Locale.ENGLISH)); this.stage = stage; } @Override public String getDescription() { - switch (stage) { - case BLUE: - return StringUtils.localize("gate.trigger.engine.blue"); - case GREEN: - return StringUtils.localize("gate.trigger.engine.green"); - case YELLOW: - return StringUtils.localize("gate.trigger.engine.yellow"); - default: - return StringUtils.localize("gate.trigger.engine.red"); - } + return StringUtils.localize("gate.trigger.engine." + stage.name().toLowerCase(Locale.ENGLISH)); } @Override @@ -60,24 +52,12 @@ public class TriggerEngineHeat extends BCTrigger implements ITileTrigger { @Override @SideOnly(Side.CLIENT) public Icon getIcon() { - switch (stage) { - case BLUE: - return iconBlue; - case GREEN: - return iconGreen; - case YELLOW: - return iconYellow; - default: - return iconRed; - } + return icon; } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { - iconBlue = iconRegister.registerIcon("buildcraft:triggers/trigger_engineheat_blue"); - iconGreen = iconRegister.registerIcon("buildcraft:triggers/trigger_engineheat_green"); - iconYellow = iconRegister.registerIcon("buildcraft:triggers/trigger_engineheat_yellow"); - iconRed = iconRegister.registerIcon("buildcraft:triggers/trigger_engineheat_red"); + icon = iconRegister.registerIcon("buildcraft:triggers/trigger_engineheat_" + stage.name().toLowerCase(Locale.ENGLISH)); } } diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index 0a9193d4..bc466234 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -613,7 +613,7 @@ public class BlockGenericPipe extends BlockBuildCraft { if (isValid(pipe)) { pipe.container.scheduleNeighborChange(); - pipe.container.redstonePowered = world.isBlockIndirectlyGettingPowered(x, y, z); + pipe.container.redstoneInput = world.getBlockPowerInput(x, y, z); } } diff --git a/common/buildcraft/transport/Gate.java b/common/buildcraft/transport/Gate.java index bb8dd9cc..d37399cf 100644 --- a/common/buildcraft/transport/Gate.java +++ b/common/buildcraft/transport/Gate.java @@ -17,6 +17,7 @@ import buildcraft.api.gates.GateExpansionController; import buildcraft.api.gates.IGateExpansion; import buildcraft.api.gates.ITileTrigger; import buildcraft.transport.gates.ItemGate; +import buildcraft.transport.triggers.ActionRedstoneFaderOutput; import buildcraft.transport.triggers.ActionSignalOutput; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; @@ -42,7 +43,7 @@ public final class Gate { public ITriggerParameter[] triggerParameters = new ITriggerParameter[8]; public IAction[] actions = new IAction[8]; public boolean broadcastSignal[] = new boolean[4]; - public boolean broadcastRedstone = false; + public int redstoneOutput = 0; // / CONSTRUCTOR public Gate(Pipe pipe, GateMaterial material, GateLogic logic) { @@ -110,7 +111,7 @@ public final class Gate { for (int i = 0; i < 4; ++i) { data.setBoolean("wireState[" + i + "]", broadcastSignal[i]); } - data.setBoolean("redstoneState", broadcastRedstone); + data.setByte("redstoneOutput", (byte) redstoneOutput); } public void readFromNBT(NBTTagCompound data) { @@ -128,7 +129,7 @@ public final class Gate { for (int i = 0; i < 4; ++i) { broadcastSignal[i] = data.getBoolean("wireState[" + i + "]"); } - broadcastRedstone = data.getBoolean("redstoneState"); + redstoneOutput = data.getByte("redstoneOutput"); } // GUI @@ -154,8 +155,8 @@ public final class Gate { } public void resetGate() { - if (broadcastRedstone) { - broadcastRedstone = false; + if (redstoneOutput != 0) { + redstoneOutput = 0; pipe.updateNeighbors(true); } } @@ -165,11 +166,11 @@ public final class Gate { if (b) return true; } - return broadcastRedstone; + return redstoneOutput > 0; } - public boolean isEmittingRedstone() { - return broadcastRedstone; + public int getRedstoneOutput() { + return redstoneOutput; } public void startResolution() { @@ -179,10 +180,10 @@ public final class Gate { } public void resolveActions() { - boolean oldBroadcastRedstone = broadcastRedstone; + int oldRedstoneOutput = redstoneOutput; boolean[] oldBroadcastSignal = broadcastSignal; - broadcastRedstone = false; + redstoneOutput = 0; broadcastSignal = new boolean[4]; // Tell the gate to prepare for resolving actions. (Disable pulser) @@ -220,7 +221,9 @@ public final class Gate { } if (action instanceof ActionRedstoneOutput) { - broadcastRedstone = true; + redstoneOutput = 15; + } else if (action instanceof ActionRedstoneFaderOutput) { + redstoneOutput = ((ActionRedstoneFaderOutput) action).level; } else if (action instanceof ActionSignalOutput) { broadcastSignal[((ActionSignalOutput) action).color.ordinal()] = true; } else { @@ -237,8 +240,9 @@ public final class Gate { pipe.actionsActivated(activeActions); - if (oldBroadcastRedstone != broadcastRedstone) { - pipe.container.scheduleRenderUpdate(); + if (oldRedstoneOutput != redstoneOutput) { + if (redstoneOutput == 0 ^ oldRedstoneOutput == 0) + pipe.container.scheduleRenderUpdate(); pipe.updateNeighbors(true); } @@ -288,52 +292,25 @@ public final class Gate { // / TRIGGERS public void addTrigger(List list) { - if (pipe.wireSet[PipeWire.Red.ordinal()] && material == GateMaterial.IRON) { - list.add(BuildCraftTransport.triggerRedSignalActive); - list.add(BuildCraftTransport.triggerRedSignalInactive); - } - - if (pipe.wireSet[PipeWire.Blue.ordinal()] && material == GateMaterial.IRON) { - list.add(BuildCraftTransport.triggerBlueSignalActive); - list.add(BuildCraftTransport.triggerBlueSignalInactive); - } - - if (pipe.wireSet[PipeWire.Green.ordinal()] && material == GateMaterial.GOLD) { - list.add(BuildCraftTransport.triggerGreenSignalActive); - list.add(BuildCraftTransport.triggerGreenSignalInactive); - } - - if (pipe.wireSet[PipeWire.Yellow.ordinal()] && material == GateMaterial.DIAMOND) { - list.add(BuildCraftTransport.triggerYellowSignalActive); - list.add(BuildCraftTransport.triggerYellowSignalInactive); + for (PipeWire wire : PipeWire.VALUES) { + if (pipe.wireSet[wire.ordinal()] && material.ordinal() >= wire.ordinal()) { + list.add(BuildCraftTransport.triggerPipeWireActive[wire.ordinal()]); + list.add(BuildCraftTransport.triggerPipeWireInactive[wire.ordinal()]); + } } for (GateExpansionController expansion : expansions.values()) { 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 void addActions(List list) { - if (pipe.wireSet[PipeWire.Red.ordinal()] && material == GateMaterial.IRON) - list.add(BuildCraftTransport.actionRedSignal); - - if (pipe.wireSet[PipeWire.Blue.ordinal()] && material == GateMaterial.IRON) - list.add(BuildCraftTransport.actionBlueSignal); - - if (pipe.wireSet[PipeWire.Green.ordinal()] && material == GateMaterial.GOLD) - list.add(BuildCraftTransport.actionGreenSignal); - - if (pipe.wireSet[PipeWire.Yellow.ordinal()] && material == GateMaterial.DIAMOND) - list.add(BuildCraftTransport.actionYellowSignal); - + for (PipeWire wire : PipeWire.VALUES) { + if (pipe.wireSet[wire.ordinal()] && material.ordinal() >= wire.ordinal()) { + list.add(BuildCraftTransport.actionPipeWire[wire.ordinal()]); + } + } for (GateExpansionController expansion : expansions.values()) { expansion.addActions(list); diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index 2bc722b9..c39a05d1 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -11,10 +11,8 @@ import buildcraft.api.transport.PipeWire; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.SafeTimeTracker; -import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.IAction; import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.TriggerParameter; import buildcraft.core.IDropControlInventory; import buildcraft.core.inventory.InvUtils; import buildcraft.core.network.TilePacketWrapper; @@ -224,20 +222,6 @@ public abstract class Pipe implements IDropControlInven for (int i = 0; i < 4; ++i) { wireSet[i] = data.getBoolean("wireSet[" + i + "]"); } - - // Legacy update code - if (hasGate()) { - for (int i = 0; i < 8; ++i) { - if (data.hasKey("trigger[" + i + "]")) - gate.triggers[i] = ActionManager.getTriggerFromLegacyId(data.getInteger("trigger[" + i + "]")); - if (data.hasKey("action[" + i + "]")) - gate.actions[i] = ActionManager.getActionFromLegacyId(data.getInteger("action[" + i + "]")); - if (data.hasKey("triggerParameters[" + i + "]")) { - gate.triggerParameters[i] = new TriggerParameter(); - gate.triggerParameters[i].readFromNBT(data.getCompoundTag("triggerParameters[" + i + "]")); - } - } - } } private boolean initialized = false; @@ -360,14 +344,14 @@ public abstract class Pipe implements IDropControlInven } public int isPoweringTo(int side) { - if (gate != null && gate.isEmittingRedstone()) { + if (gate != null && gate.getRedstoneOutput() > 0) { ForgeDirection o = ForgeDirection.getOrientation(side).getOpposite(); TileEntity tile = container.getTile(o); if (tile instanceof TileGenericPipe && container.isPipeConnected(o)) return 0; - return 15; + return gate.getRedstoneOutput(); } return 0; } diff --git a/common/buildcraft/transport/PipeTriggerProvider.java b/common/buildcraft/transport/PipeTriggerProvider.java index 52092385..42598117 100644 --- a/common/buildcraft/transport/PipeTriggerProvider.java +++ b/common/buildcraft/transport/PipeTriggerProvider.java @@ -1,11 +1,11 @@ package buildcraft.transport; -import buildcraft.BuildCraftTransport; import buildcraft.api.gates.IOverrideDefaultTriggers; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerProvider; import buildcraft.api.transport.IPipeTile; import buildcraft.transport.pipes.PipePowerWood; +import buildcraft.transport.triggers.TriggerPipeContents; import java.util.LinkedList; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; @@ -28,19 +28,19 @@ public class PipeTriggerProvider implements ITriggerProvider { switch (tile.getPipeType()) { case ITEM: - result.add(BuildCraftTransport.triggerPipeEmpty); - result.add(BuildCraftTransport.triggerPipeItems); + result.add(TriggerPipeContents.PipeContents.empty.trigger); + result.add(TriggerPipeContents.PipeContents.containsItems.trigger); break; case FLUID: - result.add(BuildCraftTransport.triggerPipeEmpty); - result.add(BuildCraftTransport.triggerPipeFluids); + result.add(TriggerPipeContents.PipeContents.empty.trigger); + result.add(TriggerPipeContents.PipeContents.containsFluids.trigger); break; case POWER: - result.add(BuildCraftTransport.triggerPipeEmpty); - result.add(BuildCraftTransport.triggerPipeContainsEnergy); - result.add(BuildCraftTransport.triggerPipeTooMuchEnergy); + result.add(TriggerPipeContents.PipeContents.empty.trigger); + result.add(TriggerPipeContents.PipeContents.containsEnergy.trigger); + result.add(TriggerPipeContents.PipeContents.tooMuchEnergy.trigger); if (pipe instanceof PipePowerWood) { - result.add(BuildCraftTransport.triggerPipeRequestsEnergy); + result.add(TriggerPipeContents.PipeContents.requestsEnergy.trigger); } break; } diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index c7c57c4e..4727b48f 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -105,7 +105,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui private boolean refreshRenderState = false; private boolean pipeBound = false; private boolean resyncGateExpansions = false; - public boolean redstonePowered = false; + public int redstoneInput = 0; private int[] facadeBlocks = new int[ForgeDirection.VALID_DIRECTIONS.length]; private int[] facadeMeta = new int[ForgeDirection.VALID_DIRECTIONS.length]; private boolean[] plugs = new boolean[ForgeDirection.VALID_DIRECTIONS.length]; @@ -116,7 +116,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - nbt.setBoolean("redstonePowered", redstonePowered); + nbt.setByte("redstoneInput", (byte)redstoneInput); if (pipe != null) { nbt.setInteger("pipeId", pipe.itemID); @@ -135,7 +135,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - redstonePowered = nbt.getBoolean("redstonePowered"); + redstoneInput = nbt.getByte("redstoneInput"); coreState.pipeId = nbt.getInteger("pipeId"); pipe = BlockGenericPipe.createPipe(coreState.pipeId); diff --git a/common/buildcraft/transport/gates/GateDefinition.java b/common/buildcraft/transport/gates/GateDefinition.java index 0d94acfc..4a37b9da 100644 --- a/common/buildcraft/transport/gates/GateDefinition.java +++ b/common/buildcraft/transport/gates/GateDefinition.java @@ -32,7 +32,7 @@ public final class GateDefinition { 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); + REDSTONE("gate_interface_1.png", 146, 1, false), IRON("gate_interface_2.png", 164, 2, false), 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; diff --git a/common/buildcraft/transport/gates/GateExpansionPulsar.java b/common/buildcraft/transport/gates/GateExpansionPulsar.java index 339b9b90..be7e5f0a 100644 --- a/common/buildcraft/transport/gates/GateExpansionPulsar.java +++ b/common/buildcraft/transport/gates/GateExpansionPulsar.java @@ -15,7 +15,7 @@ import buildcraft.api.gates.IAction; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.Type; -import buildcraft.transport.triggers.ActionEnergyPulser; +import buildcraft.transport.triggers.ActionEnergyPulsar; import buildcraft.transport.triggers.ActionSingleEnergyPulse; import java.util.List; import net.minecraft.nbt.NBTTagCompound; @@ -61,7 +61,7 @@ public class GateExpansionPulsar extends GateExpansionBuildcraft implements IGat @Override public boolean resolveAction(IAction action, int count) { - if (action instanceof ActionEnergyPulser) { + if (action instanceof ActionEnergyPulsar) { enablePulse(count); return true; } else if (action instanceof ActionSingleEnergyPulse) { diff --git a/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java b/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java new file mode 100644 index 00000000..3f098726 --- /dev/null +++ b/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java @@ -0,0 +1,58 @@ +/* + * 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.GateExpansionController; +import buildcraft.api.gates.IGateExpansion; +import buildcraft.BuildCraftTransport; +import buildcraft.api.gates.IAction; +import buildcraft.api.gates.ITrigger; +import buildcraft.api.gates.ITriggerParameter; +import buildcraft.transport.triggers.TriggerClockTimer; +import buildcraft.transport.triggers.TriggerClockTimer.Time; +import java.util.Arrays; +import java.util.List; +import net.minecraft.tileentity.TileEntity; + +/** + * + * @author CovertJaguar + */ +public class GateExpansionRedstoneFader extends GateExpansionBuildcraft implements IGateExpansion { + + public static GateExpansionRedstoneFader INSTANCE = new GateExpansionRedstoneFader(); + + private GateExpansionRedstoneFader() { + super("fader"); + } + + @Override + public GateExpansionController makeController(TileEntity pipeTile) { + return new GateExpansionControllerRedstoneFader(pipeTile); + } + + private class GateExpansionControllerRedstoneFader extends GateExpansionController { + + public GateExpansionControllerRedstoneFader(TileEntity pipeTile) { + super(GateExpansionRedstoneFader.this, pipeTile); + } + + @Override + public void addTriggers(List list) { + super.addTriggers(list); + list.addAll(Arrays.asList(BuildCraftTransport.triggerRedstoneLevel)); + } + + @Override + public void addActions(List list) { + super.addActions(list); + list.addAll(Arrays.asList(BuildCraftTransport.actionRedstoneLevel)); + } + } +} diff --git a/common/buildcraft/transport/gates/GateFactory.java b/common/buildcraft/transport/gates/GateFactory.java index 1781a028..4a9429b8 100644 --- a/common/buildcraft/transport/gates/GateFactory.java +++ b/common/buildcraft/transport/gates/GateFactory.java @@ -88,6 +88,7 @@ public class GateFactory { } Gate gate = makeGate(pipe, material, logic); + gate.readFromNBT(nbt); if (nbt.hasKey("Pulser")) { NBTTagCompound pulsarTag = nbt.getCompoundTag("Pulser"); diff --git a/common/buildcraft/transport/pipes/PipeLogicIron.java b/common/buildcraft/transport/pipes/PipeLogicIron.java index c076c62a..6c6c1e73 100644 --- a/common/buildcraft/transport/pipes/PipeLogicIron.java +++ b/common/buildcraft/transport/pipes/PipeLogicIron.java @@ -45,7 +45,6 @@ public abstract class PipeLogicIron { } } - private boolean isValidFacing(ForgeDirection side) { if (!pipe.container.isPipeConnected(side)) return false; @@ -73,7 +72,7 @@ public abstract class PipeLogicIron { } public boolean setFacing(ForgeDirection facing) { - if (isValidFacing(facing) && facing.ordinal() != pipe.container.getBlockMetadata()) { + if (facing.ordinal() != pipe.container.getBlockMetadata() && isValidFacing(facing)) { pipe.container.worldObj.setBlockMetadataWithNotify(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, facing.ordinal(), 3); pipe.container.scheduleRenderUpdate(); return true; diff --git a/common/buildcraft/transport/triggers/ActionEnergyPulser.java b/common/buildcraft/transport/triggers/ActionEnergyPulsar.java similarity index 54% rename from common/buildcraft/transport/triggers/ActionEnergyPulser.java rename to common/buildcraft/transport/triggers/ActionEnergyPulsar.java index f7e0ce14..e80e4ba1 100644 --- a/common/buildcraft/transport/triggers/ActionEnergyPulser.java +++ b/common/buildcraft/transport/triggers/ActionEnergyPulsar.java @@ -2,11 +2,12 @@ package buildcraft.transport.triggers; import buildcraft.core.triggers.ActionTriggerIconProvider; import buildcraft.core.triggers.BCAction; +import buildcraft.core.utils.StringUtils; -public class ActionEnergyPulser extends BCAction { +public class ActionEnergyPulsar extends BCAction { - public ActionEnergyPulser(int legacyId) { - super(legacyId, "buildcraft.pulser.constant"); + public ActionEnergyPulsar() { + super("buildcraft:pulsar.constant", "buildcraft.pulser.constant"); } @Override @@ -16,7 +17,7 @@ public class ActionEnergyPulser extends BCAction { @Override public String getDescription() { - return "Energy Pulser"; + return StringUtils.localize("gate.action.pulsar.constant"); } } diff --git a/common/buildcraft/transport/triggers/ActionExtractionPreset.java b/common/buildcraft/transport/triggers/ActionExtractionPreset.java index 69dd6af9..cc6ceedc 100644 --- a/common/buildcraft/transport/triggers/ActionExtractionPreset.java +++ b/common/buildcraft/transport/triggers/ActionExtractionPreset.java @@ -20,7 +20,7 @@ public class ActionExtractionPreset extends BCAction { public final EnumColor color; public ActionExtractionPreset(EnumColor color) { - super("buildcraft.extraction.preset." + color.getTag()); + super("buildcraft:extraction.preset." + color.getTag(), "buildcraft.extraction.preset." + color.getTag()); this.color = color; } diff --git a/common/buildcraft/transport/triggers/ActionPipeColor.java b/common/buildcraft/transport/triggers/ActionPipeColor.java index 9a9642bf..d70fbe99 100644 --- a/common/buildcraft/transport/triggers/ActionPipeColor.java +++ b/common/buildcraft/transport/triggers/ActionPipeColor.java @@ -20,7 +20,7 @@ public class ActionPipeColor extends BCAction { public final EnumColor color; public ActionPipeColor(EnumColor color) { - super("buildcraft.pipe." + color.getTag()); + super("buildcraft:pipe.color." + color.getTag(), "buildcraft.pipe." + color.getTag()); this.color = color; } diff --git a/common/buildcraft/transport/triggers/ActionPipeDirection.java b/common/buildcraft/transport/triggers/ActionPipeDirection.java index ead02833..1759a1a3 100644 --- a/common/buildcraft/transport/triggers/ActionPipeDirection.java +++ b/common/buildcraft/transport/triggers/ActionPipeDirection.java @@ -19,7 +19,7 @@ public class ActionPipeDirection extends BCAction { public final ForgeDirection direction; public ActionPipeDirection(ForgeDirection direction) { - super("buildcraft.pipe.dir." + direction.name().toLowerCase(Locale.ENGLISH)); + super("buildcraft:pipe.dir." + direction.name().toLowerCase(Locale.ENGLISH), "buildcraft.pipe.dir." + direction.name().toLowerCase(Locale.ENGLISH)); this.direction = direction; } diff --git a/common/buildcraft/transport/triggers/ActionPowerLimiter.java b/common/buildcraft/transport/triggers/ActionPowerLimiter.java index 2bcfcf4a..cef377e9 100644 --- a/common/buildcraft/transport/triggers/ActionPowerLimiter.java +++ b/common/buildcraft/transport/triggers/ActionPowerLimiter.java @@ -19,7 +19,7 @@ public class ActionPowerLimiter extends BCAction { public final PowerMode limit; public ActionPowerLimiter(PowerMode limit) { - super("buildcraft.power.limiter." + limit.name().toLowerCase(Locale.ENGLISH)); + super("buildcraft:power.limiter." + limit.name().toLowerCase(Locale.ENGLISH), "buildcraft.power.limiter." + limit.name().toLowerCase(Locale.ENGLISH)); this.limit = limit; } diff --git a/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java b/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java new file mode 100644 index 00000000..6ec826fd --- /dev/null +++ b/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) SpaceToad, 2011 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.triggers; + +import buildcraft.core.triggers.BCAction; +import buildcraft.core.utils.StringUtils; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.util.Icon; + +public class ActionRedstoneFaderOutput extends BCAction { + + public final int level; + @SideOnly(Side.CLIENT) + private Icon icon; + + public ActionRedstoneFaderOutput(int level) { + super(String.format("buildcraft:redstone.output.%02d", level)); + + this.level = level; + } + + @Override + public String getDescription() { + return String.format(StringUtils.localize("gate.trigger.redstone.input.level"), level); + } + + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon() { + return icon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister iconRegister) { + icon = iconRegister.registerIcon(String.format("buildcraft:triggers/redstone_%02d", level)); + } +} diff --git a/common/buildcraft/transport/triggers/ActionSignalOutput.java b/common/buildcraft/transport/triggers/ActionSignalOutput.java index 242ac3e5..064f72f0 100644 --- a/common/buildcraft/transport/triggers/ActionSignalOutput.java +++ b/common/buildcraft/transport/triggers/ActionSignalOutput.java @@ -1,58 +1,45 @@ /** - * Copyright (c) SpaceToad, 2011 - * http://www.mod-buildcraft.com + * Copyright (c) SpaceToad, 2011 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 + * 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.triggers; import buildcraft.core.triggers.ActionTriggerIconProvider; import buildcraft.core.triggers.BCAction; -import buildcraft.transport.Pipe; import buildcraft.api.transport.PipeWire; +import buildcraft.core.utils.StringUtils; import java.util.Locale; public class ActionSignalOutput extends BCAction { public PipeWire color; - public ActionSignalOutput(int id, PipeWire color) { - super(id, "buildcraft.pipe.wire.output." + color.name().toLowerCase(Locale.ENGLISH)); + public ActionSignalOutput(PipeWire color) { + super("buildcraft:pipe.wire.output." + color.name().toLowerCase(Locale.ENGLISH), "buildcraft.pipe.wire.output." + color.name().toLowerCase(Locale.ENGLISH)); this.color = color; } @Override public String getDescription() { - switch (color) { - case Red: - return "Red Pipe Signal"; - case Blue: - return "Blue Pipe Signal"; - case Green: - return "Green Pipe Signal"; - case Yellow: - return "Yellow Pipe Signal"; - } - - return ""; + return String.format(StringUtils.localize("gate.action.pipe.wire"), StringUtils.localize("color." + color.name().toLowerCase(Locale.ENGLISH))); } @Override public int getIconIndex() { switch (color) { - case Red: - return ActionTriggerIconProvider.Trigger_PipeSignal_Red_Active; - case Blue: - return ActionTriggerIconProvider.Trigger_PipeSignal_Blue_Active; - case Green: - return ActionTriggerIconProvider.Trigger_PipeSignal_Green_Active; - case Yellow: - default: - return ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Active; + case Red: + return ActionTriggerIconProvider.Trigger_PipeSignal_Red_Active; + case Blue: + return ActionTriggerIconProvider.Trigger_PipeSignal_Blue_Active; + case Green: + return ActionTriggerIconProvider.Trigger_PipeSignal_Green_Active; + case Yellow: + default: + return ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Active; } } } diff --git a/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java b/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java index 9f87b7db..3a8fb045 100644 --- a/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java +++ b/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java @@ -2,20 +2,21 @@ package buildcraft.transport.triggers; import buildcraft.core.triggers.ActionTriggerIconProvider; import buildcraft.core.triggers.BCAction; +import buildcraft.core.utils.StringUtils; public class ActionSingleEnergyPulse extends BCAction { - public ActionSingleEnergyPulse(int legacyId) { - super(legacyId, "buildcraft.pulser.single"); + public ActionSingleEnergyPulse() { + super("buildcraft:pulsar.single", "buildcraft.pulser.single"); } @Override public int getIconIndex() { - return ActionTriggerIconProvider.Trigger_Machine_Active; + return ActionTriggerIconProvider.Trigger_Machine_Active; } - + @Override public String getDescription() { - return "Single Energy Pulse"; + return StringUtils.localize("gate.action.pulsar.single"); } } diff --git a/common/buildcraft/transport/triggers/TriggerClockTimer.java b/common/buildcraft/transport/triggers/TriggerClockTimer.java index 71b5e5b4..f9b88b16 100644 --- a/common/buildcraft/transport/triggers/TriggerClockTimer.java +++ b/common/buildcraft/transport/triggers/TriggerClockTimer.java @@ -14,23 +14,23 @@ public class TriggerClockTimer extends BCTrigger { SHORT(5), MEDIUM(10), LONG(15); public static final Time[] VALUES = values(); public final int delay; - private Icon icon; private Time(int delay) { this.delay = delay; } } public final Time time; + private Icon icon; public TriggerClockTimer(Time time) { - super(-1, "buildcraft.timer." + time.name().toLowerCase(Locale.ENGLISH)); + super("buildcraft:timer." + time.name().toLowerCase(Locale.ENGLISH)); this.time = time; } @Override public Icon getIcon() { - return time.icon; + return icon; } @Override @@ -38,15 +38,8 @@ public class TriggerClockTimer extends BCTrigger { return String.format(StringUtils.localize("gate.trigger.timer"), time.delay); } - @Override - public boolean hasParameter() { - return false; - } - @Override public void registerIcons(IconRegister iconRegister) { - Time.SHORT.icon = iconRegister.registerIcon("buildcraft:triggers/trigger_timer_short"); - Time.MEDIUM.icon = iconRegister.registerIcon("buildcraft:triggers/trigger_timer_medium"); - Time.LONG.icon = iconRegister.registerIcon("buildcraft:triggers/trigger_timer_long"); + icon = iconRegister.registerIcon("buildcraft:triggers/trigger_timer_" + time.name().toLowerCase(Locale.ENGLISH)); } } diff --git a/common/buildcraft/transport/triggers/TriggerPipeContents.java b/common/buildcraft/transport/triggers/TriggerPipeContents.java index fb0035ba..75574c8f 100644 --- a/common/buildcraft/transport/triggers/TriggerPipeContents.java +++ b/common/buildcraft/transport/triggers/TriggerPipeContents.java @@ -19,6 +19,7 @@ import buildcraft.transport.TravelingItem; import buildcraft.transport.pipes.PipePowerWood; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.Locale; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.util.Icon; import net.minecraftforge.common.ForgeDirection; @@ -28,33 +29,30 @@ import net.minecraftforge.fluids.FluidTankInfo; public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { - public enum Kind { + public enum PipeContents { - Empty("buildcraft.pipe.contents.empty"), - ContainsItems("buildcraft.pipe.contents.containsItems"), - ContainsFluids("buildcraft.pipe.contents.containsFluids"), - ContainsEnergy("buildcraft.pipe.contents.containsEnergy"), - RequestsEnergy("buildcraft.pipe.contents.requestsEnergy"), - TooMuchEnergy("buildcraft.pipe.contents.tooMuchEnergy"); - private Icon icon; - public final String tag; - - private Kind(String tag) { - this.tag = tag; - } + empty, + containsItems, + containsFluids, + containsEnergy, + requestsEnergy, + tooMuchEnergy; + public BCTrigger trigger; }; - Kind kind; + private PipeContents kind; + private Icon icon; - public TriggerPipeContents(int id, Kind kind) { - super(id, kind.tag); + public TriggerPipeContents(PipeContents kind) { + super("buildcraft:pipe.contents." + kind.name().toLowerCase(Locale.ENGLISH), "buildcraft.pipe.contents." + kind.name()); this.kind = kind; + kind.trigger = this; } @Override public boolean hasParameter() { switch (kind) { - case ContainsItems: - case ContainsFluids: + case containsItems: + case containsFluids: return true; default: return false; @@ -63,23 +61,7 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { @Override public String getDescription() { - - switch (kind) { - case Empty: - return StringUtils.localize("gate.trigger.pipe.empty"); - case ContainsItems: - return StringUtils.localize("gate.trigger.pipe.containsItems"); - case ContainsFluids: - return StringUtils.localize("gate.trigger.pipe.containsFluids"); - case ContainsEnergy: - return StringUtils.localize("gate.trigger.pipe.containsEnergy"); - case RequestsEnergy: - return StringUtils.localize("gate.trigger.pipe.requestsEnergy"); - case TooMuchEnergy: - return StringUtils.localize("gate.trigger.pipe.tooMuchEnergy"); - } - - return ""; + return StringUtils.localize("gate.trigger.pipe." + kind.name()); } @Override @@ -87,10 +69,10 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { if (pipe.transport instanceof PipeTransportItems) { PipeTransportItems transportItems = (PipeTransportItems) pipe.transport; - if (kind == Kind.Empty) + if (kind == PipeContents.empty) return transportItems.items.isEmpty(); - else if (kind == Kind.ContainsItems) - if (parameter != null && parameter.getItemStack()!= null) { + else if (kind == PipeContents.containsItems) + if (parameter != null && parameter.getItemStack() != null) { for (TravelingItem item : transportItems.items) { if (item.getItemStack().itemID == parameter.getItemStack().itemID && item.getItemStack().getItemDamage() == parameter.getItemStack().getItemDamage()) @@ -107,7 +89,7 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack()); } - if (kind == Kind.Empty) { + if (kind == PipeContents.empty) { for (FluidTankInfo b : transportFluids.getTankInfo(ForgeDirection.UNKNOWN)) { if (b.fluid != null && b.fluid.amount != 0) return false; @@ -127,25 +109,25 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { PipeTransportPower transportPower = (PipeTransportPower) pipe.transport; switch (kind) { - case Empty: + case empty: for (double s : transportPower.displayPower) { if (s > 1e-4) return false; } return true; - case ContainsEnergy: + case containsEnergy: for (double s : transportPower.displayPower) { if (s > 1e-4) return true; } return false; - case RequestsEnergy: + case requestsEnergy: PipePowerWood wood = (PipePowerWood) pipe; return wood.requestsPower(); default: - case TooMuchEnergy: + case tooMuchEnergy: return transportPower.isOverloaded(); } } @@ -155,17 +137,12 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { @Override public Icon getIcon() { - return kind.icon; + return icon; } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { - Kind.Empty.icon = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_empty"); - Kind.ContainsItems.icon = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_containsitems"); - Kind.ContainsFluids.icon = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_containsliquid"); - Kind.ContainsEnergy.icon = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_containsenergy"); - Kind.RequestsEnergy.icon = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_requestsenergy"); - Kind.TooMuchEnergy.icon = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_toomuchenergy"); + icon = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_" + kind.name().toLowerCase(Locale.ENGLISH)); } } diff --git a/common/buildcraft/transport/triggers/TriggerPipeSignal.java b/common/buildcraft/transport/triggers/TriggerPipeSignal.java index eb3db69d..2571f116 100644 --- a/common/buildcraft/transport/triggers/TriggerPipeSignal.java +++ b/common/buildcraft/transport/triggers/TriggerPipeSignal.java @@ -13,6 +13,7 @@ import buildcraft.core.triggers.BCTrigger; import buildcraft.transport.IPipeTrigger; import buildcraft.transport.Pipe; import buildcraft.api.transport.PipeWire; +import buildcraft.core.utils.StringUtils; import java.util.Locale; public class TriggerPipeSignal extends BCTrigger implements IPipeTrigger { @@ -20,8 +21,9 @@ public class TriggerPipeSignal extends BCTrigger implements IPipeTrigger { boolean active; PipeWire color; - public TriggerPipeSignal(int legacyId, boolean active, PipeWire color) { - super(legacyId, "buildcraft.pipe.wire.input." + color.name().toLowerCase(Locale.ENGLISH) + (active ? ".active" : ".inactive")); + public TriggerPipeSignal(boolean active, PipeWire color) { + super("buildcraft:pipe.wire.input." + color.name().toLowerCase(Locale.ENGLISH) + (active ? ".active" : ".inactive"), + "buildcraft.pipe.wire.input." + color.name().toLowerCase(Locale.ENGLISH) + (active ? ".active" : ".inactive")); this.active = active; this.color = color; @@ -34,31 +36,7 @@ public class TriggerPipeSignal extends BCTrigger implements IPipeTrigger { @Override public String getDescription() { - if (active) { - switch (color) { - case Red: - return "Red Pipe Signal On"; - case Blue: - return "Blue Pipe Signal On"; - case Green: - return "Green Pipe Signal On"; - case Yellow: - return "Yellow Pipe Signal On"; - } - } else { - switch (color) { - case Red: - return "Red Pipe Signal Off"; - case Blue: - return "Blue Pipe Signal Off"; - case Green: - return "Green Pipe Signal Off"; - case Yellow: - return "Yellow Pipe Signal Off"; - } - } - - return ""; + return String.format(StringUtils.localize("gate.trigger.pipe.wire." + (active ? "active" : "inactive")), StringUtils.localize("color." + color.name().toLowerCase(Locale.ENGLISH))); } @Override diff --git a/common/buildcraft/transport/triggers/TriggerRedstoneInput.java b/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java similarity index 53% rename from common/buildcraft/transport/triggers/TriggerRedstoneInput.java rename to common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java index 40f6c147..34b14ca5 100644 --- a/common/buildcraft/transport/triggers/TriggerRedstoneInput.java +++ b/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java @@ -9,6 +9,7 @@ package buildcraft.transport.triggers; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.triggers.BCTrigger; +import buildcraft.core.utils.StringUtils; import buildcraft.transport.IPipeTrigger; import buildcraft.transport.Pipe; import cpw.mods.fml.relauncher.Side; @@ -16,50 +17,37 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.util.Icon; -public class TriggerRedstoneInput extends BCTrigger implements IPipeTrigger { +public class TriggerRedstoneFaderInput extends BCTrigger implements IPipeTrigger { - boolean active; + public final int level; @SideOnly(Side.CLIENT) - private Icon iconActive, iconInactive; + private Icon icon; - public TriggerRedstoneInput(int legacyId, boolean active) { - super(legacyId, active ? "buildcraft.redtone.input.active" : "buildcraft.redtone.input.inactive"); + public TriggerRedstoneFaderInput(int level) { + super(String.format("buildcraft:redtone.input.%02d", level)); - this.active = active; + this.level = level; } @Override public String getDescription() { - if (active) - return "Redstone Signal On"; - else - return "Redstone Signal Off"; + return String.format(StringUtils.localize("gate.trigger.redstone.input.level"), level); } @Override public boolean isTriggerActive(Pipe pipe, ITriggerParameter parameter) { - if (active) - return isBeingPowered(pipe); - return !isBeingPowered(pipe); - } - - private boolean isBeingPowered(Pipe pipe) { - return pipe.container.redstonePowered; + return pipe.container.redstoneInput == level; } @Override @SideOnly(Side.CLIENT) public Icon getIcon() { - if (active) - return iconActive; - else - return iconInactive; + return icon; } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { - iconActive = iconRegister.registerIcon("buildcraft:triggers/trigger_redstoneinput_active"); - iconInactive = iconRegister.registerIcon("buildcraft:triggers/trigger_redstoneinput_inactive"); + icon = iconRegister.registerIcon(String.format("buildcraft:triggers/redstone_%02d", level)); } }