use of org.bukkit.material.MaterialData in project Glowstone by GlowstoneMC.
the class BlockRedstoneRepeater method placeBlock.
@Override
public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
super.placeBlock(player, state, face, holding, clickedLoc);
MaterialData data = state.getData();
if (data instanceof Diode) {
((Diode) data).setFacingDirection(player.getDirection());
state.setData(data);
} else {
warnMaterialData(Diode.class, data);
}
state.getWorld().requestPulse(state.getBlock());
}
use of org.bukkit.material.MaterialData in project Glowstone by GlowstoneMC.
the class BlockRedstoneTorch method placeBlock.
@Override
public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
super.placeBlock(player, state, face, holding, clickedLoc);
MaterialData data = state.getData();
if (data instanceof RedstoneTorch) {
((RedstoneTorch) data).setFacingDirection(face);
} else {
warnMaterialData(RedstoneTorch.class, data);
}
}
use of org.bukkit.material.MaterialData in project Glowstone by GlowstoneMC.
the class BlockSapling method updateBlock.
@Override
public void updateBlock(GlowBlock block) {
if (block.getRelative(BlockFace.UP).getLightLevel() >= 9 && random.nextInt(7) == 0) {
int dataValue = block.getData();
if ((dataValue & 8) == 0) {
block.setData((byte) (dataValue | 8));
} else {
MaterialData data = block.getState().getData();
if (data instanceof Sapling) {
Sapling sapling = (Sapling) data;
TreeType type = getTreeType(sapling.getSpecies());
block.setType(Material.AIR);
int saplingData = block.getData() & 0x7;
if (!block.getWorld().generateTree(block.getLocation(), type)) {
block.setType(Material.SAPLING);
block.setData((byte) saplingData);
}
} else {
warnMaterialData(Sapling.class, data);
}
}
}
}
use of org.bukkit.material.MaterialData in project BKCommonLib by bergerhealer.
the class BlockData method newMaterialData.
/**
* Creates a new MaterialData instance appropriate for this Block
*
* @return Block Material Data
*/
@SuppressWarnings("deprecation")
public final MaterialData newMaterialData() {
Material type = this.getType();
// Null: return AIR
if (type == null) {
return new MaterialData(0, (byte) 0);
}
// Create new MaterialData + some fixes.
final MaterialData mdata;
if (type == Material.GOLD_PLATE || type == Material.IRON_PLATE) {
// Bukkit bugfix.
mdata = new org.bukkit.material.PressurePlate(type, (byte) this.getRawData());
} else {
mdata = type.getNewData((byte) this.getRawData());
}
// Fix attachable face returning NULL sometimes
if (mdata instanceof Attachable) {
Attachable att = (Attachable) mdata;
if (att.getAttachedFace() == null) {
att.setFacingDirection(BlockFace.NORTH);
}
}
return mdata;
}
use of org.bukkit.material.MaterialData in project BKCommonLib by bergerhealer.
the class BlockUtil method setFacing.
/**
* Sets the facing direction of a Directional block
*
* @param block to set
* @param facing direction to set to
*/
public static void setFacing(org.bukkit.block.Block block, BlockFace facing) {
MaterialData data = getData(block);
if (data != null && data instanceof Directional) {
((Directional) data).setFacingDirection(facing);
setData(block, data, true);
}
}
Aggregations