Revisión | ca5f1a26bc4df70e3f0092ca91066840e5d5fe09 (tree) |
---|---|
Tiempo | 2012-12-29 12:16:32 |
Autor | mozipi <mozipi@user...> |
Commiter | mozipi |
Merge branch 'master' of git.sourceforge.jp:/gitroot/chemicraft/chemicraft
@@ -284,6 +284,12 @@ public class ChemiCraft { | ||
284 | 284 | new Character('A'), new ItemStack(this.itemAtoms, 1, 0), |
285 | 285 | }); |
286 | 286 | |
287 | + // 化合物を追加します | |
288 | + ChemiCraftAPI.instance.addLangCompound("ja_JP", "CarbonDioxide", "二酸化炭素"); | |
289 | + | |
290 | + // 化合物のレシピを追加します | |
291 | + ChemiCraftAPI.instance.addChemicalCombinationRecipe(new ItemStack[]{new ItemStack(this.itemAtoms, 5), new ItemStack(this.itemAtoms, 7)}, new ItemStack(this.itemCompounds, 0)); | |
292 | + | |
287 | 293 | //手榴弾の追加 |
288 | 294 | ChemiCraftAPI.instance.addSharplessMaterialRecipe(new ItemStack[]{new ItemStack(Item.gunpowder)}, new ItemStack(this.itemAtomGrenade, 16, 0), new NBTRecipeGrenade()); |
289 | 295 |
@@ -5,7 +5,6 @@ import net.minecraft.src.CommandBase; | ||
5 | 5 | import net.minecraft.src.EntityPlayer; |
6 | 6 | import net.minecraft.src.ICommandSender; |
7 | 7 | import net.minecraft.src.World; |
8 | -import setBlockSupport.SetBlockSupport; | |
9 | 8 | |
10 | 9 | public class CommandSetTile extends CommandBase { |
11 | 10 |
@@ -4,8 +4,10 @@ import net.minecraft.src.EntityPlayer; | ||
4 | 4 | import net.minecraft.src.ItemStack; |
5 | 5 | import net.minecraft.src.World; |
6 | 6 | import chemicraft.ChemiCraft; |
7 | +import chemicraft.util.MathHelperPlus; | |
7 | 8 | |
8 | -public class ItemGasCollectingBottle extends ItemAtomInfoContainer { | |
9 | +public class ItemGasCollectingBottle extends ItemAtomInfoContainer | |
10 | +{ | |
9 | 11 | |
10 | 12 | public ItemGasCollectingBottle(int id) { |
11 | 13 | super(id); |
@@ -15,22 +17,54 @@ public class ItemGasCollectingBottle extends ItemAtomInfoContainer { | ||
15 | 17 | } |
16 | 18 | |
17 | 19 | @Override |
18 | - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){ | |
20 | + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) | |
21 | + { | |
19 | 22 | par1ItemStack.damageItem(1, par3EntityPlayer); |
20 | 23 | |
21 | 24 | this.atomInfo.update(par2World, par3EntityPlayer); |
22 | - if(this.atomInfo.isBelowY(129)){ | |
23 | - if (!par3EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 7))) | |
24 | - { | |
25 | - par3EntityPlayer.dropPlayerItem(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 7)); | |
26 | - } | |
27 | - } | |
28 | 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 | + } | |
29 | 55 | return par1ItemStack; |
30 | 56 | } |
31 | 57 | |
58 | + public void isStackOrDrop(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer) | |
59 | + { | |
60 | + if (!par2EntityPlayer.inventory.addItemStackToInventory(par1ItemStack)) { | |
61 | + par2EntityPlayer.dropPlayerItem(par1ItemStack); | |
62 | + } | |
63 | + } | |
64 | + | |
32 | 65 | @Override |
33 | - public String getTextureFile() { | |
66 | + public String getTextureFile() | |
67 | + { | |
34 | 68 | return "/chemicraft/items/items.png"; |
35 | 69 | } |
36 | 70 |
@@ -1,5 +1,7 @@ | ||
1 | 1 | package chemicraft.util; |
2 | 2 | |
3 | +import cpw.mods.fml.common.Side; | |
4 | +import cpw.mods.fml.common.asm.SideOnly; | |
3 | 5 | import net.minecraft.src.EntityPlayer; |
4 | 6 | import net.minecraft.src.World; |
5 | 7 |
@@ -116,6 +118,7 @@ public class AtomInfo { | ||
116 | 118 | * @param par1 |
117 | 119 | * @return 指定されたY軸より高いか |
118 | 120 | */ |
121 | + @SideOnly(Side.CLIENT) | |
119 | 122 | public boolean isOverY(int par1){ |
120 | 123 | if(this.posY >= par1){ |
121 | 124 | return true; |
@@ -131,6 +134,7 @@ public class AtomInfo { | ||
131 | 134 | * @param par1 |
132 | 135 | * @return 指定されたY軸と同等かどうか |
133 | 136 | */ |
137 | + @SideOnly(Side.CLIENT) | |
134 | 138 | public boolean isEquivalentY(int par1){ |
135 | 139 | if(this.posY == par1){ |
136 | 140 | return true; |
@@ -146,6 +150,7 @@ public class AtomInfo { | ||
146 | 150 | * @param par1 |
147 | 151 | * @return 指定されたY軸より低いか |
148 | 152 | */ |
153 | + @SideOnly(Side.CLIENT) | |
149 | 154 | public boolean isBelowY(int par1){ |
150 | 155 | if(this.posY <= par1){ |
151 | 156 | return true; |
@@ -0,0 +1,58 @@ | ||
1 | +package chemicraft.util; | |
2 | + | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.Random; | |
5 | + | |
6 | +public class MathHelperPlus | |
7 | +{ | |
8 | + | |
9 | + public static MathHelperPlus instance = new MathHelperPlus(); | |
10 | + | |
11 | + /** | |
12 | + * Return probability(0~). | |
13 | + */ | |
14 | + public static int Probability(double... par1) | |
15 | + { | |
16 | + ArrayList<Double> var1 = new ArrayList<Double>(); | |
17 | + for (int var2 = 0; var2 < par1.length; var2++){ | |
18 | + var1.add(par1[var2]); | |
19 | + } | |
20 | + return Probability(var1); | |
21 | + } | |
22 | + | |
23 | + public static int Probability(int... par1) | |
24 | + { | |
25 | + ArrayList<Double> var1 = new ArrayList<Double>(); | |
26 | + for (int var2 = 0; var2 < par1.length; var2++){ | |
27 | + var1.add((double)par1[var2]); | |
28 | + } | |
29 | + return Probability(var1); | |
30 | + } | |
31 | + | |
32 | + public static int Probability(ArrayList<Double> par1) | |
33 | + { | |
34 | + Random var2 = new Random(); | |
35 | + int var3 = var2.nextInt(100); | |
36 | + double var4 = 0.0D; | |
37 | + | |
38 | + for (int var5 = 0; var5 < par1.size(); var5++) { | |
39 | + var4 += par1.get(var5); | |
40 | + } | |
41 | + | |
42 | + ArrayList<Double> var6 = new ArrayList<Double>(); | |
43 | + for (int var7 = 0; var7 < par1.size(); var7++) { | |
44 | + var6.add(par1.get(var7) / var4 * 100); | |
45 | + } | |
46 | + | |
47 | + double var8 = 0.0D; | |
48 | + for (int var9 = 0; var9 < var6.size(); var9++) { | |
49 | + if (var3 < var6.get(var9) + var8) { | |
50 | + return var9; | |
51 | + } else { | |
52 | + var8 += var6.get(var9); | |
53 | + } | |
54 | + } | |
55 | + return var3; | |
56 | + } | |
57 | + | |
58 | +} |