Search in sources :

Example 91 with Entity

use of net.minecraft.server.v1_14_R1.Entity in project UltraCosmetics by iSach.

the class PlayerFollower method follow.

@Override
public void follow(Player player) {
    if (player == null) {
        return;
    }
    if (UltraCosmeticsData.get().getPlugin().getPlayerManager().getUltraPlayer(player).getCurrentTreasureChest() != null) {
        return;
    }
    Entity petEntity;
    if (pet.isCustomEntity()) {
        petEntity = ((CustomEntityPet) pet).getCustomEntity();
    } else {
        petEntity = ((CraftEntity) pet.getEntity()).getHandle();
    }
    if (petEntity == null) {
        return;
    }
    // Run in sync... To enhance :S
    Bukkit.getScheduler().runTask(UltraCosmeticsData.get().getPlugin(), () -> {
        if (!player.isOnline())
            return;
        if (!player.getWorld().equals(petEntity.getBukkitEntity().getWorld())) {
            petEntity.getBukkitEntity().teleport(player.getLocation());
            return;
        }
        ((EntityInsentient) petEntity).getNavigation().a(2d);
        Location targetLocation = player.getLocation();
        PathEntity path = ((EntityInsentient) petEntity).getNavigation().a(targetLocation.getX() + 1, targetLocation.getY(), targetLocation.getZ() + 1, 1);
        try {
            int distance = (int) Bukkit.getPlayer(player.getName()).getLocation().distance(petEntity.getBukkitEntity().getLocation());
            if (distance > 10 && petEntity.valid && player.isOnGround()) {
                petEntity.setLocation(targetLocation.getBlockX(), targetLocation.getBlockY(), targetLocation.getBlockZ(), 0, 0);
            }
            if (path != null && distance > 1.3) {
                double speed = 1.15d;
                if (pet.getType().getEntityType() == EntityType.ZOMBIE) {
                    speed *= 1.3;
                }
                ((EntityInsentient) petEntity).getNavigation().a(path, speed);
                ((EntityInsentient) petEntity).getNavigation().a(speed);
            }
        } catch (IllegalArgumentException exception) {
            petEntity.setLocation(targetLocation.getBlockX(), targetLocation.getBlockY(), targetLocation.getBlockZ(), 0, 0);
        // exception.printStackTrace();
        }
    });
}
Also used : CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) Entity(net.minecraft.server.v1_16_R3.Entity) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) Location(org.bukkit.Location)

Example 92 with Entity

use of net.minecraft.server.v1_14_R1.Entity in project SimplePets by brainsynder-Dev.

the class EntityControllerPet method reloadLocation.

@Override
public void reloadLocation() {
    if (displayEntity.getPassenger() != null) {
        net.minecraft.server.v1_14_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
        Location loc;
        if (this.displayRider != null) {
            if (this.displayRider.getType().equals(EntityType.SHULKER)) {
                loc = getBukkitEntity().getLocation().clone().subtract(0, 0.735, 0);
            } else {
                loc = getBukkitEntity().getLocation().clone();
            }
        } else {
            loc = getBukkitEntity().getLocation().clone();
        }
        displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
        loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
            if (entity instanceof Player) {
                Player player = (Player) entity;
                PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
                ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
            }
        });
        return;
    }
    net.minecraft.server.v1_14_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
    Location loc;
    if (this.displayRider != null) {
        if (this.displayRider.getType().equals(EntityType.SHULKER)) {
            loc = getBukkitEntity().getLocation().clone().add(0, 0.75, 0);
        } else {
            loc = getBukkitEntity().getLocation().clone();
        }
    } else {
        loc = getBukkitEntity().getLocation().clone();
    }
    displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
    loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
        if (entity instanceof Player) {
            Player player = (Player) entity;
            PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
            ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
        }
    });
}
Also used : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer) net.minecraft.server.v1_14_R1(net.minecraft.server.v1_14_R1) CraftEntity(org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity) CraftPlayer(org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer) Location(org.bukkit.Location)

Example 93 with Entity

use of net.minecraft.server.v1_14_R1.Entity in project geowave by locationtech.

the class OsmXmlLoader method process.

