Advertisement
Guest User

code

a guest
Feb 29th, 2024
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. package mc.hostilemobs.procedures;
  2.  
  3. /* imports omitted */
  4.  
  5. public class TntPhantomTickProcedure {
  6. public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
  7. if (entity == null)
  8. return;
  9. double desiredY = 0;
  10. if (!world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 199, 199, 199), e -> true).isEmpty()) {
  11. desiredY = ((Entity) world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 200, 200, 200), e -> true).stream().sorted(new Object() {
  12. Comparator<Entity> compareDistOf(double _x, double _y, double _z) {
  13. return Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_x, _y, _z));
  14. }
  15. }.compareDistOf(x, y, z)).findFirst().orElse(null)).getY() + 30;
  16. } else if (50 >= y + (-1) * world.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (int) x, (int) z)) {
  17. desiredY = world.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (int) x, (int) z) + 20;
  18. } else {
  19. desiredY = y;
  20. }
  21. if (0 >= (entity instanceof TntPhantomEntity _datEntI ? _datEntI.getEntityData().get(TntPhantomEntity.DATA_tntCoolDown) : 0)) {
  22. if (!world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 199, 199, 199), e -> true).isEmpty()) {
  23. if (!world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, (((Entity) world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 200, 200, 200), e -> true).stream().sorted(new Object() {
  24. Comparator<Entity> compareDistOf(double _x, double _y, double _z) {
  25. return Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_x, _y, _z));
  26. }
  27. }.compareDistOf(x, y, z)).findFirst().orElse(null)).getY()), z), 5, 5, 5), e -> true).isEmpty()) {
  28. if (entity instanceof TntPhantomEntity _datEntSetI)
  29. _datEntSetI.getEntityData().set(TntPhantomEntity.DATA_tntCoolDown, 300);
  30. if (world instanceof ServerLevel _level) {
  31. Entity entityToSpawn = EntityType.TNT.spawn(_level, BlockPos.containing(x, y, z), MobSpawnType.MOB_SUMMONED);
  32. if (entityToSpawn != null) {
  33. entityToSpawn.setDeltaMovement(0, 0, 0);
  34. }
  35. }
  36. } else {
  37. if (entity instanceof Mob _entity)
  38. _entity.getNavigation().moveTo((((Entity) world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 201, 201, 201), e -> true).stream().sorted(new Object() {
  39. Comparator<Entity> compareDistOf(double _x, double _y, double _z) {
  40. return Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_x, _y, _z));
  41. }
  42. }.compareDistOf(x, y, z)).findFirst().orElse(null)).getX()), desiredY, (((Entity) world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 201, 201, 201), e -> true).stream().sorted(new Object() {
  43. Comparator<Entity> compareDistOf(double _x, double _y, double _z) {
  44. return Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_x, _y, _z));
  45. }
  46. }.compareDistOf(x, y, z)).findFirst().orElse(null)).getZ()), 1.5);
  47. }
  48. }
  49. } else {
  50. if (!world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 199, 199, 199), e -> true).isEmpty()) {
  51. if (entity instanceof Mob _entity)
  52. _entity.getNavigation().moveTo((((Entity) world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 201, 201, 201), e -> true).stream().sorted(new Object() {
  53. Comparator<Entity> compareDistOf(double _x, double _y, double _z) {
  54. return Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_x, _y, _z));
  55. }
  56. }.compareDistOf(x, y, z)).findFirst().orElse(null)).getX()), desiredY, (((Entity) world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 201, 201, 201), e -> true).stream().sorted(new Object() {
  57. Comparator<Entity> compareDistOf(double _x, double _y, double _z) {
  58. return Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_x, _y, _z));
  59. }
  60. }.compareDistOf(x, y, z)).findFirst().orElse(null)).getZ()), 2);
  61. if (entity instanceof TntPhantomEntity _datEntSetI)
  62. _datEntSetI.getEntityData().set(TntPhantomEntity.DATA_tntCoolDown, (int) (-1 + (entity instanceof TntPhantomEntity _datEntI ? _datEntI.getEntityData().get(TntPhantomEntity.DATA_tntCoolDown) : 0)));
  63. } else {
  64. if (entity instanceof TntPhantomEntity _datEntSetI)
  65. _datEntSetI.getEntityData().set(TntPhantomEntity.DATA_tntCoolDown, 300);
  66. }
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement