类org.bukkit.TreeSpecies源码实例Demo

下面列出了怎么用org.bukkit.TreeSpecies的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: XSeries   文件: XBlock.java
public static XMaterial getType(Block block) {
    if (ISFLAT) return XMaterial.matchXMaterial(block.getType());
    String type = block.getType().name();
    BlockState state = block.getState();
    MaterialData data = state.getData();

    if (data instanceof Wood) {
        TreeSpecies species = ((Wood) data).getSpecies();
        return XMaterial.matchXMaterial(species.name() + block.getType().name())
                .orElseThrow(() -> new IllegalArgumentException("Unsupported material from tree species " + species.name() + ": " + block.getType().name()));
    }
    if (data instanceof Colorable) {
        Colorable color = (Colorable) data;
        return XMaterial.matchXMaterial(color.getColor().name() + '_' + type).orElseThrow(() -> new IllegalArgumentException("Unsupported colored material"));
    }
    return XMaterial.matchXMaterial(block.getType());
}
 
源代码2 项目: Kettle   文件: Door.java
/**
 * Returns the item type of a wooden door for the given tree species.
 *
 * @param species The species of wood door required.
 * @return The item type for the given species.
 * @see Material#WOODEN_DOOR
 * @see Material#SPRUCE_DOOR
 * @see Material#BIRCH_DOOR
 * @see Material#JUNGLE_DOOR
 * @see Material#ACACIA_DOOR
 * @see Material#DARK_OAK_DOOR
 */
public static Material getWoodDoorOfSpecies(TreeSpecies species) {
    switch (species) {
        default:
        case GENERIC:
            return Material.WOODEN_DOOR;
        case BIRCH:
            return Material.BIRCH_DOOR;
        case REDWOOD:
            return Material.SPRUCE_DOOR;
        case JUNGLE:
            return Material.JUNGLE_DOOR;
        case ACACIA:
            return Material.ACACIA_DOOR;
        case DARK_OAK:
            return Material.DARK_OAK_DOOR;
    }
}
 
源代码3 项目: Kettle   文件: Wood.java
/**
 * Gets the current species of this wood block
 *
 * @return TreeSpecies of this wood block
 */
public TreeSpecies getSpecies() {
    switch (getItemType()) {
        case WOOD:
        case WOOD_DOUBLE_STEP:
            return TreeSpecies.getByData((byte) getData());
        case LOG:
        case LEAVES:
            return TreeSpecies.getByData((byte) (getData() & 0x3));
        case LOG_2:
        case LEAVES_2:
            return TreeSpecies.getByData((byte) ((getData() & 0x3) | 0x4));
        case SAPLING:
        case WOOD_STEP:
            return TreeSpecies.getByData((byte) (getData() & 0x7));
        default:
            throw new IllegalArgumentException("Invalid block type for tree species");
    }
}
 
源代码4 项目: Kettle   文件: CraftBoat.java
public static TreeSpecies getTreeSpecies(EntityBoat.Type boatType) {
    switch (boatType) {
        case SPRUCE:
            return TreeSpecies.REDWOOD;
        case BIRCH:
            return TreeSpecies.BIRCH;
        case JUNGLE:
            return TreeSpecies.JUNGLE;
        case ACACIA:
            return TreeSpecies.ACACIA;
        case DARK_OAK:
            return TreeSpecies.DARK_OAK;
        case OAK:
        default:
            return TreeSpecies.GENERIC;
    }
}
 
源代码5 项目: Kettle   文件: CraftBoat.java
public static EntityBoat.Type getBoatType(TreeSpecies species) {
    switch (species) {
        case REDWOOD:
            return EntityBoat.Type.SPRUCE;
        case BIRCH:
            return EntityBoat.Type.BIRCH;
        case JUNGLE:
            return EntityBoat.Type.JUNGLE;
        case ACACIA:
            return EntityBoat.Type.ACACIA;
        case DARK_OAK:
            return EntityBoat.Type.DARK_OAK;
        case GENERIC:
        default:
            return EntityBoat.Type.OAK;
    }
}
 
源代码6 项目: Skript   文件: BoatData.java
public boolean isOfItemType(ItemType i){
	if (i.getRandom() == null)
		return false;
	int ordinal = -1;
	
	ItemStack stack = i.getRandom();
	if (oakBoat.isOfType(stack))
		ordinal = 0;
	else if (spruceBoat.isOfType(stack))
		ordinal = TreeSpecies.REDWOOD.ordinal();
	else if (birchBoat.isOfType(stack))
		ordinal = TreeSpecies.BIRCH.ordinal();
	else if (jungleBoat.isOfType(stack))
		ordinal = TreeSpecies.JUNGLE.ordinal();
	else if (acaciaBoat.isOfType(stack))
		ordinal = TreeSpecies.ACACIA.ordinal();
	else if (darkOakBoat.isOfType(stack))
		ordinal = TreeSpecies.DARK_OAK.ordinal();
	return hashCode_i() == ordinal + 2 || (matchedPattern + ordinal == 0) || ordinal == 0;
	
}
 
源代码7 项目: IridiumSkyblock   文件: XBlock.java
public static boolean setWooden(Block block, XMaterial species) {
    block.setType(species.parseMaterial());
    if (XMaterial.ISFLAT) return true;

    TreeSpecies type = species == XMaterial.SPRUCE_LOG ? TreeSpecies.REDWOOD :
            TreeSpecies.valueOf(species.name().substring(0, species.name().indexOf('_')));

    BlockState state = block.getState();
    MaterialData data = state.getData();
    ((Wood) data).setSpecies(type);
    state.update(true);
    return true;
}
 
源代码8 项目: XSeries   文件: XBlock.java
public static boolean setWooden(Block block, XMaterial species) {
    block.setType(species.parseMaterial());
    if (ISFLAT) return true;

    TreeSpecies type = species == XMaterial.SPRUCE_LOG ? TreeSpecies.REDWOOD :
            TreeSpecies.valueOf(species.name().substring(0, species.name().indexOf('_')));

    BlockState state = block.getState();
    MaterialData data = state.getData();
    ((Wood) data).setSpecies(type);
    state.update(true);
    return true;
}
 
源代码9 项目: Kettle   文件: Wood.java
/**
 * Correct the block type for certain species-type combinations.
 *
 * @param type    The desired type
 * @param species The required species
 * @return The actual type for this species given the desired type
 */
private static Material getSpeciesType(Material type, TreeSpecies species) {
    switch (species) {
        case GENERIC:
        case REDWOOD:
        case BIRCH:
        case JUNGLE:
            switch (type) {
                case LOG_2:
                    return Material.LOG;
                case LEAVES_2:
                    return Material.LEAVES;
                default:
            }
            break;
        case ACACIA:
        case DARK_OAK:
            switch (type) {
                case LOG:
                    return Material.LOG_2;
                case LEAVES:
                    return Material.LEAVES_2;
                default:
            }
            break;
    }
    return type;
}
 
源代码10 项目: Kettle   文件: Wood.java
/**
 * Sets the species of this wood block
 *
 * @param species New species of this wood block
 */
public void setSpecies(final TreeSpecies species) {
    boolean firstType = false;
    switch (getItemType()) {
        case WOOD:
        case WOOD_DOUBLE_STEP:
            setData(species.getData());
            break;
        case LOG:
        case LEAVES:
            firstType = true;
            // fall through to next switch statement below
        case LOG_2:
        case LEAVES_2:
            switch (species) {
                case GENERIC:
                case REDWOOD:
                case BIRCH:
                case JUNGLE:
                    if (!firstType) {
                        throw new IllegalArgumentException("Invalid tree species for block type, use block type 2 instead");
                    }
                    break;
                case ACACIA:
                case DARK_OAK:
                    if (firstType) {
                        throw new IllegalArgumentException("Invalid tree species for block type 2, use block type instead");
                    }
                    break;
            }
            setData((byte) ((getData() & 0xC) | (species.getData() & 0x3)));
            break;
        case SAPLING:
        case WOOD_STEP:
            setData((byte) ((getData() & 0x8) | species.getData()));
            break;
        default:
            throw new IllegalArgumentException("Invalid block type for tree species");
    }
}
 
源代码11 项目: Kettle   文件: FlowerPot.java
/**
 * Get the material in the flower pot
 *
 * @return material MaterialData for the block currently in the flower pot
 * or null if empty
 */
public MaterialData getContents() {
    switch (getData()) {
        case 1:
            return new MaterialData(Material.RED_ROSE);
        case 2:
            return new MaterialData(Material.YELLOW_FLOWER);
        case 3:
            return new Tree(TreeSpecies.GENERIC);
        case 4:
            return new Tree(TreeSpecies.REDWOOD);
        case 5:
            return new Tree(TreeSpecies.BIRCH);
        case 6:
            return new Tree(TreeSpecies.JUNGLE);
        case 7:
            return new MaterialData(Material.RED_MUSHROOM);
        case 8:
            return new MaterialData(Material.BROWN_MUSHROOM);
        case 9:
            return new MaterialData(Material.CACTUS);
        case 10:
            return new MaterialData(Material.DEAD_BUSH);
        case 11:
            return new LongGrass(GrassSpecies.FERN_LIKE);
        default:
            return null;
    }
}
 
源代码12 项目: Skript   文件: BoatData.java
@Override
public void set(Boat entity) {
	if (matchedPattern == 1) // If the type is 'any boat'.
		matchedPattern += new Random().nextInt(TreeSpecies.values().length); // It will spawn a random boat type in case is 'any boat'.
	if (matchedPattern > 1) // 0 and 1 are excluded
		entity.setWoodType(TreeSpecies.values()[matchedPattern - 2]); // Removes 2 to fix the index.
}
 
源代码13 项目: Kettle   文件: CraftBoat.java
@Override
public TreeSpecies getWoodType() {
    return getTreeSpecies(getHandle().getBoatType());
}
 
源代码14 项目: Kettle   文件: CraftBoat.java
@Override
public void setWoodType(TreeSpecies species) {
    getHandle().setBoatType(getBoatType(species));
}
 
源代码15 项目: Skript   文件: BoatData.java
public BoatData(@Nullable TreeSpecies type){
	this(type != null ? type.ordinal() + 2 : 1);
}
 
源代码16 项目: Kettle   文件: Boat.java
/**
 * Gets the wood type of the boat.
 *
 * @return the wood type
 */
TreeSpecies getWoodType();
 
源代码17 项目: Kettle   文件: Boat.java
/**
 * Sets the wood type of the boat.
 *
 * @param species the new wood type
 */
void setWoodType(TreeSpecies species);
 
源代码18 项目: Kettle   文件: Leaves.java
/**
 * Constructs a leaf block of the given tree species.
 *
 * @param species the species of the wood block
 */
public Leaves(TreeSpecies species) {
    this(DEFAULT_TYPE, species, DEFAULT_DECAYABLE);
}
 
源代码19 项目: Kettle   文件: Leaves.java
/**
 * Constructs a leaf block of the given tree species and flag for whether
 * this leaf block will disappear when too far from a log.
 *
 * @param species     the species of the wood block
 * @param isDecayable whether the block is permanent or can disappear
 */
public Leaves(TreeSpecies species, boolean isDecayable) {
    this(DEFAULT_TYPE, species, isDecayable);
}
 
源代码20 项目: Kettle   文件: Leaves.java
/**
 * Constructs a leaf block of the given type and tree species.
 *
 * @param type    the type of leaf block
 * @param species the species of the wood block
 */
public Leaves(final Material type, TreeSpecies species) {
    this(type, species, DEFAULT_DECAYABLE);
}
 
源代码21 项目: Kettle   文件: Leaves.java
/**
 * Constructs a leaf block of the given type and tree species and flag for
 * whether this leaf block will disappear when too far from a log.
 *
 * @param type        the type of leaf block
 * @param species     the species of the wood block
 * @param isDecayable whether the block is permanent or can disappear
 */
