OSDN Git Service

b6ab74ebbce34edce60fe34a58c9260580388825
[chemicraft/chemicraft.git] / common / pcc / chemicraft / util / AtomInfo.java
1 package pcc.chemicraft.util;
2
3 import pcc.chemicraft.util.Auxiliary.Probability;
4 import net.minecraft.block.Block;
5 import net.minecraft.entity.player.EntityPlayer;
6 import net.minecraft.world.World;
7 import cpw.mods.fml.common.registry.LanguageRegistry;
8 import cpw.mods.fml.relauncher.Side;
9 import cpw.mods.fml.relauncher.SideOnly;
10
11 /**
12  * いろいろなデータを格納しメソッドによってチェックするクラス
13  * 使用する場合はItemAtomInfoContainerを継承することを推奨
14  * @author ponkotate
15  *
16  */
17 public final class AtomInfo {
18
19         /**
20          * 気体
21          */
22         public static final Integer[] GASES = new Integer[]{
23                 1, 2, 7, 8, 9, 10, 17, 18, 36, 54, 86
24         };
25
26
27         /**
28          * 液体
29          */
30         public static final Integer[] LIQUIDS = new Integer[]{
31                 35, 80
32         };
33
34
35         /**
36          * 不明
37          */
38         public static final Integer[] UNKNOWN = new Integer[]{
39                 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118
40         };
41
42
43         public static final Integer[] LANTHANOID = new Integer[]{
44                 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71
45         };
46
47
48         public static final Integer[] ACTINOID = new Integer[]{
49                 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103
50         };
51
52
53         public static final Integer[] UNOFFICIAL = new Integer[]{
54                 113, 114, 115, 116, 117, 118
55         };
56
57
58         /**
59          * X, Y, Z座標
60          */
61         private  int posX;
62         private  int posY;
63         private  int posZ;
64
65
66         /**
67          * biomeの名前
68          */
69         private  String biomeName;
70
71
72         /**
73          * 天候
74          */
75         private  String weather;
76
77
78         /**
79          * EntityPlayerのインスタンス
80          */
81         private EntityPlayer entityPlayer;
82
83
84         /**
85          * Worldのインスタンス
86          */
87         private World world;
88
89
90
91         /**
92          * AtomInfoのデータをupdateします
93          * @param par1World Worldのインスタンス
94          * @param par2EntityPlayer EntityPlayerのインスタンス
95          */
96         public void update(World par1World, EntityPlayer par2EntityPlayer){
97                 //this.world = par1World;
98                 //this.entityPlayer = par2EntityPlayer;
99
100                 this.posX = (int) par2EntityPlayer.posX;
101                 this.posY = (int) par2EntityPlayer.posY;
102                 this.posZ = (int) par2EntityPlayer.posZ;
103
104                 this.biomeName = par1World.getBiomeGenForCoords(posX, posZ).biomeName;
105
106                 if (par1World.isThundering()){
107                         this.weather = "Thunder";
108                 }else if(par1World.isRaining()){
109                         this.weather = "Rain";
110                 }else{
111                         this.weather = "Sun";
112                 }
113         }
114
115
116
117         public static boolean isGas(int par1){
118                 for (int var2:GASES){
119                         if (par1 == var2){
120                                 return true;
121                         }
122                 }
123                 return false;
124         }
125
126
127
128         public static boolean isLiquid(int par1){
129                 for (int var2:LIQUIDS){
130                         if (par1 == var2){
131                                 return true;
132                         }
133                 }
134                 return false;
135         }
136
137
138
139         public static boolean isSolid(int par1){
140                 if (!isGas(par1) && !isLiquid(par1) && !isUnknown(par1)){
141                         return true;
142                 }
143                 return false;
144         }
145
146
147
148         public static boolean isUnknown(int par1){
149                 for (int var2:UNKNOWN){
150                         if (par1 == var2){
151                                 return true;
152                         }
153                 }
154                 return false;
155         }
156
157
158
159         public static boolean isLanthanoid(int par1){
160                 for (int var2:LANTHANOID){
161                         if (par1 == var2){
162                                 return true;
163                         }
164                 }
165                 return false;
166         }
167
168
169
170         public static boolean isActinoid(int par1){
171                 for (int var2:ACTINOID){
172                         if (par1 == var2){
173                                 return true;
174                         }
175                 }
176                 return false;
177         }
178
179
180
181         public static boolean isUnofficial(int par1){
182                 for (int var2:UNOFFICIAL){
183                         if (par1 == var2){
184                                 return true;
185                         }
186                 }
187                 return false;
188         }
189
190
191
192         public static boolean isRI(int par1){
193                 return collapseUraniumSeries(par1) != -1;
194         }
195
196
197
198         public static int collapseUraniumSeries(int par1){
199                 int var1 = 0;
200                 Probability var2 = new Probability();
201                 switch (par1){
202                         case 92:
203                                 var1 = 90;
204                                 break;
205                         case 91:
206                                 var1 = 92;
207                                 break;
208                         case 90:
209                                 switch (var2.getProbability(1, 1)){
210                                         case 0:
211                                                 var1 = 91;
212                                                 break;
213                                         case 1:
214                                                 var1 = 88;
215                                                 break;
216                                 }
217                                 break;
218                         case 88:
219                                 var1 = 86;
220                                 break;
221                         case 86:
222                                 var1 = 84;
223                                 break;
224                         case 85:
225                                 switch (var2.getProbability(1, 1)){
226                                         case 0:
227                                                 var1 = 86;
228                                                 break;
229                                         case 1:
230                                                 var1 = 83;
231                                                 break;
232                                 }
233                                 break;
234                         case 84:
235                                 switch (var2.getProbability(1, 1)){
236                                         case 0:
237                                                 var1 = 85;
238                                                 break;
239                                         case 1:
240                                                 var1 = 82;
241                                                 break;
242                                 }
243                                 break;
244                         case 83:
245                                 switch (var2.getProbability(1, 1)){
246                                         case 0:
247                                                 var1 = 84;
248                                                 break;
249                                         case 1:
250                                                 var1 = 81;
251                                                 break;
252                                 }
253                                 break;
254                         case 82:
255                                 switch (var2.getProbability(1, 1)){
256                                         case 0:
257                                                 var1 = 83;
258                                                 break;
259                                         case 1:
260                                                 var1 = 80;
261                                                 break;
262                                 }
263                                 break;
264                         case 81:
265                                 var1 = 82;
266                                 break;
267                         case 80:
268                                 var1 = 81;
269                                 break;
270                         default:
271                                 return -1;
272                 }
273                 return var1;
274         }
275
276
277
278         public static boolean isExisting(String par1){
279                 return false;
280         }
281
282
283
284         /**
285          * 引数に指定されたBiomeと同等か比較します
286          * @param biomeName 比較するBiomeの名前
287          * @return Biomeが一致しているか
288          */
289         public boolean isEquivalentBiome(String biomeName){
290                 if(this.biomeName != null){
291                         if(this.biomeName.equals(biomeName)){
292                                 return true;
293                         }else{
294                                 return false;
295                         }
296                 }else{
297                         System.err.println("AtonInfo:データが入っていません。updateメソッドでデータを入れてください");
298                         return false;
299                 }
300         }
301
302
303
304         /**
305          * 引数に指定された天候と同等か比較します
306          * 晴れ:Sun, 雨:Rain, 雷雨:Thunder
307          * @param weather 比較する天候
308          * @return 天候が一致しているか
309          */
310         public boolean isEquivalentWeather(String weather){
311                 if(this.weather != null){
312                         if(this.weather.equals(weather)){
313                                 return true;
314                         }else{
315                                 return false;
316                         }
317                 }else{
318                         System.err.println("AtonInfo:データが入っていません。updateメソッドでデータを入れてください");
319                         return false;
320                 }
321         }
322
323
324
325         /**
326          * 引数に指定されたY軸より高いか判定します
327          * @param par1
328          * @return 指定されたY軸より高いか
329          */
330         @SideOnly(Side.CLIENT)
331         public boolean isOverY(int par1){
332                 if(this.posY >= par1){
333                         return true;
334                 }else{
335                         return false;
336                 }
337         }
338
339
340
341         /**
342          * 引数に指定されたY軸と同等か判定します
343          * @param par1
344          * @return 指定されたY軸と同等かどうか
345          */
346         @SideOnly(Side.CLIENT)
347         public boolean isEquivalentY(int par1){
348                 if(this.posY == par1){
349                         return true;
350                 }else{
351                         return false;
352                 }
353         }
354
355
356
357         /**
358          * 引数に指定されたY軸より低いか判定します
359          * @param par1
360          * @return 指定されたY軸より低いか
361          */
362         @SideOnly(Side.CLIENT)
363         public boolean isBelowY(int par1){
364                 if(this.posY <= par1){
365                         return true;
366                 }else{
367                         return false;
368                 }
369         }
370
371 }