Guest User

Untitled

a guest
Apr 8th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.15 KB | None | 0 0
  1. public class MobEquipEvent {
  2.  
  3. @SubscribeEvent
  4. public void changeToModdedEquipment(LivingSpawnEvent.SpecialSpawn event){
  5. if ((event.getEntity() instanceof ZombieEntity) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()) {
  6. ZombieEntity zombie = (ZombieEntity) event.getEntity();
  7. World world = event.getWorld().getWorld();
  8. DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(zombie.getPosition());
  9.  
  10. // EMPTY ALL ARMOR SLOTS
  11. // zombie.getArmorInventoryList().forEach((equipment) -> equipment = ItemStack.EMPTY);
  12.  
  13.  
  14.  
  15. // EMPTY HELD ITEM SLOTS
  16. //zombie.getHeldEquipment().forEach((equipment) -> equipment = ItemStack.EMPTY);
  17.  
  18.  
  19. for (EquipmentSlotType slot : EquipmentSlotType.values()){
  20. if(!zombie.getItemStackFromSlot(slot).isEmpty()){
  21. zombie.setItemStackToSlot(slot, ItemStack.EMPTY);
  22. }
  23. }
  24.  
  25. ZombieEquipUtilities.setArmorBasedOnDifficulty(difficultyInstance, world, zombie);
  26. ZombieEquipUtilities.setHeldItemsBasedOnDifficulty(world, zombie);
  27. ZombieEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, zombie);
  28.  
  29. //HardSteel.logger.info("Zombie's armor is: " + zombie.getEquipmentAndArmor().toString());
  30. }
  31. if ((event.getEntity() instanceof HuskEntity) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()) {
  32. HuskEntity husk = (HuskEntity) event.getEntity();
  33. World world = event.getWorld().getWorld();
  34. DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(husk.getPosition());
  35.  
  36. // EMPTY ALL ARMOR SLOTS
  37. // zombie.getArmorInventoryList().forEach((equipment) -> equipment = ItemStack.EMPTY);
  38.  
  39.  
  40.  
  41. // EMPTY HELD ITEM SLOTS
  42. //zombie.getHeldEquipment().forEach((equipment) -> equipment = ItemStack.EMPTY);
  43.  
  44.  
  45. for (EquipmentSlotType slot : EquipmentSlotType.values()){
  46. if(!husk.getItemStackFromSlot(slot).isEmpty()){
  47. husk.setItemStackToSlot(slot, ItemStack.EMPTY);
  48. }
  49. }
  50.  
  51. HuskEquipUtilities.setArmorBasedOnDifficulty(difficultyInstance, world, husk);
  52. HuskEquipUtilities.setHeldItemsBasedOnDifficulty(world, husk);
  53. HuskEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, husk);
  54.  
  55. //HardSteel.logger.info("Zombie's armor is: " + zombie.getEquipmentAndArmor().toString());
  56. }
  57. if ((event.getEntity() instanceof ZombieVillagerEntity) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()) {
  58. ZombieVillagerEntity zombieVillager = (ZombieVillagerEntity) event.getEntity();
  59. World world = event.getWorld().getWorld();
  60. DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(zombieVillager.getPosition());
  61.  
  62. // EMPTY ALL ARMOR SLOTS
  63. // zombie.getArmorInventoryList().forEach((equipment) -> equipment = ItemStack.EMPTY);
  64.  
  65.  
  66.  
  67. // EMPTY HELD ITEM SLOTS
  68. //zombie.getHeldEquipment().forEach((equipment) -> equipment = ItemStack.EMPTY);
  69.  
  70.  
  71. for (EquipmentSlotType slot : EquipmentSlotType.values()){
  72. if(!zombieVillager.getItemStackFromSlot(slot).isEmpty()){
  73. zombieVillager.setItemStackToSlot(slot, ItemStack.EMPTY);
  74. }
  75. }
  76.  
  77. ZombieVillagerEquipUtilities.setArmorBasedOnDifficulty(difficultyInstance, world, zombieVillager);
  78. ZombieVillagerEquipUtilities.setHeldItemsBasedOnDifficulty(world, zombieVillager);
  79. ZombieVillagerEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, zombieVillager);
  80.  
  81. //HardSteel.logger.info("Zombie's armor is: " + zombie.getEquipmentAndArmor().toString());
  82. }
  83. if((event.getEntity() instanceof SkeletonEntity) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()){
  84. SkeletonEntity skeleton = (SkeletonEntity) event.getEntity();
  85. World world = event.getWorld().getWorld();
  86. DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(skeleton.getPosition());
  87.  
  88. // EMPTY ALL ARMOR SLOTS
  89. //skeleton.getArmorInventoryList().forEach((equipment) -> equipment = ItemStack.EMPTY);
  90.  
  91. for (EquipmentSlotType slot : EquipmentSlotType.values()){
  92. if(!skeleton.getItemStackFromSlot(slot).isEmpty() && slot != EquipmentSlotType.MAINHAND){
  93. skeleton.setItemStackToSlot(slot, ItemStack.EMPTY);
  94. }
  95. }
  96.  
  97. SkeletonEquipUtilities.setArmorBasedOnDifficulty(difficultyInstance, world, skeleton);
  98. SkeletonEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, skeleton);
  99. }
  100. if((event.getEntity() instanceof StrayEntity) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()){
  101. StrayEntity stray = (StrayEntity) event.getEntity();
  102. World world = event.getWorld().getWorld();
  103. DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(stray.getPosition());
  104.  
  105. // EMPTY ALL ARMOR SLOTS
  106. //skeleton.getArmorInventoryList().forEach((equipment) -> equipment = ItemStack.EMPTY);
  107.  
  108. for (EquipmentSlotType slot : EquipmentSlotType.values()){
  109. if(!stray.getItemStackFromSlot(slot).isEmpty() && slot != EquipmentSlotType.MAINHAND){
  110. stray.setItemStackToSlot(slot, ItemStack.EMPTY);
  111. }
  112. }
  113.  
  114. StrayEquipUtilities.setArmorBasedOnDifficulty(difficultyInstance, world, stray);
  115. StrayEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, stray);
  116. }
  117. if((event.getEntity() instanceof WitherSkeletonEntity) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()){
  118. HardSteel.logger.info("Spawned a Wither Skeleton!");
  119. WitherSkeletonEntity witherSkeleton = (WitherSkeletonEntity) event.getEntity();
  120. //World world = event.getWorld().getWorld();
  121. //DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(witherSkeleton.getPosition());
  122.  
  123. //for (EquipmentSlotType slot : EquipmentSlotType.values()){
  124. // if(!witherSkeleton.getItemStackFromSlot(slot).isEmpty()){
  125. // witherSkeleton.setItemStackToSlot(slot, ItemStack.EMPTY);
  126. // }
  127. //}
  128.  
  129. // GIVE WITHER SKELETON IRON GEAR WITH POSSIBLE ENCHANTMENTS
  130. //WitherSkeletonEquipUtilities.setArmorBasedOnDifficulty(difficultyInstance, world, witherSkeleton);
  131. WitherSkeletonEquipUtilities.setHeldItemsBasedOnDifficulty(witherSkeleton);
  132. HardSteel.logger.info("Wither Skeleton at " + witherSkeleton.getPosition().toString() + "has " + witherSkeleton.getHeldItemMainhand().toString());
  133. //WitherSkeletonEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, witherSkeleton);
  134. }
  135. if((event.getEntity() instanceof ZombiePigmanEntity) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()){
  136. ZombiePigmanEntity zombiePigman = (ZombiePigmanEntity) event.getEntity();
  137. //World world = event.getWorld().getWorld();
  138. DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(zombiePigman.getPosition());
  139.  
  140. //for (EquipmentSlotType slot : EquipmentSlotType.values()){
  141. // if(!zombiePigman.getItemStackFromSlot(slot).isEmpty()){
  142. // zombiePigman.setItemStackToSlot(slot, ItemStack.EMPTY);
  143. // }
  144. //}
  145.  
  146. // GIVE ZOMBIE PIGMAN COPPER GEAR WITH POSSIBLE ENCHANTMENTS
  147. //ZombiePigmanEquipUtilities.setArmorBasedOnDifficulty(difficultyInstance, world, zombiePigman);
  148. ZombiePigmanEquipUtilities.setHeldItemsBasedOnDifficulty(zombiePigman);
  149. ZombiePigmanEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, zombiePigman);
  150. }
  151.  
  152. }
  153. }
Advertisement
Add Comment
Please, Sign In to add comment