当前位置: 首页>>代码示例>>Java>>正文


Java Material.LEAVES属性代码示例

本文整理汇总了Java中org.bukkit.Material.LEAVES属性的典型用法代码示例。如果您正苦于以下问题:Java Material.LEAVES属性的具体用法?Java Material.LEAVES怎么用?Java Material.LEAVES使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bukkit.Material的用法示例。


在下文中一共展示了Material.LEAVES属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onTreeGrow

/**
 * Prevents trees from growing outside of the protected area.
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    // Check world
    if (!Util.inWorld(e.getLocation())) {
        return;
    }
    // Check if this is on an island
    Island island = plugin.getIslands().getIslandAt(e.getLocation());
    if (island == null || island.isSpawn()) {
        return;
    }
    Iterator<BlockState> it = e.getBlocks().iterator();
    while (it.hasNext()) {
        BlockState b = it.next();
        if (b.getType() == Material.LOG || b.getType() == Material.LOG_2
                || b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
            if (!island.onIsland(b.getLocation())) {
                it.remove();
            }
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:30,代码来源:IslandGuard.java

示例2: onTreeGrow

/**
 * Converts trees to gravel and glowstone
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + e.getEventName());

    if (!Settings.netherTrees) {
        return;
    }
    if (!Settings.netherGenerate || IslandWorld.getNetherWorld() == null) {
        return;
    }
    // Check world
    if (!e.getLocation().getWorld().equals(IslandWorld.getNetherWorld())) {
        return;
    }
    for (BlockState b : e.getBlocks()) {
        if (b.getType() == Material.LOG || b.getType() == Material.LOG_2) {
            b.setType(Material.GRAVEL);
        } else if (b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
            b.setType(Material.GLOWSTONE);
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:28,代码来源:NetherEvents.java

示例3: isNearWood

public boolean isNearWood(Block block, int range)
{
    if(range <= 0)
        return false;

    for(BlockFace face : this.faces)
    {
        Block block1 = block.getRelative(face);

        if(block1.getType() == Material.LOG || block1.getType() == Material.LOG_2)
            return true;
        else if((block1.getType() == Material.LEAVES || block1.getType() == Material.LEAVES_2) && this.isNearWood(block1, range-1))
            return true;
    }

    return false;
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:17,代码来源:FastTreeModule.java

示例4: calcSurvivalFastBreak

public static long calcSurvivalFastBreak(ItemStack tool, Material block) {
    if (isInstantBreak(block) || (tool.getType() == Material.SHEARS && block == Material.LEAVES)) {
        return 0;
    }
    double bhardness = BlockHardness.getBlockHardness(block);
    double thardness = ToolHardness.getToolHardness(tool.getType());
    long enchantlvl = (long) tool.getEnchantmentLevel(Enchantment.DIG_SPEED);

    long result = Math.round((bhardness * thardness) * 0.10 * 10000);

    if (enchantlvl > 0) {
        result /= enchantlvl * enchantlvl + 1L;
    }

    result = result > 25000 ? 25000 : result < 0 ? 0 : result;

    if (isQuickCombo(tool, block)) {
        result = result / 2;
    }

    return result;
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:22,代码来源:Utilities.java

示例5: getRandomLocation

public Location getRandomLocation(){
    int minX = corner1.getLocation().getBlockX();
    int minZ = corner1.getLocation().getBlockZ();
    int maxX = corner2.getLocation().getBlockX();
    int maxZ = corner2.getLocation().getBlockZ();

    double dx = Math.random() * (maxX - minX) + minX;
    double dz = Math.random() * (maxZ - minZ) + minZ;

    Block b = world.getHighestBlockAt(new Location(world, dx, 0, dz));

    if (b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) getRandomLocation();

    return b.getLocation();
}
 
开发者ID:cadox8,项目名称:WC,代码行数:15,代码来源:CuboidRegion.java


注:本文中的org.bukkit.Material.LEAVES属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。