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


Java Player.dataPacket方法代碼示例

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


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

示例1: 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,代碼來源:EntityChicken.java

示例2: spawnTo

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void spawnTo(Player player) {
    AddEntityPacket pk = new AddEntityPacket();
    pk.type = EntityExpBottle.NETWORK_ID;
    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:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:18,代碼來源:EntityExpBottle.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: sendToPlayer

import cn.nukkit.Player; //導入方法依賴的package包/類
/**
 * プレイヤーに送信します
 * @param  Player
 * @param  int
 * @return boolean
 */
public boolean sendToPlayer(Player player, int type) {
  switch (type) {
    case SEND_TYPE_ADD:
      AddPlayerPacket apk = getAsAddPacket();
      if (canEditFt(player)) {
        String str = TextFormat.GRAY + "[" + String.valueOf(eid) + "] " + TextFormat.RESET + TextFormat.WHITE + title + "\n" + text;
        apk.metadata.putString(Entity.DATA_TYPE_STRING, str);
      }
      player.dataPacket(apk);
      break;

    case SEND_TYPE_REMOVE:
      RemoveEntityPacket rpk = getAsRemovePacket();
      player.dataPacket(rpk);
      break;

    default:
      return false;
  }
  return true;
}
 
開發者ID:fuyutsuki,項目名稱:Texter_nukkit,代碼行數:28,代碼來源:FloatingText.java

示例5: spawnTo

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void spawnTo(Player player) {
    AddEntityPacket pk = new AddEntityPacket();
    pk.type = EntitySnowball.NETWORK_ID;
    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:CoreXDevelopment,項目名稱:CoreX,代碼行數:18,代碼來源:EntitySnowball.java

示例6: spawnTo

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void spawnTo(Player player) {
    AddEntityPacket pk = new AddEntityPacket();
    pk.type = EntityFireball.NETWORK_ID;
    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:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:18,代碼來源:EntityFireball.java

示例7: spawnTo

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void spawnTo(Player player) {
    if (this != player && !this.hasSpawned.containsKey(player.getLoaderId())) {
        this.hasSpawned.put(player.getLoaderId(), player);

        if (this.skin.getData().length < 64 * 32 * 4) {
            throw new IllegalStateException(this.getClass().getSimpleName() + " must have a valid skin set");
        }

        if (this instanceof Player)
            this.server.updatePlayerListData(this.getUniqueId(), this.getId(), this.getName(), this.skin, ((Player) this).getLoginChainData().getXUID(), new Player[]{player});
        else
            this.server.updatePlayerListData(this.getUniqueId(), this.getId(), this.getName(), this.skin, new Player[]{player});

        AddPlayerPacket pk = new AddPlayerPacket();
        pk.uuid = this.getUniqueId();
        pk.username = this.getName();
        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.yaw = (float) this.yaw;
        pk.pitch = (float) this.pitch;
        pk.item = this.getInventory().getItemInHand();
        pk.metadata = this.dataProperties;
        player.dataPacket(pk);

        this.inventory.sendArmorContents(player);

        if (!(this instanceof Player)) {
            this.server.removePlayerListData(this.getUniqueId(), new Player[]{player});
        }
    }
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:39,代碼來源:EntityHuman.java

示例8: sendImage

import cn.nukkit.Player; //導入方法依賴的package包/類
public void sendImage(Player p) {
    BufferedImage image = loadImageFromNBT();

    ClientboundMapItemDataPacket pk = new ClientboundMapItemDataPacket();
    pk.mapId = getMapId();
    pk.update = 2;
    pk.scale = 0;
    pk.width = 128;
    pk.height = 128;
    pk.offsetX = 0;
    pk.offsetZ = 0;
    pk.image = image;

    p.dataPacket(pk);
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:16,代碼來源:ItemMap.java

示例9: sendBrewTime

import cn.nukkit.Player; //導入方法依賴的package包/類
protected void sendBrewTime() {
    ContainerSetDataPacket pk = new ContainerSetDataPacket();
    pk.property = ContainerSetDataPacket.PROPERTY_BREWING_STAND_BREW_TIME;
    pk.value = this.brewTime;

    for (Player p : this.inventory.getViewers()) {
        int windowId = p.getWindowId(this.inventory);
        if (windowId > 0) {
            pk.windowId = windowId;

            p.dataPacket(pk);
        }
    }
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:15,代碼來源:BlockEntityBrewingStand.java

示例10: sendData

import cn.nukkit.Player; //導入方法依賴的package包/類
public void sendData(Player player, EntityMetadata data) {
    SetEntityDataPacket pk = new SetEntityDataPacket();
    pk.eid = this.getId();
    pk.metadata = data == null ? this.dataProperties : data;

    player.dataPacket(pk);
}
 
開發者ID:CoreXDevelopment,項目名稱:CoreX,代碼行數:8,代碼來源:Entity.java

示例11: despawnFrom

import cn.nukkit.Player; //導入方法依賴的package包/類
public void despawnFrom(Player player) {
    if (this.hasSpawned.containsKey(player.getLoaderId())) {
        RemoveEntityPacket pk = new RemoveEntityPacket();
        pk.eid = this.getId();
        player.dataPacket(pk);
        this.hasSpawned.remove(player.getLoaderId());
    }
}
 
開發者ID:CoreXDevelopment,項目名稱:CoreX,代碼行數:9,代碼來源:Entity.java

示例12: onUpdate

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onUpdate() {
    if (closed) {
        return false;
    }

    boolean ret = false;

    Item ingredient = this.inventory.getIngredient();
    boolean canBrew = false;

    for (int i = 1; i <= 3; i++) {
        if (this.inventory.getItem(i).getId() == Item.POTION) {
            canBrew = true;
        }
    }

    if (this.brewTime <= MAX_BREW_TIME && canBrew && ingredient.getCount() > 0) {
        if (!this.checkIngredient(ingredient)) {
            canBrew = false;
        }
    } else {
        canBrew = false;
    }

    if (canBrew) {
        this.brewTime--;

        for (Player player : this.inventory.getViewers()) {
            int windowId = player.getWindowId(this.inventory);
            if (windowId > 0) {
                ContainerSetDataPacket pk = new ContainerSetDataPacket();
                pk.windowid = (byte) windowId;
                pk.property = 0;
                pk.value = this.brewTime;
                player.dataPacket(pk);
            }
        }

        if (this.brewTime <= 0) { //20 seconds
            for (int i = 1; i <= 3; i++) {
                Item potion = this.inventory.getItem(i);
                BrewingRecipe recipe = Server.getInstance().getCraftingManager().matchBrewingRecipe(ingredient, potion);

                if (recipe != null) {
                    this.inventory.setItem(i, recipe.getResult());
                }
            }

            ingredient.count--;
            this.inventory.setIngredient(ingredient);

            this.brewTime = MAX_BREW_TIME;
        }

        ret = true;
    } else {
        this.brewTime = MAX_BREW_TIME;
    }

    lastUpdate = System.currentTimeMillis();

    return ret;
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:65,代碼來源:BlockEntityBrewingStand.java


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