當前位置: 首頁>>代碼示例>>Java>>正文


Java Player.getDirection方法代碼示例

本文整理匯總了Java中cn.nukkit.Player.getDirection方法的典型用法代碼示例。如果您正苦於以下問題:Java Player.getDirection方法的具體用法?Java Player.getDirection怎麽用?Java Player.getDirection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cn.nukkit.Player的用法示例。


在下文中一共展示了Player.getDirection方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: place

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    if (face == BlockFace.UP) {
        Block blockUp = this.up();
        Block blockDown = this.down();
        if (!blockUp.canBeReplaced() || blockDown.isTransparent()) {
            return false;
        }
        int direction = player != null ? player.getDirection() : 0;
        int[] faces = {3, 4, 2, 5};

        Block next = this.getSide(BlockFace.fromIndex(faces[((direction + 2) % 4)]));
        Block next2 = this.getSide(BlockFace.fromIndex(faces[direction]));
        int metaUp = 0x08;
        if (next.getId() == this.getId() || (!next2.isTransparent() && next.isTransparent())) { //Door hinge
            metaUp |= 0x01;
        }

        this.setDamage(direction & 0x03);
        this.getLevel().setBlock(block, this, true, true); //Bottom
        this.getLevel().setBlock(blockUp, Block.get(this.getId(), metaUp), true); //Top
        return true;
    }

    return false;
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:27,代碼來源:BlockDoor.java

示例2: place

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    Block down = this.down();
    if (!down.isTransparent()) {
        int[] faces = {3, 4, 2, 5};
        int d = player != null ? player.getDirection() : 0;
        Block next = this.getSide(BlockFace.fromIndex(faces[((d + 3) % 4)]));
        Block downNext = this.down();

        if (next.canBeReplaced() && !downNext.isTransparent()) {
            int meta = ((d + 3) % 4) & 0x03;
            this.getLevel().setBlock(block, Block.get(this.getId(), meta), true, true);
            this.getLevel().setBlock(next, Block.get(this.getId(), meta | 0x08), true, true);

            return true;
        }
    }

    return false;
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:21,代碼來源:BlockBed.java

示例3: place

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    int[] faces = {4, 2, 5, 3};
    this.meta = faces[player != null ? player.getDirection() : 0];

    this.getLevel().setBlock(block, this, true, true);
    CompoundTag nbt = new CompoundTag("")
            .putString("id", BlockEntity.ENDER_CHEST)
            .putInt("x", (int) this.x)
            .putInt("y", (int) this.y)
            .putInt("z", (int) this.z);

    if (item.hasCustomName()) {
        nbt.putString("CustomName", item.getCustomName());
    }

    if (item.hasCustomBlockData()) {
        Map<String, Tag> customData = item.getCustomBlockData().getTags();
        for (Map.Entry<String, Tag> tag : customData.entrySet()) {
            nbt.put(tag.getKey(), tag.getValue());
        }
    }

    new BlockEntityEnderChest(this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
    return true;
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:27,代碼來源:BlockEnderChest.java

示例4: place

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    if (!target.isTransparent()) {
        int faces[] = {0, 1, 2, 3};
        int damage = this.getDamage();
        this.meta = faces[player != null ? player.getDirection() : 0] & 0x04;
        if (damage >= 0 && damage <= 3) {
            this.meta = faces[player != null ? player.getDirection() : 0];
        } else if (damage >= 4 && damage <= 7) {
            this.meta = faces[player != null ? player.getDirection() : 0] | 0x04;
        } else if (damage >= 8 && damage <= 11) {
            this.meta = faces[player != null ? player.getDirection() : 0] | 0x08;
        }
        this.getLevel().setBlock(block, this, true);
        return true;
    }
    return false;
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:19,代碼來源:BlockAnvil.java

示例5: place

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    if (player != null) {
        if (player.getDirection() != null) {
            this.meta = (player.getDirection().getHorizontalIndex() + 5) % 4;
        }
    }
    this.getLevel().setBlock(block, this, true, true);
    return true;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:11,代碼來源:BlockPumpkin.java

示例6: place

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    if (block.getSide(BlockFace.DOWN).isTransparent()) {
        return false;
    }

    this.meta = (player.getDirection() + 5) % 4;
    this.level.setBlock(block, this, true, true);

    if (shouldBePowered()) {
        this.level.scheduleUpdate(this, 1);
    }
    return true;
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:15,代碼來源:BlockRedstoneDiode.java

示例7: place

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    int[] faces = new int[]{0, 2, 1, 3};
    this.meta = (faces[player.getDirection()] & 0x03);
    if ((fy > 0.5 && face != BlockFace.UP) || face == BlockFace.DOWN) {
        this.meta |= 0x04; //Upside-down stairs
    }
    this.getLevel().setBlock(block, this, true, true);

    return true;
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:12,代碼來源:BlockStairs.java

示例8: place

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    int faces[] = {4, 2, 5, 3};
    this.meta = faces[player != null ? player.getDirection() : 0];
    this.getLevel().setBlock(block, this, true, true);
    CompoundTag nbt = new CompoundTag()
            .putList(new ListTag<>("Items"))
            .putString("id", BlockEntity.FURNACE)
            .putInt("x", (int) this.x)
            .putInt("y", (int) this.y)
            .putInt("z", (int) this.z);

    if (item.hasCustomName()) {
        nbt.putString("CustomName", item.getCustomName());
    }

    if (item.hasCustomBlockData()) {
        Map<String, Tag> customData = item.getCustomBlockData().getTags();
        for (Map.Entry<String, Tag> tag : customData.entrySet()) {
            nbt.put(tag.getKey(), tag.getValue());
        }
    }

    new BlockEntityFurnace(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt);

    return true;
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:28,代碼來源:BlockFurnaceBurning.java

示例9: place

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    if (player != null) {
        if (player.getDirection() != null) {
            this.meta = (player.getDirection() + 5) % 4;
        }
    }
    this.getLevel().setBlock(block, this, true, true);
    return true;
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:11,代碼來源:BlockPumpkin.java

示例10: place

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    this.meta = player != null ? (player.getDirection() - 1) & 0x03 : 0;
    this.getLevel().setBlock(block, this, true, true);

    return true;
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:8,代碼來源:BlockFenceGate.java


注:本文中的cn.nukkit.Player.getDirection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。