feat: BlackKnife DeltaMine v1.0.0 - Paper 1.21.1 SWOON/Stars/Sword/Diamond/Lunge/Snipe/Tri/Overhead + Magic 4commons Parry chat 400words +12h updates
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Marker;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class SwordAttack {
|
||||
public static boolean tryUse(Player p, TensionManager tension) {
|
||||
if (tension.getTP(p) < 12.5f) { p.sendActionBar(net.kyori.adventure.text.Component.text("Need 5% TP").color(net.kyori.adventure.text.format.NamedTextColor.RED)); return false; }
|
||||
tension.setTP(p, tension.getTP(p) - 12.5f);
|
||||
launch(p, tension, p.getEyeLocation().getDirection().normalize(), 2.0);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void launch(Player p, TensionManager tension, Vector dir, double speed) {
|
||||
dir = dir.clone().normalize();
|
||||
Location spawn = p.getLocation().add(0, 2.2, 0).add(dir.clone().multiply(1));
|
||||
Marker marker = p.getWorld().spawn(spawn, Marker.class, m -> m.setPersistent(false));
|
||||
EntityTracker.mark(marker);
|
||||
p.getWorld().playSound(spawn, Sound.ENTITY_PLAYER_ATTACK_SWEEP, 1f, 1.2f);
|
||||
BlackKnifePlugin plugin = BlackKnifePlugin.getPlugin(BlackKnifePlugin.class);
|
||||
Vector initVel = dir.clone().multiply(speed);
|
||||
new BukkitRunnable() {
|
||||
Vector vel = initVel.clone();
|
||||
int homingTicks = 30;
|
||||
@Override public void run() {
|
||||
if (!marker.isValid() || marker.isDead()) { cancel(); return; }
|
||||
if (homingTicks > 0) {
|
||||
Vector gaze = p.getEyeLocation().getDirection().normalize().multiply(speed);
|
||||
vel = vel.multiply(0.82).add(gaze.multiply(0.18)).normalize().multiply(speed);
|
||||
homingTicks--;
|
||||
}
|
||||
Location cur = marker.getLocation();
|
||||
Location nl = cur.clone().add(vel);
|
||||
Vector step = nl.clone().subtract(cur).toVector();
|
||||
double len = step.length();
|
||||
int steps = Math.max(1, (int) Math.ceil(len / 0.5));
|
||||
for (int s = 0; s <= steps; s++) {
|
||||
Location check = cur.clone().add(step.clone().multiply((double) s / steps));
|
||||
if (check.getBlock().isSolid()) {
|
||||
Location expl = cur.clone().add(step.clone().multiply(Math.max(0, (double) (s - 1) / steps)));
|
||||
marker.teleport(expl);
|
||||
for (int k = 0; k < 12; k++) {
|
||||
double a = (double) k / 12 * Math.PI * 2;
|
||||
for (int h = -1; h <= 1; h++) {
|
||||
Location sphere = expl.clone().add(Math.cos(a) * 0.5, h * 0.25, Math.sin(a) * 0.5);
|
||||
sphere.getWorld().spawnParticle(Particle.SMOKE, sphere, 1, 0.02, 0.02, 0.02, 0);
|
||||
sphere.getWorld().spawnParticle(Particle.DUST, sphere, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(30, 30, 30), 0.9f));
|
||||
}
|
||||
}
|
||||
expl.getWorld().spawnParticle(Particle.CRIT, expl, 6, 0.2, 0.2, 0.2, 0.05);
|
||||
expl.getWorld().playSound(expl, Sound.BLOCK_STONE_BREAK, 1f, 0.8f);
|
||||
marker.remove();
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
int points = Math.max(1, (int) (len * 4));
|
||||
for (int i = 0; i <= points; i++) {
|
||||
Location pp = cur.clone().add(step.clone().multiply((double) i / points));
|
||||
pp.getWorld().spawnParticle(Particle.DUST, pp, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(0, 0, 0), 1.5f));
|
||||
}
|
||||
marker.teleport(nl);
|
||||
for (var ent : nl.getWorld().getNearbyEntities(nl, 0.7, 0.7, 0.7, e -> e instanceof LivingEntity && e != p)) {
|
||||
LivingEntity le = (LivingEntity) ent;
|
||||
le.getPersistentDataContainer().set(SwoonHandler.MAGIC_DAMAGE, PersistentDataType.BYTE, (byte) 1);
|
||||
le.damage(15.0, p);
|
||||
Location hit = le.getLocation().add(0, 1, 0);
|
||||
for (int k = 0; k < 12; k++) {
|
||||
double a = (double) k / 12 * Math.PI * 2;
|
||||
for (int h = -1; h <= 1; h++) {
|
||||
Location sphere = hit.clone().add(Math.cos(a) * 0.5, h * 0.25, Math.sin(a) * 0.5);
|
||||
sphere.getWorld().spawnParticle(Particle.SMOKE, sphere, 1, 0.02, 0.02, 0.02, 0);
|
||||
sphere.getWorld().spawnParticle(Particle.DUST, sphere, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(40, 40, 40), 0.9f));
|
||||
}
|
||||
}
|
||||
hit.getWorld().spawnParticle(Particle.CRIT, hit, 10, 0.3, 0.3, 0.3, 0.1);
|
||||
hit.getWorld().playSound(hit, Sound.ENTITY_PLAYER_ATTACK_CRIT, 1f, 0.9f);
|
||||
le.addPotionEffect(new org.bukkit.potion.PotionEffect(org.bukkit.potion.PotionEffectType.SLOWNESS, 40, 1, false, false, true));
|
||||
le.addPotionEffect(new org.bukkit.potion.PotionEffect(org.bukkit.potion.PotionEffectType.WEAKNESS, 30, 0, false, false, true));
|
||||
marker.remove();
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
for (Player pl : nl.getWorld().getNearbyPlayers(nl, 0.9)) {
|
||||
if (pl == p) continue;
|
||||
double d = pl.getLocation().add(0, 1, 0).distanceSquared(nl);
|
||||
if (d > 0.25 && d < 0.81) {
|
||||
BlackKnifePlugin.getPlugin(BlackKnifePlugin.class).getTension().addTP(pl, 2.5f, "DODGE +1%");
|
||||
pl.getWorld().spawnParticle(Particle.DUST, pl.getLocation().add(0, 0.25, 0), 25, 0.5, 0.05, 0.5, 0, new Particle.DustOptions(Color.fromRGB(255, 255, 255), 0.15f));
|
||||
}
|
||||
}
|
||||
if (nl.distanceSquared(p.getEyeLocation()) > 14400) { marker.remove(); cancel(); return; }
|
||||
if (marker.getTicksLived() > 80) { marker.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user