working on shell entity wrapper

master
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 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<String> 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<String> 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"

View File

@ -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);
}