Advertisement
MintTheFox

drop handler

Nov 18th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. package com.mint.quantumcoins.core;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.mint.quantumcoins.items.ItemHelper;
  6. import com.mint.quantumcoins.lib.QuantumSettings;
  7.  
  8. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  9. import net.minecraft.entity.item.EntityItem;
  10. import net.minecraft.entity.monster.EntityZombie;
  11. import net.minecraft.item.ItemStack;
  12. import net.minecraftforge.event.entity.living.LivingDropsEvent;
  13.  
  14. public class QuantumEvents
  15. {
  16.  
  17.     @SubscribeEvent
  18.     public void mobDrop(LivingDropsEvent event)
  19.     {
  20.         ItemStack droppedCoin = new ItemStack(ItemHelper.coin, 1, 0);
  21.        
  22.         if(event.recentlyHit == false) return;
  23.        
  24.         if(event.entityLiving instanceof EntityZombie)
  25.         {
  26.             if(QuantumSettings.settings.zombieDrop == true)
  27.             {
  28.                 if(dropChance(QuantumSettings.settings.zombieChance) == true)
  29.                 {
  30.                     event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ));
  31.                 }
  32.             }
  33.         }
  34.        
  35.        
  36.     }
  37.    
  38.     public boolean dropChance(int percent)
  39.     {
  40.         Random chance = new Random();
  41.         if(percent <= chance.nextInt(101)) return true;
  42.        
  43.         else return false;
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement