Java 类org.bukkit.material.Tree 实例源码

项目:craftinomicon    文件:RecipeSnapshotTest.java   
@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);
}
项目:PlotSquared-Chinese    文件:BukkitUtil.java   
@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;
    }
}
项目:StarQuestCode    文件:CropCocoa.java   
/**
 * 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;
}
项目:PlotSquared    文件:BukkitUtil.java   
@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;
    }
}
项目:McMMOPlus    文件:Woodcutting.java   
/**
 * 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());
        }
    }
}
项目:McMMOPlus    文件:Woodcutting.java   
/**
 * 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;
}
项目:McMMOPlus    文件:WoodcuttingManager.java   
/**
 * 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);
}
项目:BedrockAPI    文件:Tree.java   
public Tree() {
}
项目:BedrockAPI    文件:Tree.java   
public Tree(TreeSpecies species) {
}
项目:BedrockAPI    文件:Tree.java   
public Tree(TreeSpecies species, BlockFace dir) {
}
项目:BedrockAPI    文件:Tree.java   
@Deprecated public Tree(int type) {
}
项目:BedrockAPI    文件:Tree.java   
public Tree(Material type) {
}
项目:BedrockAPI    文件:Tree.java   
@Deprecated public Tree(int type, byte data) {
}
项目:BedrockAPI    文件:Tree.java   
@Deprecated public Tree(Material type, byte data) {
}
项目:BedrockAPI    文件:Tree.java   
public Tree clone() {
    return null;
}
项目:CraftFX    文件:MaterialDataUtil.java   
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);
    }
}