private void putVine(GlowBlock block, Vine vine, GlowBlock fromBlock) { GlowBlockState state = block.getState(); state.setType(Material.VINE); state.setData(vine); if (fromBlock != null) { BlockSpreadEvent spreadEvent = new BlockSpreadEvent(block, fromBlock, state); EventFactory.callEvent(spreadEvent); if (!spreadEvent.isCancelled()) { state.update(true); } } else { state.update(true); } }
@Override public void updateBlock(GlowBlock block) { if (isNearWater(block) || GlowBiomeClimate.isRainy(block)) { block.setData((byte) 7); // set this block as fully wet } else if (block.getData() > 0) { block.setData((byte) (block.getData() - 1)); // if this block is wet, it becomes less wet } else if (!Arrays.asList(possibleCrops).contains(block.getRelative(BlockFace.UP).getType())) { // turns block back to dirt if nothing is planted on final GlowBlockState state = block.getState(); state.setType(Material.DIRT); state.setRawData((byte) 0); BlockFadeEvent fadeEvent = new BlockFadeEvent(block, state); EventFactory.callEvent(fadeEvent); if (!fadeEvent.isCancelled()) { state.update(true); } } }