added todos, debug state can launch at 45 degree angle

master
Soper Aylamo 2021-05-12 03:09:23 -04:00
parent 80cf8d3290
commit 2756a560a9
Signed by: Soper
GPG Key ID: A27AC885ACC3BEAE
5 changed files with 57 additions and 5 deletions

View File

@ -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.");

View File

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

View File

@ -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){

View File

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

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