本文整理汇总了Java中org.bukkit.TreeType类的典型用法代码示例。如果您正苦于以下问题:Java TreeType类的具体用法?Java TreeType怎么用?Java TreeType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TreeType类属于org.bukkit包,在下文中一共展示了TreeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTrackedTreeMaterial
import org.bukkit.TreeType; //导入依赖的package包/类
public Material getTrackedTreeMaterial(String trackedType) {
if (Material.CHORUS_PLANT.toString().equals(trackedType))
return Material.CHORUS_PLANT;
else {
for (TreeType treeType : TreeType.values()) {
if (treeType.toString().equals(trackedType)) {
if (treeType == TreeType.ACACIA || treeType == TreeType.DARK_OAK)
return Material.LOG_2;
else if (treeType == TreeType.BROWN_MUSHROOM)
return Material.HUGE_MUSHROOM_1;
else if (treeType == TreeType.RED_MUSHROOM)
return Material.HUGE_MUSHROOM_2;
else
return Material.LOG;
}
}
}
CropControl.getPlugin().debug("Unable to match tracked tree type material {0}", trackedType);
return null;
}
示例2: generateTree
import org.bukkit.TreeType; //导入依赖的package包/类
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
world.captureTreeGeneration = true;
world.captureBlockStates = true;
boolean grownTree = generateTree(loc, type);
world.captureBlockStates = false;
world.captureTreeGeneration = false;
if (grownTree) { // Copy block data to delegate
for (BlockState blockstate : world.capturedBlockStates) {
int x = blockstate.getX();
int y = blockstate.getY();
int z = blockstate.getZ();
net.minecraft.server.Block oldBlock = world.getType(x, y, z);
int typeId = blockstate.getTypeId();
int data = blockstate.getRawData();
int flag = ((CraftBlockState)blockstate).getFlag();
delegate.setTypeIdAndData(x, y, z, typeId, data);
net.minecraft.server.Block newBlock = world.getType(x, y, z);
world.notifyAndUpdatePhysics(x, y, z, null, oldBlock, newBlock, flag);
}
world.capturedBlockStates.clear();
return true;
} else {
world.capturedBlockStates.clear();
return false;
}
}
示例3: grow
import org.bukkit.TreeType; //导入依赖的package包/类
public boolean grow(World world, int i, int j, int k, Random random) {
int l = world.getData(i, j, k);
world.setAir(i, j, k);
WorldGenHugeMushroom worldgenhugemushroom = null;
if (this == Blocks.BROWN_MUSHROOM) {
BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit
worldgenhugemushroom = new WorldGenHugeMushroom(0);
} else if (this == Blocks.RED_MUSHROOM) {
BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit
worldgenhugemushroom = new WorldGenHugeMushroom(1);
}
if (worldgenhugemushroom != null && worldgenhugemushroom.generate(world, random, i, j, k)) {
return true;
} else {
world.setTypeAndData(i, j, k, this, l, 3);
return false;
}
}
示例4: getTree
import org.bukkit.TreeType; //导入依赖的package包/类
@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;
}
}
}
示例5: rollTreeType
import org.bukkit.TreeType; //导入依赖的package包/类
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;
}
示例6: use
import org.bukkit.TreeType; //导入依赖的package包/类
@Override
public boolean use(Player player) {
Block targetBlock = getTargetBlock(player, null, 32);
boolean successful = targetBlock.getWorld().generateTree(targetBlock.getRelative(BlockFace.UP).getLocation(), TreeType.JUNGLE);
if (successful) {
for (LivingEntity entity : player.getWorld().getLivingEntities()) {
if (entity.getLocation().distanceSquared(targetBlock.getLocation()) <= 256) {
double damage = 15D;
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(player, entity, EntityDamageEvent.DamageCause.MAGIC, new EnumMap(ImmutableMap.of(EntityDamageEvent.DamageModifier.BASE, Double.valueOf(damage))), new EnumMap(ImmutableMap.of(EntityDamageEvent.DamageModifier.BASE, ZERO)));
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (event.getEntity() instanceof LivingEntity) {
((LivingEntity) event.getEntity()).damage(event.getDamage(), event.getDamager());
event.getEntity().setLastDamageCause(event);
}
}
}
}
} else {
player.sendMessage(ChatColor.RED + "Could not grow a tree there.");
}
return successful;
}
示例7: c
import org.bukkit.TreeType; //导入依赖的package包/类
public boolean c(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
world.setAir(blockposition);
WorldGenHugeMushroom worldgenhugemushroom = null;
if (this == Blocks.BROWN_MUSHROOM) {
BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit
worldgenhugemushroom = new WorldGenHugeMushroom(Blocks.BROWN_MUSHROOM_BLOCK);
} else if (this == Blocks.RED_MUSHROOM) {
BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit
worldgenhugemushroom = new WorldGenHugeMushroom(Blocks.RED_MUSHROOM_BLOCK);
}
if (worldgenhugemushroom != null && worldgenhugemushroom.generate(world, random, blockposition)) {
return true;
} else {
world.setTypeAndData(blockposition, iblockdata, 3);
return false;
}
}
示例8: run
import org.bukkit.TreeType; //导入依赖的package包/类
@Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final BigTree bigTree = BIGTREE_PARSER.parse(args).getValue();
final TreeType bukkitTree = bigTree.getBukkitType();
final Location loc = LocationUtil.getTarget(user.getPlayer());
final Location safeLocation = LocationUtil.getSafeDestination(loc);
final boolean success = user.getPlayer().getWorld().generateTree(safeLocation, bukkitTree);
if (success)
{
user.sendMessage(_("§6Big tree spawned."));
}
else
{
throw new Exception(_("§4Big tree generation failure. Try again on grass or dirt."));
}
}
示例9: getTrackedTypeMaterial
import org.bukkit.TreeType; //导入依赖的package包/类
public Material getTrackedTypeMaterial(String trackedType) {
for (Material material : harvestableCrops.keySet()) {
if (material.toString().equals(trackedType))
return material;
}
if (Material.MELON_BLOCK.toString().equals(trackedType))
return Material.MELON_BLOCK;
else if (Material.PUMPKIN.toString().equals(trackedType))
return Material.PUMPKIN;
for (Byte i = 0; i < 6; i++) {
if (getSaplingType(i).equals(trackedType)) // TODO: odd structure here
return Material.SAPLING;
}
for (TreeType treeType : TreeType.values()) {
if (treeType.toString().equals(trackedType)) {
if (treeType == TreeType.ACACIA || treeType == TreeType.DARK_OAK)
return Material.LOG_2;
else if (treeType == TreeType.BROWN_MUSHROOM)
return Material.HUGE_MUSHROOM_1;
else if (treeType == TreeType.RED_MUSHROOM)
return Material.HUGE_MUSHROOM_2;
else
return Material.LOG;
}
}
if (Material.CHORUS_PLANT.toString().equals(trackedType))
return Material.CHORUS_PLANT;
CropControl.getPlugin().debug("Unable to match tracked type material {0}", trackedType);
return null;
}
示例10: StructureGrowEvent
import org.bukkit.TreeType; //导入依赖的package包/类
public StructureGrowEvent(final Location location, final TreeType species, final boolean bonemeal, final Player player, final List<BlockState> blocks) {
super(location.getWorld());
this.location = location;
this.species = species;
this.bonemeal = bonemeal;
this.player = player;
this.blocks = blocks;
}
示例11: take
import org.bukkit.TreeType; //导入依赖的package包/类
@Override
public void take(Protocol.Report report) {
final Player p = getPlayer();
if (p != null) {
if (InteractivePlugin.INSTANCE != null) {
Bukkit.getScheduler().runTaskLater(InteractivePlugin.INSTANCE, new Runnable() {
@Override
public void run() {
Location position = PositionUtil.getSafeLocationWithin(p, 2, 5);
if (position == null) {
position = PositionUtil.getLocationWithin(p, 4, 6);
}
Block block = p.getWorld().getBlockAt(position);
if ((block.getType() != Material.DIRT) || (block.getType() != Material.GRASS)) {
block.setType(Material.DIRT);
position.add(0, 1, 0);
}
p.getWorld().generateTree(position, TreeType.TREE);
StringBuffer buffer = new StringBuffer();
buffer.append(ChatColor.GRAY);
buffer.append(ChatColor.ITALIC);
buffer.append("A Wild Tree Appears!");
getPlayer().sendMessage(buffer.toString());
}
}, 1);
}
}
}
示例12: generateTree
import org.bukkit.TreeType; //导入依赖的package包/类
@Override
public boolean generateTree(final Location location, final TreeType type) {
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
@Override
public void run(Boolean value) {
this.value = parent.generateTree(location, type);
}
});
}
示例13: generateTree
import org.bukkit.TreeType; //导入依赖的package包/类
@Override
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt) {
World world = getWorld();
TreeType bukkitType = toBukkitTreeType(type);
return type != null && world.generateTree(BukkitUtil.toLocation(world, pt), bukkitType,
new EditSessionBlockChangeDelegate(editSession));
}
示例14: generateTree
import org.bukkit.TreeType; //导入依赖的package包/类
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
world.captureTreeGeneration = true;
world.captureBlockStates = true;
boolean grownTree = generateTree(loc, type);
world.captureBlockStates = false;
world.captureTreeGeneration = false;
if (grownTree) { // Copy block data to delegate
for (BlockState blockstate : world.capturedBlockStates) {
int x = blockstate.getX();
int y = blockstate.getY();
int z = blockstate.getZ();
BlockPosition position = new BlockPosition(x, y, z);
net.minecraft.server.Block oldBlock = world.getType(position).getBlock();
int typeId = blockstate.getTypeId();
int data = blockstate.getRawData();
int flag = ((CraftBlockState)blockstate).getFlag();
delegate.setTypeIdAndData(x, y, z, typeId, data);
net.minecraft.server.Block newBlock = world.getType(position).getBlock();
world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, flag);
}
world.capturedBlockStates.clear();
return true;
} else {
world.capturedBlockStates.clear();
return false;
}
}
示例15: grow
import org.bukkit.TreeType; //导入依赖的package包/类
@Override
public boolean grow(Block block) {
if (block.getType() != Material.SAPLING && block.getType() != Material.BROWN_MUSHROOM
&& block.getType() != Material.RED_MUSHROOM)
return false;
TreeType type = getTree(block);
Material prevMat = block.getType();
block.setType(Material.AIR);
if (block.getWorld().generateTree(block.getLocation(), type)) {
return true;
}
block.setType(prevMat);
return false;
}