theCountChuckula

ClayBreakHandler.java

Nov 21st, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package darkevilmac.MotherOfPearl.events;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import net.minecraft.block.BlockClay;
  6. import net.minecraft.item.Item;
  7. import net.minecraft.item.ItemStack;
  8. import net.minecraft.world.World;
  9. import net.minecraftforge.event.ForgeSubscribe;
  10. import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
  11. import tcc.MotherOfPearl.items.ModItems;
  12.  
  13. public class ClayBreakHandler {
  14.  
  15.     @ForgeSubscribe
  16.     public void onBlockBreak(HarvestDropsEvent oEvent) {
  17.    
  18.         if (!oEvent.world.isRemote) {
  19.             if (oEvent.block instanceof BlockClay) {
  20.                 GenerateLootList(oEvent.drops,
  21.                         Item.clay.itemID,
  22.                         ModItems.oyster.itemID,
  23.                         ModItems.oyster.itemID,
  24.                         oEvent.fortuneLevel,
  25.                         oEvent.world);
  26.                 oEvent.dropChance = 1.0F;
  27.                 return;
  28.             }
  29.         }
  30.     }
  31.     private void GenerateLootList(ArrayList<ItemStack> oList, int cItemID, int oItemID, int foItemID, int flevel, World world)
  32.     {
  33.         int oChance = world.rand.nextInt(4);
  34.         int cCount = world.rand.nextInt(3)+1;
  35.         int oCount = 4 - cCount;
  36.         int foCount = 0;
  37.         if(flevel > 0)
  38.                 foCount = world.rand.nextInt(flevel);
  39.         oList.clear();
  40.         if(oChance == 0){
  41.             for(int i = 0; i < cCount; ++i)
  42.             {
  43.                 ItemStack cdrop = new ItemStack(cItemID, 1, 0);
  44.                 oList.add(cdrop);
  45.             }
  46.         }
  47.         if(oChance == 0){
  48.             for(int i = 0; i < oCount; ++i)
  49.             {
  50.                 ItemStack odrop = new ItemStack(oItemID, 1, 0);
  51.                 oList.add(odrop);
  52.             }
  53.         }
  54.         if(oChance > 0){
  55.             for(int i = 0; i < 4; ++i)
  56.             {
  57.                 ItemStack cdrop = new ItemStack(cItemID, 1, 0);
  58.                 oList.add(cdrop);
  59.             }
  60.         }
  61.         for(int i = 0; i < foCount; ++i)
  62.         {
  63.             ItemStack fodrop = new ItemStack(foItemID, 1, 0);
  64.             oList.add(fodrop);
  65.         }
  66.        
  67.     }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment