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