Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mc.hostilemobs.procedures;
- /* imports omitted */
- public class TntPhantomTickProcedure {
- public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
- if (entity == null)
- return;
- double desiredY = 0;
- if (!world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 199, 199, 199), e -> true).isEmpty()) {
- desiredY = ((Entity) world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 200, 200, 200), e -> true).stream().sorted(new Object() {
- Comparator<Entity> compareDistOf(double _x, double _y, double _z) {
- return Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_x, _y, _z));
- }
- }.compareDistOf(x, y, z)).findFirst().orElse(null)).getY() + 30;
- } else if (50 >= y + (-1) * world.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (int) x, (int) z)) {
- desiredY = world.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (int) x, (int) z) + 20;
- } else {
- desiredY = y;
- }
- if (0 >= (entity instanceof TntPhantomEntity _datEntI ? _datEntI.getEntityData().get(TntPhantomEntity.DATA_tntCoolDown) : 0)) {
- if (!world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 199, 199, 199), e -> true).isEmpty()) {
- 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() {
- Comparator<Entity> compareDistOf(double _x, double _y, double _z) {
- return Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_x, _y, _z));
- }
- }.compareDistOf(x, y, z)).findFirst().orElse(null)).getY()), z), 5, 5, 5), e -> true).isEmpty()) {
- if (entity instanceof TntPhantomEntity _datEntSetI)
- _datEntSetI.getEntityData().set(TntPhantomEntity.DATA_tntCoolDown, 300);
- if (world instanceof ServerLevel _level) {
- Entity entityToSpawn = EntityType.TNT.spawn(_level, BlockPos.containing(x, y, z), MobSpawnType.MOB_SUMMONED);
- if (entityToSpawn != null) {
- entityToSpawn.setDeltaMovement(0, 0, 0);
- }
- }
- } else {
- if (entity instanceof Mob _entity)
- _entity.getNavigation().moveTo((((Entity) world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 201, 201, 201), e -> true).stream().sorted(new Object() {
- Comparator<Entity> compareDistOf(double _x, double _y, double _z) {
- return Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_x, _y, _z));
- }
- }.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() {
- Comparator<Entity> compareDistOf(double _x, double _y, double _z) {
- return Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_x, _y, _z));
- }
- }.compareDistOf(x, y, z)).findFirst().orElse(null)).getZ()), 1.5);
- }
- }
- } else {
- if (!world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 199, 199, 199), e -> true).isEmpty()) {
- if (entity instanceof Mob _entity)
- _entity.getNavigation().moveTo((((Entity) world.getEntitiesOfClass(Player.class, AABB.ofSize(new Vec3(x, y, z), 201, 201, 201), e -> true).stream().sorted(new Object() {
- Comparator<Entity> compareDistOf(double _x, double _y, double _z) {
- return Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_x, _y, _z));
- }
- }.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() {
- Comparator<Entity> compareDistOf(double _x, double _y, double _z) {
- return Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_x, _y, _z));
- }
- }.compareDistOf(x, y, z)).findFirst().orElse(null)).getZ()), 2);
- if (entity instanceof TntPhantomEntity _datEntSetI)
- _datEntSetI.getEntityData().set(TntPhantomEntity.DATA_tntCoolDown, (int) (-1 + (entity instanceof TntPhantomEntity _datEntI ? _datEntI.getEntityData().get(TntPhantomEntity.DATA_tntCoolDown) : 0)));
- } else {
- if (entity instanceof TntPhantomEntity _datEntSetI)
- _datEntSetI.getEntityData().set(TntPhantomEntity.DATA_tntCoolDown, 300);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement