use of net.minecraft.server.v1_16_R1.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;
}
use of net.minecraft.server.v1_16_R1.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!");
}
}
}
use of net.minecraft.server.v1_16_R1.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));
}
use of net.minecraft.server.v1_16_R1.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));
}
use of net.minecraft.server.v1_16_R1.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));
}
Aggregations