use of org.bukkit.block.data.Directional in project EliteMobs by MagmaGuy.
the class TreasureChest method generateChest.
private void generateChest() {
try {
if (!location.getWorld().getBlockAt(location).getType().equals(customTreasureChestConfigFields.getChestMaterial()))
location.getWorld().getBlockAt(location).setType(customTreasureChestConfigFields.getChestMaterial());
} catch (Exception ex) {
new WarningMessage("Custom Treasure Chest " + customTreasureChestConfigFields.getFilename() + " has an invalid location and can not be placed.");
return;
}
if (location.getBlock().getBlockData() instanceof Directional) {
Directional chest = (Directional) location.getBlock().getBlockData();
chest.setFacing(customTreasureChestConfigFields.getFacing());
location.getBlock().setBlockData(chest);
} else {
new WarningMessage("Treasure chest " + customTreasureChestConfigFields.getFilename() + " does not have a directional block for the Treasure Chest material " + customTreasureChestConfigFields.getChestMaterial() + " ! Chest materials are directional, is your chest a chest?");
}
location.getBlock().getState().update();
}
use of org.bukkit.block.data.Directional 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);
}
Aggregations