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);
}
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;
}
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);
}
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));
}
}
Aggregations