feat: disable invuln for plugin damage + DamageUtil + DiamondTri/Barrage/Overhead nerf

This commit is contained in:
SashegDev
2026-08-28 14:17:21 +03:00
parent a8ce2375c0
commit e227ad63bd
8 changed files with 244 additions and 21 deletions
@@ -0,0 +1,80 @@
package me.sashegdev.blackknife;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.BlockDisplay;
import org.bukkit.entity.Display;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class PhantomBarrageAttack {
public static boolean tryUse(Player p, TensionManager tension) {
if (tension.getTP(p) < 100f) { p.sendActionBar(Component.text("Need 40% TP").color(NamedTextColor.RED)); return false; }
tension.setTP(p, tension.getTP(p) - 100f);
Location center = p.getLocation().add(0,1,0);
BlackKnifePlugin plugin = BlackKnifePlugin.getPlugin(BlackKnifePlugin.class);
p.getWorld().playSound(center, Sound.ENTITY_PHANTOM_AMBIENT, 1f, 0.6f);
p.getWorld().playSound(center, Sound.BLOCK_BEACON_ACTIVATE, 1f, 1.4f);
for (int i=0;i<5;i++) {
double angle = (double)i/5 * Math.PI*2;
final double fa = angle;
Location spawn = center.clone().add(Math.cos(angle)*2, Math.sin(angle*2)*0.5, Math.sin(angle)*2);
BlockDisplay orb = p.getWorld().spawn(spawn, BlockDisplay.class, d -> {
d.setBlock(Material.SCULK_CATALYST.createBlockData());
d.setBrightness(new Display.Brightness(15,15));
d.setViewRange(64);
d.setTransformation(new org.bukkit.util.Transformation(new org.joml.Vector3f(-0.35f,-0.35f,-0.35f),new org.joml.AxisAngle4f(),new org.joml.Vector3f(0.7f,0.7f,0.7f),new org.joml.AxisAngle4f()));
});
EntityTracker.mark(orb);
new BukkitRunnable() {
int ticks = 0;
Location cur = spawn.clone();
Vector dir = new Vector(-Math.sin(fa), 0, Math.cos(fa)).normalize().multiply(0.35);
@Override public void run() {
if (!orb.isValid() || orb.isDead()) { cancel(); return; }
if (ticks < 30) {
cur = cur.clone().add(dir);
dir = new Vector(-Math.sin(fa + ticks*0.15), 0, Math.cos(fa + ticks*0.15)).normalize().multiply(0.35);
orb.teleport(cur);
cur.getWorld().spawnParticle(Particle.SCULK_SOUL, cur,1,0.05,0.05,0.05,0);
cur.getWorld().spawnParticle(Particle.ASH, cur,1,0,0,0,0);
ticks++;
return;
}
if (ticks == 30) {
cur.getWorld().playSound(cur, Sound.ENTITY_PHANTOM_FLAP, 1f, 1.2f);
}
Location target = getGazeTarget(p);
if (target == null) target = p.getEyeLocation().add(p.getEyeLocation().getDirection().normalize().multiply(25));
Vector toTarget = target.clone().subtract(cur).toVector().normalize().multiply(1.6);
Location nl = cur.clone().add(toTarget);
int steps = Math.max(1,(int)Math.ceil(toTarget.length()/0.5));
for(int s=0;s<=steps;s++){ Location check=cur.clone().add(toTarget.clone().multiply((double)s/steps)); if(check.getBlock().isSolid()){orb.remove();cancel();return;} }
orb.teleport(nl);
cur = nl;
nl.getWorld().spawnParticle(Particle.DUST, nl,1,0,0,0,0,new Particle.DustOptions(Color.fromRGB(30,10,50),1.2f));
nl.getWorld().spawnParticle(Particle.SCULK_SOUL, nl,1,0.05,0.05,0.05,0);
for(LivingEntity le: nl.getWorld().getNearbyLivingEntities(nl,0.9)){ if(le==p) continue; DamageUtil.apply(p, le, 6.0); le.getWorld().spawnParticle(Particle.CRIT, le.getLocation().add(0,1,0),8,0.3,0.3,0.3,0.1); orb.remove(); cancel(); return; }
for(Player pl: nl.getWorld().getNearbyPlayers(nl,0.9)){ if(pl==p) continue; double d2=pl.getLocation().add(0,1,0).distanceSquared(nl); if(d2>0.25 && d2<0.81) plugin.getTension().addTP(pl,2.5f,"DODGE +1%"); }
if(cur.distanceSquared(target) < 1 || orb.getTicksLived() > 100){ orb.remove(); cancel(); }
ticks++;
}
}.runTaskTimer(plugin,1L,1L);
}
return true;
}
private static Location getGazeTarget(Player p){
var ray = p.getWorld().rayTraceBlocks(p.getEyeLocation(), p.getEyeLocation().getDirection(), 40);
if(ray!=null && ray.getHitPosition()!=null) return new Location(p.getWorld(), ray.getHitPosition().getX(), ray.getHitPosition().getY(), ray.getHitPosition().getZ());
return null;
}
}