OSDN Git Service

素材製作台の減算バグと
authormozipi <mozipi@users.sourceforge.jp>
Sat, 22 Dec 2012 10:32:14 +0000 (19:32 +0900)
committermozipi <mozipi@users.sourceforge.jp>
Sat, 22 Dec 2012 10:32:14 +0000 (19:32 +0900)
分解台のnullバグを修正

手榴弾の投げたときの挙動と
Entityの挙動完成

common/chemicraft/ChemiCraft.java
common/chemicraft/ChemiCraftCraftingManager.java
common/chemicraft/ContainerDecompositionTable.java
common/chemicraft/EntityAtomGrenade.java
common/chemicraft/InventoryMaterialCrafting.java
common/chemicraft/ItemAtomGrenade.java

index 0dd78ee..debd499 100644 (file)
@@ -132,7 +132,7 @@ public class ChemiCraft {
                Property atomsIDProp = cfg.getItem("AtomsID", 25000);\r
                Property compoundsIDProp = cfg.getItem("CompoundsID", 25001);\r
                Property gasCollectingBottleIDProp = cfg.getItem("gasCollectingBottleID", 25002);\r
-               Property atomGrenadeIDProp = cfg.getItem("GrenadeID0", 25003);\r
+               Property atomGrenadeIDProp = cfg.getItem("AtomGrenadeID", 25003);\r
 \r
                Property guiDecompositionTableIDProp = cfg.get("GUI", "GUIChemicalCraftingTableID", 1000);\r
                Property guiChemicalCombinationTableIDProp = cfg.get("GUI", "GUIChemicalCombinationTableID", 1001);\r
@@ -227,6 +227,6 @@ public class ChemiCraft {
        public final static int BORON = 4;\r
        public final static int CARBON = 5;\r
        public final static int NITROGEN = 6;\r
-       public final static int URANIUM = 92;\r
+       public final static int URANIUM = 91;\r
 \r
 }
\ No newline at end of file
index be0d0e1..bc5b9a3 100644 (file)
@@ -198,7 +198,9 @@ public class ChemiCraftCraftingManager {
 
                                if(ChemiCraftAPI.instance.getMaterialNBTRecipe().get(i) != null){
                                        ItemStack[] useItems = ChemiCraftAPI.instance.getMaterialNBTRecipe().get(i).setNBT(effectMaterial.toArray(new ItemStack[3]), result);
-
+                                       for(int j = 0;j < useItems.length;j++){
+                                               System.out.println(useItems[j]);
+                                       }
                                        ((InventoryMaterialCrafting) par1IInventory).subtractStack(0, 3, useItems);
                                }
 
index d0622ee..d0d066a 100644 (file)
@@ -80,8 +80,10 @@ public class ContainerDecompositionTable extends Container {
 
        @Override
        public void onCraftMatrixChanged(IInventory par1IInventory){
-               for(int i = 0;i < ChemiCraftAPI.instance.getCraftingManager().getDecompositionResults(this.inv).length;i++){
-                       this.inv.setInventorySlotContents(i, ChemiCraftAPI.instance.getCraftingManager().getDecompositionResults(this.inv)[i]);
+               if(ChemiCraftAPI.instance.getCraftingManager().getDecompositionResults(this.inv) != null){
+                       for(int i = 0;i < ChemiCraftAPI.instance.getCraftingManager().getDecompositionResults(this.inv).length;i++){
+                               this.inv.setInventorySlotContents(i, ChemiCraftAPI.instance.getCraftingManager().getDecompositionResults(this.inv)[i]);
+                       }
                }
                this.inv.setFlag(true);
        }
index 80c0ea4..9663502 100644 (file)
@@ -1,41 +1,62 @@
 package chemicraft;
 
+import java.util.List;
+
 import net.minecraft.src.DamageSource;
 import net.minecraft.src.Entity;
-import net.minecraft.src.EntityChicken;
 import net.minecraft.src.EntityLiving;
 import net.minecraft.src.EntityThrowable;
 import net.minecraft.src.MovingObjectPosition;
+import net.minecraft.src.PotionEffect;
 import net.minecraft.src.World;
 
 public class EntityAtomGrenade extends EntityThrowable
 {
 
-       private int expSize;
-       private boolean expFire;
-
-       public EntityAtomGrenade(World par1World) {
-               super(par1World);
-       }
+       private float explodeSize;
+       private boolean isExplode;
+       private boolean onFire;
+       private boolean isNuke;
 
-       public EntityAtomGrenade(World par1World, EntityLiving par2EntityLiving) {
+       public EntityAtomGrenade(World par1World, EntityLiving par2EntityLiving, boolean par3, boolean par4, boolean par5) {
                super(par1World, par2EntityLiving);
+               this.isExplode = par3;
+               this.onFire = par4;
+               this.isNuke = par5;
        }
 
-       public EntityAtomGrenade(World par1World, double par2, double par4, double par6) {
-               super(par1World, par2, par4, par6);
+       @Override
+       public void onUpdate(){
+               super.onUpdate();
        }
 
        @Override
        protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
        {
+
+               if(isExplode){
+                       this.explodeSize = 3.0F;
+               }
+
+               if(isNuke){
+                       this.explodeSize = 20.0F;
+               }
+
                if (par1MovingObjectPosition.entityHit != null) {
-                       par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.thrower), 0);
-                       
+                       par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.thrower), 2);
                }
 
-               if (!this.worldObj.isRemote) {
-                       this.worldObj.newExplosion((Entity)null, this.posX, this.posY, this.posZ, expSize, expFire);
+               if (!this.worldObj.isRemote && !isNuke) {
+                       this.worldObj.newExplosion((Entity)null, this.posX, this.posY, this.posZ, explodeSize, onFire);
+                       this.isDead = true;
+               }else if(!this.worldObj.isRemote && isNuke){
+                       this.worldObj.newExplosion((Entity)null, this.posX, this.posY, this.posZ, explodeSize, onFire);
+                       List entity = this.worldObj.getEntitiesWithinAABB(EntityLiving.class, this.boundingBox.expand(20, 20, 20));
+                       for(int i = 0;i < entity.size();i++){
+                               ((EntityLiving)entity.get(i)).addPotionEffect(new PotionEffect(18, 1, 60 * 20));
+                               ((EntityLiving)entity.get(i)).addPotionEffect(new PotionEffect(19, 1, 60 * 20));
+                       }
+                       this.isDead = true;
                }
 
        }
index 7484f3a..cab8232 100644 (file)
@@ -94,7 +94,7 @@ public class InventoryMaterialCrafting implements IInventory {
                if(flag2){
                        for(int i = 0;i < par2;i++){
                                if(par3ItemStack[i] != null){
-                                       if(par3ItemStack[i].stackSize >= 1){
+                                       if(par3ItemStack[i].stackSize > 1){
                                                this.setInventorySlotContents(i, new ItemStack(par3ItemStack[i].itemID, --par3ItemStack[i].stackSize, par3ItemStack[i].getItemDamage()));
                                        }else{
                                                this.setInventorySlotContents(i, null);
index ac384d3..509c0f3 100644 (file)
@@ -2,10 +2,12 @@ package chemicraft;
 
 import java.util.List;
 
+import net.minecraft.src.EntityPlayer;
 import net.minecraft.src.Item;
 import net.minecraft.src.ItemStack;
 import net.minecraft.src.NBTTagCompound;
 import net.minecraft.src.NBTTagList;
+import net.minecraft.src.World;
 
 public class ItemAtomGrenade extends Item {
 
@@ -13,6 +15,37 @@ public class ItemAtomGrenade extends Item {
                super(par1);
        }
 
+       public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){
+               if(par1ItemStack.stackSize <= 0){
+                       return null;
+               }
+
+               boolean var1 = false;
+               boolean var2 = false;
+               boolean var3 = false;
+
+               NBTTagList var4 = par1ItemStack.getTagCompound().getTagList("Effect");
+
+               for(int i = 0;i < 3;i++){
+                       if(!((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("")){
+                               if(((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Hydrogen")){
+                                       var1 = true;
+                               }
+                               if(((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Carbon")){
+                                       var2 = true;
+                               }
+                               if(((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Uranium")){
+                                       var3 = true;
+                               }
+                       }
+               }
+
+               EntityAtomGrenade entity = new EntityAtomGrenade(par2World, par3EntityPlayer, var1, var2, var3);
+               par2World.spawnEntityInWorld(entity);
+               par1ItemStack.stackSize--;
+               return par1ItemStack;
+       }
+
        @Override
        public void addInformation(ItemStack par1ItemStack, List par2List) {
                NBTTagList var1 = par1ItemStack.getTagCompound().getTagList("Effect");