All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.nukkit.block.BlockLeaves2 Maven / Gradle / Ivy

There is a newer version: 1.20.40-r1
Show newest version
package cn.nukkit.block;

import cn.nukkit.api.DeprecationDetails;
import cn.nukkit.api.PowerNukkitOnly;
import cn.nukkit.api.Since;
import cn.nukkit.blockproperty.ArrayBlockProperty;
import cn.nukkit.blockproperty.BlockProperties;
import cn.nukkit.blockproperty.value.WoodType;
import cn.nukkit.item.Item;

import javax.annotation.Nonnull;

/**
 * @author xtypr
 * @since 2015/12/1
 */
public class BlockLeaves2 extends BlockLeaves {
    @PowerNukkitOnly
    @Since("1.4.0.0-PN")
    public static final ArrayBlockProperty NEW_LEAF_TYPE = new ArrayBlockProperty<>("new_leaf_type", true, new WoodType[]{
            WoodType.ACACIA, WoodType.DARK_OAK
    }, 2);

    @PowerNukkitOnly @Since("1.4.0.0-PN")
    public static final BlockProperties NEW_LEAF_PROPERTIES = new BlockProperties(NEW_LEAF_TYPE, PERSISTENT, UPDATE);

    @Deprecated @DeprecationDetails(since = "1.4.0.0-PN", reason = "Magic value. Use the accessors instead")
    public static final int ACACIA = 0;

    @Deprecated @DeprecationDetails(since = "1.4.0.0-PN", reason = "Magic value. Use the accessors instead")
    public static final int DARK_OAK = 1;

    public BlockLeaves2() {
        this(0);
    }

    public BlockLeaves2(int meta) {
        super(meta);
    }

    @Since("1.4.0.0-PN")
    @PowerNukkitOnly
    @Nonnull
    @Override
    public BlockProperties getProperties() {
        return NEW_LEAF_PROPERTIES;
    }

    @PowerNukkitOnly
    @Override
    public WoodType getType() {
        return getPropertyValue(NEW_LEAF_TYPE);
    }

    @PowerNukkitOnly
    @Override
    public void setType(WoodType type) {
        setPropertyValue(NEW_LEAF_TYPE, type);
    }

    @Override
    public int getId() {
        return LEAVES2;
    }

    @Override
    protected boolean canDropApple() {
        return getType() == WoodType.DARK_OAK;
    }

    @Override
    protected Item getSapling() {
        return Item.get(BlockID.SAPLING, getIntValue(NEW_LEAF_TYPE) + 4);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy