001    import java.util.ArrayList;
002    import java.util.HashSet;
003    import java.util.List;
004    import java.util.Random;
005    import java.util.Set;
006    
007    public class fb extends hr
008    {
009      private boolean a = true;
010      private Set b = new HashSet();
011    
012      public fb(int paramInt1, int paramInt2) {
013        super(paramInt1, paramInt2, mh.n);
014        a(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
015      }
016    
017      public fa d(fv paramfv, int paramInt1, int paramInt2, int paramInt3)
018      {
019        return null;
020      }
021    
022      public boolean a() {
023        return false;
024      }
025    
026      public boolean a(fv paramfv, int paramInt1, int paramInt2, int paramInt3)
027      {
028        return paramfv.d(paramInt1, paramInt2 - 1, paramInt3);
029      }
030    
031      private void g(fv paramfv, int paramInt1, int paramInt2, int paramInt3) {
032        a(paramfv, paramInt1, paramInt2, paramInt3, paramInt1, paramInt2, paramInt3);
033        ArrayList localArrayList = new ArrayList(b);
034        b.clear();
035        for (int i = 0; i < localArrayList.size(); i++) {
036          jq localjq = (jq)localArrayList.get(i);
037          paramfv.h(localjq.a, localjq.b, localjq.c, bi);
038        }
039      }
040    
041      private void a(fv paramfv, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6) {
042        int i = paramfv.b(paramInt1, paramInt2, paramInt3);
043        int j = 0;
044    
045        a = false;
046        boolean bool = paramfv.p(paramInt1, paramInt2, paramInt3);
047        a = true;
048        int k;
049        int m;
050        int n;
051        if (bool) {
052          j = 15;
053        } else {
054          for (k = 0; k < 4; k++) {
055            m = paramInt1;
056            n = paramInt3;
057            if (k == 0) m--;
058            if (k == 1) m++;
059            if (k == 2) n--;
060            if (k == 3) n++;
061    
062            if ((m != paramInt4) || (paramInt2 != paramInt5) || (n != paramInt6)) j = f(paramfv, m, paramInt2, n, j);
063            if ((paramfv.d(m, paramInt2, n)) && (!paramfv.d(paramInt1, paramInt2 + 1, paramInt3))) {
064              if ((m == paramInt4) && (paramInt2 + 1 == paramInt5) && (n == paramInt6)) continue; j = f(paramfv, m, paramInt2 + 1, n, j);
065            } else if ((!paramfv.d(m, paramInt2, n)) && (
066              (m != paramInt4) || (paramInt2 - 1 != paramInt5) || (n != paramInt6))) { j = f(paramfv, m, paramInt2 - 1, n, j);
067            }
068          }
069          if (j > 0) j--; else {
070            j = 0;
071          }
072        }
073         // hMod: Allow redstone wire current changes
074            if (i != j) {
075                j = (Integer) etc.getLoader().callHook(PluginLoader.Hook.REDSTONE_CHANGE, new Object[]{new Block(this.bh, paramInt1, paramInt2, paramInt3), i, j});
076            }
077    
078        if (i != j) {
079          paramfv.i = true;
080          paramfv.c(paramInt1, paramInt2, paramInt3, j);
081          paramfv.b(paramInt1, paramInt2, paramInt3, paramInt1, paramInt2, paramInt3);
082          paramfv.i = false;
083    
084          for (k = 0; k < 4; k++) {
085            m = paramInt1;
086            n = paramInt3;
087            int i1 = paramInt2 - 1;
088            if (k == 0) m--;
089            if (k == 1) m++;
090            if (k == 2) n--;
091            if (k == 3) n++;
092    
093            if (paramfv.d(m, paramInt2, n)) i1 += 2;
094    
095            int i2 = 0;
096            i2 = f(paramfv, m, paramInt2, n, -1);
097            j = paramfv.b(paramInt1, paramInt2, paramInt3);
098            if (j > 0) j--;
099            if ((i2 >= 0) && (i2 != j)) {
100              a(paramfv, m, paramInt2, n, paramInt1, paramInt2, paramInt3);
101            }
102            i2 = f(paramfv, m, i1, n, -1);
103            j = paramfv.b(paramInt1, paramInt2, paramInt3);
104            if (j > 0) j--;
105            if ((i2 >= 0) && (i2 != j)) {
106              a(paramfv, m, i1, n, paramInt1, paramInt2, paramInt3);
107            }
108          }
109    
110          if ((i == 0) || (j == 0)) {
111            b.add(new jq(paramInt1, paramInt2, paramInt3));
112            b.add(new jq(paramInt1 - 1, paramInt2, paramInt3));
113            b.add(new jq(paramInt1 + 1, paramInt2, paramInt3));
114            b.add(new jq(paramInt1, paramInt2 - 1, paramInt3));
115            b.add(new jq(paramInt1, paramInt2 + 1, paramInt3));
116            b.add(new jq(paramInt1, paramInt2, paramInt3 - 1));
117            b.add(new jq(paramInt1, paramInt2, paramInt3 + 1));
118          }
119        }
120      }
121    
122      private void h(fv paramfv, int paramInt1, int paramInt2, int paramInt3) {
123        if (paramfv.a(paramInt1, paramInt2, paramInt3) != bi) return;
124    
125        paramfv.h(paramInt1, paramInt2, paramInt3, bi);
126        paramfv.h(paramInt1 - 1, paramInt2, paramInt3, bi);
127        paramfv.h(paramInt1 + 1, paramInt2, paramInt3, bi);
128        paramfv.h(paramInt1, paramInt2, paramInt3 - 1, bi);
129        paramfv.h(paramInt1, paramInt2, paramInt3 + 1, bi);
130    
131        paramfv.h(paramInt1, paramInt2 - 1, paramInt3, bi);
132        paramfv.h(paramInt1, paramInt2 + 1, paramInt3, bi);
133      }
134    
135      public void e(fv paramfv, int paramInt1, int paramInt2, int paramInt3) {
136        super.e(paramfv, paramInt1, paramInt2, paramInt3);
137        if (paramfv.z) return;
138    
139        g(paramfv, paramInt1, paramInt2, paramInt3);
140        paramfv.h(paramInt1, paramInt2 + 1, paramInt3, bi);
141        paramfv.h(paramInt1, paramInt2 - 1, paramInt3, bi);
142    
143        h(paramfv, paramInt1 - 1, paramInt2, paramInt3);
144        h(paramfv, paramInt1 + 1, paramInt2, paramInt3);
145        h(paramfv, paramInt1, paramInt2, paramInt3 - 1);
146        h(paramfv, paramInt1, paramInt2, paramInt3 + 1);
147    
148        if (paramfv.d(paramInt1 - 1, paramInt2, paramInt3)) h(paramfv, paramInt1 - 1, paramInt2 + 1, paramInt3); else
149          h(paramfv, paramInt1 - 1, paramInt2 - 1, paramInt3);
150        if (paramfv.d(paramInt1 + 1, paramInt2, paramInt3)) h(paramfv, paramInt1 + 1, paramInt2 + 1, paramInt3); else
151          h(paramfv, paramInt1 + 1, paramInt2 - 1, paramInt3);
152        if (paramfv.d(paramInt1, paramInt2, paramInt3 - 1)) h(paramfv, paramInt1, paramInt2 + 1, paramInt3 - 1); else
153          h(paramfv, paramInt1, paramInt2 - 1, paramInt3 - 1);
154        if (paramfv.d(paramInt1, paramInt2, paramInt3 + 1)) h(paramfv, paramInt1, paramInt2 + 1, paramInt3 + 1); else
155          h(paramfv, paramInt1, paramInt2 - 1, paramInt3 + 1);
156      }
157    
158      public void b(fv paramfv, int paramInt1, int paramInt2, int paramInt3) {
159        super.b(paramfv, paramInt1, paramInt2, paramInt3);
160        if (paramfv.z) return;
161    
162        paramfv.h(paramInt1, paramInt2 + 1, paramInt3, bi);
163        paramfv.h(paramInt1, paramInt2 - 1, paramInt3, bi);
164        g(paramfv, paramInt1, paramInt2, paramInt3);
165    
166        h(paramfv, paramInt1 - 1, paramInt2, paramInt3);
167        h(paramfv, paramInt1 + 1, paramInt2, paramInt3);
168        h(paramfv, paramInt1, paramInt2, paramInt3 - 1);
169        h(paramfv, paramInt1, paramInt2, paramInt3 + 1);
170    
171        if (paramfv.d(paramInt1 - 1, paramInt2, paramInt3)) h(paramfv, paramInt1 - 1, paramInt2 + 1, paramInt3); else
172          h(paramfv, paramInt1 - 1, paramInt2 - 1, paramInt3);
173        if (paramfv.d(paramInt1 + 1, paramInt2, paramInt3)) h(paramfv, paramInt1 + 1, paramInt2 + 1, paramInt3); else
174          h(paramfv, paramInt1 + 1, paramInt2 - 1, paramInt3);
175        if (paramfv.d(paramInt1, paramInt2, paramInt3 - 1)) h(paramfv, paramInt1, paramInt2 + 1, paramInt3 - 1); else
176          h(paramfv, paramInt1, paramInt2 - 1, paramInt3 - 1);
177        if (paramfv.d(paramInt1, paramInt2, paramInt3 + 1)) h(paramfv, paramInt1, paramInt2 + 1, paramInt3 + 1); else
178          h(paramfv, paramInt1, paramInt2 - 1, paramInt3 + 1);
179      }
180    
181      private int f(fv paramfv, int paramInt1, int paramInt2, int paramInt3, int paramInt4) {
182        if (paramfv.a(paramInt1, paramInt2, paramInt3) != bi) return paramInt4;
183        int i = paramfv.b(paramInt1, paramInt2, paramInt3);
184        if (i > paramInt4) return i;
185        return paramInt4;
186      }
187    
188      public void b(fv paramfv, int paramInt1, int paramInt2, int paramInt3, int paramInt4) {
189        if (paramfv.z) return;
190        int i = paramfv.b(paramInt1, paramInt2, paramInt3);
191    
192        boolean bool = a(paramfv, paramInt1, paramInt2, paramInt3);
193    
194        if (!bool) {
195          a_(paramfv, paramInt1, paramInt2, paramInt3, i);
196          paramfv.e(paramInt1, paramInt2, paramInt3, 0);
197        } else {
198          g(paramfv, paramInt1, paramInt2, paramInt3);
199        }
200    
201        super.b(paramfv, paramInt1, paramInt2, paramInt3, paramInt4);
202      }
203    
204      public int a(int paramInt, Random paramRandom) {
205        return hg.aA.ba;
206      }
207    
208      public boolean d(fv paramfv, int paramInt1, int paramInt2, int paramInt3, int paramInt4) {
209        if (!a) return false;
210        // hMod: Forced downcast!
211        return b((la)paramfv, paramInt1, paramInt2, paramInt3, paramInt4);
212      }
213    
214      public boolean b(la paramla, int paramInt1, int paramInt2, int paramInt3, int paramInt4) {
215        if (!a) return false;
216        if (paramla.b(paramInt1, paramInt2, paramInt3) == 0) return false;
217    
218        if (paramInt4 == 1) return true;
219    
220        int i = (b(paramla, paramInt1 - 1, paramInt2, paramInt3)) || ((!paramla.d(paramInt1 - 1, paramInt2, paramInt3)) && (b(paramla, paramInt1 - 1, paramInt2 - 1, paramInt3))) ? 1 : 0;
221        int j = (b(paramla, paramInt1 + 1, paramInt2, paramInt3)) || ((!paramla.d(paramInt1 + 1, paramInt2, paramInt3)) && (b(paramla, paramInt1 + 1, paramInt2 - 1, paramInt3))) ? 1 : 0;
222        int k = (b(paramla, paramInt1, paramInt2, paramInt3 - 1)) || ((!paramla.d(paramInt1, paramInt2, paramInt3 - 1)) && (b(paramla, paramInt1, paramInt2 - 1, paramInt3 - 1))) ? 1 : 0;
223        int m = (b(paramla, paramInt1, paramInt2, paramInt3 + 1)) || ((!paramla.d(paramInt1, paramInt2, paramInt3 + 1)) && (b(paramla, paramInt1, paramInt2 - 1, paramInt3 + 1))) ? 1 : 0;
224        if (!paramla.d(paramInt1, paramInt2 + 1, paramInt3)) {
225          if ((paramla.d(paramInt1 - 1, paramInt2, paramInt3)) && (b(paramla, paramInt1 - 1, paramInt2 + 1, paramInt3))) i = 1;
226          if ((paramla.d(paramInt1 + 1, paramInt2, paramInt3)) && (b(paramla, paramInt1 + 1, paramInt2 + 1, paramInt3))) j = 1;
227          if ((paramla.d(paramInt1, paramInt2, paramInt3 - 1)) && (b(paramla, paramInt1, paramInt2 + 1, paramInt3 - 1))) k = 1;
228          if ((paramla.d(paramInt1, paramInt2, paramInt3 + 1)) && (b(paramla, paramInt1, paramInt2 + 1, paramInt3 + 1))) m = 1;
229        }
230    
231        if ((k == 0) && (j == 0) && (i == 0) && (m == 0) && (paramInt4 >= 2) && (paramInt4 <= 5)) return true;
232    
233        if ((paramInt4 == 2) && (k != 0) && (i == 0) && (j == 0)) return true;
234        if ((paramInt4 == 3) && (m != 0) && (i == 0) && (j == 0)) return true;
235        if ((paramInt4 == 4) && (i != 0) && (k == 0) && (m == 0)) return true;
236        return (paramInt4 == 5) && (j != 0) && (k == 0) && (m == 0);
237      }
238    
239      public boolean c()
240      {
241        return a;
242      }
243    
244      public static boolean b(la paramla, int paramInt1, int paramInt2, int paramInt3)
245      {
246        int i = paramla.a(paramInt1, paramInt2, paramInt3);
247        if (i == hr.av.bi) return true;
248        if (i == 0) return false;
249        return hr.m[i].c();
250      }
251    }