OSDN Git Service

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