theCountChuckula

ClayBreakHandler .java

Nov 21st, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. package darkevilmac.MotherOfPearl.events;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Random;
  5.  
  6. import net.minecraft.block.Block;
  7. import net.minecraft.item.Item;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraftforge.event.ForgeSubscribe;
  10. import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
  11. import tcc.MotherOfPearl.items.ModItems;
  12. import darkevilmac.MotherOfPearl.utils.Utilities;
  13.  
  14. public class ClayBreakHandler {
  15.  
  16. public static Random random = new Random();
  17. public static final ItemStack clayItemRandom = new ItemStack(Item.clay, Utilities.getRandom(1, 3), 0);
  18. public static final ItemStack oysterRandom = new ItemStack(ModItems.oyster, Utilities.getRandom(1, 2), 0);
  19. public static final ItemStack oysterRandomFortune = new ItemStack(ModItems.oyster, Utilities.getRandom(1, 4), 0);
  20.  
  21. @ForgeSubscribe
  22. public void onBlockBreak(HarvestDropsEvent oEvent) {
  23.  
  24. if (!oEvent.world.isRemote) {
  25. if (oEvent.block.blockID == Block.blockClay.blockID){
  26.  
  27. //System.out.println("[MOP] Clay Broken");
  28. // if (event.block instanceof BlockClay) {
  29. //event.drops.clear();
  30. //System.out.println("[MOP] Clearing Drops");
  31. //int cDrop = Utilities.getRandom(1, 4);
  32. //int oDrop = 4 - cDrop;
  33. //int foDrop = Utilities.getRandom(0, oEvent.fortuneLevel);
  34. GenerateLootList(oEvent.drops,
  35. Item.clay.itemID,
  36. ModItems.oyster.itemID,
  37. ModItems.oyster.itemID,
  38. oEvent.fortuneLevel);
  39.  
  40. oEvent.dropChance = 1.0F;
  41.  
  42. //System.out.println("[MOP] 100% Chance to drop new items");
  43. //if (oEvent.fortuneLevel > 0) {
  44.  
  45. //System.out.println("[MOP] Fortune Determined");
  46. // event.drops.add(oysterRandomFortune);
  47. //System.out.println("[MOP] Randomizing Fortune Oyster Drops");
  48. //}
  49. //event.drops.add(oysterRandom);
  50. //System.out.println("[MOP] Randomizing Oyster Drops");
  51. //event.drops.add(clayItemRandom);
  52. //System.out.println("[MOP] Randomizing ItemClay Drops");
  53. return;
  54. }
  55. }
  56.  
  57. }
  58. private void GenerateLootList(ArrayList<ItemStack> oList, int cItemID, int oItemID, int foItemID, int flevel)
  59. {
  60. int cCount = Utilities.getRandom(1, 4);
  61. int oCount = 4 - cCount;
  62. int foCount = Utilities.getRandom(0, flevel);
  63. oList.clear();
  64. for(int i = 0; i < cCount; ++i)
  65. {
  66. ItemStack cdrop = new ItemStack(cItemID, 1, 0);
  67. oList.add(cdrop);
  68. }
  69. for(int i = 0; i < oCount; ++i)
  70. {
  71. ItemStack odrop = new ItemStack(oItemID, 1, 0);
  72. oList.add(odrop);
  73. }
  74. for(int i = 0; i < foCount; ++i)
  75. {
  76. ItemStack fodrop = new ItemStack(foItemID, 1, 0);
  77. oList.add(fodrop);
  78. }
  79.  
  80. }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment