OSDN Git Service

修正・変更
authorponkotate <ponkotate@users.sourceforge.jp>
Fri, 19 Apr 2013 11:39:35 +0000 (20:39 +0900)
committerponkotate <ponkotate@users.sourceforge.jp>
Fri, 19 Apr 2013 11:39:35 +0000 (20:39 +0900)
・Formulaクラス修正
・AtomsGrenadeをディスペンサーで撃てるようにした

common/pcc/chemicraft/base/ChemiCraftBase.java
common/pcc/chemicraft/base/ChemiCraftRegisterBaseRecipe.java
common/pcc/chemicraft/base/dispenser/DispenserBehaviorAtomsGrenade.java [new file with mode: 0644]
common/pcc/chemicraft/base/entity/EntityAtomsGrenade.java
common/pcc/chemicraft/base/ore/ItemAtomIngots.java
common/pcc/chemicraft/core/item/ItemAtoms.java
common/pcc/chemicraft/testcase/FormulaTest.java
common/pcc/chemicraft/util/Formula.java

index ffb1368..7359b95 100644 (file)
@@ -5,6 +5,7 @@ import java.util.Iterator;
 import java.util.List;
 
 import net.minecraft.block.Block;
+import net.minecraft.block.BlockDispenser;
 import net.minecraft.creativetab.CreativeTabs;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
@@ -16,6 +17,7 @@ import pcc.chemicraft.ChemiCraftConfiguration;
 import pcc.chemicraft.ChemiCraftRegister;
 import pcc.chemicraft.EnumLoggingType;
 import pcc.chemicraft.base.creativetab.CreativeTabAtomOres;
+import pcc.chemicraft.base.dispenser.DispenserBehaviorAtomsGrenade;
 import pcc.chemicraft.base.system.CommonProxy;
 import pcc.chemicraft.base.system.PacketHandler;
 import pcc.chemicraft.core.ChemiCraftCore;
@@ -203,6 +205,9 @@ public class ChemiCraftBase extends ChemiCraft {
                this.registerChemicalRecipe.start();
                this.registerRecipe.start();
                this.registerEntitys.start();
+
+               BlockDispenser.dispenseBehaviorRegistry.putObject(this.itemAtomGrenade, new DispenserBehaviorAtomsGrenade());
+
        }
 
        private void apiProcessing(final FMLPostInitializationEvent event) {
@@ -235,6 +240,7 @@ public class ChemiCraftBase extends ChemiCraft {
                                                ingotsName.get(i)
                                                );
                                                */
+
                        }
                }
 
