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);
}
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;
}
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);
}
}
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;
}
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));
}
Aggregations