本文整理汇总了Java中org.bukkit.TreeType.TREE属性的典型用法代码示例。如果您正苦于以下问题:Java TreeType.TREE属性的具体用法?Java TreeType.TREE怎么用?Java TreeType.TREE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.TreeType
的用法示例。
在下文中一共展示了TreeType.TREE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTree
@SuppressWarnings("deprecation")
private TreeType getTree(Block block) {
if (block.getType() == Material.SAPLING) {
switch (block.getData()) {
case 0:
return TreeType.TREE;
case 1:
return TreeType.REDWOOD;
case 2:
return TreeType.BIRCH;
case 3:
return TreeType.SMALL_JUNGLE;
case 4:
return TreeType.ACACIA;
case 5:
return TreeType.DARK_OAK;
}
return TreeType.TREE;
} else {
if (block.getType() == Material.BROWN_MUSHROOM) {
return TreeType.BROWN_MUSHROOM;
} else {
return TreeType.RED_MUSHROOM;
}
}
}
示例2: rollTreeType
public TreeType rollTreeType(Random random) {
double total = 0.0;
for(int i = 0; i < treeTypeChance.length; i++) {
total += treeTypeChance[i];
}
double d = random.nextDouble()*total;
double chance = 0.0;
for(int i = 0; i < treeType.length; i++) {
if(d < chance+treeTypeChance[i]) {
return treeType[i];
} else {
chance += treeTypeChance[i];
}
}
return TreeType.TREE;
}
示例3: growtreeOperation
@Operation(desc = "Grow a tree of the given type on top of this block. Returns 1 uppon success, 0 otherwise.")
public static Parameter growtreeOperation(org.bukkit.block.Block block, Context ctx, StringParameter type) {
TreeType t = TreeType.TREE;
if ( type != null ) t = type.asEnum(TreeType.class);
if ( t == null ) fizzle("No such tree type: " + type.asString());
return Parameter.from(block.getWorld().generateTree(block.getLocation().add(0, 1.0, 0), t) ? 1 : 0);
}
示例4: run
@Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
TreeType tree;
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
else if (args[0].equalsIgnoreCase("birch"))
{
tree = TreeType.BIRCH;
}
else if (args[0].equalsIgnoreCase("redwood"))
{
tree = TreeType.REDWOOD;
}
else if (args[0].equalsIgnoreCase("tree"))
{
tree = TreeType.TREE;
}
else if (args[0].equalsIgnoreCase("redmushroom"))
{
tree = TreeType.RED_MUSHROOM;
}
else if (args[0].equalsIgnoreCase("brownmushroom"))
{
tree = TreeType.BROWN_MUSHROOM;
}
else if (args[0].equalsIgnoreCase("jungle"))
{
tree = TreeType.SMALL_JUNGLE;
}
else if (args[0].equalsIgnoreCase("junglebush"))
{
tree = TreeType.JUNGLE_BUSH;
}
else if (args[0].equalsIgnoreCase("swamp"))
{
tree = TreeType.SWAMP;
}
else
{
throw new NotEnoughArgumentsException();
}
final Location loc = LocationUtil.getTarget(user.getPlayer());
final Location safeLocation = LocationUtil.getSafeDestination(loc);
final boolean success = user.getPlayer().getWorld().generateTree(safeLocation, tree);
if (success)
{
user.sendMessage(_("§6Tree spawned."));
}
else
{
user.sendMessage(_("§4Tree generation failure. Try again on grass or dirt."));
}
}
示例5: populate
@Override
public void populate(World world, Random random, Chunk chunk) {
int worldChunkX = chunk.getX();
int worldChunkZ = chunk.getZ();
TreeType[] treeTypes = new TreeType[] {};
int treesPerChunk = 0;
switch (world.getBiome(worldChunkX, worldChunkZ)) {
case EXTREME_HILLS:
treeTypes = new TreeType[] {TreeType.TREE};
treesPerChunk = 1;
break;
case FOREST: case FOREST_HILLS:
treeTypes = new TreeType[] {TreeType.TREE, TreeType.BIRCH};
treesPerChunk = 8;
break;
case FROZEN_OCEAN:
treeTypes = new TreeType[] {TreeType.TREE};
treesPerChunk = 1;
break;
case FROZEN_RIVER:
treeTypes = new TreeType[] {TreeType.TREE};
treesPerChunk = 1;
break;
case ICE_MOUNTAINS:
treeTypes = new TreeType[] {TreeType.TREE};
treesPerChunk = 2;
break;
case ICE_PLAINS:
treeTypes = new TreeType[] {TreeType.TREE};
treesPerChunk = 1;
break;
case JUNGLE: case JUNGLE_HILLS:
treeTypes = new TreeType[] {TreeType.JUNGLE, TreeType.SMALL_JUNGLE, TreeType.JUNGLE_BUSH};
treesPerChunk = 4;
break;
case MUSHROOM_ISLAND: case MUSHROOM_SHORE:
treeTypes = new TreeType[] {TreeType.RED_MUSHROOM, TreeType.BROWN_MUSHROOM};
treesPerChunk = 4;
break;
case RIVER:
treeTypes = new TreeType[] {TreeType.TREE};
treesPerChunk = 4;
break;
case SMALL_MOUNTAINS:
treeTypes = new TreeType[] {TreeType.TREE};
treesPerChunk = 1;
break;
case SWAMPLAND:
treeTypes = new TreeType[] {TreeType.SWAMP};
break;
case TAIGA: case TAIGA_HILLS:
treeTypes = new TreeType[] {TreeType.REDWOOD, TreeType.TALL_REDWOOD};
break;
default:
break;
}
if (treeTypes.length > 0 && treesPerChunk != 0) {
for (int i = 0; i < treesPerChunk; i++) {
world.generateTree(world.getHighestBlockAt(worldChunkX + random.nextInt(16), worldChunkZ + random.nextInt(16)).getLocation(), treeTypes[random.nextInt(treeTypes.length)]);
}
}
}