本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}