tweak grenade: no flight cap, range 15, preview matches
This commit is contained in:
@@ -284,7 +284,7 @@ public class BlackKnifeListener implements Listener {
|
||||
if (!p.isOnline() || !getMode(p).equals("GRENADE")) { cancel(); return; }
|
||||
if (p.hasCooldown(Material.NETHERITE_SWORD)) return;
|
||||
if (!BlackKnifeItem.is(p.getInventory().getItemInMainHand()) && !BlackKnifeItem.is(p.getInventory().getItemInOffHand())) return;
|
||||
Location gp = getGazePoint(p);
|
||||
Location gp = GrenadeAttack.computeTarget(p, p.getEyeLocation(), p.getEyeLocation().getDirection().normalize());
|
||||
for (int i = 0; i < 16; i++) {
|
||||
double a = (double) i / 16 * Math.PI * 2;
|
||||
Location ring = gp.clone().add(Math.cos(a) * 1.5, 0.1, Math.sin(a) * 1.5);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class GrenadeAttack {
|
||||
private static final double CHIP_RADIUS = 3.0;
|
||||
private static final double LETHAL_DAMAGE = 35.0;
|
||||
private static final double CHIP_DAMAGE = 5.5;
|
||||
private static final double MAX_RANGE = 30.0;
|
||||
private static final double MAX_RANGE = 15.0;
|
||||
private static final double ARC_MIN = 1.5;
|
||||
private static final double ARC_PER_BLOCK = 0.25;
|
||||
private static final double ARC_MAX = 4.0;
|
||||
@@ -39,7 +39,7 @@ public class GrenadeAttack {
|
||||
Vector dir = eye.getDirection().normalize();
|
||||
Location target = computeTarget(p, eye, dir);
|
||||
double dist = eye.distance(target);
|
||||
int duration = (int) Math.max(10, Math.min(40, dist * 3));
|
||||
int duration = Math.max(10, (int) (dist * 3));
|
||||
double arcH = Math.max(ARC_MIN, Math.min(ARC_MAX, dist * ARC_PER_BLOCK));
|
||||
Location spawn = eye.clone().add(dir.clone().multiply(1)).add(0, 0.2, 0);
|
||||
Vector throwDir = target.clone().subtract(spawn).toVector().normalize();
|
||||
@@ -132,7 +132,7 @@ public class GrenadeAttack {
|
||||
flightStart = cur.clone();
|
||||
flightTarget = nt.clone();
|
||||
double remaining = Math.max(1.0, cur.distance(nt));
|
||||
flightDuration = (int) Math.max(6, Math.min(40, remaining * 3));
|
||||
flightDuration = Math.max(6, (int) (remaining * 3));
|
||||
elapsed = 0;
|
||||
arc = Math.max(ARC_MIN, Math.min(ARC_MAX, remaining * ARC_PER_BLOCK));
|
||||
targetWasSolid = flightTarget.getBlock().isSolid();
|
||||
@@ -169,14 +169,14 @@ public class GrenadeAttack {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Location computeTarget(Player p, Location eye, Vector dir) {
|
||||
public static Location computeTarget(Player p, Location eye, Vector dir) {
|
||||
var ray = p.getWorld().rayTraceBlocks(eye, dir, MAX_RANGE);
|
||||
if (ray != null && ray.getHitPosition() != null) {
|
||||
Location loc = new Location(p.getWorld(), ray.getHitPosition().getX(), ray.getHitPosition().getY(), ray.getHitPosition().getZ());
|
||||
if (ray.getHitBlockFace() != null) loc.add(0, 0.1, 0);
|
||||
return loc;
|
||||
}
|
||||
Location fallback = eye.clone().add(dir.clone().multiply(20));
|
||||
Location fallback = eye.clone().add(dir.clone().multiply(MAX_RANGE));
|
||||
fallback.setY(p.getWorld().getHighestBlockYAt(fallback) + 1);
|
||||
return fallback;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user