Search in sources :

Example 21 with PacketPlayOutAnimation

use of net.minecraft.server.v1_16_R3.PacketPlayOutAnimation in project Warlords by ebicep.

the class EarthenSpike method onActivate.

@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
    Location location = player.getLocation();
    for (WarlordsPlayer p : PlayerFilter.entitiesAround(player, radius, radius, radius).aliveEnemiesOf(wp).lookingAtFirst(wp)) {
        if (Utils.isLookingAt(player, p.getEntity()) && Utils.hasLineOfSight(player, p.getEntity())) {
            PacketPlayOutAnimation playOutAnimation = new PacketPlayOutAnimation(((CraftPlayer) player).getHandle(), 0);
            ((CraftPlayer) player).getHandle().playerConnection.sendPacket(playOutAnimation);
            FallingBlock block = spawnFallingBlock(location, location);
            EarthenSpikeBlock earthenSpikeBlock = new EarthenSpikeBlock(new CustomFallingBlock(block, block.getLocation().getY() - .2), p, wp);
            wp.subtractEnergy(energyCost);
            new GameRunnable(wp.getGame()) {

                private final float SPEED = 1;

                private final float SPEED_SQUARED = SPEED * SPEED;

                private final Location spikeLoc = location;

                {
                    spikeLoc.setY(spikeLoc.getBlockY());
                }

                @Override
                public void run() {
                    earthenSpikeBlock.addDuration();
                    List<CustomFallingBlock> customFallingBlocks = earthenSpikeBlock.getFallingBlocks();
                    WarlordsPlayer target = earthenSpikeBlock.getTarget();
                    WarlordsPlayer user = earthenSpikeBlock.getUser();
                    if (earthenSpikeBlock.getDuration() % 5 == 1) {
                        Utils.playGlobalSound(spikeLoc, REPEATING_SOUND[(earthenSpikeBlock.getDuration() / 5) % 4], 2, 1);
                    }
                    if (earthenSpikeBlock.getDuration() > 30) {
                        // out of time
                        earthenSpikeBlock.setDuration(-1);
                        this.cancel();
                        return;
                    }
                    Vector change = target.getLocation().toVector().subtract(spikeLoc.toVector());
                    change.setY(0);
                    double length = change.lengthSquared();
                    if (length > SPEED_SQUARED) {
                        change.multiply(1 / (Math.sqrt(length) / SPEED));
                        spikeLoc.add(change);
                        // moving vertically
                        if (target.getLocation().getY() < spikeLoc.getY()) {
                            for (int j = 0; j < 10; j++) {
                                if (spikeLoc.clone().add(0, -1, 0).getBlock().getType() == Material.AIR) {
                                    spikeLoc.add(0, -1, 0);
                                } else {
                                    break;
                                }
                            }
                        } else {
                            for (int j = 0; j < 10; j++) {
                                if (spikeLoc.getBlock().getType() != Material.AIR) {
                                    spikeLoc.add(0, 1, 0);
                                } else {
                                    break;
                                }
                            }
                        }
                        // temp fix for block glitch
                        for (int i = 0; i < 10; i++) {
                            if (spikeLoc.getBlock().getType() != Material.AIR) {
                                spikeLoc.add(0, 1, 0);
                            } else {
                                break;
                            }
                        }
                        FallingBlock newBlock = spawnFallingBlock(spikeLoc, spikeLoc);
                        customFallingBlocks.add(new CustomFallingBlock(newBlock, newBlock.getLocation().getY() - .20));
                    } else {
                        // impact
                        Location targetLocation = target.getLocation();
                        for (WarlordsPlayer spikeTarget : PlayerFilter.entitiesAround(targetLocation, 2.5, 2.5, 2.5).aliveEnemiesOf(wp)) {
                            spikeTarget.addDamageInstance(user, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
                            // todo tweak distance to ground where you cant get kbed up (1.81 is max jump blocks, double spike kb might be possible with this)
                            if (Utils.getDistance(spikeTarget.getEntity(), .1) < 1.81) {
                                spikeTarget.setVelocity(new Vector(0, .625, 0));
                            }
                        }
                        Utils.playGlobalSound(wp.getLocation(), "shaman.earthenspike.impact", 2, 1);
                        targetLocation.setYaw(0);
                        for (int i = 0; i < 100; i++) {
                            if (targetLocation.clone().add(0, -1, 0).getBlock().getType() == Material.AIR) {
                                targetLocation.add(0, -1, 0);
                            } else {
                                break;
                            }
                        }
                        ArmorStand stand = (ArmorStand) targetLocation.getWorld().spawnEntity(targetLocation.add(0, -.6, 0), EntityType.ARMOR_STAND);
                        stand.setHelmet(new ItemStack(Material.BROWN_MUSHROOM));
                        stand.setGravity(false);
                        stand.setVisible(false);
                        stand.setMarker(true);
                        new BukkitRunnable() {

                            @Override
                            public void run() {
                                stand.remove();
                                this.cancel();
                            }
                        }.runTaskTimer(Warlords.getInstance(), 10, 0);
                        earthenSpikeBlock.setDuration(-1);
                        this.cancel();
                    }
                    if (target.isDead()) {
                        earthenSpikeBlock.setDuration(-1);
                        this.cancel();
                    }
                }
            }.runTaskTimer(0, 2);
            new GameRunnable(wp.getGame()) {

                @Override
                public void run() {
                    for (CustomFallingBlock fallingBlock : earthenSpikeBlock.getFallingBlocks()) {
                        FallingBlock block = fallingBlock.getBlock();
                        if (block.isValid()) {
                            if (block.getLocation().getY() <= fallingBlock.getyLevelToRemove()) {
                                // || block.getTicksLived() >= 10) {
                                block.remove();
                                earthenSpikeBlock.addRemoved();
                            }
                        }
                    }
                    if (earthenSpikeBlock.getDuration() == -1 && earthenSpikeBlock.getRemoved() == earthenSpikeBlock.getFallingBlocks().size()) {
                        this.cancel();
                    }
                }
            }.runTaskTimer(0, 0);
            break;
        }
    }
    return true;
}
Also used : WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) FallingBlock(org.bukkit.entity.FallingBlock) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) ArmorStand(org.bukkit.entity.ArmorStand) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(org.bukkit.inventory.ItemStack) Vector(org.bukkit.util.Vector) PacketPlayOutAnimation(net.minecraft.server.v1_8_R3.PacketPlayOutAnimation) Location(org.bukkit.Location)