public Leaves(final Material type, TreeSpecies species, boolean isDecayable) {
    super(type, species);
    setDecayable(isDecayable);
}
 
源代码22 项目: Kettle   文件: Sapling.java
/**
 * Constructs a sapling of the given tree species.
 *
 * @param species the species of the sapling
 */
public Sapling(TreeSpecies species) {
    this(species, false);
}
 
源代码23 项目: Kettle   文件: Sapling.java
/**
 * Constructs a sapling of the given tree species and if is it instant
 * growable
 *
 * @param species           the species of the tree block
 * @param isInstantGrowable true if the Sapling should grow when next ticked with bonemeal
 */
public Sapling(TreeSpecies species, boolean isInstantGrowable) {
    this(Material.SAPLING, species, isInstantGrowable);
}
 
源代码24 项目: Kettle   文件: Sapling.java
/**
 * Constructs a sapling of the given type and tree species.
 *
 * @param type    the type of sapling
 * @param species the species of the sapling
 */
public Sapling(final Material type, TreeSpecies species) {
    this(type, species, false);
}
 
源代码25 项目: Kettle   文件: Sapling.java
/**
 * Constructs a sapling of the given type and tree species and if is it
 * instant growable
 *
 * @param type              the type of sapling
 * @param species           the species of the sapling
 * @param isInstantGrowable true if the Sapling should grow when next ticked
 *                          with bonemeal
 */
public Sapling(final Material type, TreeSpecies species, boolean isInstantGrowable) {
    super(type, species);
    setIsInstantGrowable(isInstantGrowable);
}
 
源代码26 项目: Kettle   文件: Door.java
/**
 * Constructs the bottom half of a wooden door of the given species, facing the specified direction and set to
 * closed
 *
 * @param species The species this wooden door is made of. This must match the species of the block above.
 * @param face    The direction the door is facing.
 * @see TreeSpecies
 * @see BlockFace#WEST
 * @see BlockFace#NORTH
 * @see BlockFace#EAST
 * @see BlockFace#SOUTH
 */
public Door(final TreeSpecies species, BlockFace face) {
    this(getWoodDoorOfSpecies(species), face, false);
}
 
源代码27 项目: Kettle   文件: Door.java
/**
 * Constructs the bottom half of a wooden door of the given species, facing the specified direction and set to open
 * or closed
 *
 * @param species The species this wooden door is made of. This must match the species of the block above.
 * @param face    The direction the door is facing.
 * @param isOpen  Whether the door is currently opened.
 * @see TreeSpecies
 * @see BlockFace#WEST
 * @see BlockFace#NORTH
 * @see BlockFace#EAST
 * @see BlockFace#SOUTH
 */
public Door(final TreeSpecies species, BlockFace face, boolean isOpen) {
    this(getWoodDoorOfSpecies(species), face, isOpen);
}
 
源代码28 项目: Kettle   文件: Door.java
/**
 * Constructs the top half of a wooden door of the given species and with the hinge on the left or right
 *
 * @param species      The species this wooden door is made of. This must match the species of the block below.
 * @param isHingeRight True if the hinge is on the right hand side, false if the hinge is on the left hand side.
 * @see TreeSpecies
 */
public Door(final TreeSpecies species, boolean isHingeRight) {
    this(getWoodDoorOfSpecies(species), isHingeRight);
}
 
源代码29 项目: Kettle   文件: Tree.java
/**
 * Constructs a tree block of the given tree species.
 *
 * @param species the species of the tree block
 */
public Tree(TreeSpecies species) {
    this(DEFAULT_TYPE, species, DEFAULT_DIRECTION);
}
 
源代码30 项目: Kettle   文件: Tree.java
/**
 * Constructs a tree block of the given tree species, and facing the given
 * direction.
 *
 * @param species the species of the tree block
 * @param dir     the direction the tree block is facing
 */
public Tree(TreeSpecies species, BlockFace dir) {
    this(DEFAULT_TYPE, species, dir);
}
 
 类所在包
 类方法
 同包方法