/** * Checks whether this tree can grow on top of the given block. * @param soil the block we're growing on * @return true if this tree can grow on the type of block below it; false otherwise */ public boolean canPlaceOn(BlockState soil) { return soil.getType() == Material.GRASS || soil.getType() == Material.DIRT || soil.getType() == Material.SOIL; }
/** * Returns the block type at the given coordinates. * @param x the x coordinate * @param y the y coordinate * @param z the z coordinate * @param world the world we are generating in * @return the block type */ protected Material blockTypeAt(int x, int y, int z, World world) { return delegate.getBlockState(world, x, y, z).getType(); } }
if ((Math.abs(x - l.getBlockX()) != radius || Math.abs(z - l.getBlockZ()) != radius || random.nextBoolean()) && !delegate.getBlockState(world, x, y, z).getType().isSolid()) { delegate .setTypeAndRawData(world, x, y, z, Material.LEAVES, leavesType);
} else if (!builder.getBlockState(new Vector(x, y - 1, z)).getType() .isSolid()) { } else if (state.getType().isSolid()) { int x = random.nextInt((radiusX << 1) - 1) + 1; int z = random.nextInt((radiusZ << 1) - 1) + 1; if (builder.getBlockState(new Vector(x, 1, z)).getType() == Material.AIR) { BlockFace face = null; int solidBlocksCount = 0; if (builder.getBlockState(new Vector(x - 1, 1, z)).getType() == Material.COBBLESTONE) { solidBlocksCount++; face = BlockFace.EAST; if (builder.getBlockState(new Vector(x + 1, 1, z)).getType() == Material.COBBLESTONE) { solidBlocksCount++; face = BlockFace.WEST; if (builder.getBlockState(new Vector(x, 1, z - 1)).getType() == Material.COBBLESTONE) { solidBlocksCount++; face = BlockFace.SOUTH; if (builder.getBlockState(new Vector(x, 1, z + 1)).getType() == Material.COBBLESTONE) { solidBlocksCount++;
while (builder.getBlockState(new Vector(2, 1, 2)).getType() == Material.AIR && boundingBox.getMin().getBlockY() > 0) { boundingBox.offset(new Vector(0, -1, 0)); if (builder.getBlockState(new Vector(2, 1, 2)).getType() != Material.SAND) { return false; if (builder.getBlockState(new Vector(x, 0, z)).getType() == Material.AIR && builder.getBlockState(new Vector(x, -1, z)).getType() == Material.AIR) { return false;
/** * Determine if a given block is an mcMMO anvil * * @param blockState * The {@link BlockState} of the block to check * @return true if the block is an mcMMO anvil, false otherwise */ public static boolean isMcMMOAnvil(BlockState blockState) { Material type = blockState.getType(); return type == Repair.anvilMaterial || type == Salvage.anvilMaterial; }
/** * Check if a given block is an ore * * @param blockState * The {@link BlockState} of the block to check * @return true if the block is an ore, false otherwise */ public static boolean isOre(BlockState blockState) { return MaterialUtils.isOre(blockState.getType()); }
/** * Calculate XP gain for Mining. * * @param blockState The {@link BlockState} to check ability activation for */ public static int getBlockXp(BlockState blockState) { int xp = ExperienceConfig.getInstance().getXp(PrimarySkillType.MINING, blockState.getType()); if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) { xp = mcMMO.getModManager().getBlock(blockState).getXpGain(); } return xp; }
protected static int getBlockXP(BlockState blockState) { int xp = ExperienceConfig.getInstance().getXp(PrimarySkillType.EXCAVATION, blockState.getType()); if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) { xp = mcMMO.getModManager().getBlock(blockState).getXpGain(); } return xp; } }
@EventHandler(ignoreCancelled = true) public void onEntityBlockForm(EntityBlockFormEvent event) { if (event.getEntity() instanceof Player) { // should just be frostwalker...other uses of EntityBlockForm are in BlockListener Events.fireToCancel(event, new PlaceBlockEvent(event, create(event.getEntity()), event.getBlock().getLocation(), event.getNewState().getType())); } }
public boolean canGreenThumbBlock(BlockState blockState) { if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_GREEN_THUMB)) return false; Player player = getPlayer(); ItemStack item = player.getInventory().getItemInMainHand(); return item.getAmount() > 0 && item.getType() == Material.WHEAT_SEEDS && BlockUtils.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType()); }
@EventHandler public void blockFormEvent(BlockFormEvent event) { if (event.getNewState().getType() == Material.SNOW) { WorldClimateEngine climateEngine = ClimateEngine.getInstance().getClimateEngine(event.getBlock().getWorld().getUID()); if (climateEngine != null && climateEngine.isEffectEnabled(ClimateEffectType.SNOW_FORMATION)) { double temperature = climateEngine.getTemperature(); if (event.getBlock().getY() < heightMap.getValue(temperature)) { event.setCancelled(true); } } } }
@EventHandler public void blockFormEvent(BlockFormEvent event) { if (event.getNewState().getType() == Material.ICE) { WorldClimateEngine climateEngine = ClimateEngine.getInstance().getClimateEngine(event.getBlock().getWorld().getUID()); if (climateEngine != null && climateEngine.isEffectEnabled(ClimateEffectType.ICE_FORMATION)) { if (event.getBlock().getY() < heightMap.getValue(climateEngine.getTemperature())) { event.setCancelled(true); } } } }