Search in sources :

Example 6 with Directional

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();
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) Directional(org.bukkit.block.data.Directional)

Example 7 with Directional

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);
}
Also used : BlockData(org.bukkit.block.data.BlockData) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location) Directional(org.bukkit.block.data.Directional)

Aggregations

Directional (org.bukkit.block.data.Directional)7 Vector (org.bukkit.util.Vector)2 BukkitScriptEvent (com.denizenscript.denizen.events.BukkitScriptEvent)1 NMSHandler (com.denizenscript.denizen.nms.NMSHandler)1 BiomeNMS (com.denizenscript.denizen.nms.abstracts.BiomeNMS)1 EntityHelper (com.denizenscript.denizen.nms.interfaces.EntityHelper)1 PlayerProfile (com.denizenscript.denizen.nms.util.PlayerProfile)1 MaterialDirectional (com.denizenscript.denizen.objects.properties.material.MaterialDirectional)1 MaterialHalf (com.denizenscript.denizen.objects.properties.material.MaterialHalf)1 MaterialPersistent (com.denizenscript.denizen.objects.properties.material.MaterialPersistent)1 MaterialSwitchFace (com.denizenscript.denizen.objects.properties.material.MaterialSwitchFace)1 SwitchCommand (com.denizenscript.denizen.scripts.commands.world.SwitchCommand)1 BukkitTagContext (com.denizenscript.denizen.tags.BukkitTagContext)1 AdvancedTextImpl (com.denizenscript.denizen.utilities.AdvancedTextImpl)1 Settings (com.denizenscript.denizen.utilities.Settings)1 Utilities (com.denizenscript.denizen.utilities.Utilities)1 SpawnableHelper (com.denizenscript.denizen.utilities.blocks.SpawnableHelper)1 Debug (com.denizenscript.denizen.utilities.debugging.Debug)1 DenizenEntityType (com.denizenscript.denizen.utilities.entity.DenizenEntityType)1 DataPersistenceFlagTracker (com.denizenscript.denizen.utilities.flags.DataPersistenceFlagTracker)1