Java 类org.bukkit.block.BlockFace 实例源码

项目:Crescent    文件:BehaviourListeners.java   
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    final Player player = event.getPlayer();

    final Material from = event.getFrom().getBlock().getRelative(BlockFace.DOWN).getType();

    final Behaviour behaviour = Profile.getProfile(player.getUniqueId()).getBehaviour();

    final long current = System.currentTimeMillis();

    if (player.isSprinting()) {
        behaviour.getMotion().setLastSprint(current);
    }
    if (player.isFlying()) {
        behaviour.getMotion().setLastFly(current);
    }

    if (from.isSolid() || behaviour.getMotion().getLastY() == -1.0 || !behaviour.getMotion().isDescending()) {
        behaviour.getMotion().setLastY(player.getLocation().getY());
    }

    if (!behaviour.isOnGround()) {
        behaviour.getMotion().setLastYDiff(event.getTo().getY() - event.getFrom().getY());
    }
}
项目:PA    文件:IronElevators.java   
@EventHandler(priority = EventPriority.HIGH)
public void downElevator(PlayerToggleSneakEvent e) {
    Player p = e.getPlayer();
    Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN);
    if (!p.isSneaking() && b.getType() == elevatorMaterial) {
        b = b.getRelative(BlockFace.DOWN, minElevation);
        int i = maxElevation; //16
        while (i > 0 && !(b.getType() == elevatorMaterial && b.getRelative(BlockFace.UP).getType().isTransparent() && b.getRelative(BlockFace.UP, 2).getType().isTransparent())) {
            i--;
            b = b.getRelative(BlockFace.DOWN);
        }
        if (i > 0) {
            Location l = p.getLocation();
            l.setY(l.getY() - maxElevation - 2 + i);
            p.teleport(l);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1);
        }
    }
}
项目:CropControl    文件:CropControlEventHandler.java   
/**
 * So far specifically handles these cases:
 * 
 * 1) Block broken is tracked
 * 2) Block breaks by not-players
 * 3) Block breaks by players
 * 4) Indirect block breaks -- destroying block supporting a crop or collapsible tree, or under mushrooms
 * 5) Indirect block break of cocoa bearing logs
 * 6) Block broken had mushroom on top and cocoa on the sides
 * 
 * @param e The event
 */
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
    Block block = e.getBlock();
    Player player = e.getPlayer();
    BreakType type = player != null ? BreakType.PLAYER : BreakType.NATURAL;
    UUID uuid = player != null ? player.getUniqueId() : null;
    if (maybeSideTracked(block)) {
        trySideBreak(block, type, uuid);
    }
    if (maybeBelowTracked(block)) {
        block = block.getRelative(BlockFace.UP);
    }
    Location loc = block.getLocation();
    if (!pendingChecks.contains(loc)) {
        pendingChecks.add(loc);
        handleBreak(block, type, uuid, null);
    }
}
项目:CropControl    文件:CropControlEventHandler.java   
/**
 * So far specifically handles these cases:
 * 
 * 1) Block burnt is tracked
 * 2) Block burnt is under a tracked block (probably only mushrooms eligible)
 * 3) Block burnt was a jungle tree, checks for cocoa.
 * 4) Burnt block had mushroom on top and cocoa on the sides
 * 
 * @param e The event
 */
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBurn(BlockBurnEvent e) {
    Block block = e.getBlock();
    if (maybeSideTracked(block)) {
        trySideBreak(block, BreakType.FIRE, null);
    }
    if (maybeBelowTracked(block)) {
        block = block.getRelative(BlockFace.UP);
    }
    Location loc = block.getLocation();
    if (!pendingChecks.contains(loc)) {
        pendingChecks.add(loc);
        handleBreak(block, BreakType.FIRE, null, null);
    }
}
项目:Uranium    文件:CraftBlock.java   
/**
 * Notch uses a 0-5 to mean DOWN, UP, NORTH, SOUTH, WEST, EAST
 * in that order all over. This method is convenience to convert for us.
 *
 * @return BlockFace the BlockFace represented by this number
 */
public static BlockFace notchToBlockFace(int notch) {
    switch (notch) {
    case 0:
        return BlockFace.DOWN;
    case 1:
        return BlockFace.UP;
    case 2:
        return BlockFace.NORTH;
    case 3:
        return BlockFace.SOUTH;
    case 4:
        return BlockFace.WEST;
    case 5:
        return BlockFace.EAST;
    default:
        return BlockFace.SELF;
    }
}
项目:Uranium    文件:CraftBlock.java   
public static int blockFaceToNotch(BlockFace face) {
    switch (face) {
    case DOWN:
        return 0;
    case UP:
        return 1;
    case NORTH:
        return 2;
    case SOUTH:
        return 3;
    case WEST:
        return 4;
    case EAST:
        return 5;
    default:
        return 7; // Good as anything here, but technically invalid
    }
}
项目:NeverLag    文件:AntiQuickShopDoubleChest.java   
private boolean isShopBlockNearby(Block b) {
    if (b == null) {
        return false;
    }
    Block nearChest = null;
    if (b.getType() == Material.CHEST) {
        nearChest = getBlockNearby(b, Material.CHEST);
    } else if (b.getType() == Material.TRAPPED_CHEST) {
        nearChest = getBlockNearby(b, Material.TRAPPED_CHEST);
    }
    if (nearChest == null) {
        return false;
    }
    for (BlockFace face : BLOCKFACE) {
        Block maybeSign = nearChest.getRelative(face);
        if (maybeSign != null && Material.WALL_SIGN == maybeSign.getType()) {
            Sign sign = (Sign) maybeSign.getState();
            if (sign.getLines().length > 0 && sign.getLines()[0].contains(cm.quickshopSignFlag)) {
                return true;
            }
        }
    }
    return false;
}
项目:EscapeLag    文件:BonemealDupePatch.java   
@EventHandler
public void TreeGrowChecker(StructureGrowEvent event) {
    if (ConfigPatch.safetyBonemeal) {
        if(event.isFromBonemeal() == false) {
            return;
        }
        List<BlockState> blocks = event.getBlocks();
        int bs = blocks.size();
        for(int i = 0;i<bs;i++){
            Block block = blocks.get(i).getBlock();
            if(block.getType() != Material.AIR && block.getType() != Material.SAPLING && block.getType() != event.getLocation().getBlock().getRelative(BlockFace.DOWN).getType()){
                event.setCancelled(true);
                if (event.getPlayer() != null) {
                    AzureAPI.log(event.getPlayer(), "§c这棵树生长区域有方块阻挡,请不要尝试利用骨粉BUG!");
                    return;
                }
            }
        }
    }
}
项目:Arcadia-Spigot    文件:DeadEndGame.java   
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    if(this.getAPI().getGameManager().isAlive(event.getPlayer())) {
        if(event.getTo().getY() <= Integer.valueOf((String) this.getGameMap().fetchSetting("floorLevel"))) {
            this.getAPI().getGameManager().setAlive(event.getPlayer(), false);
        } else {
            final Block block = event.getTo().getBlock().getRelative(BlockFace.DOWN);
            if(block.getType() != Material.AIR) {
                if(!pendingDeletion.contains(block)) {
                    pendingDeletion.add(block);
                    new BukkitRunnable() {
                        public void run() {
                            if(pendingDeletion.contains(block)) {
                                block.setType(Material.AIR);
                                pendingDeletion.remove(block);
                            }
                        }
                    }.runTaskLater(this.getAPI().getPlugin(), 3L);
                }
            }
        }
    }
}
项目:AlphaLibary    文件:BarrelForm.java   
@Override
public void send(Player p) {
    if (direction == BlockFace.UP || direction == BlockFace.DOWN) {
        new CircleForm(getLocation(), "y", getDense(), getRadius(), getAction()).send(p);
        new CircleForm(getLocation().clone().add(0, getDepth(), 0), "y", getDense(), getRadius(), getAction()).send(p);

        for (double d = getDense(); d < getDepth() - getDense(); d += getDense())
            new CircleForm(getLocation().clone().add(0, d, 0), "y", getDense(), getRadius(), getAction()).send(p);
    } else if (direction == BlockFace.EAST || direction == BlockFace.WEST) {
        new CircleForm(getLocation(), "z", getDense(), getRadius(), getAction()).send(p);
        new CircleForm(getLocation().clone().add(getDepth(), 0, 0), "z", getDense(), getRadius(), getAction()).send(p);

        for (double d = getDense(); d < getDepth() - getDense(); d += getDense())
            new CircleForm(getLocation().clone().add(d, 0, 0), "z", getDense(), getRadius(), getAction()).send(p);
    } else {
        new CircleForm(getLocation(), "x", getDense(), getRadius(), getAction()).send(p);
        new CircleForm(getLocation().clone().add(0, 0, getDepth()), "x", getDense(), getRadius(), getAction()).send(p);

        for (double d = getDense(); d < getDepth() - getDense(); d += getDense())
            new CircleForm(getLocation().clone().add(0, 0, d), "x", getDense(), getRadius(), getAction()).send(p);
    }
}
项目:SparseBukkitAPI    文件:BukkitUtils.java   
public static Vector2d excludeFaceCoordinate(Vector3d vector, BlockFace face)
    {
        if(!isCardinal(face))
            throw new IllegalArgumentException("Cannot exclude coordinate from non-cardinal BlockFace");

        if(face.getModX() != 0)
            return new Vector2d(vector.y(), vector.z());
        if(face.getModY() != 0)
            return new Vector2d(vector.x(), vector.z());
        if(face.getModZ() != 0)
            return new Vector2d(vector.x(), vector.y());
        throw new IllegalStateException("Unexpected BlockFace coordinates. ("+face+")");

//      List<Float> values = vector.getGetters().stream().map(Supplier::get).collect(Collectors.toList());
//      values.remove(getAxisIndex(face));
//      return Vector2f.create(values.get(0), values.get(1));
    }
项目:SparseBukkitAPI    文件:BukkitUtils.java   
public static Vector3d mergeFaceCoordinate(Vector2d excluded, double extracted, BlockFace face)
    {
        if(!isCardinal(face))
            throw new IllegalArgumentException("Cannot merge coordinates from non-cardinal BlockFace");
        if(face.getModX() != 0)
            return new Vector3d(extracted, excluded.x(), excluded.y());
        if(face.getModY() != 0)
            return new Vector3d(excluded.x(), extracted, excluded.y());
        if(face.getModZ() != 0)
            return new Vector3d(excluded.x(), excluded.y(), extracted);
        throw new IllegalStateException("Unexpected BlockFace coordinates. ("+face+")");
//      List<Float> values = new ArrayList<>(Arrays.asList(excluded.getX(), excluded.getY()));
//      int axis = getAxisIndex(face);
//      values.add(axis, extracted);
//      return Vector3f.create(values.get(0), values.get(1), values.get(2));
    }
项目:ProjectAres    文件:LaneMatchModule.java   
private static boolean isIllegallyOutsideLane(Region lane, Location loc) {
    Block feet = loc.getBlock();
    if(feet == null) return false;

    if(isIllegalBlock(lane, feet)) {
        return true;
    }

    Block head = feet.getRelative(BlockFace.UP);
    if(head == null) return false;

    if(isIllegalBlock(lane, head)) {
        return true;
    }

    return false;
}
项目:ProjectAres    文件:Flag.java   
public boolean canDropAt(Location location) {
    if(!match.getWorld().equals(location.getWorld())) return false;

    Block block = location.getBlock();
    Block below = block.getRelative(BlockFace.DOWN);
    if(!canDropOn(below.getState())) return false;
    if(block.getRelative(BlockFace.UP).getType() != Material.AIR) return false;

    switch(block.getType()) {
        case AIR:
        case LONG_GRASS:
            return true;
        default:
            return false;
    }
}
项目:Kineticraft    文件:Dungeons.java   
@EventHandler(ignoreCancelled = true) // Handles special items entering hoppers.
public void onHopperPickup(InventoryPickupItemEvent evt) {
    if (!(evt.getInventory().getHolder() instanceof Hopper))
        return; // Verify the inventory the item is going to enter is a hopper.

    Hopper hp = (Hopper) evt.getInventory().getHolder();
    Matcher mName = Pattern.compile("<Custom ID: (\\w+)>").matcher(hp.getInventory().getName());
    if (!mName.find())
        return; // If it doesn't have a Custom item ID defined, don't handle it.

    ItemWrapper iw = ItemManager.constructItem(evt.getItem().getItemStack());
    evt.setCancelled(true);

    if (mName.group(1).equalsIgnoreCase(iw.getTagString("id"))) { // We've found the right item! Consume it.
        evt.getItem().remove();
        hp.getBlock().getRelative(BlockFace.DOWN).setType(Material.REDSTONE_BLOCK);
    } else { // This item isn't acceptable, spit it back out.
        evt.getItem().setVelocity(new Vector(0, .15F, 0));
    }
}
项目:ProjectAres    文件:FallingBlocksMatchModule.java   
/**
 * Return the number of unsupported blocks connected to any blocks neighboring the given location,
 * which is assumed to contain an air block. The search may bail out early when the count is greater
 * or equal to the given limit, though this cannot be guaranteed.
 */
private int countUnsupportedNeighbors(long pos, int limit) {
    TLongSet supported = new TLongHashSet();
    TLongSet unsupported = new TLongHashSet();

    try {
        for(BlockFace face : NEIGHBORS) {
            if(!this.isSupported(neighborPos(pos, face), supported, unsupported)) {
                if(unsupported.size() >= limit) break;
            }
        }
    }
    catch(MaxSearchVisitsExceeded ex) {
        this.logError(ex);
    }

    return unsupported.size();
}
项目:ProjectAres    文件:BlockTransformListener.java   
@EventWrapper
public void onBlockBurn(final BlockBurnEvent event) {
    Match match = PGM.getMatchManager().getMatch(event.getBlock().getWorld());
    if(match == null) return;

    BlockState oldState = event.getBlock().getState();
    BlockState newState = BlockStateUtils.toAir(oldState);
    MatchPlayerState igniterState = null;

    for(BlockFace face : NEIGHBORS) {
        Block neighbor = oldState.getBlock().getRelative(face);
        if(neighbor.getType() == Material.FIRE) {
            igniterState = blockResolver.getOwner(neighbor);
            if(igniterState != null) break;
        }
    }

    this.callEvent(event, oldState, newState, igniterState);
}
项目:DynamicAC    文件:BackendChecks.java   
public void checkAscension(Player player, double y1, double y2) {
    int max = MagicNumbers.ASCENSION_COUNT_MAX;
    if(player.hasPotionEffect(PotionEffectType.JUMP)) {
        max += 12;
    }
    Block block = player.getLocation().getBlock();
    if(!isMovingExempt(player) && !Utilities.isInWater(player) && !player.isFlying() && !Utilities
            .isClimbableBlock(player.getLocation().getBlock()) && !player.isInsideVehicle() && !MOVE_UP_BLOCKS
            .contains(player.getLocation().add(0,-1,0).getBlock().getType()) && !MOVE_UP_BLOCKS.contains(player
            .getLocation().add(0,-1.5,0).getBlock().getType())) {
        if(y1 < y2) {
            if(!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid() && !block.getRelative(BlockFace.EAST).isLiquid() && !block.getRelative(BlockFace.WEST).isLiquid()) {
                incrementOld(player,ascensionCount,max);
                if(ascensionCount.get(player) > max) {
                    for(Player pla : DynamicAC.instance.onlinestaff) {
                        pla.sendMessage(DynamicAC.prefix + player.getName() + " ascended Y Axis too fast!");
                    }
                    DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName
                            ()),"Climbed too fast");
                }
            }
        }
    }
}
项目:NavyCraft2-Lite    文件:OneCannon.java   
public void loadingTorp(final boolean left, final Block b, final BlockFace torpHeading, final boolean lift) {
new Thread() {
    @Override
    public void run()
    {

    setPriority(Thread.MIN_PRIORITY);
        try
        { 

sleep(1000);
for( int i=0; i<16; i++ )
{
    loadingTorpUpdate(left, b, torpHeading, lift, i);
    sleep(1000);
}

        } catch (InterruptedException e) 
        {
        }
    }
}.start();
   }
项目:PA    文件:IronElevators.java   
@EventHandler(priority = EventPriority.HIGH)
public void upElevator(PlayerMoveEvent e) {
    Player p = e.getPlayer();
    Block b = e.getTo().getBlock().getRelative(BlockFace.DOWN);
    if (e.getFrom().getY() < e.getTo().getY() && b.getType() == elevatorMaterial) { b = b.getRelative(BlockFace.UP, minElevation);
        int i = maxElevation;
        while (i > 0 && !(b.getType() == elevatorMaterial && b.getRelative(BlockFace.UP).getType().isTransparent() && b.getRelative(BlockFace.UP, 2).getType().isTransparent())) {
            i--;
            b = b.getRelative(BlockFace.UP);
        }
        if (i > 0) {
            Location l = p.getLocation();
            l.setY(l.getY() + maxElevation + 3 - i);
            p.teleport(l);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1);
        }
    }
}
项目:SurvivalPlus    文件:Chairs.java   
private boolean checkSign(Block block, BlockFace face)
{
    // Go through the blocks next to the clicked block and check if are signs on the end.
    for(int i = 1; true; i++)
    {
        Block relative = block.getRelative(face, i);
        if(!(Survival.allowedBlocks.contains(relative.getType())) || (block instanceof Stairs && ((Stairs)relative.getState().getData()).getDescendingDirection() != ((Stairs)block.getState().getData()).getDescendingDirection()))
        {
            switch(relative.getType())
            {
                case SIGN:
                case WALL_SIGN:
                case SIGN_POST:
                case ITEM_FRAME:
                case PAINTING:
                case TRAP_DOOR:
                case IRON_TRAPDOOR:
                    return true;
                default:
                    return false;
            }
        }
    }
}
项目:MinecraftMarket-Plugin    文件:SignsListener.java   
@EventHandler
public void onBlockBreakEvent(BlockBreakEvent e) {
    if (plugin.getMainConfig().isUseSigns()) {
        if (e.getPlayer().hasPermission("minecraftmarket.signs")) {
            if (plugin.getSignsConfig().getDonorSignFor(e.getBlock()) != null) {
                if (plugin.getSignsConfig().removeDonorSign(e.getBlock())) {
                    e.getPlayer().sendMessage(Colors.color(I18n.tl("prefix") + " " + I18n.tl("sign_removed")));
                    plugin.getSignsTask().updateSigns();
                }
            } else {
                for (BlockFace blockFace : blockFaces) {
                    Block block = e.getBlock().getRelative(blockFace);
                    if (block != null && block.getState() instanceof Sign && Objects.equals(getAttachedBlock(block), e.getBlock())) {
                        if (plugin.getSignsConfig().getDonorSignFor(block) != null) {
                            if (plugin.getSignsConfig().removeDonorSign(block)) {
                                e.getPlayer().sendMessage(Colors.color(I18n.tl("prefix") + " " + I18n.tl("sign_removed")));
                                plugin.getSignsTask().updateSigns();
                            }
                        }
                    }
                }
            }
        }
    }
}
项目:Hub    文件:ParkourBackend.java   
private void startCheckingTask(Hub hub, Parkour parkour)
{
    this.checkingTask = hub.getServer().getScheduler().runTaskTimerAsynchronously(hub, () ->
    {
        for (UUID uuid : parkour.getPlayersIn().keySet())
        {
            Player player = hub.getServer().getPlayer(uuid);

            if (player == null || !player.isOnline())
            {
                parkour.removePlayer(player);
            }
            else
            {
                Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);

                if (parkour instanceof WhitelistBasedParkour && !((WhitelistBasedParkour) parkour).isWhitelisted(block.getType()) && block.getType().isSolid())
                    parkour.failPlayer(player);
            }
        }
    }, 20L, 20L);
}
项目:VoxelGamesLibv2    文件:DirectionUtil.java   
/**
 * Gets the horizontal BlockFace from a given yaw angle
 *
 * @param yaw                      angle
 * @param useSubCardinalDirections setting, True to allow NORTH_WEST to be returned
 * @return The direction of the angle
 */
@Nonnull
public static BlockFace yawToDirection(float yaw, boolean useSubCardinalDirections) {
    if (useSubCardinalDirections) {
        return RADIAL[(Math.round((yaw - 90) / 45f) & 0x7)];
    } else {
        return AXIS[Math.round(yaw / 90f) & 0x3];
    }
}
项目:SurvivalAPI    文件:SurvivalTeamSelector.java   
/**
 * Event fired when a player rename his team
 *
 * @param event Event
 */
@EventHandler
public void onSignChange(SignChangeEvent event)
{
    if (this.game.getStatus().equals(Status.IN_GAME))
    {
        event.getHandlers().unregister(this);
        return;
    }

    if (!this.game.getStatus().equals(Status.IN_GAME))
    {
        SurvivalTeam team = this.game.getPlayerTeam(event.getPlayer().getUniqueId());
        String name = event.getLine(0);
        name = name.trim();

        if (!name.isEmpty())
        {
            team.setTeamName(name);
            event.getPlayer().sendMessage(this.game.getCoherenceMachine().getGameTag() + " " + ChatColor.GREEN + "Le nom de votre équipe est désormais : " + team.getChatColor() + team.getTeamName());
            this.openGui(event.getPlayer(), new GuiSelectTeam());
        }
        else
        {
            event.getPlayer().sendMessage(this.game.getCoherenceMachine().getGameTag() + " " + ChatColor.RED + "Le nom de l'équipe ne peut être vide.");
            this.openGui(event.getPlayer(), new GuiSelectTeam());
        }
        this.game.getPlugin().getServer().getScheduler().runTaskLater(this.game.getPlugin(), () ->
        {
            event.getBlock().setType(Material.AIR);
            event.getBlock().getRelative(BlockFace.DOWN).setType(Material.AIR);
        }, 1L);
    }
}
项目:CropControl    文件:CropControlEventHandler.java   
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
    Block block = e.getBlock();
    if (maybeSideTracked(block)) {
        trySideBreak(block, BreakType.NATURAL, null);
    }
    if (maybeBelowTracked(block)) {
        block = block.getRelative(BlockFace.UP);
    }
    Location loc = block.getLocation();
    if (!pendingChecks.contains(loc)) {
        pendingChecks.add(loc);
        handleBreak(block, BreakType.NATURAL, null, null);
    }
}
项目:PA    文件:GameEvents.java   
@EventHandler
public void onInteract(PlayerInteractEvent e) {
    final TOAUser u = TOA.getPlayer(e.getPlayer());

    if (e.getItem() != null) {
        Material m = e.getItem().getType();
        if (m == Material.WRITTEN_BOOK || m == Material.BOW || m == Material.SHEARS || m == Material.DIAMOND_SWORD) return;
        Ability.useAbility(u, e.getItem().getType());
        e.setCancelled(true);
    }

    if (!u.isOnRank(PACmd.Grupo.Builder)) {
        if (e.getClickedBlock() != null) {
            if (e.getClickedBlock().getType().equals(Material.TRAP_DOOR) || e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)
                    || e.getClickedBlock().getType().equals(Material.FENCE_GATE) || e.getClickedBlock().getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType().equals(Material.CAULDRON) || e.getClickedBlock().getRelative(BlockFace.UP).getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType() == Material.CHEST || e.getClickedBlock().getType() == Material.TRAPPED_CHEST
                    || e.getClickedBlock().getType() == Material.DROPPER || e.getClickedBlock().getType() == Material.DISPENSER
                    || e.getClickedBlock().getType() == Material.BED_BLOCK || e.getClickedBlock().getType() == Material.BED
                    || e.getClickedBlock().getType() == Material.WORKBENCH || e.getClickedBlock().getType() == Material.BREWING_STAND
                    || e.getClickedBlock().getType() == Material.ANVIL || e.getClickedBlock().getType() == Material.DARK_OAK_FENCE_GATE
                    || e.getClickedBlock().getType() == Material.SPRUCE_FENCE_GATE || e.getClickedBlock().getType() == Material.FURNACE
                    || e.getClickedBlock().getType() == Material.BURNING_FURNACE || e.getClickedBlock().getType() == Material.HOPPER
                    || e.getClickedBlock().getType() == Material.STONE_BUTTON || e.getClickedBlock().getType() == Material.WOOD_BUTTON) {
                e.setCancelled(true);
            }
        }
    }
}
项目:Uranium    文件:CraftItemFrame.java   
public boolean setFacingDirection(BlockFace face, boolean force) {
    if (!super.setFacingDirection(face, force)) {
        return false;
    }

    net.minecraft.world.WorldServer world = ((CraftWorld) this.getWorld()).getHandle();
    world.getEntityTracker().removeEntityFromAllTrackingPlayers(this.getHandle());
    world.getEntityTracker().addEntityToTracker(this.getHandle());
    return true;
}
项目:MT_Core    文件:GeckPowerListener.java   
@EventHandler
public void onPlayerLeaverInteract(PlayerInteractEvent e) {
    Player p = e.getPlayer();
    Block clicked = e.getClickedBlock();

    if (clicked == null)
        return;

    Block underneath = clicked.getRelative(BlockFace.DOWN);
    Location underneathLoc = underneath.getLocation();

    if (e.getAction() != Action.RIGHT_CLICK_BLOCK || e.getHand() == EquipmentSlot.OFF_HAND)
        return;

    if (clicked.getType() != Material.LEVER || underneath == null)
        return;

    String chunk = clicked.getLocation().getChunk().getX() + ";" + clicked.getLocation().getChunk().getZ();

    if (underneath.getType() == Material.SPONGE && !underneath.isBlockPowered()) {
        if (!main.getGeckManager().isGeckBuildCorrect(underneath)) {
            p.sendMessage(ChatColor.RED + "You must build the GECK correctly!");

            // Check if the geck is inside the powerables list
        } else if (main.getGenListener().getPowerable().get(clicked.getWorld().getName()).getList(chunk)
                .contains(underneathLoc)) {
            main.getGeckObjectManager().addGeckLocation(underneathLoc);
            main.getGeckObjectManager().getGeckObject(underneathLoc).setCorrect(true);
            main.getGeckObjectManager().getGeckObject(underneathLoc).setPowered(true);
            p.sendMessage(ChatColor.GREEN + "GECK Enabled!");
            return;
        }

    } else if (main.getGeckObjectManager().getGeckObject(underneathLoc) != null && underneath.isBlockPowered()) {
        main.getGeckObjectManager().getGeckObject(underneathLoc).setPowered(false);
        main.getGeckObjectManager().removeGeckLocation(underneathLoc);
        p.sendMessage(ChatColor.RED + "GECK Disabled!");
    }
}
项目:Uranium    文件:CraftHanging.java   
public boolean setFacingDirection(BlockFace face, boolean force) {
    Block block = getLocation().getBlock().getRelative(getAttachedFace()).getRelative(face.getOppositeFace()).getRelative(getFacing());
    net.minecraft.entity.EntityHanging hanging = getHandle();
    int x = hanging.field_146063_b, y = hanging.field_146064_c, z = hanging.field_146062_d, dir = hanging.hangingDirection;
    hanging.field_146063_b = block.getX();
    hanging.field_146064_c = block.getY();
    hanging.field_146062_d = block.getZ();
    switch (face) {
        case SOUTH:
        default:
            getHandle().setDirection(0);
            break;
        case WEST:
            getHandle().setDirection(1);
            break;
        case NORTH:
            getHandle().setDirection(2);
            break;
        case EAST:
            getHandle().setDirection(3);
            break;
    }
    if (!force && !hanging.onValidSurface()) {
        // Revert since it doesn't fit
        hanging.field_146063_b = x;
        hanging.field_146064_c = y;
        hanging.field_146062_d = z;
        hanging.setDirection(dir);
        return false;
    }
    return true;
}
项目:Uranium    文件:CraftBlock.java   
public BlockFace getFace(final Block block) {
    BlockFace[] values = BlockFace.values();

    for (BlockFace face : values) {
        if ((this.getX() + face.getModX() == block.getX()) &&
            (this.getY() + face.getModY() == block.getY()) &&
            (this.getZ() + face.getModZ() == block.getZ())
        ) {
            return face;
        }
    }

    return null;
}
项目:NavyCraft2-Lite    文件:OneCannon.java   
public void fireShell(Vector look, Player p)
{
    tntp.setVelocity(look);
    if( cannonType == 1 )
 {

    tntp2.setVelocity(look);
 }
 if( cannonType == 6 )
 {
    tntp2.setVelocity(look);
    tntp3.setVelocity(look);
 }
 charged = 0;

 Block b;
 b = loc.getBlock().getRelative(BlockFace.UP);
 b.getWorld().createExplosion(loc.getBlock().getRelative(direction,4).getLocation(), 0);

 if( cannonType == 6 )
 {
    if( direction == BlockFace.EAST || direction == BlockFace.WEST )
    {
        b.getWorld().createExplosion(loc.getBlock().getRelative(direction,4).getRelative(BlockFace.NORTH,2).getLocation(), 0);
        b.getWorld().createExplosion(loc.getBlock().getRelative(direction,4).getRelative(BlockFace.SOUTH,2).getLocation(), 0);
    }else
    {
        b.getWorld().createExplosion(loc.getBlock().getRelative(direction,4).getRelative(BlockFace.EAST,2).getLocation(), 0);
        b.getWorld().createExplosion(loc.getBlock().getRelative(direction,4).getRelative(BlockFace.WEST,2).getLocation(), 0);
    }
 }
}
项目:Uranium    文件:CraftBlock.java   
public boolean isBlockFaceIndirectlyPowered(BlockFace face) {
    int power = chunk.getHandle().worldObj.getIndirectPowerLevelTo(x, y, z, blockFaceToNotch(face));

    Block relative = getRelative(face);
    if (relative.getType() == Material.REDSTONE_WIRE) {
        return Math.max(power, relative.getData()) > 0;
    }

    return power > 0;
}
项目:mczone    文件:GameEvents.java   
@EventHandler(ignoreCancelled = true)
  public void onPlayerMove(PlayerMoveEvent event) {
Player p = event.getPlayer();
      Location to = event.getTo();
      Location from = event.getFrom();
      World world = to.getWorld();

      if (to.clone().add(0, -1, 0).getBlock().getType() != Material.REDSTONE_LAMP_ON)
        return;

      if (from.clone().add(0, -1, 0).getBlock().getType() == Material.REDSTONE_LAMP_ON)
        return;

      for (Block block : getPortalNear(world, to.getBlockX(), to.getBlockY(), to.getBlockZ())) {
          for (BlockFace bf : BlockFace.values()) {
              Block relative = block.getRelative(bf);
              if (relative.getTypeId() == SIGN) {

                // Specific server
                Sign sign = (Sign) relative.getState();
                Portal portal = null;
                for (Portal po : Portal.getList()) {
                    if (WorldUtil.sameBlock(po.getSign().getBlock(), sign.getBlock())) {
                        portal = po;
                        break;
                    }
                }
                if (portal == null)
                    return; 

                if (portal.getCurrent().getStatus() == Status.CLOSED)
                    Chat.player(p, "&cThat server is currently unavailable!");
                else                    
                    portal.getCurrent().connect(event.getPlayer());

                portal.updateSign();
              }
          }
      }
  }
