コード例 #1
0
 @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);
     }
   }
 }
コード例 #2
0
 @Override
 public void blockDestroy(GlowPlayer player, GlowBlock block, BlockFace face) {
   // vanilla set leaf decay check in a 9x9x9 neighboring when a log block is removed
   final GlowWorld world = block.getWorld();
   for (int x = 0; x < 9; x++) {
     for (int z = 0; z < 9; z++) {
       for (int y = 0; y < 9; y++) {
         final GlowBlock b = world.getBlockAt(block.getLocation().add(x - 4, y - 4, z - 4));
         if (b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
           final GlowBlockState state = b.getState();
           if ((state.getRawData() & 0x08) == 0
               && (state.getRawData() & 0x04) == 0) { // check decay is off and decay is on
             // set decay check on for this leaves block
             state.setRawData((byte) (state.getRawData() | 0x08));
             state.update(true);
           }
         }
       }
     }
   }
 }