Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.92 KB | None | 0 0
  1. public class ZombiePigmanEquipUtilities {
  2. public static Random zombiePigman_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, ZombiePigmanEntity zombiePigman) {
  7.  
  8. if (zombiePigman_rand.nextFloat() < 0.15F * difficulty.getClampedAdditionalDifficulty()) {
  9. int i = zombiePigman_rand.nextInt(2);
  10. float f = world.getDifficulty() == Difficulty.HARD ? 0.1F : 0.25F;
  11. if (zombiePigman_rand.nextFloat() < 0.095F) {
  12. ++i;
  13. }
  14.  
  15. if (zombiePigman_rand.nextFloat() < 0.095F) {
  16. ++i;
  17. }
  18.  
  19. if (zombiePigman_rand.nextFloat() < 0.095F) {
  20. ++i;
  21. }
  22.  
  23. boolean flag = true;
  24.  
  25. boolean useChain = zombiePigman_rand.nextBoolean();
  26.  
  27. for(EquipmentSlotType equipmentslottype : EquipmentSlotType.values()) {
  28. if (equipmentslottype.getSlotType() == EquipmentSlotType.Group.ARMOR) {
  29. ItemStack itemstack = zombiePigman.getItemStackFromSlot(equipmentslottype);
  30. if (!flag && zombiePigman_rand.nextFloat() < f) {
  31. break;
  32. }
  33.  
  34. flag = false;
  35. if (itemstack.isEmpty()) {
  36. Item item = Items.AIR;
  37. if(useChain){
  38. item = getModdedChainArmor(equipmentslottype, i);
  39. }
  40. else{
  41. item = getModdedPlateArmor(equipmentslottype, i);
  42. }
  43. if (item != null) {
  44. zombiePigman.setItemStackToSlot(equipmentslottype, new ItemStack(item));
  45. }
  46. }
  47. }
  48. }
  49. }
  50. } // END of setEquipmentBasedOnDifficulty
  51.  
  52. // Wither Skeleton wields an Iron Sword instead of a Stone Sword
  53. public static void setHeldItemsBasedOnDifficulty(ZombiePigmanEntity zombiePigman) {
  54. zombiePigman.setItemStackToSlot(EquipmentSlotType.MAINHAND, new ItemStack(ItemList.copper_sword));
  55.  
  56. }
  57.  
  58. @Nullable
  59. public static Item getModdedPlateArmor(EquipmentSlotType slotIn, int chance) {
  60. switch(slotIn) {
  61. case HEAD:
  62. if (chance == 0) {
  63. return Items.LEATHER_HELMET;
  64. } else if (chance == 1) {
  65. return ItemList.copper_helmet;
  66. } else if (chance == 2) {
  67. return ItemList.bronze_helmet;
  68. } else if (chance == 3) {
  69. return ItemList.iron_helmet;
  70. } else if (chance == 4) {
  71. return ItemList.steel_helmet;
  72. }
  73. case CHEST:
  74. if (chance == 0) {
  75. return Items.LEATHER_CHESTPLATE;
  76. } else if (chance == 1) {
  77. return ItemList.copper_chestplate;
  78. } else if (chance == 2) {
  79. return ItemList.bronze_chestplate;
  80. } else if (chance == 3) {
  81. return ItemList.iron_chestplate;
  82. } else if (chance == 4) {
  83. return ItemList.steel_chestplate;
  84. }
  85. case LEGS:
  86. if (chance == 0) {
  87. return Items.LEATHER_LEGGINGS;
  88. } else if (chance == 1) {
  89. return ItemList.copper_leggings;
  90. } else if (chance == 2) {
  91. return ItemList.bronze_leggings;
  92. } else if (chance == 3) {
  93. return ItemList.iron_leggings;
  94. } else if (chance == 4) {
  95. return ItemList.steel_leggings;
  96. }
  97. case FEET:
  98. if (chance == 0) {
  99. return Items.LEATHER_BOOTS;
  100. } else if (chance == 1) {
  101. return ItemList.copper_boots;
  102. } else if (chance == 2) {
  103. return ItemList.bronze_boots;
  104. } else if (chance == 3) {
  105. return ItemList.iron_boots;
  106. } else if (chance == 4) {
  107. return ItemList.steel_boots;
  108. }
  109. default:
  110. return null;
  111. }
  112. }
  113.  
  114. @Nullable
  115. public static Item getModdedChainArmor(EquipmentSlotType slotIn, int chance) {
  116. switch(slotIn) {
  117. case HEAD:
  118. if (chance == 0) {
  119. return Items.LEATHER_HELMET;
  120. } else if (chance == 1) {
  121. return ItemList.copper_chainhead;
  122. } else if (chance == 2) {
  123. return ItemList.bronze_chainhead;
  124. } else if (chance == 3) {
  125. return ItemList.iron_chainhead;
  126. } else if (chance == 4) {
  127. return ItemList.steel_chainhead;
  128. }
  129. case CHEST:
  130. if (chance == 0) {
  131. return Items.LEATHER_CHESTPLATE;
  132. } else if (chance == 1) {
  133. return ItemList.copper_chainbody;
  134. } else if (chance == 2) {
  135. return ItemList.bronze_chainbody;
  136. } else if (chance == 3) {
  137. return ItemList.iron_chainbody;
  138. } else if (chance == 4) {
  139. return ItemList.steel_chainbody;
  140. }
  141. case LEGS:
  142. if (chance == 0) {
  143. return Items.LEATHER_LEGGINGS;
  144. } else if (chance == 1) {
  145. return ItemList.copper_chainlegs;
  146. } else if (chance == 2) {
  147. return ItemList.bronze_chainlegs;
  148. } else if (chance == 3) {
  149. return ItemList.iron_chainlegs;
  150. } else if (chance == 4) {
  151. return ItemList.steel_chainlegs;
  152. }
  153. case FEET:
  154. if (chance == 0) {
  155. return Items.LEATHER_BOOTS;
  156. } else if (chance == 1) {
  157. return ItemList.copper_chainfeet;
  158. } else if (chance == 2) {
  159. return ItemList.bronze_chainfeet;
  160. } else if (chance == 3) {
  161. return ItemList.iron_chainfeet;
  162. } else if (chance == 4) {
  163. return ItemList.steel_chainfeet;
  164. }
  165. default:
  166. return null;
  167. }
  168. }
  169.  
  170. /**
  171. * Enchants Entity's current equipments based on given DifficultyInstance
  172. */
  173. public static void setEnchantmentBasedOnDifficulty(DifficultyInstance difficulty, ZombiePigmanEntity zombiePigman) {
  174. float f = difficulty.getClampedAdditionalDifficulty();
  175. if (!zombiePigman.getHeldItemMainhand().isEmpty() && zombiePigman_rand.nextFloat() < 0.25F * f) {
  176. zombiePigman.setItemStackToSlot(EquipmentSlotType.MAINHAND, EnchantmentHelper.addRandomEnchantment(zombiePigman_rand, zombiePigman.getHeldItemMainhand(), (int)(5.0F + f * (float)zombiePigman_rand.nextInt(18)), false));
  177. }
  178.  
  179. for(EquipmentSlotType equipmentslottype : EquipmentSlotType.values()) {
  180. if (equipmentslottype.getSlotType() == EquipmentSlotType.Group.ARMOR) {
  181. ItemStack itemstack = zombiePigman.getItemStackFromSlot(equipmentslottype);
  182. if (!itemstack.isEmpty() && zombiePigman_rand.nextFloat() < 0.5F * f) {
  183. zombiePigman.setItemStackToSlot(equipmentslottype, EnchantmentHelper.addRandomEnchantment(zombiePigman_rand, itemstack, (int)(5.0F + f * (float)zombiePigman_rand.nextInt(18)), false));
  184. }
  185. }
  186. }
  187.  
  188. }
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement