Search in sources :

Example 31 with BlockData

use of org.bukkit.block.data.BlockData in project EliteMobs by MagmaGuy.

the class TransitiveBossBlock method setBlockData.

private static void setBlockData(CustomBossEntity customBossEntity, TransitiveBlock transitiveBlock, Location spawnLocation) {
    Location location;
    double rotation = 0;
    if (customBossEntity.getMinidungeon() != null)
        rotation = customBossEntity.getMinidungeon().getDungeonPackagerConfigFields().getRotation();
    BlockData blockData = transitiveBlock.getBlockData().clone();
    if (rotation == 0)
        location = new Location(spawnLocation.getWorld(), spawnLocation.getX() + transitiveBlock.getRelativeLocation().getX(), spawnLocation.getY() + transitiveBlock.getRelativeLocation().getY(), spawnLocation.getZ() + transitiveBlock.getRelativeLocation().getZ());
    else {
        location = customBossEntity.getMinidungeon().getRotatedFinalLocation(spawnLocation.getBlock().getLocation().clone().add(new Vector(0.5, 0.5, 0.5)), transitiveBlock.getRelativeLocation().clone().add(new Vector(0.5, 0.5, 0.5)));
        if (blockData instanceof Directional)
            ((Directional) blockData).setFacing(rotateBlockFace(((Directional) blockData).getFacing(), rotation));
    }
    location.getBlock().setBlockData(blockData);
}
Also used : BlockData(org.bukkit.block.data.BlockData) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location) Directional(org.bukkit.block.data.Directional)

Example 32 with BlockData

use of org.bukkit.block.data.BlockData in project Glowstone by GlowstoneMC.

the class BlockRedstoneOre method blockInteract.

@Override
public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face, Vector clickedLoc) {
    BlockData blockData = Bukkit.getServer().createBlockData(Material.REDSTONE_ORE);
    ((Lightable) blockData).setLit(true);
    EntityChangeBlockEvent changeBlockEvent = new EntityChangeBlockEvent(player, block, blockData);
    EventFactory.getInstance().callEvent(changeBlockEvent);
    if (!changeBlockEvent.isCancelled()) {
        GlowBlockState state = block.getState();
        state.setType(Material.REDSTONE_ORE);
        state.update(true);
    }
    return false;
}
Also used : Lightable(org.bukkit.block.data.Lightable) GlowBlockState(net.glowstone.block.GlowBlockState) BlockData(org.bukkit.block.data.BlockData) EntityChangeBlockEvent(org.bukkit.event.entity.EntityChangeBlockEvent)

Example 33 with BlockData

use of org.bukkit.block.data.BlockData in project Glowstone by GlowstoneMC.

the class FallingBlockStore method load.

@Override
public void load(GlowFallingBlock entity, CompoundTag tag) {
    super.load(entity, tag);
    BlockData data = NbtSerialization.readBlockData(tag.getCompound("BlockState"));
    entity.setBlockData(data);
    tag.readBoolean("HurtEntities", entity::setHurtEntities);
    tag.readBoolean("DropItem", entity::setDropItem);
    tag.readCompound("TileEntityData", entity::setBlockEntityCompoundTag);
}
Also used : BlockData(org.bukkit.block.data.BlockData)

Example 34 with BlockData

use of org.bukkit.block.data.BlockData in project Glowstone by GlowstoneMC.

the class EndermanStore method save.

@Override
public void save(GlowEnderman entity, CompoundTag tag) {
    super.save(entity, tag);
    BlockData carried = entity.getCarriedBlock();
    // Save the carried block, if there is one.
    if (carried != null && carried.getMaterial() != Material.AIR) {
        tag.putCompound("carriedBlockState", NbtSerialization.writeBlockData(carried));
    }
}
Also used : BlockData(org.bukkit.block.data.BlockData)

Aggregations

BlockData (org.bukkit.block.data.BlockData)34 Block (org.bukkit.block.Block)10 MaterialTag (com.denizenscript.denizen.objects.MaterialTag)8 Location (org.bukkit.Location)7 MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)3 ArrayList (java.util.ArrayList)3 Material (org.bukkit.Material)3 BlockState (org.bukkit.block.BlockState)3 Lightable (org.bukkit.block.data.Lightable)3 ItemStack (org.bukkit.inventory.ItemStack)3 LocationTag (com.denizenscript.denizen.objects.LocationTag)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 MaterialState (me.botsko.prism.api.objects.MaterialState)2 BlockStateChangeImpl (me.botsko.prism.events.BlockStateChangeImpl)2 Bisected (org.bukkit.block.data.Bisected)2 Bed (org.bukkit.block.data.type.Bed)2 Player (org.bukkit.entity.Player)2