pjc21

supplyCrateEvents.zs

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