当前位置: 首页>>代码示例>>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;未经允许,请勿转载。