index ed3df5b..049fab4 100644 (file)
@@ -50,7 +50,7 @@ public class ChemiCraftRegisterBaseRecipe extends ChemiCraftBaseRegister {
                this.mod.api.addPyrolysisDecompositionRecipe(new ItemStack(Block.oreCoal),
                                new Formula("C"));
 
-               this.mod.api.addPyrolysisDecompositionRecipe(new ItemStack(Item.coal),
+               this.mod.api.addReversibleOfPyrolysis(new ItemStack(Item.coal),
                                new Formula("C"));
 
                this.mod.api.addPyrolysisDecompositionRecipe(new ItemStack(Block.oreIron),
@@ -59,7 +59,7 @@ public class ChemiCraftRegisterBaseRecipe extends ChemiCraftBaseRegister {
                this.mod.api.addPyrolysisDecompositionRecipe(new ItemStack(Item.ingotIron),
                                new Formula("Fe"));
 
-               this.mod.api.addPyrolysisDecompositionRecipe(new ItemStack(Block.blockSteel),
+               this.mod.api.addReversibleOfPyrolysis(new ItemStack(Block.blockSteel),
                                new Formula("9Fe"));
 
                this.mod.api.addPyrolysisDecompositionRecipe(new ItemStack(Block.oreGold),
diff --git a/common/pcc/chemicraft/base/dispenser/DispenserBehaviorAtomsGrenade.java b/common/pcc/chemicraft/base/dispenser/DispenserBehaviorAtomsGrenade.java
new file mode 100644 (file)
index 0000000..21d4561
--- /dev/null
@@ -0,0 +1,16 @@
+package pcc.chemicraft.base.dispenser;
+
+import net.minecraft.dispenser.BehaviorProjectileDispense;
+import net.minecraft.dispenser.IPosition;
+import net.minecraft.entity.IProjectile;
+import net.minecraft.world.World;
+import pcc.chemicraft.base.entity.EntityAtomsGrenade;
+
+public class DispenserBehaviorAtomsGrenade extends BehaviorProjectileDispense {
+
+       @Override
+       protected IProjectile getProjectileEntity(World par1World, IPosition par2IPosition) {
+               return new EntityAtomsGrenade(par1World, par2IPosition.getX(), par2IPosition.getY(), par2IPosition.getZ(), true, true, true);
+       }
+
+}
index 6d90d89..2338d3b 100644 (file)
@@ -32,6 +32,13 @@ public class EntityAtomsGrenade extends EntityThrowable {
                this.isNuke = par5;
        }
 
+       public EntityAtomsGrenade(World par1World, double par2, double par3, double par4, boolean par5, boolean par6, boolean par7) {
+               super(par1World, par2, par3, par4);
+               this.isExplode = par5;
+               this.onFire = par6;
+               this.isNuke = par7;
+       }
+
        @Override
        public void onUpdate() {
                super.onUpdate();
index 8394ab2..98f7078 100644 (file)
@@ -32,9 +32,9 @@ public class ItemAtomIngots extends Item {
        @SideOnly(Side.CLIENT)
        @Override
        public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List){
-               for(int type = 0; type < ChemiCraftBaseAPI.instance().getAtomOresAtomName().size(); type++)
+               for(int i = 0; i < ChemiCraftBaseAPI.instance().getAtomOresAtomName().size(); i++)
                {
-                       par3List.add(new ItemStack(par1, 1, type));
+                       par3List.add(new ItemStack(par1, 1, i));
                }
        }
 
index d6838f1..6ac63e8 100644 (file)
@@ -20,6 +20,7 @@ import cpw.mods.fml.relauncher.SideOnly;
 
 public class ItemAtoms extends Item {
 
+       @SideOnly(Side.CLIENT)
        private Icon[] icons;
 
        public ItemAtoms(int par1){
index 31f2a43..cc6558e 100644 (file)
@@ -1,3 +1,4 @@
+/*
 package pcc.chemicraft.testcase;
 
 import static org.junit.Assert.*;
@@ -79,3 +80,4 @@ public class FormulaTest extends Formula {
        }
 
 }
+*/
index 0250b77..620f06c 100644 (file)
@@ -39,7 +39,7 @@ public class Formula {
                for (int i = 0; i < var2.length; i++) {
                        if (var2[i] == '・') {
                                if (this.lastSpell != null) {
-                                       setAtom(this.lastSpell, this.magnification);
+                                       setAtom(this.lastSpell, 1);
                                }
                                setAtoms(new Formula(new String(var2, ++i, var2.length - i)));
                                return;
@@ -47,8 +47,8 @@ public class Formula {
                                // 括弧対応はまだ未完成です。 --WIP--
                        } else if (Character.isDigit(var2[i])) {
                                if (this.lastIndex > 0) {
-                                       this.amonts.set(this.amonts.size() - 1, this.magnification
-                                                       * (this.lastIndex = this.lastIndex * 10 + Integer.valueOf(Character.toString(var2[i]))));
+                                       this.amonts.set(this.amonts.size() - 1,
+                                                       this.lastIndex = this.lastIndex * 10 + Integer.valueOf(Character.toString(var2[i])));
                                } else if (this.lastSpell != null) {
                                        setAtom(this.lastSpell, this.lastIndex = Integer.valueOf(Character.toString(var2[i])));
                                } else {
@@ -58,7 +58,7 @@ public class Formula {
                        } else if (Character.isLetter(var2[i])) {
                                if (Character.isUpperCase(var2[i])) {
                                        if (this.lastSpell != null) {
-                                               setAtom(this.lastSpell, this.magnification);
+                                               setAtom(this.lastSpell, 1);
                                        }
                                        this.lastSpell = Character.toString(var2[i]);
                                } else if (Character.isLowerCase(var2[i])) {
@@ -66,16 +66,15 @@ public class Formula {
                                                throw new IllegalArgumentException();
                                        }
                                        this.lastSpell = this.lastSpell.concat(Character.toString(var2[i]));
-
-                                       if (var2.length <= i + 1) {
-                                               setAtom(this.lastSpell, this.magnification);
-                                       }
                                }
                                this.lastIndex = 0;
                        } else {
                                throw new IllegalArgumentException();
                        }
                }
+               if (this.lastSpell != null) {
+                       setAtom(this.lastSpell, 1);
+               }
        }
 
        public boolean isAtom(String par1) {
@@ -89,6 +88,7 @@ public class Formula {
 
        public void setAtom(String par1,  int par2) {
                if (isAtom(par1)) {
+                       par2 *= this.magnification;
                        int var3 = this.atoms.indexOf(par1);
                        if (var3 == -1) {
                                this.atoms.add(par1);