From 05e0f308965fb7522c96ced68d52d3c3448c7a6d Mon Sep 17 00:00:00 2001 From: Soper Date: Fri, 21 May 2021 00:44:50 -0400 Subject: [PATCH] fireShell cannot fire with a non-existent directional vector --- src/xyz/soper/arty/util/MortarHandler.java | 64 +++++++++++++++------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/src/xyz/soper/arty/util/MortarHandler.java b/src/xyz/soper/arty/util/MortarHandler.java index c4f23d1..2cf94f9 100644 --- a/src/xyz/soper/arty/util/MortarHandler.java +++ b/src/xyz/soper/arty/util/MortarHandler.java @@ -15,38 +15,62 @@ public class MortarHandler { * Fires a shell projectile from the specified mortar. * @param mortar * @param shell - */ - public static void fireShell(Mortar mortar, Shell shell){ - //TODO: Fire shell method - } - - /** - * Fires a shell projectile from the specified mortar by the specified shooter. - * @param mortar - * @param shell * @param shooter */ public static void fireShell(Mortar mortar, Shell shell, ProjectileSource shooter){ - //TODO: Use linkProjectile method and finalize fireShell method to create a proper non-debug fireShell method. - //As it stands, this method creates a shell with no actual data so the Shell wrapper uses default values. - - - - Vector debugVector = new Vector(1, 1, 0).normalize(); + //TODO: Create a way to modify the mortar's direction vector. + //It currently cannot fire an arrow because it does not exist. + Location topOfMortar = mortar.getBlock().getLocation().add(.5, 1, .5); mortar.getBlock().getWorld().playSound( mortar.getBlock().getLocation(), "entity.generic.explode", 1, 1.5F ); - Location mortarLocation = mortar.getBlock().getLocation().add(.5, 1, .5); - Arrow shellProjectile = mortar.getBlock().getWorld().spawn(mortarLocation, Arrow.class); - shellProjectile.setVelocity(debugVector.multiply(shell.baseVelocity)); + Arrow shellProjectile = mortar.getBlock().getWorld().spawnArrow( + topOfMortar, + mortar.getDirection(), + (float)(shell.baseVelocity*mortar.velocityMultiplier), + .1f + ); shellProjectile.setShooter(shooter); - shellProjectile.setCustomName("shell"); - mortar.getBlock().getWorld().spawnParticle(Particle.SMOKE_NORMAL, mortarLocation, 500, .5, 0, .5, .5); + shell.linkProjectile(shellProjectile); + mortar.getBlock().getWorld().spawnParticle(Particle.SMOKE_NORMAL, + topOfMortar, + 500, + .5, + 0, + .5, + .5 + ); if(shooter instanceof Player) ((Player) shooter).sendMessage("DEBUG: Shell fired with a velocity " + shell.baseVelocity); } +// /** +// * Fires a shell projectile from the specified mortar by the specified shooter. +// * @param mortar +// * @param shell +// * @param shooter +// */ +// public static void fireShell(Mortar mortar, Shell shell, ProjectileSource shooter){ +// //TODO: Use linkProjectile method and finalize fireShell method to create a proper non-debug fireShell method. +// //As it stands, this method creates a shell with no actual data so the Shell wrapper uses default values. +// +// Vector debugVector = new Vector(1, 1, 0).normalize(); +// mortar.getBlock().getWorld().playSound( +// mortar.getBlock().getLocation(), +// "entity.generic.explode", +// 1, +// 1.5F +// ); +// Location mortarLocation = mortar.getBlock().getLocation().add(.5, 1, .5); +// Arrow shellProjectile = mortar.getBlock().getWorld().spawnArrow(mortarLocation, debugVector, (float)shell.baseVelocity, 0f); +// shellProjectile.setShooter(shooter); +// shellProjectile.setCustomName("shell"); +// mortar.getBlock().getWorld().spawnParticle(Particle.SMOKE_NORMAL, mortarLocation, 500, .5, 0, .5, .5); +// if(shooter instanceof Player) +// ((Player) shooter).sendMessage("DEBUG: Shell fired with a velocity " + shell.baseVelocity); +// } + } \ No newline at end of file