added explosion testing

master
Soper Aylamo 2021-05-10 10:16:20 -04:00
parent 67bb44d3f5
commit 80cf8d3290
4 changed files with 30 additions and 4 deletions

View File

@ -36,6 +36,15 @@ public class DebugCommand implements TabExecutor, Listener {
} }
else if(args[0].equalsIgnoreCase("getVector")){ else if(args[0].equalsIgnoreCase("getVector")){
player.sendMessage(ChatColor.GOLD + "Your current facing vector is: " + player.getLocation().getDirection()); player.sendMessage(ChatColor.GOLD + "Your current facing vector is: " + player.getLocation().getDirection());
return true;
}
else if(args[0].equalsIgnoreCase("explode")){
player.getWorld().createExplosion(player.getLocation(),
(float)Double.parseDouble(args[1]),
false,
Boolean.parseBoolean(args[2]),
player);
return true;
} }
else player.sendMessage(ChatColor.RED + "Incorrect usage. This command does not exist."); else player.sendMessage(ChatColor.RED + "Incorrect usage. This command does not exist.");
} }
@ -45,7 +54,7 @@ public class DebugCommand implements TabExecutor, Listener {
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if(args.length != 1) return null; if(args.length != 1) return null;
return Arrays.asList("fire", "getVector"); return Arrays.asList("fire", "getVector", "explode");
} }
@EventHandler @EventHandler

View File

@ -4,10 +4,12 @@ import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Nameable; import org.bukkit.Nameable;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -48,4 +50,17 @@ public class MortarInteract implements Listener {
} }
} }
} }
public void onShellLand(ProjectileHitEvent event){
if(event.getEntity() instanceof Arrow
&& event.getEntity().getCustomName() != null
&& event.getEntity().getCustomName().equals("shell")){
if(event.getHitBlock() != null){
event.getHitBlock().getWorld().createExplosion(event.getHitBlock().getLocation(), 2.5F, false, true);
}
else if(event.getHitEntity() != null){
}
}
}
} }

View File

@ -15,7 +15,7 @@ public class Shell {
public double failChance = .01; public double failChance = .01;
public Shell(){ public Shell(){
//TODO: Create default constructor
} }
public Shell(ItemStack shell){ public Shell(ItemStack shell){

View File

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