theCountChuckula

ClayBreakHandler.java

Nov 21st, 2013
92
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. import java.util.Random;
  5.  
  6. import net.minecraft.block.BlockClay;
  7. import net.minecraft.item.Item;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.util.MathHelper;
  10. import net.minecraftforge.event.ForgeSubscribe;
  11. import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
  12. import tcc.MotherOfPearl.items.ModItems;
  13. import darkevilmac.MotherOfPearl.utils.Utilities;
  14.  
  15. public class ClayBreakHandler {
  16.  
  17. public static Random random = new Random();
  18. public static final ItemStack clayItemRandom = new ItemStack(Item.clay, Utilities.getRandom(1, 3), 0);
  19. public static final ItemStack oysterRandom = new ItemStack(ModItems.oyster, Utilities.getRandom(1, 2), 0);
  20. public static final ItemStack oysterRandomFortune = new ItemStack(ModItems.oyster, Utilities.getRandom(1, 4), 0);
  21.  
  22. @ForgeSubscribe
  23. public void onBlockBreak(HarvestDropsEvent oEvent) {
  24.  
  25. if (!oEvent.world.isRemote) {
  26. if (oEvent.block instanceof BlockClay) {
  27. GenerateLootList(oEvent.drops,
  28. Item.clay.itemID,
  29. ModItems.oyster.itemID,
  30. ModItems.oyster.itemID,
  31. oEvent.fortuneLevel);
  32. oEvent.dropChance = 1.0F;
  33. return;
  34. }
  35. }
  36. }
  37. private void GenerateLootList(ArrayList<ItemStack> oList, int cItemID, int oItemID, int foItemID, int flevel)
  38. {
  39. int cCount = MathHelper.getRandomIntegerInRange(random, 1, 4);
  40. int oCount = 4 - cCount;
  41. int foCount = MathHelper.getRandomIntegerInRange(random, 0, flevel);
  42. oList.clear();
  43. for(int i = 0; i < cCount; ++i)
  44. {
  45. ItemStack cdrop = new ItemStack(cItemID, 1, 0);
  46. oList.add(cdrop);
  47. }
  48. for(int i = 0; i < oCount; ++i)
  49. {
  50. ItemStack odrop = new ItemStack(oItemID, 1, 0);
  51. oList.add(odrop);
  52. }
  53. for(int i = 0; i < foCount; ++i)
  54. {
  55. ItemStack fodrop = new ItemStack(foItemID, 1, 0);
  56. oList.add(fodrop);
  57. }
  58.  
  59. }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment