Search in sources :

Example 86 with BlockFace

use of org.bukkit.block.BlockFace in project BKCommonLib by bergerhealer.

the class EntityMoveHandler_1_13 method onBlockCollided.

// Called from getBlockCollisions_method
public boolean onBlockCollided(Block block) {
    // Find out what direction the block is hit
    BlockFace hitFace;
    AxisAlignedBBHandle entityBounds = this.that.getBoundingBox();
    if (entityBounds.getMaxY() > (block.getY() + 1.0)) {
        hitFace = BlockFace.UP;
    } else if (entityBounds.getMinY() < (double) block.getY()) {
        hitFace = BlockFace.DOWN;
    } else {
        double dx = this.that.getLocX() - block.getX() - 0.5;
        double dz = this.that.getLocZ() - block.getZ() - 0.5;
        hitFace = FaceUtil.getDirection(dx, dz, false);
    }
    // Block collision event
    return controller.onBlockCollision(block, hitFace);
}
Also used : AxisAlignedBBHandle(com.bergerkiller.generated.net.minecraft.world.phys.AxisAlignedBBHandle) BlockFace(org.bukkit.block.BlockFace)

Example 87 with BlockFace

use of org.bukkit.block.BlockFace in project BKCommonLib by bergerhealer.

the class EntityMoveHandler_1_14 method onBlockCollided.

// Called from getBlockCollisions_method
public boolean onBlockCollided(Block block) {
    // Find out what direction the block is hit
    BlockFace hitFace;
    AxisAlignedBBHandle entityBounds = this.that.getBoundingBox();
    if (entityBounds.getMaxY() > (block.getY() + 1.0)) {
        hitFace = BlockFace.UP;
    } else if (entityBounds.getMinY() < (double) block.getY()) {
        hitFace = BlockFace.DOWN;
    } else {
        double dx = this.that.getLocX() - block.getX() - 0.5;
        double dz = this.that.getLocZ() - block.getZ() - 0.5;
        hitFace = FaceUtil.getDirection(dx, dz, false);
    }
    // Block collision event
    return controller.onBlockCollision(block, hitFace);
}
Also used : AxisAlignedBBHandle(com.bergerkiller.generated.net.minecraft.world.phys.AxisAlignedBBHandle) BlockFace(org.bukkit.block.BlockFace)

Example 88 with BlockFace

use of org.bukkit.block.BlockFace in project Bukkit by Bukkit.

the class Lever method setFacingDirection.

/**
 * Sets the direction this lever is pointing in
 */
public void setFacingDirection(BlockFace face) {
    byte data = (byte) (getData() & 0x8);
    BlockFace attach = getAttachedFace();
    if (attach == BlockFace.DOWN) {
        switch(face) {
            case SOUTH:
            case NORTH:
                data |= 0x5;
                break;
            case EAST:
            case WEST:
                data |= 0x6;
                break;
        }
    } else if (attach == BlockFace.UP) {
        switch(face) {
            case SOUTH:
            case NORTH:
                data |= 0x7;
                break;
            case EAST:
            case WEST:
                data |= 0x0;
                break;
        }
    } else {
        switch(face) {
            case EAST:
                data |= 0x1;
                break;
            case WEST:
                data |= 0x2;
                break;
            case SOUTH:
                data |= 0x3;
                break;
            case NORTH:
                data |= 0x4;
                break;
        }
    }
    setData(data);
}
Also used : BlockFace(org.bukkit.block.BlockFace)

Example 89 with BlockFace

use of org.bukkit.block.BlockFace in project HawkEye by oliverwoodings.

the class SignEntry method interpretSqlData.

@Override
public void interpretSqlData(String data) {
    if (data.indexOf("@") == -1)
        return;
    String[] arr = data.split("@");
    // Parse wall sign or not
    if (arr[0].equals("true"))
        wallSign = true;
    else
        wallSign = false;
    // Parse sign direction
    for (BlockFace face : BlockFace.values()) if (face.toString().equalsIgnoreCase(arr[1]))
        facing = face;
    // Parse lines
    if (arr.length != 3)
        return;
    BASE64Decoder decoder = new BASE64Decoder();
    List<String> decoded = new ArrayList<String>();
    String[] encLines = arr[2].split(",");
    for (int i = 0; i < encLines.length; i++) {
        try {
            decoded.add(new String(decoder.decodeBuffer(encLines[i])));
        } catch (IOException e) {
            Util.severe("Unable to decode sign data from database");
        }
    }
    lines = decoded.toArray(new String[0]);
}
Also used : BlockFace(org.bukkit.block.BlockFace) ArrayList(java.util.ArrayList) IOException(java.io.IOException) BASE64Decoder(sun.misc.BASE64Decoder)

Example 90 with BlockFace

use of org.bukkit.block.BlockFace in project WildernessTp by AcmeProject.

the class TeleportGoneWild method goWild.

private void goWild(Location loc) {
    PaperLib.getChunkAtAsync(loc, true).thenAccept(chunk -> {
        if (!TooCool2Teleport.microwave(who)) {
            WildTP.debug("unmicrowaved leftovers.");
            return;
        }
        WildTP.debug("Teleporting " + who.getName() + loc);
        if (WildWarrantTax.bonelessIceScream(loc)) {
            if (wc.whoYaGonaCall) {
                WildTP.debug("Here come the §cfiremen§r!");
                Block block = loc.getBlock();
                block.setType(Material.AIR);
                for (BlockFace flame : new BlockFace[] { BlockFace.UP, BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST }) {
                    Block bed = block.getRelative(flame);
                    if (bed.getType() == Material.FIRE)
                        bed.setType(Material.AIR);
                }
            // How do we sleep while our beds are burning? //Ask St. John Vianney
            }
        } else if (wc.dr0p1n) {
            WildTP.debug("Drop in feature enabled: Setting y=" + wc.dr0pFr0m);
            loc.setY(wc.dr0pFr0m);
            loc.setPitch(64);
            OuchieListener.plsSaveDisDood(who);
        }
        if (!who.teleport(loc.clone().add(0.5, 0.5, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND)) {
            WildTP.debug("teleport was canceled.");
            return;
        }
        WildTP.debug(who.getName() + " Teleported to " + who.getLocation());
        if (!bypass("cooldown")) {
            WildTP.debug(who.getName() + " Adding to cooldown");
            wc.checKar.addKewlzDown(who.getUniqueId());
            WildTP.debug("Added to cooldown " + who.getUniqueId());
        }
        PostWildTeleportEvent postWildTeleportEvent = new PostWildTeleportEvent(who, wc);
        Bukkit.getPluginManager().callEvent(postWildTeleportEvent);
    });
}
Also used : BlockFace(org.bukkit.block.BlockFace) Block(org.bukkit.block.Block)

Aggregations

BlockFace (org.bukkit.block.BlockFace)136 Block (org.bukkit.block.Block)53 GlowBlock (net.glowstone.block.GlowBlock)32 Location (org.bukkit.Location)23 Material (org.bukkit.Material)23 Vector (org.bukkit.util.Vector)18 ArrayList (java.util.ArrayList)12 ItemStack (org.bukkit.inventory.ItemStack)12 Sign (org.bukkit.block.Sign)10 BlockState (org.bukkit.block.BlockState)9 EventHandler (org.bukkit.event.EventHandler)8 MaterialData (org.bukkit.material.MaterialData)8 List (java.util.List)7 ItemTable (net.glowstone.block.ItemTable)7 Player (org.bukkit.entity.Player)7 GlowBlockState (net.glowstone.block.GlowBlockState)6 GlowPlayer (net.glowstone.entity.GlowPlayer)6 UUID (java.util.UUID)5 BlockType (net.glowstone.block.blocktype.BlockType)5 PulseTask (net.glowstone.scheduler.PulseTask)5