byte data = state.getRawData(); switch (attachedFace) { case UP:
@Override public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { BlockStateDelegate blockStateDelegate = new BlockStateDelegate(); if (GlowTree.newInstance(type, ThreadLocalRandom.current(), blockStateDelegate) .generate(loc)) { List<BlockState> blockStates = new ArrayList<>(blockStateDelegate.getBlockStates()); StructureGrowEvent growEvent = new StructureGrowEvent(loc, type, false, null, blockStates); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { for (BlockState state : blockStates) { state.update(true); if (delegate != null) { delegate.setTypeIdAndData(state.getX(), state.getY(), state.getZ(), state .getTypeId(), state.getRawData()); } } return true; } } return false; }
private void flow(GlowBlock source, BlockFace direction) { // if we're not going down BlockFromToEvent fromToEvent = new BlockFromToEvent(source, direction); if (fromToEvent.isCancelled()) { return; } byte strength = fromToEvent.getBlock().getState().getRawData(); if (DOWN != fromToEvent.getFace()) { if (strength < (isWater(fromToEvent.getBlock().getType()) || fromToEvent.getBlock().getBiome() == Biome.HELL ? STRENGTH_MIN_WATER : STRENGTH_MIN_LAVA)) { // decrease the strength strength += 1; } else { // no strength, can't flow return; } } else { // reset the strength if we're going down strength = STRENGTH_MAX; } // flow to the target GlowBlock toBlock = (GlowBlock) fromToEvent.getToBlock(); toBlock.setType(fromToEvent.getBlock().getType(), strength, false); toBlock.getWorld().requestPulse(toBlock); }
@Override public byte getRawData() { return base.getRawData(); }
public static byte getRawData(BlockState state) { // @deprecated Magic value return state.getRawData(); }
/** * @param block */ public BlockTypeEntry(BlockState block) { this.material = block.getType(); this.data = block.getRawData(); }
@Override public void run() { tblock.revertBlock(); if (TEMP_LAVA_BLOCKS.values().contains(tblock)) { LavaFlow.this.affectedBlocks.remove(tblock); TEMP_LAVA_BLOCKS.remove(tblock.getBlock()); } if (TEMP_LAND_BLOCKS.values().contains(tblock)) { LavaFlow.this.affectedBlocks.remove(tblock); TEMP_LAND_BLOCKS.remove(tblock.getBlock()); } if (TEMP_AIR_BLOCKS.values().contains(tblock)) { LavaFlow.this.affectedBlocks.remove(tblock); TEMP_AIR_BLOCKS.remove(tblock.getBlock()); } if (isTempAir && tblock.getState().getType() == Material.DOUBLE_PLANT) { tblock.getBlock().getRelative(BlockFace.UP).setType(Material.DOUBLE_PLANT); tblock.getBlock().getRelative(BlockFace.UP).setData((byte) (tblock.getState().getRawData() + 8)); } } }.runTaskLater(ProjectKorra.plugin, (long) (i / this.shiftRemoveSpeed));
public static void moveEarthBlock(final Block source, final Block target) { Information info; if (MOVED_EARTH.containsKey(source)) { info = MOVED_EARTH.get(source); MOVED_EARTH.remove(source); } else { info = new Information(); info.setBlock(source); info.setTime(System.currentTimeMillis()); info.setState(source.getState()); } info.setTime(System.currentTimeMillis()); MOVED_EARTH.put(target, info); if (info.getState().getType() == Material.SAND) { if (info.getState().getRawData() == (byte) 0x1) { target.setType(Material.RED_SANDSTONE); } else { target.setType(Material.SANDSTONE); } } else if (info.getState().getType() == Material.GRAVEL) { target.setType(Material.STONE); } else { target.setType(info.getState().getType()); target.setData(info.getState().getRawData()); } source.setType(Material.AIR); }
/** * @param state */ public GriefBlock(BlockState state) { super(state.getX(), state.getY(), state.getZ(), state.getWorld().getName()); this.type = new BlockTypeEntry(state.getTypeId(), state.getRawData()); this.empty = true; }
/** * @param state */ public TranslocationBlock(BlockState state) { super(state.getX(), state.getY(), state.getZ(), state.getWorld().getName()); this.type = new BlockTypeEntry(state.getTypeId(), state.getRawData()); this.empty = true; }
/** * Revert the temp fire at the location if any is there. * * @param location The Location */ public static void revertTempFire(final Location location) { if (!TEMP_FIRE.containsKey(location)) { return; } final Information info = TEMP_FIRE.get(location); if (info.getLocation().getBlock().getType() != Material.FIRE && info.getLocation().getBlock().getType() != Material.AIR) { if (info.getState().getType() == Material.RED_ROSE || info.getState().getType() == Material.YELLOW_FLOWER) { final ItemStack itemStack = new ItemStack(info.getState().getData().getItemType(), 1, info.getState().getRawData()); info.getState().getBlock().getWorld().dropItemNaturally(info.getLocation(), itemStack); } } else { info.getBlock().setType(info.getState().getType()); info.getBlock().setData(info.getState().getRawData()); } TEMP_FIRE.remove(location); }
public static Block getLavaBlock(final Player player, final double range) { final Location location = player.getEyeLocation(); final Vector vector = location.getDirection().clone().normalize(); for (double i = 0; i <= range; i++) { final Block block = location.clone().add(vector.clone().multiply(i)).getBlock(); if (GeneralMethods.isRegionProtectedFromBuild(player, location)) { continue; } if (isLava(block)) { if (TempBlock.isTempBlock(block)) { final TempBlock tb = TempBlock.get(block); final byte full = 0x0; if (tb.getState().getRawData() != full && !isLava(tb.getState().getType())) { continue; } } return block; } } return null; }
/** * Finds a valid Lava source for a Player. To use dynamic source selection, * use BlockSource.getLavaSourceBlock() instead of this method. Dynamic * source selection saves the user's previous source for future use. * {@link BlockSource#getLavaSourceBlock(Player, double, com.projectkorra.projectkorra.util.ClickType)} * * @param range the maximum block selection range. * @return a valid Lava source block, or null if one could not be found. */ public static Block getLavaSourceBlock(final Player player, final String abilityName, final double range) { final Location location = player.getEyeLocation(); final Vector vector = location.getDirection().clone().normalize(); for (double i = 0; i <= range; i++) { final Block block = location.clone().add(vector.clone().multiply(i)).getBlock(); if (GeneralMethods.isRegionProtectedFromBuild(player, abilityName, location)) { continue; } if (isLavabendable(player, block)) { if (TempBlock.isTempBlock(block)) { final TempBlock tb = TempBlock.get(block); final byte full = 0x0; if (tb.getState().getRawData() != full && !isLava(tb.getState().getType())) { continue; } } return block; } } return null; }