Guest User

Untitled

a guest
Apr 8th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.54 KB | None | 0 0
  1. public class WitherSkeletonEquipUtilities {
  2. public static Random witherSkeleton_rand = new Random();
  3. /**
  4. * Gives armor or weapon for entity based on given DifficultyInstance
  5. */
  6. public static void setArmorBasedOnDifficulty(DifficultyInstance difficulty, World world, WitherSkeletonEntity witherSkeleton) {
  7.  
  8. if (witherSkeleton_rand.nextFloat() < 0.15F * difficulty.getClampedAdditionalDifficulty()) {
  9. int i = witherSkeleton_rand.nextInt(2);
  10. float f = world.getDifficulty() == Difficulty.HARD ? 0.1F : 0.25F;
  11. if (witherSkeleton_rand.nextFloat() < 0.095F) {
  12. ++i;
  13. }
  14.  
  15. if (witherSkeleton_rand.nextFloat() < 0.095F) {
  16. ++i;
  17. }
  18.  
  19. if (witherSkeleton_rand.nextFloat() < 0.095F) {
  20. ++i;
  21. }
  22.  
  23. boolean flag = true;
  24.  
  25. for(EquipmentSlotType equipmentslottype : EquipmentSlotType.values()) {
  26. if (equipmentslottype.getSlotType() == EquipmentSlotType.Group.ARMOR) {
  27. ItemStack itemstack = witherSkeleton.getItemStackFromSlot(equipmentslottype);
  28. if (!flag && witherSkeleton_rand.nextFloat() < f) {
  29. break;
  30. }
  31.  
  32. flag = false;
  33. if (itemstack.isEmpty()) {
  34. Item item = getModdedArmorByChance(equipmentslottype, i);
  35. if (item != null) {
  36. witherSkeleton.setItemStackToSlot(equipmentslottype, new ItemStack(item));
  37. }
  38. }
  39. }
  40. }
  41. }
  42. } // END of setEquipmentBasedOnDifficulty
  43.  
  44. // Wither Skeleton wields an Iron Sword instead of a Stone Sword
  45. public static void setHeldItemsBasedOnDifficulty(WitherSkeletonEntity witherSkeleton) {
  46. witherSkeleton.setItemStackToSlot(EquipmentSlotType.MAINHAND, new ItemStack(ItemList.iron_sword));
  47.  
  48.  
  49. }
  50.  
  51. // Wither Skeleton can only wear Iron Armor to fit its "dark" theme - it will also be a source of iron nuggets
  52. @Nullable
  53. public static Item getModdedArmorByChance(EquipmentSlotType slotIn, int chance) {
  54. switch(slotIn) {
  55. case HEAD:
  56. if (chance == 0) {
  57. return ItemList.iron_helmet;
  58. } else if (chance == 1) {
  59. return ItemList.iron_helmet;
  60. } else if (chance == 2) {
  61. return ItemList.iron_helmet;
  62. } else if (chance == 3) {
  63. return ItemList.iron_helmet;
  64. } else if (chance == 4) {
  65. return ItemList.iron_helmet;
  66. }
  67. case CHEST:
  68. if (chance == 0) {
  69. return ItemList.iron_chestplate;
  70. } else if (chance == 1) {
  71. return ItemList.iron_chestplate;
  72. } else if (chance == 2) {
  73. return ItemList.iron_chestplate;
  74. } else if (chance == 3) {
  75. return ItemList.iron_chestplate;
  76. } else if (chance == 4) {
  77. return ItemList.iron_chestplate;
  78. }
  79. case LEGS:
  80. if (chance == 0) {
  81. return ItemList.iron_leggings;
  82. } else if (chance == 1) {
  83. return ItemList.iron_leggings;
  84. } else if (chance == 2) {
  85. return ItemList.iron_leggings;
  86. } else if (chance == 3) {
  87. return ItemList.iron_leggings;
  88. } else if (chance == 4) {
  89. return ItemList.iron_leggings;
  90. }
  91. case FEET:
  92. if (chance == 0) {
  93. return ItemList.iron_boots;
  94. } else if (chance == 1) {
  95. return ItemList.iron_boots;
  96. } else if (chance == 2) {
  97. return ItemList.iron_boots;
  98. } else if (chance == 3) {
  99. return ItemList.iron_boots;
  100. } else if (chance == 4) {
  101. return ItemList.iron_boots;
  102. }
  103. default:
  104. return null;
  105. }
  106. }
  107.  
  108. /**
  109. * Enchants Entity's current equipments based on given DifficultyInstance
  110. */
  111. public static void setEnchantmentBasedOnDifficulty(DifficultyInstance difficulty, WitherSkeletonEntity witherSkeleton) {
  112. float f = difficulty.getClampedAdditionalDifficulty();
  113. if (!witherSkeleton.getHeldItemMainhand().isEmpty() && witherSkeleton_rand.nextFloat() < 0.25F * f) {
  114. witherSkeleton.setItemStackToSlot(EquipmentSlotType.MAINHAND, EnchantmentHelper.addRandomEnchantment(witherSkeleton_rand, witherSkeleton.getHeldItemMainhand(), (int)(5.0F + f * (float)witherSkeleton_rand.nextInt(18)), false));
  115. }
  116.  
  117. for(EquipmentSlotType equipmentslottype : EquipmentSlotType.values()) {
  118. if (equipmentslottype.getSlotType() == EquipmentSlotType.Group.ARMOR) {
  119. ItemStack itemstack = witherSkeleton.getItemStackFromSlot(equipmentslottype);
  120. if (!itemstack.isEmpty() && witherSkeleton_rand.nextFloat() < 0.5F * f) {
  121. witherSkeleton.setItemStackToSlot(equipmentslottype, EnchantmentHelper.addRandomEnchantment(witherSkeleton_rand, itemstack, (int)(5.0F + f * (float)witherSkeleton_rand.nextInt(18)), false));
  122. }
  123. }
  124. }
  125.  
  126. }
  127. }
Add Comment
Please, Sign In to add comment