OSDN Git Service

修正・変更
[chemicraft/chemicraft.git] / common / pcc / chemicraft / core / item / ItemAtoms.java
index afc31d6..b3ee9a3 100644 (file)
@@ -1,14 +1,20 @@
 package pcc.chemicraft.core.item;
 
 import java.util.List;
+import java.util.Random;
 
 import net.minecraft.creativetab.CreativeTabs;
 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.PotionEffect;
+import net.minecraft.util.DamageSource;
+import net.minecraft.util.EntityDamageSource;
 import net.minecraft.world.World;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
 import pcc.chemicraft.ChemiCraft;
 import pcc.chemicraft.core.ChemiCraftCore;
 import pcc.chemicraft.util.AtomInfo;
@@ -30,13 +36,23 @@ public class ItemAtoms extends Item {
        @Override
        public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
        {
-               if (AtomInfo.isRI(par1ItemStack.getItemDamage())){
-                       if (par3Entity instanceof EntityLiving){
-                               EntityLiving entity = (EntityLiving)par3Entity;
-                               entity.addPotionEffect(new PotionEffect(2, 1, 1));
-                               entity.addPotionEffect(new PotionEffect(4, 1, 1));
-                               entity.addPotionEffect(new PotionEffect(18, 1, 1));
-                               entity.addPotionEffect(new PotionEffect(19, 1, 1));
+               if (AtomInfo.isRI(par1ItemStack.getItemDamage() + 1)){
+                       Random random = new Random();
+                       if (random.nextInt(100) == 0){
+                               if (par3Entity instanceof EntityLiving){
+                                       EntityLiving entity = (EntityLiving)par3Entity;
+                                       entity.attackEntityFrom(ChemiCraftCore.getRadiationDamageSource(entity), 1);
+                               }
+                               if (par3Entity instanceof EntityPlayer){
+                                       EntityPlayer player = (EntityPlayer)par3Entity;
+                                       ItemStack itemstack = new ItemStack(
+                                                       par1ItemStack.itemID,
+                                                       1,
+                                                       par1ItemStack.getItemDamage());
+                                       itemstack.setItemDamage(AtomInfo.collapseUraniumSeries(itemstack.getItemDamage() + 1) - 1);
+                                       player.inventory.addItemStackToInventory(itemstack);
+                                       player.inventory.consumeInventoryItem(par1ItemStack.itemID);
+                               }
                        }
                }
        }