Advertisement
Guest User

Adaption

a guest
Jun 4th, 2024
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.67 KB | None | 0 0
  1. package net.mcreator.chillzoneoriginsaddon.procedures;
  2.  
  3. /* imports omitted */
  4.  
  5. @Mod.EventBusSubscriber
  6. public class AdaptionProcedure {
  7. @SubscribeEvent
  8. public static void onEntityAttacked(LivingHurtEvent event) {
  9. if (event != null && event.getEntity() != null) {
  10. execute(event, event.getEntity().level(), event.getSource(), event.getEntity(), event.getSource().getEntity());
  11. }
  12. }
  13.  
  14. public static void execute(LevelAccessor world, DamageSource damagesource, Entity entity, Entity sourceentity) {
  15. execute(null, world, damagesource, entity, sourceentity);
  16. }
  17.  
  18. private static void execute(@Nullable Event event, LevelAccessor world, DamageSource damagesource, Entity entity, Entity sourceentity) {
  19. if (damagesource == null || entity == null || sourceentity == null)
  20. return;
  21. double index = 0;
  22. if ((entity.getCapability(ChillzoneoriginsaddonModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ChillzoneoriginsaddonModVariables.PlayerVariables())).Morphai) {
  23. index = 0;
  24. for (int index0 = 0; index0 < (int) ChillzoneoriginsaddonModVariables.Adaption.size(); index0++) {
  25. if ((ChillzoneoriginsaddonModVariables.Adaption.get((int) index) instanceof Entity _e ? _e : null) == sourceentity) {
  26. if (event != null && event.isCancelable()) {
  27. event.setCanceled(true);
  28. }
  29. }
  30. index = index + 1;
  31. }
  32. if (sourceentity == null) {
  33. index = 0;
  34. for (int index1 = 0; index1 < (int) ChillzoneoriginsaddonModVariables.AdaptionEnviroment.size(); index1++) {
  35. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.FALLING_ANVIL)) {
  36. if (event != null && event.isCancelable()) {
  37. event.setCanceled(true);
  38. }
  39. break;
  40. }
  41. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.BAD_RESPAWN_POINT)) {
  42. if (event != null && event.isCancelable()) {
  43. event.setCanceled(true);
  44. }
  45. break;
  46. }
  47. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.CACTUS)) {
  48. if (event != null && event.isCancelable()) {
  49. event.setCanceled(true);
  50. }
  51. break;
  52. }
  53. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.CRAMMING)) {
  54. if (event != null && event.isCancelable()) {
  55. event.setCanceled(true);
  56. }
  57. break;
  58. }
  59. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.DRAGON_BREATH)) {
  60. if (event != null && event.isCancelable()) {
  61. event.setCanceled(true);
  62. }
  63. break;
  64. }
  65. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.DROWN)) {
  66. if (event != null && event.isCancelable()) {
  67. event.setCanceled(true);
  68. }
  69. break;
  70. }
  71. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.DRY_OUT)) {
  72. if (event != null && event.isCancelable()) {
  73. event.setCanceled(true);
  74. }
  75. break;
  76. }
  77. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.EXPLOSION)) {
  78. if (event != null && event.isCancelable()) {
  79. event.setCanceled(true);
  80. }
  81. break;
  82. }
  83. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.FALL)) {
  84. if (event != null && event.isCancelable()) {
  85. event.setCanceled(true);
  86. }
  87. break;
  88. }
  89. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.FALLING_BLOCK)) {
  90. if (event != null && event.isCancelable()) {
  91. event.setCanceled(true);
  92. }
  93. break;
  94. }
  95. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.FALLING_STALACTITE)) {
  96. if (event != null && event.isCancelable()) {
  97. event.setCanceled(true);
  98. }
  99. break;
  100. }
  101. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.FIREBALL)) {
  102. if (event != null && event.isCancelable()) {
  103. event.setCanceled(true);
  104. }
  105. break;
  106. }
  107. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.FLY_INTO_WALL)) {
  108. if (event != null && event.isCancelable()) {
  109. event.setCanceled(true);
  110. }
  111. break;
  112. }
  113. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.FREEZE)) {
  114. if (event != null && event.isCancelable()) {
  115. event.setCanceled(true);
  116. }
  117. break;
  118. }
  119. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.HOT_FLOOR)) {
  120. if (event != null && event.isCancelable()) {
  121. event.setCanceled(true);
  122. }
  123. break;
  124. }
  125. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.IN_FIRE)) {
  126. if (event != null && event.isCancelable()) {
  127. event.setCanceled(true);
  128. }
  129. break;
  130. }
  131. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.IN_WALL)) {
  132. if (event != null && event.isCancelable()) {
  133. event.setCanceled(true);
  134. }
  135. break;
  136. }
  137. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.INDIRECT_MAGIC)) {
  138. if (event != null && event.isCancelable()) {
  139. event.setCanceled(true);
  140. }
  141. break;
  142. }
  143. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.LAVA)) {
  144. if (event != null && event.isCancelable()) {
  145. event.setCanceled(true);
  146. }
  147. break;
  148. }
  149. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.LIGHTNING_BOLT)) {
  150. if (event != null && event.isCancelable()) {
  151. event.setCanceled(true);
  152. }
  153. break;
  154. }
  155. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.MAGIC)) {
  156. if (event != null && event.isCancelable()) {
  157. event.setCanceled(true);
  158. }
  159. break;
  160. }
  161. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.ON_FIRE)) {
  162. if (event != null && event.isCancelable()) {
  163. event.setCanceled(true);
  164. }
  165. break;
  166. }
  167. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.SONIC_BOOM)) {
  168. if (event != null && event.isCancelable()) {
  169. event.setCanceled(true);
  170. }
  171. break;
  172. }
  173. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.STALAGMITE)) {
  174. if (event != null && event.isCancelable()) {
  175. event.setCanceled(true);
  176. }
  177. break;
  178. }
  179. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.STARVE)) {
  180. if (event != null && event.isCancelable()) {
  181. event.setCanceled(true);
  182. }
  183. break;
  184. }
  185. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.STING)) {
  186. if (event != null && event.isCancelable()) {
  187. event.setCanceled(true);
  188. }
  189. break;
  190. }
  191. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.SWEET_BERRY_BUSH)) {
  192. if (event != null && event.isCancelable()) {
  193. event.setCanceled(true);
  194. }
  195. break;
  196. }
  197. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.THROWN)) {
  198. if (event != null && event.isCancelable()) {
  199. event.setCanceled(true);
  200. }
  201. break;
  202. }
  203. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.UNATTRIBUTED_FIREBALL)) {
  204. if (event != null && event.isCancelable()) {
  205. event.setCanceled(true);
  206. }
  207. break;
  208. }
  209. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.WITHER)) {
  210. if (event != null && event.isCancelable()) {
  211. event.setCanceled(true);
  212. }
  213. break;
  214. }
  215. if (ChillzoneoriginsaddonModVariables.AdaptionEnviroment.get((int) index).is(DamageTypes.WITHER_SKULL)) {
  216. if (event != null && event.isCancelable()) {
  217. event.setCanceled(true);
  218. }
  219. break;
  220. }
  221. index = index + 1;
  222. }
  223. ChillzoneoriginsaddonMod.queueServerWork(1200, () -> {
  224. ChillzoneoriginsaddonModVariables.AdaptionEnviroment.add(damagesource);
  225. if (entity instanceof Player _player && !_player.level().isClientSide())
  226. _player.displayClientMessage(Component.literal("ADAPTED"), true);
  227. });
  228. }
  229. }
  230. }
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement