OSDN Git Service

素材製作台&手榴弾完成版
authormozipi <mozipi@users.sourceforge.jp>
Sat, 29 Dec 2012 10:01:43 +0000 (19:01 +0900)
committermozipi <mozipi@users.sourceforge.jp>
Sat, 29 Dec 2012 10:01:43 +0000 (19:01 +0900)
common/chemicraft/ChemiCraft.java
common/chemicraft/entity/EntityAtomGrenade.java
common/chemicraft/inventory/InventoryChemicalCraftingNBT.java
common/chemicraft/system/ChemiCraftCraftingManager.java
common/chemicraft/util/ComparatorItemStack.java
common/chemicraft/util/MaterialRecipe.java
common/chemicraft/util/NBTRecipeGrenade.java

index 991b668..db86a69 100644 (file)
@@ -294,7 +294,7 @@ public class ChemiCraft {
                ChemiCraftAPI.instance.addChemicalCombinationRecipe(new ItemStack[]{new ItemStack(this.itemAtoms, 5), new ItemStack(this.itemAtoms, 7)}, new ItemStack(this.itemCompounds, 0));\r
 \r
                //手榴弾の追加\r
-               ChemiCraftAPI.instance.addMaterialRecipe(new ItemStack[]{new ItemStack(Item.gunpowder), new ItemStack(Block.stone)}, new ItemStack(this.itemAtomGrenade, 16, 0), new NBTRecipeGrenade());\r
+               ChemiCraftAPI.instance.addMaterialRecipe(new ItemStack[]{null, new ItemStack(Block.stone), null, new ItemStack(Block.stone), new ItemStack(Item.gunpowder), new ItemStack(Block.stone), null, new ItemStack(Block.stone), null}, new ItemStack(this.itemAtomGrenade, 16, 0), new NBTRecipeGrenade());\r
 \r
        }\r
 \r
index 98823db..ad7e9fa 100644 (file)
@@ -1,6 +1,6 @@
 package chemicraft.entity;
 
-import java.util.List;
+import java.util.Iterator;
 
 import net.minecraft.src.DamageSource;
 import net.minecraft.src.Entity;
@@ -52,10 +52,19 @@ public class EntityAtomGrenade extends EntityThrowable
                        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));
+                       Iterator itr = this.worldObj.getEntitiesWithinAABB(EntityLiving.class, this.boundingBox.expand(30, 30, 30)).iterator();
+                       while(itr.hasNext()){
+                               EntityLiving entity = (EntityLiving) itr.next();
+                               double dx = Math.abs(entity.posX - this.posX);
+                               double dy = Math.abs(entity.posY - this.posY);
+                               double dz = Math.abs(entity.posZ - this.posZ);
+                               int distance = (int)Math.sqrt( Math.pow(dx, 2) + Math.pow(dy, 2) + Math.pow(dz, 2) );
+                               if(30 - distance >= 0){
+                                       entity.addPotionEffect(new PotionEffect(2, (60 + (30 - distance)) * 20, (30 - distance) / 5));
+                                       entity.addPotionEffect(new PotionEffect(4, (60 + (30 - distance)) * 20, (30 - distance) / 5));
+                                       entity.addPotionEffect(new PotionEffect(18, (60 + (30 - distance)) * 20, (30 - distance) / 5));
+                                       entity.addPotionEffect(new PotionEffect(19, (60 + (30 - distance)) * 20, (30 - distance) / 5));
+                               }
                        }
                        this.isDead = true;
                }