Example 22 with PacketPlayOutAnimation

use of net.minecraft.server.v1_16_R3.PacketPlayOutAnimation in project Warlords by ebicep.

the class HolyRadianceProtector method chain.

@Override
public void chain(WarlordsPlayer wp, Player player) {
    for (WarlordsPlayer markTarget : PlayerFilter.entitiesAround(player, markRadius, markRadius, markRadius).aliveTeammatesOfExcludingSelf(wp).lookingAtFirst(wp).limit(1)) {
        if (Utils.isLookingAtMark(player, markTarget.getEntity()) && Utils.hasLineOfSight(player, markTarget.getEntity())) {
            wp.subtractEnergy(energyCost);
            for (WarlordsPlayer healTarget : PlayerFilter.playingGame(wp.getGame()).excluding(getPlayersHit()).aliveTeammatesOf(wp)) {
                markTarget.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
            }
            Utils.playGlobalSound(player.getLocation(), "paladin.consecrate.activation", 2, 0.65f);
            PacketPlayOutAnimation playOutAnimation = new PacketPlayOutAnimation(((CraftPlayer) player).getHandle(), 0);
            ((CraftPlayer) player).getHandle().playerConnection.sendPacket(playOutAnimation);
            // chain particles
            EffectUtils.playParticleLinkAnimation(player.getLocation(), markTarget.getLocation(), 0, 255, 70, 1);
            EffectUtils.playChainAnimation(wp.getLocation(), markTarget.getLocation(), new ItemStack(Material.RED_ROSE), 8);
            HolyRadianceProtector tempMark = new HolyRadianceProtector(minDamageHeal, maxDamageHeal, cooldown, energyCost, critChance, critMultiplier);
            markTarget.getCooldownManager().addRegularCooldown(name, "PROT MARK", HolyRadianceProtector.class, tempMark, wp, CooldownTypes.BUFF, cooldownManager -> {
                ParticleEffect.SPELL.display(1, 1, 1, 0.06F, 12, markTarget.getLocation(), 500);
                Utils.playGlobalSound(markTarget.getLocation(), "paladin.holyradiance.activation", 2, 0.95f);
                for (WarlordsPlayer waveTarget : PlayerFilter.entitiesAround(markTarget, 6, 6, 6).aliveTeammatesOf(markTarget)) {
                    wp.getGame().registerGameTask(new FlyingArmorStand(markTarget.getLocation(), waveTarget, wp, 1.1, minDamageHeal * 0.5f, maxDamageHeal * 0.5f).runTaskTimer(Warlords.getInstance(), 1, 1));
                }
            }, markDuration * 20);
            player.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " You have marked " + ChatColor.GREEN + markTarget.getName() + ChatColor.GRAY + "!");
            markTarget.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " You have been granted " + ChatColor.GREEN + "Protector's Mark" + ChatColor.GRAY + " by " + wp.getName() + "!");
            new GameRunnable(wp.getGame()) {

                @Override
                public void run() {
                    if (markTarget.getCooldownManager().hasCooldown(tempMark)) {
                        Location playerLoc = markTarget.getLocation();
                        Location particleLoc = playerLoc.clone();
                        for (int i = 0; i < 4; i++) {
                            for (int j = 0; j < 10; j++) {
                                double angle = j / 9D * Math.PI * 2;
                                double width = 1;
                                particleLoc.setX(playerLoc.getX() + Math.sin(angle) * width);
                                particleLoc.setY(playerLoc.getY() + i / 6D);
                                particleLoc.setZ(playerLoc.getZ() + Math.cos(angle) * width);
                                ParticleEffect.REDSTONE.display(new ParticleEffect.OrdinaryColor(0, 255, 70), particleLoc, 500);
                            }
                        }
                    } else {
                        this.cancel();
                    }
                }
            }.runTaskTimer(0, 10);
        } else {
            player.sendMessage("§cYour mark was out of range or you did not target a player!");
        }
    }
}
Also used : WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) ItemStack(org.bukkit.inventory.ItemStack) PacketPlayOutAnimation(net.minecraft.server.v1_8_R3.PacketPlayOutAnimation) Location(org.bukkit.Location)

Example 23 with PacketPlayOutAnimation

use of net.minecraft.server.v1_16_R3.PacketPlayOutAnimation in project PublicCrafters by BananaPuncher714.

the class ContainerManager_v1_13_R2 method animate.

@Override
public void animate(Player player) {
    EntityPlayer NMSPlayer = ((CraftPlayer) player).getHandle();
    broadcastPacket(player, new PacketPlayOutAnimation(NMSPlayer, ThreadLocalRandom.current().nextInt(2) == 1 ? 0 : 3));
}
Also used : EntityPlayer(net.minecraft.server.v1_13_R2.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer) PacketPlayOutAnimation(net.minecraft.server.v1_13_R2.PacketPlayOutAnimation)

Example 24 with PacketPlayOutAnimation

use of net.minecraft.server.v1_16_R3.PacketPlayOutAnimation in project PublicCrafters by BananaPuncher714.

the class ContainerManager_v1_14_R1 method animate.

@Override
public void animate(Player player) {
    EntityPlayer NMSPlayer = ((CraftPlayer) player).getHandle();
    broadcastPacket(player, new PacketPlayOutAnimation(NMSPlayer, ThreadLocalRandom.current().nextInt(2) == 1 ? 0 : 3));
}
Also used : EntityPlayer(net.minecraft.server.v1_14_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer) PacketPlayOutAnimation(net.minecraft.server.v1_14_R1.PacketPlayOutAnimation)

Example 25 with PacketPlayOutAnimation

use of net.minecraft.server.v1_16_R3.PacketPlayOutAnimation in project PublicCrafters by BananaPuncher714.

the class ContainerManager_v1_8_R3 method animate.

@Override
public void animate(Player player) {
    EntityPlayer NMSPlayer = ((CraftPlayer) player).getHandle();
    broadcastPacket(player, new PacketPlayOutAnimation(NMSPlayer, 0));
}
Also used : EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) PacketPlayOutAnimation(net.minecraft.server.v1_8_R3.PacketPlayOutAnimation)

Aggregations

PacketPlayOutAnimation (net.minecraft.server.v1_8_R3.PacketPlayOutAnimation)9 CraftPlayer (org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer)7 PacketPlayOutAnimation (net.minecraft.server.v1_16_R3.PacketPlayOutAnimation)4 WarlordsPlayer (com.ebicep.warlords.player.WarlordsPlayer)3 GameRunnable (com.ebicep.warlords.util.warlords.GameRunnable)3 PacketPlayOutAnimation (net.minecraft.server.v1_15_R1.PacketPlayOutAnimation)3 Location (org.bukkit.Location)3 Player (org.bukkit.entity.Player)3 ItemStack (org.bukkit.inventory.ItemStack)3 PacketPlayOutAnimation (net.minecraft.server.v1_10_R1.PacketPlayOutAnimation)2 PacketPlayOutAnimation (net.minecraft.server.v1_11_R1.PacketPlayOutAnimation)2 PacketPlayOutAnimation (net.minecraft.server.v1_12_R1.PacketPlayOutAnimation)2 PacketPlayOutAnimation (net.minecraft.server.v1_13_R2.PacketPlayOutAnimation)2 PacketPlayOutAnimation (net.minecraft.server.v1_14_R1.PacketPlayOutAnimation)2 EntityPlayer (net.minecraft.server.v1_15_R1.EntityPlayer)2 EntityPlayer (net.minecraft.server.v1_16_R3.EntityPlayer)2 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)2 CraftPlayer (org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)2 ArmorStand (org.bukkit.entity.ArmorStand)2 CooldownFilter (com.ebicep.warlords.player.cooldowns.CooldownFilter)1