OSDN Git Service

ts
[chemicraft/chemicraft.git] / AtomInfo.java
1 package net.minecraft.src.ChemiCraft;
2
3 import net.minecraft.src.EntityPlayer;
4 import net.minecraft.src.ItemStack;
5 import net.minecraft.src.World;
6
7 public class AtomInfo {
8
9         protected static int posX;
10         protected static int posY;
11         protected static int posZ;
12         protected static String biomeName;
13         protected static String weather;
14
15         public AtomInfo(World par1World, EntityPlayer par2EntityPlayer){
16
17                 this.biomeName = par1World.getBiomeGenForCoords(posX, posZ).biomeName;
18
19                 this.posX = (int) par2EntityPlayer.posX; // X\8dÀ\95W
20                 this.posY = (int) par2EntityPlayer.posY; // Y\8dÀ\95W
21                 this.posZ = (int) par2EntityPlayer.posZ; // Z\8dÀ\95W
22
23                 boolean rainy = par1World.isRaining();
24                 boolean thunder = par1World.isThundering();
25                 if (rainy && thunder){ // \89J\8a\8e\82Â\97\8b
26                         this.weather = "THUNDER";
27                 }else if(rainy){ // \89J\82Ü\82½\82Í\90á
28                         this.weather = "RAINY";
29                 }else{ //\90°\82ê
30                         this.weather = "SUNNY";
31                 }
32         }
33
34         /**
35          * Y\8dÀ\95W\82Æ\82Ì\94ä\8ar
36          * @param EntityPlayer EntityPlayer
37          * @param y Y\8dÀ\95W
38          * @param biomeName \83o\83C\83I\81[\83\80\82Ì\96¼\91O(null\82Å\82à\89Â)
39          * @param weather \93V\8bC(null\82Å\82à\89Â)
40          * @param par1 \93ü\8eè\90\94
41          * @param par2 \8eí\97Þ(\83_\83\81\81[\83W\92l)
42          */
43         private boolean equivalentBiome(String biomeName){
44                 boolean ver1 = biomeName != null ? ((this.biomeName == biomeName) ? true : false) : true;
45                 return ver1;
46         }
47         private boolean equivalentWeather(String weather){
48                 boolean ver1 = weather != null ? ((this.weather == weather) ? true : false) : true;
49                 return ver1;
50         }
51
52         protected void overY(EntityPlayer EntityPlayer, int y, String biomeName, String weather, int par1, int par2){
53                 if(this.posY >= y && this.equivalentBiome(biomeName) && this.equivalentWeather(weather)){
54                         if (!EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ChemiCraft.itemAtoms, par1, par2)))
55                         {
56                                 EntityPlayer.dropPlayerItem(new ItemStack(ChemiCraft.itemAtoms.shiftedIndex, par1, par2));
57                         }
58                 }
59         }
60         protected void aboveY(EntityPlayer EntityPlayer, int y, String biomeName, String weather, int par1, int par2){
61                 if(this.posY > y && this.equivalentBiome(biomeName) && this.equivalentWeather(weather)){
62                         if (!EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ChemiCraft.itemAtoms, par1, par2)))
63                         {
64                                 EntityPlayer.dropPlayerItem(new ItemStack(ChemiCraft.itemAtoms.shiftedIndex, par1, par2));
65                         }
66                 }
67         }
68         protected void equivalentY(EntityPlayer EntityPlayer, int y, String biomeName, String weather, int par1, int par2){
69                 if(this.posY == y && this.equivalentBiome(biomeName) && this.equivalentWeather(weather)){
70                         if (!EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ChemiCraft.itemAtoms, par1, par2)))
71                         {
72                                 EntityPlayer.dropPlayerItem(new ItemStack(ChemiCraft.itemAtoms.shiftedIndex, par1, par2));
73                         }
74                 }
75         }
76         protected void lessY(EntityPlayer EntityPlayer, int y, String biomeName, String weather, int par1, int par2){
77                 if(this.posY < y && this.equivalentBiome(biomeName) && this.equivalentWeather(weather)){
78                         if (!EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ChemiCraft.itemAtoms, par1, par2)))
79                         {
80                                 EntityPlayer.dropPlayerItem(new ItemStack(ChemiCraft.itemAtoms.shiftedIndex, par1, par2));
81                         }
82                 }
83         }
84         protected void belowY(EntityPlayer EntityPlayer, int y, String biomeName, String weather, int par1, int par2){
85                 if(this.posY <= y && this.equivalentBiome(biomeName) && this.equivalentWeather(weather)){
86                         if (!EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ChemiCraft.itemAtoms, par1, par2)))
87                         {
88                                 EntityPlayer.dropPlayerItem(new ItemStack(ChemiCraft.itemAtoms.shiftedIndex, par1, par2));
89                         }
90                 }
91         }
92
93 }