Search in sources :

Example 1 with FlowerPot

use of org.bukkit.material.FlowerPot in project Glowstone by GlowstoneMC.

the class BlockFlowerPot method blockInteract.

@Override
public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face, Vector clickedLoc) {
    GlowBlockState state = block.getState();
    MaterialData data = state.getData();
    if (!(data instanceof FlowerPot)) {
        warnMaterialData(FlowerPot.class, data);
        return false;
    }
    if (state instanceof GlowFlowerPot) {
        GlowFlowerPot pot = (GlowFlowerPot) state;
        ItemStack heldItem = player.getItemInHand();
        // Only change contents if there is none and if the held item is valid pot contents.
        if (pot.getContents() == null && heldItem != null && isValidContents(heldItem.getData())) {
            // Null-check in isValidContents.
            pot.setContents(heldItem.getData().clone());
            return pot.update();
        }
    }
    return false;
}
Also used : GlowBlockState(net.glowstone.block.GlowBlockState) GlowFlowerPot(net.glowstone.block.state.GlowFlowerPot) FlowerPot(org.bukkit.material.FlowerPot) MaterialData(org.bukkit.material.MaterialData) ItemStack(org.bukkit.inventory.ItemStack) GlowFlowerPot(net.glowstone.block.state.GlowFlowerPot)

Aggregations

GlowBlockState (net.glowstone.block.GlowBlockState)1 GlowFlowerPot (net.glowstone.block.state.GlowFlowerPot)1 ItemStack (org.bukkit.inventory.ItemStack)1 FlowerPot (org.bukkit.material.FlowerPot)1 MaterialData (org.bukkit.material.MaterialData)1