fireShell cannot fire with a non-existent directional vector

master
Soper Aylamo 2021-05-21 00:44:50 -04:00
parent 44de70cb88
commit 05e0f30896
Signed by: Soper
GPG Key ID: A27AC885ACC3BEAE
1 changed files with 44 additions and 20 deletions

View File

@ -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);
// }
}