index b390bc1..9c21cc2 100644 (file)
@@ -72,6 +72,7 @@ public class InventoryChemicalCraftingNBT implements IInventory {
 
        @Override
        public void onInventoryChanged() {
+               this.eventHandelr.onCraftMatrixChanged(this);
        }
 
        @Override
index 5ecf8c5..a9dbf13 100644 (file)
@@ -144,11 +144,13 @@ public class ChemiCraftCraftingManager {
                        ItemStack resultArg = null;
                        if(result != null){
                                resultArg = new ItemStack(result.itemID, result.stackSize, result.getItemDamage());
-                               ItemStack[] nbtInv = new ItemStack[par3IInventory.getSizeInventory()];
-                               for(int j = 0;j < par3IInventory.getSizeInventory();j++){
-                                       nbtInv[j] = par3IInventory.getStackInSlot(j);
+                               if(api.getMaterialRecipe().get(i).nbtMatch(par1IInventory) != null){
+                                       ItemStack[] nbtInv = new ItemStack[par3IInventory.getSizeInventory()];
+                                       for(int j = 0;j < par3IInventory.getSizeInventory();j++){
+                                               nbtInv[j] = par3IInventory.getStackInSlot(j);
+                                       }
+                                       api.getMaterialRecipe().get(i).nbtMatch(par1IInventory).setNBT(nbtInv, resultArg);
                                }
-                               api.getMaterialRecipe().get(i).nbtMatch(par1IInventory).setNBT(nbtInv, resultArg);
                                returnObj = api.getMaterialRecipe().get(i).nbtMatch(par1IInventory);
                        }
                        par2IInventory.setInventorySlotContents(0, resultArg);
index 27de526..8cc5412 100644 (file)
@@ -11,10 +11,17 @@ public class ComparatorItemStack implements Comparator {
        public int compare(Object o1, Object o2) {
                ItemStack i1 = (ItemStack) o1;
                ItemStack i2 = (ItemStack) o2;
-               if(i1.itemID == i2.itemID){
-                       return i1.getItemDamage() > i2.getItemDamage() ? 1 : -1;
+
+               if(i1 != null && i2 != null){
+                       if(i1.itemID == i2.itemID){
+                               return i1.getItemDamage() > i2.getItemDamage() ? 1 : -1;
+                       }
+                       return i1.itemID > i2.itemID ? 1 : -1;
                }
-               return i1.itemID > i2.itemID ? 1 : -1;
+               if(i1 == null && i2 == null) return 0;
+               if(i1 != null && i2 == null) return -1;
+               if(i1 == null && i2 != null) return 1;
+               return 0;
        }
 
 }
index e36dd78..38561cf 100644 (file)
@@ -29,11 +29,11 @@ public class MaterialRecipe {
                        invItemsArray.add(par1IInventory.getStackInSlot(i));
                }
                invItems = invItemsArray.toArray(new ItemStack[invItemsArray.size()]);
-               invItems = (ItemStack[]) ChemiCraft.instance.arrayAuxiliary.deleteNull(invItems);
 
                if(isSharpless){
                        Arrays.sort(invItems, new ComparatorItemStack());
                        Arrays.sort(this.material, new ComparatorItemStack());
+                       invItems = (ItemStack[]) ChemiCraft.instance.arrayAuxiliary.deleteNull(invItems);
                        if(invItems.length != this.material.length) return null;
                        for(int i = 0;i < this.material.length;i++){
                                if(this.material[i].itemID != invItems[i].itemID) return null;
@@ -61,16 +61,17 @@ public class MaterialRecipe {
                        invItemsArray.add(par1IInventory.getStackInSlot(i));
                }
                invItems = invItemsArray.toArray(new ItemStack[invItemsArray.size()]);
-               invItems = (ItemStack[]) ChemiCraft.instance.arrayAuxiliary.deleteNull(invItems);
 
                if(isSharpless){
                        Arrays.sort(invItems, new ComparatorItemStack());
                        Arrays.sort(this.material, new ComparatorItemStack());
+                       invItems = (ItemStack[]) ChemiCraft.instance.arrayAuxiliary.deleteNull(invItems);
                        if(invItems.length != this.material.length) return null;
                        for(int i = 0;i < this.material.length;i++){
                                if(this.material[i].itemID != invItems[i].itemID) return null;
                                if(this.material[i].getItemDamage() != invItems[i].getItemDamage()) return null;
                        }
+                       System.out.println(this.nbtRecipe);
                        return this.nbtRecipe;
                }else{
                        if(this.material.length != invItems.length) return null;
index 8a04c8e..827e936 100644 (file)
@@ -9,6 +9,32 @@ public class NBTRecipeGrenade extends ChemicalNBTRecipe {
 
        @Override
        public void setNBT(ItemStack[] materials, ItemStack result) {
+               if(result.stackTagCompound == null){
+                       result.stackTagCompound = new NBTTagCompound();
+               }
+
+               if (!result.stackTagCompound.hasKey("Effect"))
+               {
+                       result.stackTagCompound.setTag("Effect", new NBTTagList("Effect"));
+               }
+
+               NBTTagList tagList = (NBTTagList) result.getTagCompound().getTag("Effect");
+               NBTTagCompound tag = new NBTTagCompound();
+
+               for(int i = 0;i < materials.length;i++){
+                       if(materials[i] != null){
+                               if(materials[i].itemID-256 == ChemiCraft.instance.atomsID && materials[i].getItemDamage() == ChemiCraft.HYDROGEN){
+                                       tag.setString("GrenadeEffect" + i, "Hydrogen");
+                               }
+                               if(materials[i].itemID-256 == ChemiCraft.instance.atomsID && materials[i].getItemDamage() == ChemiCraft.CARBON){
+                                       tag.setString("GrenadeEffect" + i, "Carbon");
+                               }
+                               if(materials[i].itemID-256 == ChemiCraft.instance.atomsID && materials[i].getItemDamage() == ChemiCraft.URANIUM){
+                                       tag.setString("GrenadeEffect" + i, "Uranium");
+                               }
+                       }
+               }
+               tagList.appendTag(tag);
 
        }