1 package chemicraft.item;
3 import net.minecraft.src.Block;
4 import net.minecraft.src.BlockFire;
5 import net.minecraft.src.EntityPlayer;
6 import net.minecraft.src.ItemStack;
7 import net.minecraft.src.World;
8 import chemicraft.ChemiCraft;
9 import chemicraft.ChemiCraftAPI;
10 import chemicraft.util.MathHelperPlus;
12 public class ItemGasCollectingBottle extends ItemAtomInfoContainer
15 public ItemGasCollectingBottle(int id) {
17 this.setMaxStackSize(1);
19 this.setCreativeTab(ChemiCraft.instance.creativeTab);
23 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
25 par1ItemStack.damageItem(1, par3EntityPlayer);
27 this.atomInfo.update(par2World, par3EntityPlayer);
29 int heightValue = par2World.getHeightValue((int) par3EntityPlayer.posX, (int) par3EntityPlayer.posZ);
31 int result1 = MathHelperPlus.probability(99, 1);
32 int result2 = MathHelperPlus.probability(78, 21, 1);
33 int result3 = MathHelperPlus.probability(0.032, 0.0018, 0.000012, 0.00052);
34 if (this.atomInfo.isOverY(heightValue)) {
37 this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 6), par3EntityPlayer);
38 } else if (result2 == 1) {
39 this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 7), par3EntityPlayer);
41 this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 17), par3EntityPlayer);
45 this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemCompounds, 1, ChemiCraftAPI.instance.getCompound("CarbonDioxide")), par3EntityPlayer);
46 } else if (result3 == 1) {
47 this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 9), par3EntityPlayer);
48 } else if (result3 == 2) {
49 this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemCompounds, 1, 1), par3EntityPlayer);
51 this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 1), par3EntityPlayer);
57 if (par2World.isRemote) {
58 par3EntityPlayer.addChatMessage("result1=" + result1 + " result2=" + result2 + " result3=" + result3);
64 public void isStackOrDrop(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer)
66 if (!par2EntityPlayer.inventory.addItemStackToInventory(par1ItemStack)) {
67 par2EntityPlayer.dropPlayerItem(par1ItemStack);
72 public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
74 int var11 = par3World.getBlockId(par4, par5, par6);
75 Block block = Block.blocksList[var11];
77 if (block instanceof BlockFire){
78 par1ItemStack.damageItem(1, par2EntityPlayer);
80 int result1 = MathHelperPlus.probability(99, 1);
83 this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemCompounds, 1, ChemiCraftAPI.instance.getCompound("CarbonDioxide")), par2EntityPlayer);
85 this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 17), par2EntityPlayer);
94 public String getTextureFile()
96 return "/chemicraft/items/items.png";