From 2756a560a9e0a668ccb13da30b00b074b56c2d18 Mon Sep 17 00:00:00 2001 From: Soper Date: Wed, 12 May 2021 03:09:23 -0400 Subject: [PATCH] added todos, debug state can launch at 45 degree angle --- src/xyz/soper/arty/debug/DebugCommand.java | 6 +++- .../arty/event/Listener/MortarInteract.java | 15 ++++++-- src/xyz/soper/arty/item/Mortar.java | 4 ++- src/xyz/soper/arty/item/Shell.java | 34 +++++++++++++++++++ src/xyz/soper/arty/util/MortarHandler.java | 3 +- 5 files changed, 57 insertions(+), 5 deletions(-) diff --git a/src/xyz/soper/arty/debug/DebugCommand.java b/src/xyz/soper/arty/debug/DebugCommand.java index 06aa6f3..f1c6861 100644 --- a/src/xyz/soper/arty/debug/DebugCommand.java +++ b/src/xyz/soper/arty/debug/DebugCommand.java @@ -2,7 +2,6 @@ package xyz.soper.arty.debug; import org.bukkit.ChatColor; import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Arrow; @@ -44,6 +43,11 @@ public class DebugCommand implements TabExecutor, Listener { false, Boolean.parseBoolean(args[2]), player); + player.getWorld().createExplosion(player.getLocation(), + (float)(Double.parseDouble(args[1])*3), + false, + false, + player); return true; } else player.sendMessage(ChatColor.RED + "Incorrect usage. This command does not exist."); diff --git a/src/xyz/soper/arty/event/Listener/MortarInteract.java b/src/xyz/soper/arty/event/Listener/MortarInteract.java index 697a94b..9cc0f36 100644 --- a/src/xyz/soper/arty/event/Listener/MortarInteract.java +++ b/src/xyz/soper/arty/event/Listener/MortarInteract.java @@ -51,15 +51,26 @@ public class MortarInteract implements Listener { } } + @EventHandler 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); + //TODO: This needs to have another accompanying explosion that does more player damage than physical damage. + event.getHitBlock().getWorld().createExplosion( + event.getHitBlock() + .getLocation() + .add(.5, 0, .5) + .add(event.getHitBlockFace() + .getDirection()), + 2.5F, + false, + true); + event.getEntity().remove(); } else if(event.getHitEntity() != null){ - + event.getHitEntity().getWorld().createExplosion(event.getHitEntity().getLocation(), 2.5F, false, true); } } } diff --git a/src/xyz/soper/arty/item/Mortar.java b/src/xyz/soper/arty/item/Mortar.java index d73d624..a40aa1a 100644 --- a/src/xyz/soper/arty/item/Mortar.java +++ b/src/xyz/soper/arty/item/Mortar.java @@ -5,7 +5,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Nameable; import org.bukkit.block.Block; -import org.bukkit.block.Container; +import org.bukkit.util.Vector; public class Mortar { @@ -24,6 +24,8 @@ public class Mortar { public double velocityMultiplier; //Multiplier applied to the shell's velocity public boolean incendiaryCapable; //Is the mortar fit to fire an incendiary-type shell? + private Vector direction; + private Block block; public Mortar(Block mortar){ diff --git a/src/xyz/soper/arty/item/Shell.java b/src/xyz/soper/arty/item/Shell.java index c765c0b..e1930b8 100644 --- a/src/xyz/soper/arty/item/Shell.java +++ b/src/xyz/soper/arty/item/Shell.java @@ -6,6 +6,9 @@ import org.bukkit.inventory.ItemStack; import java.util.List; +/** + * A wrapper class for an arrow. Represents a mortar shell. + */ public class Shell { public double explosionMultiplier = 1.0; @@ -14,10 +17,17 @@ public class Shell { public double baseVelocity = 2.5; public double failChance = .01; + /** + * Creates a shell with default stats. Represents the first basic craftable shell in-game. + */ public Shell(){ //TODO: Create default constructor } + /** + * Creates a shell from a pre-existing arrow ItemStack with lore. If arrow is not a Shell, will create a default shell. + * @param shell The ItemStack with lore + */ public Shell(ItemStack shell){ List stats = shell.getItemMeta().getLore(); explosionMultiplier = Double.parseDouble(stats.get(1).substring(11, 14)); @@ -27,6 +37,14 @@ public class Shell { failChance = Double.parseDouble(stats.get(5).substring(13)); } + /** + * Creates a shell with the specified statistics. + * @param explosionMultiplier Explosion multiplier. 1 represents default 2.5 + * @param penetration + * @param incendiaryType + * @param baseVelocity + * @param failChance + */ public Shell(double explosionMultiplier, int penetration, boolean incendiaryType, double baseVelocity, double failChance){ this.explosionMultiplier = explosionMultiplier; this.penetration = penetration; @@ -48,4 +66,20 @@ public class Shell { return false; } + public ItemStack getShell(){ + //TODO: Create getShell method that returns ItemStack with shell metadata. + + return null; + } + + /** + * Uses the stats defined by this function to create a shell with lore and item information. + * @return + */ + private ItemStack createShell(){ + //TODO: Create createShell method + + return null; + } + } diff --git a/src/xyz/soper/arty/util/MortarHandler.java b/src/xyz/soper/arty/util/MortarHandler.java index a9b5b3a..b2a70a3 100644 --- a/src/xyz/soper/arty/util/MortarHandler.java +++ b/src/xyz/soper/arty/util/MortarHandler.java @@ -26,6 +26,7 @@ public class MortarHandler { shellProjectile.setShooter(shooter); shellProjectile.setCustomName("shell"); 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("DEBUG: Shell fired with a velocity " + shell.baseVelocity); } + } \ No newline at end of file