本文整理汇总了Java中cn.nukkit.Player类的典型用法代码示例。如果您正苦于以下问题:Java Player类的具体用法?Java Player怎么用?Java Player使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Player类属于cn.nukkit包,在下文中一共展示了Player类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onOpen
import cn.nukkit.Player; //导入依赖的package包/类
@Override
public void onOpen(Player who) {
super.onOpen(who);
if (this.levels == null) {
this.levels = new int[3];
this.bookshelfAmount = this.countBookshelf();
if (this.bookshelfAmount < 0) {
this.bookshelfAmount = 0;
}
if (this.bookshelfAmount > 15) {
this.bookshelfAmount = 15;
}
NukkitRandom random = new NukkitRandom();
double base = (double) random.nextRange(1, 8) + (bookshelfAmount / 2d) + (double) random.nextRange(0, bookshelfAmount);
this.levels[0] = (int) Math.max(base / 3, 1);
this.levels[1] = (int) ((base * 2) / 3 + 1);
this.levels[2] = (int) Math.max(base, bookshelfAmount * 2);
}
}
示例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) {
int[] faces = {2, 5, 3, 4};
this.meta = faces[player != null ? player.getDirection().getHorizontalIndex() : 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;
}
示例3: spawnTo
import cn.nukkit.Player; //导入依赖的package包/类
@Override
public void spawnTo(Player player) {
AddEntityPacket packet = new AddEntityPacket();
packet.type = getNetworkId();
packet.entityUniqueId = this.getId();
packet.entityRuntimeId = getId();
packet.x = (float) this.x;
packet.y = (float) this.y;
packet.z = (float) this.z;
packet.speedX = (float) this.motionX;
packet.speedY = (float) this.motionY;
packet.speedZ = (float) this.motionZ;
packet.metadata = new EntityMetadata();
player.dataPacket(packet);
//this.sendData(player);
super.spawnTo(player);
}
示例4: spawnTo
import cn.nukkit.Player; //导入依赖的package包/类
@Override
public void spawnTo(Player player) {
AddEntityPacket pk = new AddEntityPacket();
pk.type = this.getNetworkId();
pk.entityUniqueId = this.getId();
pk.entityRuntimeId = this.getId();
pk.x = (float) this.x;
pk.y = (float) this.y;
pk.z = (float) this.z;
pk.speedX = (float) this.motionX;
pk.speedY = (float) this.motionY;
pk.speedZ = (float) this.motionZ;
pk.metadata = this.dataProperties;
player.dataPacket(pk);
super.spawnTo(player);
}
示例5: onOpen
import cn.nukkit.Player; //导入依赖的package包/类
@Override
public void onOpen(Player who) {
super.onOpen(who);
if (this.getViewers().size() == 1) {
BlockEventPacket pk = new BlockEventPacket();
pk.x = (int) this.getHolder().getX();
pk.y = (int) this.getHolder().getY();
pk.z = (int) this.getHolder().getZ();
pk.case1 = 1;
pk.case2 = 2;
Level level = this.getHolder().getLevel();
if (level != null) {
level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk);
}
}
}
示例6: spawnTo
import cn.nukkit.Player; //导入依赖的package包/类
@Override
public void spawnTo(Player player) {
AddEntityPacket pk = new AddEntityPacket();
pk.entityUniqueId = this.getId();
pk.entityRuntimeId = this.getId();
pk.type = EntityLightning.NETWORK_ID;
pk.x = (float) this.x;
pk.y = (float) this.y;
pk.z = (float) this.z;
pk.speedX = 0;
pk.speedY = 0;
pk.speedZ = 0;
pk.yaw = (float) this.yaw;
pk.pitch = (float) this.pitch;
pk.metadata = this.dataProperties;
player.dataPacket(pk);
super.spawnTo(player);
}
示例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) {
if (target.isSolid()) {
int[] faces = new int[]{
0,
0,
1,
4,
8,
2
};
this.meta = faces[face.getIndex()];
this.getLevel().setBlock(block, this, true, true);
return true;
}
return false;
}
示例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) {
if (!target.isTransparent()) {
int damage = this.getDamage();
int[] faces = {1, 2, 3, 0};
this.meta = faces[player != null ? player.getDirection().getHorizontalIndex() : 0];
if (damage >= 4 && damage <= 7) {
this.meta |= 0x04;
} else if (damage >= 8 && damage <= 11) {
this.meta |= 0x08;
}
this.getLevel().setBlock(block, this, true);
return true;
}
return false;
}
示例9: spawnTo
import cn.nukkit.Player; //导入依赖的package包/类
@Override
public void spawnTo(Player player) {
AddEntityPacket packet = new AddEntityPacket();
packet.type = EntityFallingBlock.NETWORK_ID;
packet.entityUniqueId = this.getId();
packet.entityRuntimeId = getId();
packet.x = (float) x;
packet.y = (float) y;
packet.z = (float) z;
packet.speedX = (float) motionX;
packet.speedY = (float) motionY;
packet.speedZ = (float) motionZ;
packet.yaw = (float) yaw;
packet.pitch = (float) pitch;
packet.metadata = dataProperties;
player.dataPacket(packet);
super.spawnTo(player);
}
示例10: canUpdate
import cn.nukkit.Player; //导入依赖的package包/类
public boolean canUpdate() {
if (this.getNetworkId() == 0) {
return false;
}
int count = 0;
boolean hasPlayer = false;
AxisAlignedBB boundingBox = new AxisAlignedBB(x - 8.5, y - 4.5, z - 8.5, x + 8.5, y + 4.5, z + 8.5);
for (Entity entity : this.level.getNearbyEntities(boundingBox)) {
if (entity.getNetworkId() == this.getNetworkId()) {
++count;
}
if (entity instanceof Player) {
hasPlayer = true;
}
}
if (hasPlayer && count < 6) {
return true;
}
return false;
}
示例11: spawnTo
import cn.nukkit.Player; //导入依赖的package包/类
public void spawnTo(Player player) {
if (this.closed) {
return;
}
CompoundTag tag = this.getSpawnCompound();
BlockEntityDataPacket pk = new BlockEntityDataPacket();
pk.x = (int) this.x;
pk.y = (int) this.y;
pk.z = (int) this.z;
try {
pk.namedTag = NBTIO.write(tag, ByteOrder.LITTLE_ENDIAN, true);
} catch (IOException e) {
throw new RuntimeException(e);
}
player.dataPacket(pk);
}
示例12: 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.getId() == Block.WOOD && target.getDamage() == BlockWood.JUNGLE) {
if (face != BlockFace.DOWN && face != BlockFace.UP) {
int[] faces = new int[]{
0,
0,
0,
2,
3,
1,
};
this.meta = faces[face.getIndex()];
this.level.setBlock(block, this, true, true);
return true;
}
}
return false;
}
示例13: onActivate
import cn.nukkit.Player; //导入依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
if (item.getId() == Item.DYE && item.getDamage() == 0x0F) {
item.count--;
ObjectTallGrass.growGrass(this.getLevel(), this, new NukkitRandom(), 15, 10);
return true;
} else if (item.isHoe()) {
item.useOn(this);
this.getLevel().setBlock(this, new BlockFarmland());
return true;
} else if (item.isShovel()) {
item.useOn(this);
this.getLevel().setBlock(this, new BlockGrassPath());
return true;
}
return false;
}
示例14: sendArmorSlot
import cn.nukkit.Player; //导入依赖的package包/类
public void sendArmorSlot(int index, Player[] players) {
Item[] armor = this.getArmorContents();
MobArmorEquipmentPacket pk = new MobArmorEquipmentPacket();
pk.eid = this.getHolder().getId();
pk.slots = armor;
pk.encode();
pk.isEncoded = true;
for (Player player : players) {
if (player.equals(this.getHolder())) {
InventorySlotPacket pk2 = new InventorySlotPacket();
pk2.inventoryId = InventoryContentPacket.SPECIAL_ARMOR;
pk2.slot = index - this.getSize();
pk2.item = this.getItem(index);
player.dataPacket(pk2);
} else {
player.dataPacket(pk);
}
}
}
示例15: usebu
import cn.nukkit.Player; //导入依赖的package包/类
public void usebu(Player player,int rel,int cart,int kindid){
int now = cgun.get(player.getName()+"-"+kindid);
cgun.put(player.getName()+"-"+kindid,now-1);
player.sendPopup(lj.usebu_remaining+(now-1));
if(cgun.get(player.getName()+"-"+kindid) <= 0){
Server.getInstance().getScheduler().scheduleDelayedTask(new Runnable() {
@Override
public void run() {
cgun.put(player.getName()+"-"+kindid,cart);
player.sendPopup(lj.usebu_reloadcomp);
}
},20*rel);
cgun.put(player.getName()+"-"+kindid,0);
player.sendPopup(lj.usebu_relstart1+rel+lj.usebu_relstart2);
}
}