OSDN Git Service

b5b783648b8f29a1540bfa8005f3b3cefd1a37e4
[chemicraft/chemicraft.git] / common / chemicraft / item / ItemGasCollectingBottle.java
1 package chemicraft.item;
2
3 import net.minecraft.src.EntityPlayer;
4 import net.minecraft.src.ItemStack;
5 import net.minecraft.src.World;
6 import chemicraft.ChemiCraft;
7
8 public class ItemGasCollectingBottle extends ItemAtomInfoContainer
9 {
10
11         public ItemGasCollectingBottle(int id) {
12                 super(id);
13                 this.setMaxStackSize(1);
14                 this.setMaxDamage(2);
15                 this.setCreativeTab(ChemiCraft.instance.creativeTab);
16         }
17
18         @Override
19         public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
20         {
21                 par1ItemStack.damageItem(1, par3EntityPlayer);
22
23                 this.atomInfo.update(par2World, par3EntityPlayer);
24
25                 int heightValue = par2World.getHeightValue((int) par3EntityPlayer.posX, (int) par3EntityPlayer.posZ);
26
27                 int result1 = MathHelperPlus.instance.Probability(99, 1);
28                 int result2 = MathHelperPlus.instance.Probability(78, 21, 1);
29                 int result3 = MathHelperPlus.instance.Probability(0.032, 0.0018, 0.000012, 0.00052);
30                 if (this.atomInfo.isOverY(heightValue)) {
31                         if (result1 == 0) {
32                                 if (result2 == 0) {
33                                         this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 6), par3EntityPlayer);
34                                 } else if (result2 == 1) {
35                                         this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 7), par3EntityPlayer);
36                                 } else {
37                                         this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 17), par3EntityPlayer);
38                                 }
39                         } else {
40                                 if (result3 == 0) {
41                                         this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemCompounds, 1, 0), par3EntityPlayer);
42                                 } else if (result3 == 1) {
43                                         this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 9), par3EntityPlayer);
44                                 } else if (result3 == 2) {
45                                         this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemCompounds, 1, 1), par3EntityPlayer);
46                                 } else {
47                                         this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 1), par3EntityPlayer);
48                                 }
49                         }
50                 }
51                 if (par2World.isRemote) {
52                         par3EntityPlayer.addChatMessage("result1=" + result1 + " result2=" + result2 + " result3=" + result3);
53                 }
54                 return par1ItemStack;
55         }
56
57         public void isStackOrDrop(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer)
58         {
59                 if (!par2EntityPlayer.inventory.addItemStackToInventory(par1ItemStack)) {
60                         par2EntityPlayer.dropPlayerItem(par1ItemStack);
61                 }
62         }
63
64         @Override
65         public String getTextureFile()
66         {
67                 return "/chemicraft/items/items.png";
68         }
69
70 }