OSDN Git Service

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