use of net.glowstone.block.data.BlockDataManager in project Glowstone by GlowstoneMC.
the class StructureBuilder method setBlock.
/**
* Sets the block at a given point, if it is inside this builder's bounding box.
*
* @param pos a point relative to this structure's root point
* @param type the new block type
* @param data the new block data
*/
public void setBlock(Vector pos, Material type, int data) {
Vector vec = translate(pos);
BlockDataManager blockDataManager = ((GlowServer) Bukkit.getServer()).getBlockDataManager();
if (boundingBox.isVectorInside(vec)) {
delegate.setTypeAndData(world, vec.getBlockX(), vec.getBlockY(), vec.getBlockZ(), type, blockDataManager.createBlockData(type));
}
}
use of net.glowstone.block.data.BlockDataManager in project Glowstone by GlowstoneMC.
the class StructureBuilder method setBlockDownward.
/**
* Builds a 1x1 column out of the given block, replacing non-solid blocks starting at a given
* location and proceeding downward until a solid block is reached.
*
* @param pos the highest point to possibly replace, relative to this structure's root
* point
* @param type the block type to fill
* @param data the block data
*/
public void setBlockDownward(Vector pos, Material type, int data) {
Vector vec = translate(pos);
BlockDataManager blockDataManager = ((GlowServer) Bukkit.getServer()).getBlockDataManager();
if (boundingBox.isVectorInside(vec)) {
int y = vec.getBlockY();
while (!world.getBlockAt(vec.getBlockX(), y, vec.getBlockZ()).getType().isSolid() && y > 1) {
// TODO: 1.13 use actual data
delegate.setTypeAndData(world, vec.getBlockX(), y, vec.getBlockZ(), type, blockDataManager.createBlockData(type));
y--;
}
}
}
use of net.glowstone.block.data.BlockDataManager in project Glowstone by GlowstoneMC.
the class StructureBuilder method setBlock.
/**
* Sets the block at a given point, if it is inside this structure's bounding box.
*
* @param pos a point relative to this structure's root point
* @param type the new block type
* @param data the new block data
*/
public void setBlock(Vector pos, Material type, MaterialData data) {
Vector vec = translate(pos);
BlockDataManager blockDataManager = ((GlowServer) Bukkit.getServer()).getBlockDataManager();
if (boundingBox.isVectorInside(vec)) {
// TODO: 1.13 use actual data
delegate.setTypeAndData(world, vec.getBlockX(), vec.getBlockY(), vec.getBlockZ(), type, blockDataManager.createBlockData(type));
}
}
use of net.glowstone.block.data.BlockDataManager in project Glowstone by GlowstoneMC.
the class BlockRedstone method receivePulse.
@Override
public void receivePulse(GlowBlock me) {
GlowChunk.Key key = GlowChunk.Key.of(me.getX() >> 4, me.getZ() >> 4);
BlockDataManager blockDataManager = ((GlowServer) Bukkit.getServer()).getBlockDataManager();
BlockChangeMessage bcmsg = new BlockChangeMessage(me.getX(), me.getY(), me.getZ(), blockDataManager.convertToBlockId(blockDataManager.createBlockData(me.getType())), me.getData());
me.getWorld().broadcastBlockChangeInRange(key, bcmsg);
}
use of net.glowstone.block.data.BlockDataManager in project Glowstone by GlowstoneMC.
the class GlowBlock method setData.
public void setData(byte data, boolean applyPhysics) {
byte oldData = getData();
((GlowChunk) world.getChunkAt(this)).setMetaData(x & 0xf, z & 0xf, y, data);
if (applyPhysics) {
applyPhysics(getType(), getType(), oldData, data);
}
GlowChunk.Key key = GlowChunk.Key.of(x >> 4, z >> 4);
BlockDataManager blockDataManager = ((GlowServer) Bukkit.getServer()).getBlockDataManager();
StatefulBlockData blockData = blockDataManager.createBlockData(getType());
BlockChangeMessage bcmsg = new BlockChangeMessage(x, y, z, blockDataManager.convertToBlockId(blockData), data);
world.broadcastBlockChangeInRange(key, bcmsg);
}
Aggregations