working on shell entity wrapper

This commit is contained in:
Soper Aylamo 2021-05-13 15:50:17 -04:00
parent 2756a560a9
commit 3038df3197
2 changed files with 17 additions and 10 deletions

View File

@ -17,29 +17,35 @@ public class Shell {
public double baseVelocity = 2.5; public double baseVelocity = 2.5;
public double failChance = .01; 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(){ public Shell(){
isFired = false;
//TODO: Create default constructor //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 * @param shell The ItemStack with lore
*/ */
public Shell(ItemStack shell){ public Shell(ItemStack shell){
List<String> stats = shell.getItemMeta().getLore(); isFired = false;
explosionMultiplier = Double.parseDouble(stats.get(1).substring(11, 14)); if(isShell(shell)){
penetration = Integer.parseInt(stats.get(2).substring(13)); List<String> stats = shell.getItemMeta().getLore();
incendiaryType = Boolean.parseBoolean(stats.get(3).substring(12).toLowerCase()); explosionMultiplier = Double.parseDouble(stats.get(1).substring(11, 14));
baseVelocity = Double.parseDouble(stats.get(4).substring(10)); penetration = Integer.parseInt(stats.get(2).substring(13));
failChance = Double.parseDouble(stats.get(5).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. * 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 penetration
* @param incendiaryType * @param incendiaryType
* @param baseVelocity * @param baseVelocity
@ -53,7 +59,7 @@ public class Shell {
this.failChance = failChance; this.failChance = failChance;
} }
/** /** TODO: Finish documentation for this
* Checks if the item stack is a shell * Checks if the item stack is a shell
* @param item ItemStack to check against * @param item ItemStack to check against
* @return True if item is an arrow with a gray name "Shell" * @return True if item is an arrow with a gray name "Shell"

View File

@ -26,6 +26,7 @@ public class MortarHandler {
shellProjectile.setShooter(shooter); shellProjectile.setShooter(shooter);
shellProjectile.setCustomName("shell"); shellProjectile.setCustomName("shell");
mortar.getBlock().getWorld().spawnParticle(Particle.SMOKE_NORMAL, mortarLocation, 500, 0, 0, 0, .5); 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); if(shooter instanceof Player) ((Player) shooter).sendMessage("DEBUG: Shell fired with a velocity " + shell.baseVelocity);
} }