use of net.glowstone.block.state.GlowFlowerPot 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;
}
use of net.glowstone.block.state.GlowFlowerPot in project Glowstone by GlowstoneMC.
the class BlockFlowerPot method getDrops.
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
List<ItemStack> drops = new LinkedList<>(Arrays.asList(new ItemStack(Material.FLOWER_POT)));
GlowBlockState state = block.getState();
if (state instanceof GlowFlowerPot) {
MaterialData contents = ((GlowFlowerPot) state).getContents();
if (contents != null) {
drops.add(new ItemStack(contents.getItemType(), 1, contents.getData()));
}
}
return Collections.unmodifiableList(drops);
}
Aggregations