From 3038df31974008743697f3d09c208e9e32847eb8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 13 May 2021 15:50:17 -0400 Subject: [PATCH] working on shell entity wrapper --- src/xyz/soper/arty/item/Shell.java | 26 +++++++++++++--------- src/xyz/soper/arty/util/MortarHandler.java | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/xyz/soper/arty/item/Shell.java b/src/xyz/soper/arty/item/Shell.java index e1930b8..c173a37 100644 --- a/src/xyz/soper/arty/item/Shell.java +++ b/src/xyz/soper/arty/item/Shell.java @@ -17,29 +17,35 @@ public class Shell { public double baseVelocity = 2.5; public double failChance = .01; + public boolean isFired; + /** - * Creates a shell with default stats. Represents the first basic craftable shell in-game. + * Creates a shell item wrapper with default stats. Represents the first basic craftable shell in-game. */ public Shell(){ + isFired = false; //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. + * Creates a shell item wrapper 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)); - penetration = Integer.parseInt(stats.get(2).substring(13)); - incendiaryType = Boolean.parseBoolean(stats.get(3).substring(12).toLowerCase()); - baseVelocity = Double.parseDouble(stats.get(4).substring(10)); - failChance = Double.parseDouble(stats.get(5).substring(13)); + isFired = false; + if(isShell(shell)){ + List stats = shell.getItemMeta().getLore(); + explosionMultiplier = Double.parseDouble(stats.get(1).substring(11, 14)); + penetration = Integer.parseInt(stats.get(2).substring(13)); + incendiaryType = Boolean.parseBoolean(stats.get(3).substring(12).toLowerCase()); + baseVelocity = Double.parseDouble(stats.get(4).substring(10)); + 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 explosionMultiplier Explosion multiplier. 1 represents default 3 (for blockDamage) * @param penetration * @param incendiaryType * @param baseVelocity @@ -53,7 +59,7 @@ public class Shell { this.failChance = failChance; } - /** + /** TODO: Finish documentation for this * Checks if the item stack is a shell * @param item ItemStack to check against * @return True if item is an arrow with a gray name "Shell" diff --git a/src/xyz/soper/arty/util/MortarHandler.java b/src/xyz/soper/arty/util/MortarHandler.java index b2a70a3..bb25410 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); + //TODO: Experiment with spawnParticle offset parameters. This may create more realistic smoke. if(shooter instanceof Player) ((Player) shooter).sendMessage("DEBUG: Shell fired with a velocity " + shell.baseVelocity); }