Search in sources :

Example 16 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project Citizens2 by CitizensDev.

the class PlayerlistTrackerEntry method updatePlayer.

@Override
public void updatePlayer(final EntityPlayer entityplayer) {
    // prevent updates to NPC "viewers"
    if (entityplayer instanceof EntityHumanNPC)
        return;
    Entity tracker = getTracker(this);
    if (entityplayer != tracker && c(entityplayer)) {
        if (!this.trackedPlayers.contains(entityplayer) && ((entityplayer.u().getPlayerChunkMap().a(entityplayer, tracker.ae, tracker.ag)) || (tracker.attachedToPlayer))) {
            if ((tracker instanceof SkinnableEntity)) {
                SkinnableEntity skinnable = (SkinnableEntity) tracker;
                Player player = skinnable.getBukkitEntity();
                if (!entityplayer.getBukkitEntity().canSee(player))
                    return;
                skinnable.getSkinTracker().updateViewer(entityplayer.getBukkitEntity());
            }
        }
    }
    super.updatePlayer(entityplayer);
}
Also used : SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) Entity(net.minecraft.server.v1_8_R3.Entity) Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) EntityHumanNPC(net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)

Example 17 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project Village_Defense by Plajer.

the class RidableIronGolem method g.

@Override
public void g(float f, float f1) {
    EntityLiving entityliving = (EntityLiving) bw();
    if (entityliving == null) {
        // search first human passenger
        for (final Entity e : passengers) {
            if (e instanceof EntityHuman) {
                entityliving = (EntityLiving) e;
                break;
            }
        }
        if (entityliving == null) {
            this.l((float) 0.12);
            super.g(f, f1);
            return;
        }
    }
    this.lastYaw = this.yaw = entityliving.yaw;
    this.pitch = entityliving.pitch * 0.5F;
    this.setYawPitch(this.yaw, this.pitch);
    this.aQ = this.aO = this.yaw;
    f = entityliving.be * 0.75F;
    f1 = entityliving.bf;
    if (f1 <= 0.0f) {
        f1 *= 0.25F;
    }
    this.l((float) 0.12);
    super.g(f, f1);
    P = (float) 1.0;
}
Also used : Entity(net.minecraft.server.v1_11_R1.Entity) EntityHuman(net.minecraft.server.v1_11_R1.EntityHuman) EntityLiving(net.minecraft.server.v1_11_R1.EntityLiving)

Example 18 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project Village_Defense by Plajer.

the class RidableIronGolem method a.

public void a(float f, float f1, float f2) {
    EntityLiving entityliving = null;
    for (final Entity e : passengers) {
        if (e instanceof EntityHuman) {
            entityliving = (EntityLiving) e;
            break;
        }
    }
    if (entityliving == null) {
        this.P = 0.5F;
        this.aR = 0.02F;
        this.k((float) 0.12);
        super.a(f, f1, f2);
        return;
    }
    this.lastYaw = this.yaw = entityliving.yaw;
    this.pitch = entityliving.pitch * 0.5F;
    this.setYawPitch(this.yaw, this.pitch);
    this.aO = this.aM = this.yaw;
    f = entityliving.be * 0.5F * 0.75F;
    f2 = entityliving.bg;
    if (f2 <= 0.0f) {
        f2 *= 0.25F;
    }
    k(0.12f);
    super.a(f, f1, f2);
    P = (float) 1.0;
}
Also used : Entity(net.minecraft.server.v1_12_R1.Entity) EntityHuman(net.minecraft.server.v1_12_R1.EntityHuman) EntityLiving(net.minecraft.server.v1_12_R1.EntityLiving)

Example 19 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project MagicPlugin by elBukkit.

the class CompatibilityUtils method spawnFireworkEffect.

@Override
public Entity spawnFireworkEffect(Material fireworkMaterial, Server server, Location location, FireworkEffect effect, int power, Vector direction, Integer expectedLifespan, Integer ticksFlown, boolean silent) {
    Entity entity = null;
    try {
        if (fireworkMaterial == null) {
            return null;
        }
        ServerLevel level = ((CraftWorld) location.getWorld()).getHandle();
        ItemStack itemStack = new ItemStack(fireworkMaterial);
        FireworkMeta meta = (FireworkMeta) itemStack.getItemMeta();
        meta.addEffect(effect);
        meta.setPower(power);
        itemStack.setItemMeta(meta);
        Object item = platform.getItemUtils().getHandle(platform.getItemUtils().makeReal(itemStack));
        final FireworkRocketEntity fireworkHandle = new FireworkRocketEntity(level, location.getX(), location.getY(), location.getZ(), (net.minecraft.world.item.ItemStack) item);
        fireworkHandle.setSilent(silent);
        if (direction != null) {
            fireworkHandle.setDeltaMovement(new Vec3(direction.getX(), direction.getY(), direction.getZ()));
        }
        if (ticksFlown != null) {
            ReflectionUtils.setPrivateNeedsFixing(platform.getLogger(), fireworkHandle, FireworkRocketEntity.class, "life", "e", ticksFlown);
        }
        if (expectedLifespan != null) {
            fireworkHandle.lifetime = expectedLifespan;
        }
        if (direction == null) {
            ClientboundAddEntityPacket fireworkPacket = new ClientboundAddEntityPacket(fireworkHandle, CompatibilityConstants.FIREWORK_TYPE);
            int fireworkId = fireworkHandle.getId();
            SynchedEntityData watcher = fireworkHandle.getEntityData();
            ClientboundSetEntityDataPacket metadataPacket = new ClientboundSetEntityDataPacket(fireworkId, watcher, true);
            ClientboundEntityEventPacket statusPacket = new ClientboundEntityEventPacket(fireworkHandle, (byte) 17);
            ClientboundRemoveEntitiesPacket destroyPacket = new ClientboundRemoveEntitiesPacket(fireworkId);
            Collection<? extends Player> players = server.getOnlinePlayers();
            sendPacket(server, location, players, fireworkPacket);
            sendPacket(server, location, players, metadataPacket);
            sendPacket(server, location, players, statusPacket);
            sendPacket(server, location, players, destroyPacket);
            return null;
        }
        level.addFreshEntity(fireworkHandle, CreatureSpawnEvent.SpawnReason.CUSTOM);
        entity = fireworkHandle.getBukkitEntity();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return entity;
}
Also used : FireworkRocketEntity(net.minecraft.world.entity.projectile.FireworkRocketEntity) Entity(org.bukkit.entity.Entity) HangingEntity(net.minecraft.world.entity.decoration.HangingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) FallingBlockEntity(net.minecraft.world.entity.item.FallingBlockEntity) LivingEntity(org.bukkit.entity.LivingEntity) ItemEntity(net.minecraft.world.entity.item.ItemEntity) SignBlockEntity(net.minecraft.world.level.block.entity.SignBlockEntity) HumanEntity(org.bukkit.entity.HumanEntity) CraftEntity(org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity) ServerLevel(net.minecraft.server.level.ServerLevel) ClientboundRemoveEntitiesPacket(net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket) SynchedEntityData(net.minecraft.network.syncher.SynchedEntityData) ClientboundAddEntityPacket(net.minecraft.network.protocol.game.ClientboundAddEntityPacket) FireworkMeta(org.bukkit.inventory.meta.FireworkMeta) FireworkRocketEntity(net.minecraft.world.entity.projectile.FireworkRocketEntity) Vec3(net.minecraft.world.phys.Vec3) ClientboundEntityEventPacket(net.minecraft.network.protocol.game.ClientboundEntityEventPacket) ItemStack(org.bukkit.inventory.ItemStack) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) ClientboundSetEntityDataPacket(net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket)

Example 20 with org.bukkit.craftbukkit.v1_18_R2.entity

use of org.bukkit.craftbukkit.v1_18_R2.entity in project MagicPlugin by elBukkit.

the class CompatibilityUtils method addToWorld.

@Override
public boolean addToWorld(World world, Entity entity, CreatureSpawnEvent.SpawnReason reason) {
    ServerLevel level = ((CraftWorld) world).getHandle();
    net.minecraft.world.entity.Entity entityHandle = ((CraftEntity) entity).getHandle();
    level.addFreshEntity(entityHandle, reason);
    return true;
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) CraftEntity(org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)114 Entity (org.hypertrace.entity.data.service.v1.Entity)110 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)102 Test (org.junit.jupiter.api.Test)95 CraftEntity (org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity)53 Entity (net.minecraft.world.entity.Entity)42 Location (org.bukkit.Location)41 ArrayList (java.util.ArrayList)39 Entity (com.google.datastore.v1.Entity)33 net.minecraft.world.entity (net.minecraft.world.entity)33 org.bukkit.entity (org.bukkit.entity)32 EnrichedEntity (org.hypertrace.entity.data.service.v1.EnrichedEntity)32 Player (org.bukkit.entity.Player)29 ServerPlayer (net.minecraft.server.level.ServerPlayer)28 LivingEntity (net.minecraft.world.entity.LivingEntity)28 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)28 CraftPlayer (org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer)27 Event (org.hypertrace.core.datamodel.Event)27 Mob (net.minecraft.world.entity.Mob)25 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)23