added methods to shell wrapper
parent
5fdce6b5a8
commit
8b5e847b1b
|
@ -65,7 +65,8 @@ public class DebugCommand implements TabExecutor, Listener {
|
|||
public void onArrowHit(ProjectileHitEvent event){
|
||||
if(event.getEntity() instanceof Arrow
|
||||
&& event.getEntity().getCustomName() != null
|
||||
&& event.getEntity().getCustomName().equals("shell")){
|
||||
&& event.getEntity().getCustomName().equals("shell")
|
||||
&& event.getHitBlock() != null){
|
||||
int x = event.getHitBlock().getLocation().getBlockX();
|
||||
int y = event.getHitBlock().getLocation().getBlockY();
|
||||
int z = event.getHitBlock().getLocation().getBlockZ();
|
||||
|
|
|
@ -40,9 +40,7 @@ public class MortarInteract implements Listener {
|
|||
if(Shell.isShell(item)){
|
||||
player.sendMessage("DEBUG: Player has a shell in hand.");
|
||||
MortarHandler mortarHandler = new MortarHandler(new Mortar(block));
|
||||
mortarHandler.fireShell(/*new Shell(item)*/
|
||||
//THIS IS FOR DEBUGGING. PLEASE FIX AFTER.
|
||||
new Shell(), player);
|
||||
mortarHandler.fireShell(new Shell(item), player);
|
||||
if(item.getAmount() > 1) item.setAmount(item.getAmount()-1);
|
||||
else player.getInventory().setItemInMainHand(null);
|
||||
}
|
||||
|
@ -72,7 +70,12 @@ public class MortarInteract implements Listener {
|
|||
event.getEntity().remove();
|
||||
}
|
||||
else if(event.getHitEntity() != null){
|
||||
event.getHitEntity().getWorld().createExplosion(event.getHitEntity().getLocation(), 2.5F, false, true);
|
||||
event.getHitEntity().getWorld().createExplosion(
|
||||
event.getHitEntity().getLocation(),
|
||||
2.5F,
|
||||
false,
|
||||
true);
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package xyz.soper.arty.item;
|
|||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.Nameable;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
|||
*/
|
||||
public class Shell {
|
||||
|
||||
public double explosivePower = 2.5;
|
||||
public float explosivePower = 2.5f;
|
||||
public int penetration = 0;
|
||||
public boolean incendiaryType = false;
|
||||
public double baseVelocity = 2.5;
|
||||
|
@ -38,7 +38,7 @@ public class Shell {
|
|||
isFired = false;
|
||||
if(isShell(shell)){
|
||||
List<String> stats = shell.getItemMeta().getLore();
|
||||
explosivePower = Double.parseDouble(stats.get(1).substring(11));
|
||||
explosivePower = Float.parseFloat(stats.get(1).substring(11));
|
||||
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));
|
||||
|
@ -55,7 +55,8 @@ public class Shell {
|
|||
* @param failChance Chance of the shell failing. Type of failure is dependent on the mortar type.
|
||||
*/
|
||||
public Shell(double explosivePower, int penetration, boolean incendiaryType, double baseVelocity, double failChance){
|
||||
this.explosivePower = explosivePower;
|
||||
isFired = false;
|
||||
this.explosivePower = (float)explosivePower;
|
||||
this.penetration = penetration;
|
||||
this.incendiaryType = incendiaryType;
|
||||
this.baseVelocity = baseVelocity;
|
||||
|
@ -63,10 +64,11 @@ public class Shell {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a shell entity wrapper from a shell entity in the world. If
|
||||
* Creates a shell entity wrapper from a shell entity in the world.
|
||||
* @param shell Entity that represents a shell entity
|
||||
*/
|
||||
public Shell(Entity shell){
|
||||
public Shell(Projectile shell){
|
||||
isFired = true;
|
||||
|
||||
}
|
||||
|
||||
|
@ -107,14 +109,36 @@ public class Shell {
|
|||
return shell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the stats defined by this function to create a shell with lore and item information.
|
||||
* @return
|
||||
*/
|
||||
@Deprecated private ItemStack createShell(){
|
||||
//TODO: Figure out the initial purpose of this method
|
||||
// /**
|
||||
// * Uses the stats defined by this function to create a shell with lore and item information.
|
||||
// * @return
|
||||
// */
|
||||
// @Deprecated private ItemStack createShell(){
|
||||
// //TODO: Figure out the initial purpose of this method
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
|
||||
return null;
|
||||
public void explodeShell(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Links a Projectile in the world with the shell represented by this object.
|
||||
* @param projectile Projectile to link with this shell.
|
||||
* @return True if the link was successful.
|
||||
*/
|
||||
public boolean linkProjectile(Projectile projectile){
|
||||
if(projectile instanceof Nameable){
|
||||
projectile.setCustomName(
|
||||
"shell-" +
|
||||
explosivePower + "," +
|
||||
penetration + "," +
|
||||
incendiaryType + "," +
|
||||
baseVelocity + "," +
|
||||
failChance
|
||||
);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue