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


Java Player.getWindowId方法代碼示例

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


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

示例1: sendContents

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void sendContents(Player[] players) {
    InventoryContentPacket pk = new InventoryContentPacket();
    pk.slots = new Item[this.getSize()];
    for (int i = 0; i < this.getSize(); ++i) {
        pk.slots[i] = this.getItem(i);
    }

    /*//Because PE is stupid and shows 9 less slots than you send it, give it 9 dummy slots so it shows all the REAL slots.
    for(int i = this.getSize(); i < this.getSize() + this.getHotbarSize(); ++i){
        pk.slots[i] = new ItemBlock(new BlockAir());
    }
        pk.slots[i] = new ItemBlock(new BlockAir());
    }*/

    for (Player player : players) {
        int id = player.getWindowId(this);
        if (id == -1 || !player.spawned) {
            this.close(player);
            continue;
        }
        pk.inventoryId = id;
        player.dataPacket(pk.clone());

    }
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:27,代碼來源:PlayerInventory.java

示例2: sendSlot

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void sendSlot(int index, Player... players) {
    InventorySlotPacket pk = new InventorySlotPacket();
    pk.slot = index;
    pk.item = this.getItem(index).clone();

    for (Player player : players) {
        if (player.equals(this.getHolder())) {
            pk.inventoryId = ContainerIds.INVENTORY;
            player.dataPacket(pk);
        } else {
            int id = player.getWindowId(this);
            if (id == -1) {
                this.close(player);
                continue;
            }
            pk.inventoryId = id;
            player.dataPacket(pk.clone());
        }
    }
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:22,代碼來源:PlayerInventory.java

示例3: sendContents

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void sendContents(Player... players) {
    InventoryContentPacket pk = new InventoryContentPacket();
    pk.slots = new Item[this.getSize()];
    for (int i = 0; i < this.getSize(); ++i) {
        pk.slots[i] = this.getItem(i);
    }

    for (Player player : players) {
        int id = player.getWindowId(this);
        if (id == -1 || !player.spawned) {
            this.close(player);
            continue;
        }
        pk.inventoryId = id;
        player.dataPacket(pk);
    }
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:19,代碼來源:BaseInventory.java

示例4: sendSlot

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void sendSlot(int index, Player[] players) {
    ContainerSetSlotPacket pk = new ContainerSetSlotPacket();
    pk.slot = index;
    pk.item = this.getItem(index).clone();

    for (Player player : players) {
        if (player.equals(this.getHolder())) {
            pk.windowid = 0;
            player.dataPacket(pk);
        } else {
            int id = player.getWindowId(this);
            if (id == -1) {
                this.close(player);
                continue;
            }
            pk.windowid = (byte) id;
            player.dataPacket(pk.clone());
        }
    }
}
 
開發者ID:CoreXDevelopment,項目名稱:CoreX,代碼行數:22,代碼來源:PlayerInventory.java

示例5: sendContents

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void sendContents(Player[] players) {
    ContainerSetContentPacket pk = new ContainerSetContentPacket();
    pk.slots = new Item[this.getSize()];
    for (int i = 0; i < this.getSize(); ++i) {
        pk.slots[i] = this.getItem(i);
    }

    for (Player player : players) {
        pk.eid = player.getId();
        int id = player.getWindowId(this);
        if (id == -1 || !player.spawned) {
            this.close(player);
            continue;
        }
        pk.windowid = (byte) id;
        player.dataPacket(pk);
    }
}
 
開發者ID:CoreXDevelopment,項目名稱:CoreX,代碼行數:20,代碼來源:BaseInventory.java

示例6: onOpen

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void onOpen(Player who) {
    CompoundTag nbt = this.getHolder().getOffers();
    if (nbt != null) {
        super.onOpen(who);

        UpdateTradePacket pk1 = new UpdateTradePacket();
        pk1.windowId = (byte) who.getWindowId(this);
        pk1.windowType = 15;
        pk1.unknownVarInt1 = 0;
        pk1.unknownVarInt2 = 0;
        pk1.isWilling = false;
        pk1.trader = this.getHolder().getId();
        pk1.player = who.getId();
        pk1.displayName = this.getHolder().getName();
        try {
            pk1.offers = NBTIO.write(nbt, ByteOrder.LITTLE_ENDIAN, true);
        } catch (IOException e) {
            e.printStackTrace();
        }
        who.dataPacket(pk1);
    } else {
        super.onClose(who);
    }
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:26,代碼來源:TradingInventory.java

示例7: sendFuel

import cn.nukkit.Player; //導入方法依賴的package包/類
protected void sendFuel() {
    ContainerSetDataPacket pk = new ContainerSetDataPacket();

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

            pk.property = ContainerSetDataPacket.PROPERTY_BREWING_STAND_FUEL_AMOUNT;
            pk.value = this.fuelAmount;
            p.dataPacket(pk);

            pk.property = ContainerSetDataPacket.PROPERTY_BREWING_STAND_FUEL_TOTAL;
            pk.value = this.fuelTotal;
            p.dataPacket(pk);
        }
    }
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:19,代碼來源:BlockEntityBrewingStand.java

示例8: sendSlot

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void sendSlot(int index, Player[] players) {
    ContainerSetSlotPacket pk = new ContainerSetSlotPacket();
    pk.slot = index;
    pk.item = this.getItem(index).clone();

    for (Player player : players) {
        int id = player.getWindowId(this);
        if (id == -1) {
            this.close(player);
            continue;
        }
        pk.windowid = (byte) id;
        player.dataPacket(pk);
    }
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:17,代碼來源:BaseInventory.java

示例9: sendSlot

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void sendSlot(int index, Player... players) {
    InventorySlotPacket pk = new InventorySlotPacket();
    pk.slot = index;
    pk.item = this.getItem(index);

    for (Player player : players) {
        int id = player.getWindowId(this);
        if (id == -1) {
            this.close(player);
            continue;
        }
        pk.inventoryId = id;
        player.dataPacket(pk);
    }
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:17,代碼來源:BaseInventory.java

示例10: onOpen

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void onOpen(Player who) {
    super.onOpen(who);
    ContainerOpenPacket pk = new ContainerOpenPacket();
    pk.windowid = (byte) who.getWindowId(this);
    pk.type = (byte) this.getType().getNetworkType();
    pk.slots = this.getSize();
    InventoryHolder holder = this.getHolder();
    if (holder instanceof Vector3) {
        pk.x = (int) ((Vector3) holder).getX();
        pk.y = (int) ((Vector3) holder).getY();
        pk.z = (int) ((Vector3) holder).getZ();
    } else {
        pk.x = pk.y = pk.z = 0;
    }

    who.dataPacket(pk);

    this.sendContents(who);
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:21,代碼來源:ContainerInventory.java

示例11: sendContents

import cn.nukkit.Player; //導入方法依賴的package包/類
public void sendContents(Player... players) {
	InventoryContentPacket pk = new InventoryContentPacket();
	pk.slots = new Item[this.getSize()];
	for (int i = 0; i < this.getSize(); ++i) {
		pk.slots[i] = this.getItem(i);
	}

	for (Player player : players) {
		int id = player.getWindowId(this);
		if (id == -1 || !player.spawned) {
			this.close(player);
			continue;
		}
		pk.inventoryId = id;
		player.dataPacket(pk.clone());
	}
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:18,代碼來源:PlayerOffhandInventory.java

示例12: onClose

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void onClose(Player who) {
    ContainerClosePacket pk = new ContainerClosePacket();
    pk.windowId = who.getWindowId(this);
    who.dataPacket(pk);
    super.onClose(who);
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:8,代碼來源:ContainerInventory.java

示例13: onOpen

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void onOpen(Player who) {
    if (who != this.getHolder()) {
        return;
    }
    super.onOpen(who);
    ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket();
    containerOpenPacket.windowId = who.getWindowId(this);
    containerOpenPacket.type = this.getType().getNetworkType();
    BlockEnderChest chest = who.getViewingEnderChest();
    if (chest != null) {
        containerOpenPacket.x = (int) chest.getX();
        containerOpenPacket.y = (int) chest.getY();
        containerOpenPacket.z = (int) chest.getZ();
    } else {
        containerOpenPacket.x = containerOpenPacket.y = containerOpenPacket.z = 0;
    }

    who.dataPacket(containerOpenPacket);

    this.sendContents(who);

    if (chest != null && chest.getViewers().size() == 1) {
        BlockEventPacket blockEventPacket = new BlockEventPacket();
        blockEventPacket.x = (int) chest.getX();
        blockEventPacket.y = (int) chest.getY();
        blockEventPacket.z = (int) chest.getZ();
        blockEventPacket.case1 = 1;
        blockEventPacket.case2 = 2;

        Level level = this.getHolder().getLevel();
        if (level != null) {
            level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_CHEST_OPEN, 1, -1, this.getHolder().add(0.5, 0.5, 0.5));
            level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, blockEventPacket);
        }
    }
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:38,代碼來源:PlayerEnderChestInventory.java

示例14: 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

示例15: onOpen

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public void onOpen(Player who) {
    if (who != this.getHolder()) {
        return;
    }
    super.onOpen(who);
    ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket();
    containerOpenPacket.windowid = (byte) who.getWindowId(this);
    containerOpenPacket.type = (byte) this.getType().getNetworkType();
    BlockEnderChest chest = who.getViewingEnderChest();
    if (chest != null) {
        containerOpenPacket.x = (int) chest.getX();
        containerOpenPacket.y = (int) chest.getY();
        containerOpenPacket.z = (int) chest.getZ();
    } else {
        containerOpenPacket.x = containerOpenPacket.y = containerOpenPacket.z = 0;
    }

    who.dataPacket(containerOpenPacket);

    this.sendContents(who);

    if (chest != null && chest.getViewers().size() == 1) {
        BlockEventPacket blockEventPacket = new BlockEventPacket();
        blockEventPacket.x = (int) chest.getX();
        blockEventPacket.y = (int) chest.getY();
        blockEventPacket.z = (int) chest.getZ();
        blockEventPacket.case1 = 1;
        blockEventPacket.case2 = 2;

        Level level = this.getHolder().getLevel();
        if (level != null) {
            level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, blockEventPacket);
        }
    }
}
 
開發者ID:CoreXDevelopment,項目名稱:CoreX,代碼行數:37,代碼來源:PlayerEnderChestInventory.java


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