本文整理汇总了Java中org.bukkit.Material.LEAVES_2属性的典型用法代码示例。如果您正苦于以下问题:Java Material.LEAVES_2属性的具体用法?Java Material.LEAVES_2怎么用?Java Material.LEAVES_2使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.LEAVES_2属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
}
}
示例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);
}
}
}
示例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;
}
示例4: 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();
}