OSDN Git Service

Merge branch 'master' of https://scm.sourceforge.jp/gitroot/chemicraft/chemicraft
[chemicraft/chemicraft.git] / common / chemicraft / item / ItemGasCollectingBottle.java
index 9a0906e..b5b7836 100644 (file)
@@ -5,7 +5,8 @@ import net.minecraft.src.ItemStack;
 import net.minecraft.src.World;
 import chemicraft.ChemiCraft;
 
-public class ItemGasCollectingBottle extends ItemAtomInfoContainer {
+public class ItemGasCollectingBottle extends ItemAtomInfoContainer
+{
 
        public ItemGasCollectingBottle(int id) {
                super(id);
@@ -15,22 +16,54 @@ public class ItemGasCollectingBottle extends ItemAtomInfoContainer {
        }
 
        @Override
-       public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){
+       public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
+       {
                par1ItemStack.damageItem(1, par3EntityPlayer);
 
                this.atomInfo.update(par2World, par3EntityPlayer);
-               if(this.atomInfo.isBelowY(129)){
-            if (!par3EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 7)))
-            {
-                par3EntityPlayer.dropPlayerItem(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 7));
-            }
-               }
 
+               int heightValue = par2World.getHeightValue((int) par3EntityPlayer.posX, (int) par3EntityPlayer.posZ);
+
+               int result1 = MathHelperPlus.instance.Probability(99, 1);
+               int result2 = MathHelperPlus.instance.Probability(78, 21, 1);
+               int result3 = MathHelperPlus.instance.Probability(0.032, 0.0018, 0.000012, 0.00052);
+               if (this.atomInfo.isOverY(heightValue)) {
+                       if (result1 == 0) {
+                               if (result2 == 0) {
+                                       this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 6), par3EntityPlayer);
+                               } else if (result2 == 1) {
+                                       this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 7), par3EntityPlayer);
+                               } else {
+                                       this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 17), par3EntityPlayer);
+                               }
+                       } else {
+                               if (result3 == 0) {
+                                       this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemCompounds, 1, 0), par3EntityPlayer);
+                               } else if (result3 == 1) {
+                                       this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 9), par3EntityPlayer);
+                               } else if (result3 == 2) {
+                                       this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemCompounds, 1, 1), par3EntityPlayer);
+                               } else {
+                                       this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 1), par3EntityPlayer);
+                               }
+                       }
+               }
+               if (par2World.isRemote) {
+                       par3EntityPlayer.addChatMessage("result1=" + result1 + " result2=" + result2 + " result3=" + result3);
+               }
                return par1ItemStack;
        }
 
+       public void isStackOrDrop(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer)
+       {
+               if (!par2EntityPlayer.inventory.addItemStackToInventory(par1ItemStack)) {
+                       par2EntityPlayer.dropPlayerItem(par1ItemStack);
+               }
+       }
+
        @Override
-       public String getTextureFile() {
+       public String getTextureFile()
+       {
                return "/chemicraft/items/items.png";
        }