fixed unbreakable mortar, buggy brewing stands, added blast sound, and fixed interaction code
parent
65f0a2fa1b
commit
501bd77d4e
|
@ -8,6 +8,7 @@ import org.bukkit.block.Container;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
@ -23,13 +24,18 @@ public class MortarInteract implements Listener {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ItemStack item = player.getInventory().getItemInMainHand();
|
ItemStack item = player.getInventory().getItemInMainHand();
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
|
if(block == null) return;
|
||||||
if(block.getBlockData().getMaterial() == Material.BREWING_STAND){
|
if(block.getBlockData().getMaterial() == Material.BREWING_STAND){
|
||||||
Nameable brewingStandMortar = (Nameable) event.getClickedBlock().getState();
|
Nameable brewingStandMortar = (Nameable) event.getClickedBlock().getState();
|
||||||
String blockName = brewingStandMortar.getCustomName();
|
String blockName = brewingStandMortar.getCustomName();
|
||||||
|
if(blockName == null) return;
|
||||||
if(blockName.equals(ChatColor.GRAY + "Basic Mortar") || blockName.equals(ChatColor.GRAY + "Mortar")){
|
if(blockName.equals(ChatColor.GRAY + "Basic Mortar") || blockName.equals(ChatColor.GRAY + "Mortar")){
|
||||||
|
if(event.getAction() == Action.RIGHT_CLICK_BLOCK) event.setCancelled(true);
|
||||||
if((item.getType() == Material.ARROW) && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equals(ChatColor.GRAY + "Shell")){
|
if((item.getType() == Material.ARROW) && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equals(ChatColor.GRAY + "Shell")){
|
||||||
MortarHandler mortarHandler = new MortarHandler(new Mortar(block));
|
MortarHandler mortarHandler = new MortarHandler(new Mortar(block));
|
||||||
mortarHandler.fireShell(new Shell(item));
|
player.sendMessage(mortarHandler.fireShell(new Shell(item)));
|
||||||
|
if(item.getAmount() > 1) item.setAmount(item.getAmount()-1);
|
||||||
|
else player.getInventory().setItemInMainHand(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.bukkit.block.Container;
|
||||||
|
|
||||||
public class Mortar {
|
public class Mortar {
|
||||||
|
|
||||||
Location location;
|
public Location location;
|
||||||
|
|
||||||
public static String BASIC_MORTAR_NAME = ChatColor.GRAY + "Basic Mortar";
|
public static String BASIC_MORTAR_NAME = ChatColor.GRAY + "Basic Mortar";
|
||||||
public static String NORMAL_MORTAR_NAME = ChatColor.GRAY + "Mortar";
|
public static String NORMAL_MORTAR_NAME = ChatColor.GRAY + "Mortar";
|
||||||
|
@ -23,7 +23,10 @@ public class Mortar {
|
||||||
public double velocityMultiplier; //Multiplier applied to the shell's velocity
|
public double velocityMultiplier; //Multiplier applied to the shell's velocity
|
||||||
public boolean incendiaryCapable; //Is the mortar fit to fire an incendiary-type shell?
|
public boolean incendiaryCapable; //Is the mortar fit to fire an incendiary-type shell?
|
||||||
|
|
||||||
|
public Block block;
|
||||||
|
|
||||||
public Mortar(Block mortar){
|
public Mortar(Block mortar){
|
||||||
|
block = mortar;
|
||||||
location = mortar.getLocation();
|
location = mortar.getLocation();
|
||||||
Nameable brewingStandMortar = (Nameable) mortar.getState();
|
Nameable brewingStandMortar = (Nameable) mortar.getState();
|
||||||
String mortarName = brewingStandMortar.getCustomName();
|
String mortarName = brewingStandMortar.getCustomName();
|
||||||
|
|
|
@ -11,8 +11,9 @@ public class MortarHandler {
|
||||||
this.mortar = mortar;
|
this.mortar = mortar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fireShell(Shell shell){
|
public String /*void*/ fireShell(Shell shell){
|
||||||
|
mortar.block.getWorld().playSound(mortar.location, "entity.generic.explode", 1, 1.5F);
|
||||||
|
return "DEBUG: Shell has been fired.";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue