本文整理汇总了Java中org.bukkit.material.Tree类的典型用法代码示例。如果您正苦于以下问题:Java Tree类的具体用法?Java Tree怎么用?Java Tree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Tree类属于org.bukkit.material包,在下文中一共展示了Tree类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jungleWoodPlanksCanCreateCraftingTableAndJungleWoodStairs
import org.bukkit.material.Tree; //导入依赖的package包/类
@Test
public void jungleWoodPlanksCanCreateCraftingTableAndJungleWoodStairs() {
Tree planks = new Tree(Material.WOOD);
planks.setSpecies(TreeSpecies.JUNGLE);
MaterialRecipes materialRecipes = recipeSnapshot.getMaterialRecipes(planks);
boolean foundWorkBench = false;
boolean foundJungleWoodPlanks = false;
for (Recipe recipe : materialRecipes.getUsages()) {
ItemStack result = recipe.getResult();
if (Material.WORKBENCH.equals(result.getType())) {
foundWorkBench = true;
} else if (Material.JUNGLE_WOOD_STAIRS.equals(result.getType())) {
foundJungleWoodPlanks = true;
}
}
assertEqual(true, foundWorkBench);
assertEqual(true, foundJungleWoodPlanks);
}
示例2: isBlockSolid
import org.bukkit.material.Tree; //导入依赖的package包/类
@Override
public boolean isBlockSolid(PlotBlock block) {
try {
Material material = Material.getMaterial(block.id);
if (material.isBlock() && material.isSolid() && !material.hasGravity()) {
Class<? extends MaterialData> data = material.getData();
if (data.equals(MaterialData.class) || data.equals(Tree.class) || data.equals(Sandstone.class) || data.equals(Wool.class) || data.equals(Step.class)) {
return true;
}
}
return false;
}
catch (Exception e) {
return false;
}
}
示例3: findJungleLog
import org.bukkit.material.Tree; //导入依赖的package包/类
/**
* Finds a jungle log around this crop block.
* @param crop The block to check around.
* @return The rotation for which a jungle log was found, null otherwise.
*/
private BlockRotation findJungleLog(BlockLocation crop) {
for (BlockRotation r : BlockRotation.values()) {
Block block = crop.getRelative(r.getYawFace()).getBlock();
if (block.getType() == Material.LOG) {
BlockState state = block.getState();
try {
Tree tree = (Tree) state.getData();
if (tree.getSpecies() == TreeSpecies.JUNGLE) {
return r;
}
} catch (ClassCastException e) {
}
}
}
return null;
}
示例4: isBlockSolid
import org.bukkit.material.Tree; //导入依赖的package包/类
@Override
public boolean isBlockSolid(PlotBlock block) {
try {
Material material = Material.getMaterial(block.id);
if (material.isBlock() && material.isSolid() && !material.hasGravity()) {
Class<? extends MaterialData> data = material.getData();
if (data.equals(MaterialData.class) && !material.isTransparent() && material.isOccluding()
|| data.equals(Tree.class)
|| data.equals(Sandstone.class)
|| data.equals(Wool.class)
|| data.equals(Step.class)
|| data.equals(WoodenStep.class)) {
switch (material) {
case NOTE_BLOCK:
case MOB_SPAWNER:
return false;
default:
return true;
}
}
}
return false;
} catch (Exception ignored) {
return false;
}
}
示例5: checkForDoubleDrop
import org.bukkit.material.Tree; //导入依赖的package包/类
/**
* Checks for double drops
*
* @param blockState Block being broken
*/
protected static void checkForDoubleDrop(BlockState blockState) {
if (mcMMO.getModManager().isCustomLog(blockState) && mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
}
else {
//TODO Remove this workaround when casting to Tree works again
TreeSpecies species = TreeSpecies.GENERIC;
if (blockState.getData() instanceof Tree) {
species = ((Tree) blockState.getData()).getSpecies();
}
if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(species)) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
}
}
}
示例6: getExperienceFromLog
import org.bukkit.material.Tree; //导入依赖的package包/类
/**
* Retrieves the experience reward from a log
*
* @param blockState Log being broken
* @param experienceGainMethod How the log is being broken
* @return Amount of experience
*/
protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) {
// Mushrooms aren't trees so we could never get species data from them
switch (blockState.getType()) {
case HUGE_MUSHROOM_1:
return ExperienceConfig.getInstance().getWoodcuttingXPHugeBrownMushroom();
case HUGE_MUSHROOM_2:
return ExperienceConfig.getInstance().getWoodcuttingXPHugeRedMushroom();
default:
break;
}
if (mcMMO.getModManager().isCustomLog(blockState)) {
return mcMMO.getModManager().getBlock(blockState).getXpGain();
}
//TODO Remove this workaround when casting to Tree works again
TreeSpecies species = TreeSpecies.GENERIC;
if (blockState.getData() instanceof Tree) {
species = ((Tree) blockState.getData()).getSpecies();
}
int xp = ExperienceConfig.getInstance().getWoodcuttingTreeXP(species);
if (species == TreeSpecies.JUNGLE && experienceGainMethod == ExperienceGainMethod.TREE_FELLER) {
xp *= 0.5;
}
return xp;
}
示例7: dropBlocks
import org.bukkit.material.Tree; //导入依赖的package包/类
/**
* Handles the dropping of blocks
*
* @param treeFellerBlocks List of blocks to be dropped
*/
private void dropBlocks(Set<BlockState> treeFellerBlocks) {
Player player = getPlayer();
int xp = 0;
for (BlockState blockState : treeFellerBlocks) {
Block block = blockState.getBlock();
if (!EventUtils.simulateBlockBreak(block, player, true)) {
break; // TODO: Shouldn't we use continue instead?
}
Material material = blockState.getType();
if (material == Material.HUGE_MUSHROOM_1 || material == Material.HUGE_MUSHROOM_2) {
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
Misc.dropItems(blockState.getLocation(), block.getDrops());
}
else if (mcMMO.getModManager().isCustomLog(blockState)) {
if (canGetDoubleDrops()) {
Woodcutting.checkForDoubleDrop(blockState);
}
CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState);
xp = customBlock.getXpGain();
Misc.dropItems(blockState.getLocation(), block.getDrops());
}
else if (mcMMO.getModManager().isCustomLeaf(blockState)) {
Misc.dropItems(blockState.getLocation(), block.getDrops());
}
else {
//TODO Remove this workaround when casting to Tree works again
if (blockState.getData() instanceof Tree) {
Tree tree = (Tree) blockState.getData();
tree.setDirection(BlockFace.UP);
}
switch (material) {
case LOG:
case LOG_2:
if (canGetDoubleDrops()) {
Woodcutting.checkForDoubleDrop(blockState);
}
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
Misc.dropItems(blockState.getLocation(), block.getDrops());
break;
case LEAVES:
case LEAVES_2:
Misc.dropItems(blockState.getLocation(), block.getDrops());
break;
default:
break;
}
}
blockState.setType(Material.AIR);
blockState.update(true);
}
applyXpGain(xp, XPGainReason.PVE);
}
示例8: Tree
import org.bukkit.material.Tree; //导入依赖的package包/类
public Tree() {
}
示例9: clone
import org.bukkit.material.Tree; //导入依赖的package包/类
public Tree clone() {
return null;
}
示例10: getMaterialData
import org.bukkit.material.Tree; //导入依赖的package包/类
public static MaterialData getMaterialData(String identifier) {
final String[] split = identifier.replaceAll("\\s+", "_").split("\\W");
// TODO: Add additional material/name database like essentials/worldedit have
Material material = matchMaterial(split[0]);
if (material == null) {
// try worldedit
material = getWEMaterial(split[0]);
if (material == null) return null;
}
if (split.length == 1) {
return new MaterialData(material);
}
try {
final byte rawData = Byte.parseByte(split[1]);
return new MaterialData(material, rawData);
} catch (NumberFormatException e) {
// ignore
}
switch (material) {
case LEAVES:
return getMaterialData(material, Leaves::new, TreeSpecies.class, split[1]);
case COAL:
return getMaterialData(material, Coal::new, CoalType.class, split[1]);
case LONG_GRASS:
return getMaterialData(material, LongGrass::new, GrassSpecies.class, split[1]);
case SANDSTONE:
return getMaterialData(material, Sandstone::new, SandstoneType.class, split[1]);
case MONSTER_EGG:
return getMaterialData(material, SpawnEgg::new, EntityType.class, split[1]);
case LOG:
return getMaterialData(material, Tree::new, TreeSpecies.class, split[1]);
case WOOD_STEP:
return getMaterialData(material, WoodenStep::new, TreeSpecies.class, split[1]);
case WOOL:
return getMaterialData(material, Wool::new, DyeColor.class, split[1]);
// TODO: Add Dye here when Spigot finally accepts my PR to match other MaterialData types
default:
// Couldn't find additional data for this material
return new MaterialData(material);
}
}