// Sink implementation
@Override
public void process(final EntityContainer entityContainer) {
    final Entity entity = entityContainer.getEntity();
    if (entity instanceof Node) {
        final Node node = (Node) entity;
        nodes.add(node);
        nodeById.put(node.getId(), node);
    } else if (entity instanceof Way) {
        final Way way = (Way) entity;
        ways.add(way);
    } else if (entity instanceof Relation) {
        final Relation rel = (Relation) entity;
        relations.add(rel);
    }
}
Also used : Entity(org.openstreetmap.osmosis.core.domain.v0_6.Entity) Relation(org.openstreetmap.osmosis.core.domain.v0_6.Relation) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Way(org.openstreetmap.osmosis.core.domain.v0_6.Way)

Example 94 with Entity

use of net.minecraft.server.v1_14_R1.Entity in project nomulus by google.

the class BulkDeleteDatastorePipelineTest method splitEntitiesByKind.

@Test
void splitEntitiesByKind() {
    TupleTagList tags = getDeletionTags(2);
    PCollection<String> kinds = testPipeline.apply("InjectKinds", Create.of("A", "B"));
    PCollectionView<Map<String, TupleTag<Entity>>> kindToTagMapping = BulkDeleteDatastorePipeline.mapKindsToDeletionTags(kinds, tags).apply(View.asMap());
    Entity entityA = createTestEntity("A", 1);
    Entity entityB = createTestEntity("B", 2);
    PCollection<Entity> entities = testPipeline.apply("InjectEntities", Create.of(entityA, entityB));
    PCollectionTuple allCollections = entities.apply("SplitByKind", ParDo.of(new SplitEntities(kindToTagMapping)).withSideInputs(kindToTagMapping).withOutputTags(getOneDeletionTag("placeholder"), tags));
    PAssert.that(allCollections.get((TupleTag<Entity>) tags.get(0))).containsInAnyOrder(entityA);
    PAssert.that(allCollections.get((TupleTag<Entity>) tags.get(1))).containsInAnyOrder(entityB);
    testPipeline.run();
}
Also used : Entity(com.google.datastore.v1.Entity) SplitEntities(google.registry.beam.datastore.BulkDeleteDatastorePipeline.SplitEntities) TupleTagList(org.apache.beam.sdk.values.TupleTagList) PCollectionTuple(org.apache.beam.sdk.values.PCollectionTuple) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.jupiter.api.Test)

Example 95 with Entity

use of net.minecraft.server.v1_14_R1.Entity in project nomulus by google.

the class BulkDeleteDatastorePipelineTest method mapKindsToTags_fewerKindsThanTags.

@Test
void mapKindsToTags_fewerKindsThanTags() {
    TupleTagList tags = getDeletionTags(3);
    PCollection<String> kinds = testPipeline.apply("InjectKinds", Create.of("A", "B"));
    PCollection<KV<String, TupleTag<Entity>>> kindToTagMapping = BulkDeleteDatastorePipeline.mapKindsToDeletionTags(kinds, tags);
    PAssert.thatMap(kindToTagMapping).isEqualTo(ImmutableMap.of("A", new TupleTag<Entity>("0"), "B", new TupleTag<Entity>("1")));
    testPipeline.run();
}
Also used : Entity(com.google.datastore.v1.Entity) TupleTagList(org.apache.beam.sdk.values.TupleTagList) TupleTag(org.apache.beam.sdk.values.TupleTag) KV(org.apache.beam.sdk.values.KV) Test(org.junit.jupiter.api.Test)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)95 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)88 net.minecraft.world.entity (net.minecraft.world.entity)32 org.bukkit.entity (org.bukkit.entity)32 Entity (com.google.datastore.v1.Entity)31 Location (org.bukkit.Location)30 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)21 Entity (net.minecraft.server.v1_12_R1.Entity)20 Entity (net.minecraft.server.v1_16_R3.Entity)19 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)18 Player (org.bukkit.entity.Player)18 Entity (net.minecraft.server.v1_8_R3.Entity)17 Entity (net.minecraft.server.v1_11_R1.Entity)16 Mob (net.minecraft.world.entity.Mob)16 CraftEntity (org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity)16 org.bukkit.craftbukkit.v1_17_R1.entity (org.bukkit.craftbukkit.v1_17_R1.entity)16 PathEntity (net.minecraft.server.v1_16_R3.PathEntity)13 Entity (net.minecraft.server.v1_15_R1.Entity)12 Entity (net.minecraft.server.v1_13_R2.Entity)11