项目:VoxelGamesLibv2    文件:JumpPadFeature.java   
@GameEvent
public void onStep(@Nonnull PlayerInteractEvent event) {
    if (event.getAction() == Action.PHYSICAL) {
        if (event.getClickedBlock().getType() != Material.WOOD_PLATE && event.getClickedBlock().getType() != Material.STONE_PLATE) {
            return;
        }
        if (event.isCancelled()) {
            return;
        }
        double strength = 1.5;
        double up = 1;
        if (event.getClickedBlock().getRelative(BlockFace.DOWN, 2).getState() instanceof Sign) {
            Sign sign = (Sign) event.getClickedBlock().getRelative(BlockFace.DOWN, 2).getState();
            if (sign.getLine(0).contains("[Boom]")) {
                try {
                    strength = Double.parseDouble(sign.getLine(1));
                    up = Double.parseDouble(sign.getLine(2));
                } catch (final Exception ex) {
                    log.warning("Invalid boom sign at " + sign.getLocation());
                }
            }
        }

        event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ENDERDRAGON_SHOOT, 10.0F, 1.0F);
        event.getPlayer().playEffect(event.getPlayer().getLocation(), Effect.SMOKE, 10);
        Vector v = event.getPlayer().getLocation().getDirection().multiply(strength / 2).setY(up / 2);
        event.getPlayer().setVelocity(v);
        event.setCancelled(true);
    }
}
项目:Uranium    文件:CraftSkull.java   
static BlockFace getBlockFace(byte rotation) {
    switch (rotation) {
        case 0:
            return BlockFace.NORTH;
        case 1:
            return BlockFace.NORTH_NORTH_EAST;
        case 2:
            return BlockFace.NORTH_EAST;
        case 3:
            return BlockFace.EAST_NORTH_EAST;
        case 4:
            return BlockFace.EAST;
        case 5:
            return BlockFace.EAST_SOUTH_EAST;
        case 6:
            return BlockFace.SOUTH_EAST;
        case 7:
            return BlockFace.SOUTH_SOUTH_EAST;
        case 8:
            return BlockFace.SOUTH;
        case 9:
            return BlockFace.SOUTH_SOUTH_WEST;
        case 10:
            return BlockFace.SOUTH_WEST;
        case 11:
            return BlockFace.WEST_SOUTH_WEST;
        case 12:
            return BlockFace.WEST;
        case 13:
            return BlockFace.WEST_NORTH_WEST;
        case 14:
            return BlockFace.NORTH_WEST;
        case 15:
            return BlockFace.NORTH_NORTH_WEST;
        default:
            throw new AssertionError(rotation);
    }
}
项目:NavyCraft2-Lite    文件:OneCannon.java   
public Block getDirectionFromRelative(Block blockIn, BlockFace dir, boolean left)
{
    Block b;
    if( dir == BlockFace.NORTH )    
    {
        if( left )
            b = blockIn.getRelative(BlockFace.WEST);
        else
            b = blockIn.getRelative(BlockFace.EAST);
    }else if( dir == BlockFace.SOUTH )
    {
        if( left )
            b = blockIn.getRelative(BlockFace.EAST);
        else
            b = blockIn.getRelative(BlockFace.WEST);
    }else if( dir == BlockFace.EAST )
    {
        if( left )
            b = blockIn.getRelative(BlockFace.NORTH);
        else
            b = blockIn.getRelative(BlockFace.SOUTH);
    }else //if( direction == BlockFace.WEST )
    {
        if( left )
            b = blockIn.getRelative(BlockFace.SOUTH);
        else
            b = blockIn.getRelative(BlockFace.NORTH);
    }
    return b;
}
项目:ZentrelaRPG    文件:SchematicManager.java   
public static void grow(Player p, int radius) {
    Block target = p.getTargetBlock((HashSet<Byte>) null, 100);
    int radius_squared = radius * radius;
    Block toHandle;
    SchematicUserConfig cfg = getConfig(p);
    ArrayList<Block> list = new ArrayList<Block>();
    for (int x = -radius; x <= radius; x++) {
        for (int z = -radius; z <= radius; z++) {
            toHandle = target.getWorld().getHighestBlockAt(target.getX() + x, target.getZ() + z);
            if (toHandle.getType() == Material.AIR && toHandle.getRelative(BlockFace.DOWN).getType() == Material.GRASS) { // Block beneath is grass
                if (target.getLocation().distanceSquared(toHandle.getLocation()) <= radius_squared) { // Block is in radius
                    double rand = Math.random();
                    if (rand < cfg.growDensity * 5 / 6) {
                        toHandle.setType(Material.LONG_GRASS);
                        toHandle.setData((byte) 1);
                        list.add(toHandle);
                    } else if (rand < cfg.growDensity) {
                        toHandle.setType(Material.RED_ROSE); //0 4 5 6 7 8
                        byte data = (byte) (Math.random() * 6);
                        if (data > 0)
                            data += 3; //1 + 3 = 4, 2 + 3 = 5, ..., 5 + 3 = 8
                        toHandle.setData(data);
                        list.add(toHandle);
                    }
                }
            }
        }
    }
    cfg.lastGrow.add(list);
    if (SchematicManager.getConfig(p).verbose)
        p.sendMessage("Grew with radius " + radius + ".");
}
项目:NeverLag    文件:AntiQuickShopDoubleChest.java   
private static Block getBlockNearby(Block b, Material type) {
    Block relativeBlock;
    for (BlockFace face : BLOCKFACE) {
        relativeBlock = b.getRelative(face);
        if (relativeBlock != null && type == relativeBlock.getType()) {
            return relativeBlock;
        }
    }
    return null;
}
项目:Arcadia-Spigot    文件:ElectricFloorGame.java   
private void updateBlock(Player player, Block block) {
    if(this.getAPI().getGameManager().isAlive(player)) {
        if(block.getType() == Material.AIR
                && block.getRelative(BlockFace.DOWN).getType() != Material.AIR) {
            block = block.getRelative(BlockFace.DOWN);
        }
        MaterialData currentData = floorOrder.currentData(block);
        if(floorOrder.match(block, floorOrder.last())) {
            this.getAPI().getGameManager().setAlive(player, false);
        } else {
            if(floorOrder.contains(block)) {
                if(!changePending.contains(block)) {
                    final Block finalBlock = block;
                    final MaterialData next = floorOrder.nextData(block);
                    changePending.add(block);
                    new BukkitRunnable() {
                        public void run() {
                            if(changePending.contains(finalBlock)) {
                                finalBlock.setTypeIdAndData(next.getItemTypeId(), next.getData(), false);
                                changePending.remove(finalBlock);
                            }
                        }
                    }.runTaskLater(this.getAPI().getPlugin(), 10L);
                }
            }
        }
    }
}