pjc21

supplyCrateEvent.zs

May 12th, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #priority 500
  2.  
  3. import crafttweaker.item.IItemStack;
  4. import crafttweaker.item.WeightedItemStack;
  5. import crafttweaker.events.IEventManager;
  6. import crafttweaker.event.BlockHarvestDropsEvent;
  7. import crafttweaker.event.IBlockEvent;
  8. import crafttweaker.world.IWorld;
  9. import crafttweaker.util.IRandom;
  10.  
  11.  
  12. static weaponSets as WeightedItemStack[][string] = {
  13. "Glock-19": [
  14. <mw:glock_19>,
  15. <mw:glockmag13>,
  16. <mw:bullet9x19mm> *64
  17. ],
  18. "Uzi": [
  19. <mw:uzi>,
  20. <mw:uzimag_2>,
  21. <mw:bullet9x19mm> *64
  22. ],
  23. "HS-12": [
  24. <mw:hs12>,
  25. <mw:shotgun12gauge> *64
  26. ],
  27. "L96A1": [
  28. <mw:l96a1>,
  29. <mw:l96a1mag_2>,
  30. <mw:bullet762x54> *64
  31. ],
  32. "BFG 9000": [
  33. <mw:bfg_9000>,
  34. <mw:bfgammo> *32
  35. ]
  36. };
  37.  
  38. var minNum as int = 0;
  39. var maxNum as int = weaponSets.length - 1;
  40.  
  41. events.onBlockHarvestDrops(function (event as BlockHarvestDropsEvent) {
  42. if ("contenttweaker:supply_crate".matches(event.block.definition.id)) {
  43. if (event.silkTouch) {
  44. event.drops = [<contenttweaker:supply_crate>];
  45. } else {
  46. val worldInstance = event.world as IWorld;
  47. var randomNum as int = worldInstance.random.nextInt(minNum, maxNum);
  48. val supplyItems = weaponSets.entrySet[randomNum];
  49.  
  50. for item in supplyItems.value {
  51. event.drops += item;
  52. }
  53. }
  54. }
  55. });
Add Comment
Please, Sign In to add comment