debugged state now shoots default shell properly at 1,1,0 vector

master
Soper Aylamo 2021-05-09 16:28:44 -04:00
parent cee3adaf13
commit 67bb44d3f5
Signed by: Soper
GPG Key ID: A27AC885ACC3BEAE
3 changed files with 21 additions and 5 deletions

View File

@ -25,6 +25,7 @@ public class DebugCommand implements TabExecutor, Listener {
double multiplier = (double)Integer.parseInt(args[1])/10; double multiplier = (double)Integer.parseInt(args[1])/10;
Arrow arrow = player.getWorld().spawn(player.getLocation().add(0,1,0), Arrow.class); Arrow arrow = player.getWorld().spawn(player.getLocation().add(0,1,0), Arrow.class);
arrow.setShooter(player); arrow.setShooter(player);
arrow.setCustomName("shell");
arrow.setVelocity(player.getLocation().getDirection().multiply(multiplier)); arrow.setVelocity(player.getLocation().getDirection().multiply(multiplier));
player.sendMessage(ChatColor.GOLD + "You just fired an arrow with a velocity " + multiplier); player.sendMessage(ChatColor.GOLD + "You just fired an arrow with a velocity " + multiplier);
return true; return true;
@ -49,7 +50,9 @@ public class DebugCommand implements TabExecutor, Listener {
@EventHandler @EventHandler
public void onArrowHit(ProjectileHitEvent event){ public void onArrowHit(ProjectileHitEvent event){
if(event.getEntity().getShooter() instanceof Player && event.getEntity() instanceof Arrow){ if(event.getEntity() instanceof Arrow
&& event.getEntity().getCustomName() != null
&& event.getEntity().getCustomName().equals("shell")){
int x = event.getHitBlock().getLocation().getBlockX(); int x = event.getHitBlock().getLocation().getBlockX();
int y = event.getHitBlock().getLocation().getBlockY(); int y = event.getHitBlock().getLocation().getBlockY();
int z = event.getHitBlock().getLocation().getBlockZ(); int z = event.getHitBlock().getLocation().getBlockZ();

View File

@ -38,7 +38,9 @@ public class MortarInteract implements Listener {
if(Shell.isShell(item)){ if(Shell.isShell(item)){
player.sendMessage("DEBUG: Player has a shell in hand."); player.sendMessage("DEBUG: Player has a shell in hand.");
MortarHandler mortarHandler = new MortarHandler(new Mortar(block)); MortarHandler mortarHandler = new MortarHandler(new Mortar(block));
mortarHandler.fireShell(new Shell(item)); mortarHandler.fireShell(/*new Shell(item)*/
//THIS IS FOR DEBUGGING. PLEASE FIX AFTER.
new Shell(), player);
if(item.getAmount() > 1) item.setAmount(item.getAmount()-1); if(item.getAmount() > 1) item.setAmount(item.getAmount()-1);
else player.getInventory().setItemInMainHand(null); else player.getInventory().setItemInMainHand(null);
} }

View File

@ -1,5 +1,10 @@
package xyz.soper.arty.util; package xyz.soper.arty.util;
import org.bukkit.Particle;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector;
import xyz.soper.arty.item.Mortar; import xyz.soper.arty.item.Mortar;
import xyz.soper.arty.item.Shell; import xyz.soper.arty.item.Shell;
@ -11,8 +16,14 @@ public class MortarHandler {
this.mortar = mortar; this.mortar = mortar;
} }
public void fireShell(Shell shell){ public void fireShell(Shell shell, ProjectileSource shooter){
mortar.block.getWorld().playSound(mortar.location, "entity.generic.explode", 1, 1.5F); Vector debugVector = new Vector(1, 1, 0).normalize();
mortar.getBlock().getWorld().playSound(mortar.location, "entity.generic.explode", 1, 1.5F);
Arrow shellProjectile = mortar.getBlock().getWorld().spawn(mortar.getBlock().getLocation(), Arrow.class);
shellProjectile.setVelocity(debugVector.multiply(shell.baseVelocity));
shellProjectile.setShooter(shooter);
shellProjectile.setCustomName("shell");
mortar.getBlock().getWorld().spawnParticle(Particle.SMOKE_NORMAL, mortar.location, 500, 0, 0, 0, .5);
if(shooter instanceof Player) ((Player) shooter).sendMessage("Shell fired with a velocity " + shell.baseVelocity);
} }
} }