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


Java Player類代碼示例

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

}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:26,代碼來源:EnchantInventory.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) {
    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;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:27,代碼來源:BlockEnderChest.java

示例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);
}
 
開發者ID:CoreXDevelopment,項目名稱:CoreX,代碼行數:19,代碼來源:EntityXPOrb.java

示例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);
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:18,代碼來源:EntityMagmaCube.java

示例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);
        }
    }
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:19,代碼來源:DispenserInventory.java

示例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);
}
 
開發者ID:CoreXDevelopment,項目名稱:CoreX,代碼行數:20,代碼來源:EntityLightning.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) {
    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;
}
 
開發者ID:CoreXDevelopment,項目名稱:CoreX,代碼行數:18,代碼來源:BlockVine.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) {
    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;
}
 
開發者ID:CoreXDevelopment,項目名稱:CoreX,代碼行數:17,代碼來源:BlockAnvil.java

示例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);
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:19,代碼來源:EntityFallingBlock.java

示例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;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:25,代碼來源:BlockEntityMobSpawner.java

示例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);
}
 
開發者ID:CoreXDevelopment,項目名稱:CoreX,代碼行數:18,代碼來源:BlockEntitySpawnable.java

示例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;
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:21,代碼來源:BlockCocoa.java

示例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;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:19,代碼來源:BlockGrass.java

示例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);
        }
    }
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:22,代碼來源:PlayerInventory.java

示例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);
 }
}
 
開發者ID:haniokasai,項目名稱:NuclearGunWars-plugin,代碼行數:18,代碼來源:gunsys.java


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