Search in sources :

Example 1 with GlowBed

use of net.glowstone.block.entity.state.GlowBed in project Glowstone by GlowstoneMC.

the class BlockBed method afterPlace.

@Override
public void afterPlace(GlowPlayer player, GlowBlock block, ItemStack holding, GlowBlockState oldState) {
    Material type = block.getType();
    if (!MaterialTags.BEDS.isTagged(type)) {
        return;
    }
    GlowBed bed = (GlowBed) block.getState();
    bed.setColor(DyeColor.getByWoolData(holding.getData().getData()));
    bed.update(true);
    BlockFace direction = ((Bed) bed.getData()).getFacing();
    GlowBlock headBlock = block.getRelative(direction);
    headBlock.setType(type);
    GlowBed headBlockState = (GlowBed) headBlock.getState();
    headBlockState.setColor(DyeColor.getByWoolData(holding.getData().getData()));
    MaterialData data = headBlockState.getData();
    ((Bed) data).setHeadOfBed(true);
    ((Bed) data).setFacingDirection(direction);
    headBlockState.setData(data);
    headBlockState.update(true);
}
Also used : Bed(org.bukkit.material.Bed) GlowBed(net.glowstone.block.entity.state.GlowBed) GlowBlock(net.glowstone.block.GlowBlock) BlockFace(org.bukkit.block.BlockFace) Material(org.bukkit.Material) MaterialData(org.bukkit.material.MaterialData) GlowBed(net.glowstone.block.entity.state.GlowBed)

Aggregations

GlowBlock (net.glowstone.block.GlowBlock)1 GlowBed (net.glowstone.block.entity.state.GlowBed)1 Material (org.bukkit.Material)1 BlockFace (org.bukkit.block.BlockFace)1 Bed (org.bukkit.material.Bed)1 MaterialData (org.bukkit.material.MaterialData)1