当前位置: 首页>>代码示例>>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;未经允许,请勿转载。