Search in sources :

Example 6 with BlockData

use of org.bukkit.block.data.BlockData in project Minigames by AddstarMC.

the class MenuItemBlockData method checkValidEntry.

@Override
public void checkValidEntry(String entry) {
    String err = "No MgBlockData detected";
    try {
        BlockData d = Bukkit.createBlockData(entry);
        if (d != null) {
            data.setValue(d);
            setDescription(createDescription(data.getValue()));
            getContainer().cancelReopenTimer();
            getContainer().displayMenu(getContainer().getViewer());
            return;
        }
    } catch (IllegalArgumentException e) {
        err = "Invalid MgBlockData !";
    }
    getContainer().cancelReopenTimer();
    getContainer().displayMenu(getContainer().getViewer());
    getContainer().getViewer().sendMessage(err, MinigameMessageType.ERROR);
}
Also used : BlockData(org.bukkit.block.data.BlockData)

Example 7 with BlockData

use of org.bukkit.block.data.BlockData in project Glowstone by GlowstoneMC.

the class BlockRedstone method canPlaceAt.

@Override
public boolean canPlaceAt(GlowPlayer player, GlowBlock block, BlockFace against) {
    if (block.getRelative(BlockFace.DOWN).getType().isSolid()) {
        return true;
    }
    GlowBlock target = block.getRelative(BlockFace.DOWN);
    BlockData data = target.getState().getBlockData();
    return data instanceof Stairs && ((Stairs) data).getHalf() == Bisected.Half.TOP || data instanceof Slab && ((Slab) data).getType() == Slab.Type.TOP;
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) Stairs(org.bukkit.block.data.type.Stairs) BlockData(org.bukkit.block.data.BlockData) Slab(org.bukkit.block.data.type.Slab)

Example 8 with BlockData

use of org.bukkit.block.data.BlockData in project Glowstone by GlowstoneMC.

the class BlockFalling method transformToFallingEntity.

protected void transformToFallingEntity(GlowBlock me) {
    // Force block to update otherwise it can sometimes duplicate
    me = me.getWorld().getBlockAt(me.getX(), me.getY(), me.getZ());
    if (!me.isEmpty()) {
        BlockData data = me.getBlockData();
        me.setType(Material.AIR);
        me.getWorld().spawnFallingBlock(me.getLocation().add(0.50, 0.00, 0.50), data);
    }
}
Also used : BlockData(org.bukkit.block.data.BlockData)

Example 9 with BlockData

use of org.bukkit.block.data.BlockData in project Glowstone by GlowstoneMC.

the class TerrainObject method killPlantAbove.

/**
 * Removes the grass, shrub, flower or mushroom directly above the given block, if present. Does
 * not drop an item.
 *
 * @param block the block to update
 * @return true if a plant was removed; false if none was present
 */
static boolean killPlantAbove(Block block) {
    Block blockAbove = block.getRelative(BlockFace.UP);
    BlockData blockAboveData = blockAbove.getBlockData();
    Material mat = blockAboveData.getMaterial();
    if (PLANT_TYPES.contains(mat)) {
        if (blockAboveData instanceof Bisected && ((Bisected) blockAboveData).getHalf() == Bisected.Half.BOTTOM) {
            // Large plant
            Block plantTop = blockAbove.getRelative(BlockFace.UP);
            BlockData plantTopData = plantTop.getBlockData();
            if (plantTopData.getMaterial() == mat && ((Bisected) plantTopData).getHalf() == Bisected.Half.TOP) {
                plantTop.setType(Material.AIR);
            }
        }
        blockAbove.setType(Material.AIR);
        return true;
    }
    return false;
}
Also used : Block(org.bukkit.block.Block) Material(org.bukkit.Material) BlockData(org.bukkit.block.data.BlockData) Bisected(org.bukkit.block.data.Bisected)

Example 10 with BlockData

use of org.bukkit.block.data.BlockData in project Denizen-For-Bukkit by DenizenScript.

the class MaterialMode method describes.

public static boolean describes(ObjectTag material) {
    if (!(material instanceof MaterialTag)) {
        return false;
    }
    MaterialTag mat = (MaterialTag) material;
    if (!mat.hasModernData()) {
        return false;
    }
    BlockData data = mat.getModernData();
    return data instanceof Comparator || data instanceof PistonHead || data instanceof BubbleColumn || data instanceof StructureBlock || data instanceof DaylightDetector || data instanceof CommandBlock || (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) && (data instanceof SculkSensor || data instanceof BigDripleaf));
}
Also used : MaterialTag(com.denizenscript.denizen.objects.MaterialTag) BlockData(org.bukkit.block.data.BlockData)

Aggregations

BlockData (org.bukkit.block.data.BlockData)34 Block (org.bukkit.block.Block)10 MaterialTag (com.denizenscript.denizen.objects.MaterialTag)8 Location (org.bukkit.Location)7 MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)3 ArrayList (java.util.ArrayList)3 Material (org.bukkit.Material)3 BlockState (org.bukkit.block.BlockState)3 Lightable (org.bukkit.block.data.Lightable)3 ItemStack (org.bukkit.inventory.ItemStack)3 LocationTag (com.denizenscript.denizen.objects.LocationTag)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 MaterialState (me.botsko.prism.api.objects.MaterialState)2 BlockStateChangeImpl (me.botsko.prism.events.BlockStateChangeImpl)2 Bisected (org.bukkit.block.data.Bisected)2 Bed (org.bukkit.block.data.type.Bed)2 Player (org.bukkit.entity.Player)2