Search in sources :

Example 11 with EntityPlayer

use of net.minecraft.server.v1_6_R1.EntityPlayer in project Citizens2 by CitizensDev.

the class NMSImpl method sendTabListAdd.

@Override
public void sendTabListAdd(Player recipient, Player listPlayer) {
    Preconditions.checkNotNull(recipient);
    Preconditions.checkNotNull(listPlayer);
    EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();
    NMSImpl.sendPacket(recipient, new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entity));
}
Also used : EntityPlayer(net.minecraft.server.v1_10_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer) PacketPlayOutPlayerInfo(net.minecraft.server.v1_10_R1.PacketPlayOutPlayerInfo)

Example 12 with EntityPlayer

use of net.minecraft.server.v1_6_R1.EntityPlayer in project Citizens2 by CitizensDev.

the class NMSImpl method attack.

@Override
public void attack(LivingEntity attacker, LivingEntity btarget) {
    EntityLiving handle = getHandle(attacker);
    EntityLiving target = getHandle(btarget);
    if (handle instanceof EntityPlayer) {
        EntityPlayer humanHandle = (EntityPlayer) handle;
        humanHandle.attack(target);
        PlayerAnimation.ARM_SWING.play(humanHandle.getBukkitEntity());
        return;
    }
    AttributeInstance attackDamage = handle.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE);
    float f = (float) (attackDamage == null ? 1 : attackDamage.getValue());
    int i = 0;
    if (target instanceof EntityLiving) {
        f += EnchantmentManager.a(handle.getItemInMainHand(), target.getMonsterType());
        i += EnchantmentManager.a(handle);
    }
    boolean flag = target.damageEntity(DamageSource.mobAttack(handle), f);
    if (!flag)
        return;
    if (i > 0) {
        target.g(-Math.sin(handle.yaw * Math.PI / 180.0F) * i * 0.5F, 0.1D, Math.cos(handle.yaw * Math.PI / 180.0F) * i * 0.5F);
        handle.motX *= 0.6D;
        handle.motZ *= 0.6D;
    }
    int fireAspectLevel = EnchantmentManager.getFireAspectEnchantmentLevel(handle);
    if (fireAspectLevel > 0) {
        target.setOnFire(fireAspectLevel * 4);
    }
}
Also used : EntityLiving(net.minecraft.server.v1_10_R1.EntityLiving) AttributeInstance(net.minecraft.server.v1_10_R1.AttributeInstance) EntityPlayer(net.minecraft.server.v1_10_R1.EntityPlayer) PathPoint(net.minecraft.server.v1_10_R1.PathPoint)

Example 13 with EntityPlayer

use of net.minecraft.server.v1_6_R1.EntityPlayer in project Citizens2 by CitizensDev.

the class NMSImpl method sendTabListRemove.

@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
    Preconditions.checkNotNull(recipient);
    Preconditions.checkNotNull(skinnableNPCs);
    EntityPlayer[] entities = new EntityPlayer[skinnableNPCs.size()];
    int i = 0;
    for (SkinnableEntity skinnable : skinnableNPCs) {
        entities[i] = (EntityPlayer) skinnable;
        i++;
    }
    NMSImpl.sendPacket(recipient, new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entities));
}
Also used : SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) EntityPlayer(net.minecraft.server.v1_10_R1.EntityPlayer) PacketPlayOutPlayerInfo(net.minecraft.server.v1_10_R1.PacketPlayOutPlayerInfo) PathPoint(net.minecraft.server.v1_10_R1.PathPoint)

Example 14 with EntityPlayer

use of net.minecraft.server.v1_6_R1.EntityPlayer in project Citizens2 by CitizensDev.

the class NMSImpl method sendTabListRemove.

@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
    Preconditions.checkNotNull(recipient);
    Preconditions.checkNotNull(skinnableNPCs);
    EntityPlayer[] entities = new EntityPlayer[skinnableNPCs.size()];
    int i = 0;
    for (SkinnableEntity skinnable : skinnableNPCs) {
        entities[i] = (EntityPlayer) skinnable;
        i++;
    }
    NMSImpl.sendPacket(recipient, new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entities));
}
Also used : SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) PacketPlayOutPlayerInfo(net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo) PathPoint(net.minecraft.server.v1_8_R3.PathPoint)

