OSDN Git Service

放射線銃完成
authormozipi <mozipi@users.sourceforge.jp>
Sun, 10 Mar 2013 06:48:58 +0000 (15:48 +0900)
committermozipi <mozipi@users.sourceforge.jp>
Sun, 10 Mar 2013 06:48:58 +0000 (15:48 +0900)
common/pcc/chemicraft/ChemiCraft.java
common/pcc/chemicraft/item/ItemRadiationBallet.java [new file with mode: 0644]
common/pcc/chemicraft/item/ItemRadiationGun.java [new file with mode: 0644]
resources/pcc/chemicraft/items/items.png

index bb32218..8a7d951 100644 (file)
@@ -30,6 +30,8 @@ import pcc.chemicraft.item.ItemChemiCell;
 import pcc.chemicraft.item.ItemCompounds;
 import pcc.chemicraft.item.ItemDust;
 import pcc.chemicraft.item.ItemGasCollectingBottle;
+import pcc.chemicraft.item.ItemRadiationBallet;
+import pcc.chemicraft.item.ItemRadiationGun;
 import pcc.chemicraft.ore.BlockAtomOres;
 import pcc.chemicraft.ore.ItemAtomOres;
 import pcc.chemicraft.system.CommonProxy;
@@ -106,6 +108,9 @@ public class ChemiCraft implements Runnable {
        public int gasCollectingBottleID;
        public int atomGrenadeID;
        public int chemicalCellsID;
+       public int dustID;
+       public int radiationGunID;
+       public int radiationBalletID;
 
        /**
         * BlockID.
@@ -147,6 +152,8 @@ public class ChemiCraft implements Runnable {
        public Item itemAtomGrenade;
        public Item itemChemicalCells;
        public Item itemDust;
+       public Item itemRadiationGun;
+       public Item itemRadiationBallet;
 
        /**
         * このmodで使用するTextureのパス.
@@ -206,6 +213,9 @@ public class ChemiCraft implements Runnable {
                Property gasCollectingBottleIDProp = cfg.getItem("gasCollectingBottleID", 25002);
                Property atomGrenadeIDProp = cfg.getItem("AtomGrenadeID", 25003);
                Property chemicalCellsIDProp = cfg.getItem("ChemicalCellID", 25004);
+               Property dustIDProp = cfg.getItem("DustID", 25005);
+               Property radiationGunIDProp = cfg.getItem("RadiationGunID", 25006);
+               Property radiationBalletIDProp = cfg.getItem("RadiationBalletID", 25007);
 
                Property guiPyrolysisTableIDProp = cfg.get("GUI", "GUIPyrolysisID", 1000);
                Property guiElectrolysisTableIDProp = cfg.get("GUI", "GUIElectrolysisTableIDProp", 1001);
@@ -228,6 +238,9 @@ public class ChemiCraft implements Runnable {
                this.gasCollectingBottleID = gasCollectingBottleIDProp.getInt();
                this.atomGrenadeID = atomGrenadeIDProp.getInt();
                this.chemicalCellsID = chemicalCellsIDProp.getInt();
+               this.dustID = dustIDProp.getInt();
+               this.radiationGunID = radiationGunIDProp.getInt();
+               this.radiationBalletID = radiationBalletIDProp.getInt();
 
                this.guiPyrolysisTableID = guiPyrolysisTableIDProp.getInt();
                this.guiElectrolysisTableID = guiElectrolysisTableIDProp.getInt();
@@ -323,6 +336,9 @@ public class ChemiCraft implements Runnable {
                this.itemAtomGrenade = new ItemAtomsGrenade(this.atomGrenadeID).setItemName("grenade").setIconIndex(1);
                this.itemChemicalCells = new ItemChemiCell(this.chemicalCellsID).setItemName("chemiCell").setIconIndex(3);
                this.itemDust = new ItemDust(15000).setItemName("dust").setIconIndex(12);
+               this.itemRadiationGun = new ItemRadiationGun(this.radiationGunID).setIconIndex(4).setItemName("RadiationGun");
+               this.itemRadiationBallet = new ItemRadiationBallet(this.radiationBalletID).setIconIndex(5).setItemName("RadiationBallet");
+
 
                // BlockをMinecraftに登録します
                GameRegistry.registerBlock(this.blockPyrolysisTable, "BlockPyrolysisTable");
@@ -352,6 +368,10 @@ public class ChemiCraft implements Runnable {
                this.nameAuxiliary.addName(this.itemAtomGrenade, "ja_JP", "元素手榴弾");
                this.nameAuxiliary.addName(this.itemDust, "dust");
                this.nameAuxiliary.addName(this.itemDust, "ja_JP", "粉塵");
+               this.nameAuxiliary.addName(this.itemRadiationGun, "RadiationGun");
+               this.nameAuxiliary.addName(this.itemRadiationGun, "ja_JP", "放射線銃");
+               this.nameAuxiliary.addName(this.itemRadiationBallet, "RadiationBallet");
+               this.nameAuxiliary.addName(this.itemRadiationGun, "ja_JP", "放射線弾");
 
                // TileEntityを追加します
                GameRegistry.registerTileEntity(TileEntityPyrolysisTable.class, "TileEntityPyrolysisTable");
diff --git a/common/pcc/chemicraft/item/ItemRadiationBallet.java b/common/pcc/chemicraft/item/ItemRadiationBallet.java
new file mode 100644 (file)
index 0000000..f9fbc2a
--- /dev/null
@@ -0,0 +1,19 @@
+package pcc.chemicraft.item;
+
+import pcc.chemicraft.ChemiCraft;
+import net.minecraft.item.Item;
+
+public class ItemRadiationBallet extends Item {
+
+       public ItemRadiationBallet(int par1) {
+               super(par1);
+               this.setCreativeTab(ChemiCraft.creativeTabChemiCraft);
+               this.maxStackSize = 16;
+       }
+
+       @Override
+       public String getTextureFile() {
+               return ChemiCraft.instance.ITEM_TEXTURE;
+       }
+
+}
diff --git a/common/pcc/chemicraft/item/ItemRadiationGun.java b/common/pcc/chemicraft/item/ItemRadiationGun.java
new file mode 100644 (file)
index 0000000..0d202ea
--- /dev/null
@@ -0,0 +1,112 @@
+package pcc.chemicraft.item;
+
+import java.util.Iterator;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLiving;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.DamageSource;
+import net.minecraft.world.World;
+import pcc.chemicraft.ChemiCraft;
+
+public class ItemRadiationGun extends Item {
+
+       private short delay;
+
+       public ItemRadiationGun(int par1) {
+               super(par1);
+               this.setCreativeTab(ChemiCraft.creativeTabChemiCraft);
+               this.maxStackSize = 1;
+       }
+
+       @Override
+       public String getTextureFile() {
+               return ChemiCraft.instance.ITEM_TEXTURE;
+       }
+
+       @Override
+       public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
+                       EntityPlayer par3EntityPlayer) {
+
+               boolean isCreative = par3EntityPlayer.capabilities.isCreativeMode;
+
+               if (this.delay <= 0) {
+                       if (isCreative) {
+                               if (par3EntityPlayer.inventory.hasItem(ChemiCraft.instance.itemRadiationBallet.shiftedIndex)) {
+                                       this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
+                                       par3EntityPlayer.inventory.consumeInventoryItem(ChemiCraft.instance.itemRadiationBallet.shiftedIndex);
+                                       par2World.playSound(par3EntityPlayer.posX,
+                                                       par3EntityPlayer.posY,
+                                                       par3EntityPlayer.posZ,
+                                                       "mob.endermen.portal",
+                                                       1.0F,
+                                                       1.3F,
+                                                       false);
+                                       if (!par2World.isRemote) {
+                                               this.delay = 100;
+                                       }
+                               } else {
+                                       this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
+                                       par2World.playSound(par3EntityPlayer.posX,
+                                                       par3EntityPlayer.posY,
+                                                       par3EntityPlayer.posZ,
+                                                       "mob.endermen.portal",
+                                                       1.0F,
+                                                       1.3F,
+                                                       false);
+                                       if (!par2World.isRemote) {
+                                               this.delay = 100;
+                                       }
+                               }
+                       }
+               }
+
+               return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer);
+       }
+
+       private void field_00001(ItemStack par1ItemStack, World par2World,
+                       EntityPlayer par3EntityPlayer) {
+               int distance = 0;
+               double minX = par3EntityPlayer.posX;
+               double minZ = par3EntityPlayer.posZ;
+               double maxX = par3EntityPlayer.posX - Math.sin(Math.toRadians(par3EntityPlayer.rotationYaw)) * 20;
+               double maxZ = par3EntityPlayer.posZ + Math.cos(Math.toRadians(par3EntityPlayer.rotationYaw)) * 20;
+               double posY = par3EntityPlayer.posY;
+               for(distance = 0;distance < Math.abs(((minX-maxX) + (minZ-maxZ))) / 2;distance++){
+                       AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(
+                                       minX + -Math.sin(Math.toRadians(par3EntityPlayer.rotationYaw)) * distance,
+                                       posY + 1,
+                                       minZ + Math.cos(Math.toRadians(par3EntityPlayer.rotationYaw)) * distance,
+                                       minX + -Math.sin(Math.toRadians(par3EntityPlayer.rotationYaw)) * distance,
+                                       posY + 1,
+                                       minZ + Math.cos(Math.toRadians(par3EntityPlayer.rotationYaw)) * distance
+                                       ).expand(1.5, 3, 1.5);
+
+                       Iterator itr = par2World.getEntitiesWithinAABB(EntityLiving.class, aabb).iterator();
+                       while(itr.hasNext()){
+                               EntityLiving entity = (EntityLiving) itr.next();
+                               if(entity != par3EntityPlayer){
+                                       entity.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), 10);
+                                       entity.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), (int) (10 + Math.random() * 11));
+                                       entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 1, 20*20));
+                                       entity.addPotionEffect(new PotionEffect(Potion.weakness.getId(), 1, 20*20));
+                               }
+                       }
+               }
+       }
+
+       @Override
+       public void onUpdate(ItemStack par1ItemStack, World par2World,
+                       Entity par3Entity, int par4, boolean par5) {
+               if (this.delay > 0 && !par2World.isRemote) {
+                       this.delay--;
+               }
+       }
+
+
+}
index 3ec284e..5be4625 100644 (file)
Binary files a/resources/pcc/chemicraft/items/items.png and b/resources/pcc/chemicraft/items/items.png differ