Search in sources :

Example 1 with StatefulBlockData

use of net.glowstone.block.data.states.StatefulBlockData 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);
}
Also used : BlockChangeMessage(net.glowstone.net.message.play.game.BlockChangeMessage) GlowServer(net.glowstone.GlowServer) BlockDataManager(net.glowstone.block.data.BlockDataManager) GlowChunk(net.glowstone.chunk.GlowChunk) StatefulBlockData(net.glowstone.block.data.states.StatefulBlockData)

Aggregations

GlowServer (net.glowstone.GlowServer)1 BlockDataManager (net.glowstone.block.data.BlockDataManager)1 StatefulBlockData (net.glowstone.block.data.states.StatefulBlockData)1 GlowChunk (net.glowstone.chunk.GlowChunk)1 BlockChangeMessage (net.glowstone.net.message.play.game.BlockChangeMessage)1