Example 15 with EntityPlayer

use of net.minecraft.server.v1_6_R1.EntityPlayer in project Citizens2 by CitizensDev.

the class PlayerAnimationImpl method play.

public static void play(PlayerAnimation animation, Player bplayer, int radius) {
    // TODO: this is pretty gross
    final EntityPlayer player = (EntityPlayer) NMSImpl.getHandle(bplayer);
    if (DEFAULTS.containsKey(animation)) {
        playDefaultAnimation(player, radius, DEFAULTS.get(animation));
        return;
    }
    switch(animation) {
        case SIT:
            player.getBukkitEntity().setMetadata("citizens.sitting", new FixedMetadataValue(CitizensAPI.getPlugin(), true));
            final NPC holder = CitizensAPI.getNPCRegistry().createNPC(EntityType.ARMOR_STAND, "");
            holder.spawn(player.getBukkitEntity().getLocation());
            ArmorStandTrait trait = holder.getTrait(ArmorStandTrait.class);
            trait.setGravity(false);
            trait.setHasArms(false);
            trait.setHasBaseplate(false);
            trait.setSmall(true);
            trait.setMarker(true);
            trait.setVisible(false);
            holder.getTrait(ArmorStandTrait.class).setVisible(false);
            holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
            holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
            new BukkitRunnable() {

                @Override
                public void cancel() {
                    super.cancel();
                    holder.destroy();
                }

                @Override
                public void run() {
                    if (player.dead || !player.valid || !player.getBukkitEntity().getMetadata("citizens.sitting").get(0).asBoolean()) {
                        cancel();
                        return;
                    }
                    if (player instanceof NPCHolder && !((NPCHolder) player).getNPC().isSpawned()) {
                        cancel();
                        return;
                    }
                    if (!NMS.getPassengers(holder.getEntity()).contains(player.getBukkitEntity())) {
                        NMS.mount(holder.getEntity(), player.getBukkitEntity());
                    }
                }
            }.runTaskTimer(CitizensAPI.getPlugin(), 0, 1);
            break;
        case SLEEP:
            PacketPlayOutBed packet = new PacketPlayOutBed(player, new BlockPosition((int) player.locX, (int) player.locY, (int) player.locZ));
            sendPacketNearby(packet, player, radius);
            break;
        case SNEAK:
            player.getBukkitEntity().setSneaking(true);
            sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
            break;
        case STOP_SITTING:
            player.getBukkitEntity().setMetadata("citizens.sitting", new FixedMetadataValue(CitizensAPI.getPlugin(), false));
            NMS.mount(player.getBukkitEntity(), null);
            break;
        case STOP_SLEEPING:
            playDefaultAnimation(player, radius, 2);
            break;
        case STOP_SNEAKING:
            player.getBukkitEntity().setSneaking(false);
            sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
            break;
        default:
            throw new UnsupportedOperationException();
    }
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) PacketPlayOutEntityMetadata(net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ArmorStandTrait(net.citizensnpcs.trait.ArmorStandTrait) PacketPlayOutBed(net.minecraft.server.v1_8_R3.PacketPlayOutBed)

Aggregations

Player (org.bukkit.entity.Player)17 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)14 EntityPlayer (net.minecraft.server.v1_10_R1.EntityPlayer)12 EntityPlayer (net.minecraft.server.v1_11_R1.EntityPlayer)12 EntityPlayer (net.minecraft.server.v1_12_R1.EntityPlayer)12 MyPet (de.Keyle.MyPet.api.entity.MyPet)9 Behavior (de.Keyle.MyPet.skill.skills.Behavior)9 NPC (net.citizensnpcs.api.npc.NPC)8 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)8 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)8 CraftPlayer (org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer)8 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)8 CraftPlayer (org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer)6 CraftPlayer (org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer)6 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)5 UUID (java.util.UUID)4 PacketPlayOutPlayerInfo (net.minecraft.server.v1_10_R1.PacketPlayOutPlayerInfo)4 EntityPlayer (net.minecraft.server.v1_9_R2.EntityPlayer)4 CraftPlayer (org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer)4 ArmorStandTrait (net.citizensnpcs.trait.ArmorStandTrait)3