OSDN Git Service

f11ef3387181405f33cc5f8e22229f29df82e301
[chemicraft/chemicraft.git] / common / chemicraft / AtomInfo.java
1 package chemicraft;\r
2 \r
3 import net.minecraft.src.EntityPlayer;\r
4 import net.minecraft.src.ItemStack;\r
5 import net.minecraft.src.World;\r
6 \r
7 public class AtomInfo {\r
8 \r
9         protected static int posX;\r
10         protected static int posY;\r
11         protected static int posZ;\r
12         protected static String biomeName;\r
13         protected static String weather;\r
14 \r
15         public AtomInfo(World par1World, EntityPlayer par2EntityPlayer){\r
16 \r
17                 this.biomeName = par1World.getBiomeGenForCoords(posX, posZ).biomeName;\r
18 \r
19                 this.posX = (int) par2EntityPlayer.posX; // X座標\r
20                 this.posY = (int) par2EntityPlayer.posY; // Y座標\r
21                 this.posZ = (int) par2EntityPlayer.posZ; // Z座標\r
22 \r
23                 boolean rainy = par1World.isRaining();\r
24                 boolean thunder = par1World.isThundering();\r
25                 if (rainy && thunder){ // 雨且つ雷\r
26                         this.weather = "THUNDER";\r
27                 }else if(rainy){ // 雨または雪\r
28                         this.weather = "RAINY";\r
29                 }else{ //晴れ\r
30                         this.weather = "SUNNY";\r
31                 }\r
32         }\r
33 \r
34         /**\r
35          * Y座標との比較\r
36          * @param EntityPlayer EntityPlayer\r
37          * @param y Y座標\r
38          * @param biomeName バイオームの名前(nullでも可)\r
39          * @param weather 天気(nullでも可)\r
40          * @param par1 入手数\r
41          * @param par2 種類(ダメージ値)\r
42          */\r
43         private boolean equivalentBiome(String biomeName){\r
44                 boolean ver1 = biomeName != null ? ((this.biomeName == biomeName) ? true : false) : true;\r
45                 return ver1;\r
46         }\r
47         private boolean equivalentWeather(String weather){\r
48                 boolean ver1 = weather != null ? ((this.weather == weather) ? true : false) : true;\r
49                 return ver1;\r
50         }\r
51 \r
52         protected void overY(EntityPlayer EntityPlayer, int y, String biomeName, String weather, int par1, int par2){\r
53                 if(this.posY >= y && this.equivalentBiome(biomeName) && this.equivalentWeather(weather)){\r
54                         if (!EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ChemiCraft.itemAtoms, par1, par2)))\r
55                         {\r
56                                 EntityPlayer.dropPlayerItem(new ItemStack(ChemiCraft.itemAtoms.shiftedIndex, par1, par2));\r
57                         }\r
58                 }\r
59         }\r
60         protected void aboveY(EntityPlayer EntityPlayer, int y, String biomeName, String weather, int par1, int par2){\r
61                 if(this.posY > y && this.equivalentBiome(biomeName) && this.equivalentWeather(weather)){\r
62                         if (!EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ChemiCraft.itemAtoms, par1, par2)))\r
63                         {\r
64                                 EntityPlayer.dropPlayerItem(new ItemStack(ChemiCraft.itemAtoms.shiftedIndex, par1, par2));\r
65                         }\r
66                 }\r
67         }\r
68         protected void equivalentY(EntityPlayer EntityPlayer, int y, String biomeName, String weather, int par1, int par2){\r
69                 if(this.posY == y && this.equivalentBiome(biomeName) && this.equivalentWeather(weather)){\r
70                         if (!EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ChemiCraft.itemAtoms, par1, par2)))\r
71                         {\r
72                                 EntityPlayer.dropPlayerItem(new ItemStack(ChemiCraft.itemAtoms.shiftedIndex, par1, par2));\r
73                         }\r
74                 }\r
75         }\r
76         protected void lessY(EntityPlayer EntityPlayer, int y, String biomeName, String weather, int par1, int par2){\r
77                 if(this.posY < y && this.equivalentBiome(biomeName) && this.equivalentWeather(weather)){\r
78                         if (!EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ChemiCraft.itemAtoms, par1, par2)))\r
79                         {\r
80                                 EntityPlayer.dropPlayerItem(new ItemStack(ChemiCraft.itemAtoms.shiftedIndex, par1, par2));\r
81                         }\r
82                 }\r
83         }\r
84         protected void belowY(EntityPlayer EntityPlayer, int y, String biomeName, String weather, int par1, int par2){\r
85                 if(this.posY <= y && this.equivalentBiome(biomeName) && this.equivalentWeather(weather)){\r
86                         if (!EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ChemiCraft.itemAtoms, par1, par2)))\r
87                         {\r
88                                 EntityPlayer.dropPlayerItem(new ItemStack(ChemiCraft.itemAtoms.shiftedIndex, par1, par2));\r
89                         }\r
90                 }\r
91         }\r
92 \r
93 }\r