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