pjc21

witherSkeletonSpawnEvent.zs

May 16th, 2021
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. #priority 500
  2.  
  3. import crafttweaker.event.EntityJoinWorldEvent;
  4. import crafttweaker.event.IEntityEvent;
  5. import crafttweaker.entity.IEntityLiving;
  6. import crafttweaker.entity.IEntity;
  7. import crafttweaker.entity.IEntityLivingBase;
  8. import crafttweaker.entity.IEntityDefinition;
  9.  
  10. import crafttweaker.util.IRandom;
  11. import crafttweaker.world.IWorld;
  12. import crafttweaker.item.IItemStack;
  13.  
  14. import crafttweaker.data.IData;
  15.  
  16. events.onEntityJoinWorld(function (event as EntityJoinWorldEvent) {
  17.  
  18. if event.entity instanceof IEntityLiving {
  19.  
  20. val entityLiving as IEntityLiving = event.entity;
  21.  
  22. if (event.entity.definition.id).matches("minecraft:wither_skeleton") {
  23.  
  24. val world = event.world;
  25.  
  26. val head = crafttweaker.entity.IEntityEquipmentSlot.head();
  27. val chest = crafttweaker.entity.IEntityEquipmentSlot.chest();
  28. val legs = crafttweaker.entity.IEntityEquipmentSlot.legs();
  29. val feet = crafttweaker.entity.IEntityEquipmentSlot.feet();
  30.  
  31. // Set 50% chance for each individual armor slot
  32. if (world.getRandom().nextDouble() <= 0.5) {
  33. entityLiving.setItemToSlot(head, <minecraft:diamond_helmet>);
  34. }
  35.  
  36. if (world.getRandom().nextDouble() <= 0.5) {
  37. entityLiving.setItemToSlot(chest, <minecraft:diamond_chestplate>);
  38. }
  39.  
  40. if (world.getRandom().nextDouble() <= 0.5) {
  41. entityLiving.setItemToSlot(legs, <minecraft:diamond_leggings>);
  42. }
  43.  
  44. if (world.getRandom().nextDouble() <= 0.5) {
  45. entityLiving.setItemToSlot(feet, <minecraft:diamond_boots>);
  46. }
  47. }
  48. }
  49. });
Advertisement
Add Comment
Please, Sign In to add comment