本文整理汇总了Java中cn.nukkit.inventory.PlayerInventory类的典型用法代码示例。如果您正苦于以下问题:Java PlayerInventory类的具体用法?Java PlayerInventory怎么用?Java PlayerInventory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlayerInventory类属于cn.nukkit.inventory包,在下文中一共展示了PlayerInventory类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getEmptySlots
import cn.nukkit.inventory.PlayerInventory; //导入依赖的package包/类
private int getEmptySlots(PlayerInventory inventory) {
int amount = 0;
for (Item item : inventory.getContents().values()) {
if (item == null || item.getId() < 1) {
amount++;
}
}
return amount;
}
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:10,代码来源:PurchasesTask.java
示例2: onCollideWithPlayer
import cn.nukkit.inventory.PlayerInventory; //导入依赖的package包/类
@Override
public void onCollideWithPlayer(Player player) {
if(this.getPickupDelay() > 0) {
return;
}
Item item = this.getItem();
PlayerInventory playerInventory = player.getInventory();
if(!(item instanceof Item) || (player.isSurvival() && !playerInventory.canAddItem(item))) {
return;
}
InventoryPickupItemEvent ev;
this.server.getPluginManager().callEvent(ev = new InventoryPickupItemEvent(playerInventory, this));
if(ev.isCancelled()) {
return;
}
TakeItemEntityPacket pk = new TakeItemEntityPacket();
pk.entityRuntimeId = player.getId();
pk.target = this.getId();
Server.broadcastPacket(this.getViewers().values(), pk);
playerInventory.addItem(item);
this.kill();
}
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:28,代码来源:EntityItem.java
示例3: onCollideWithPlayer
import cn.nukkit.inventory.PlayerInventory; //导入依赖的package包/类
@Override
public void onCollideWithPlayer(Player player) {
if(!this.hadCollision) {
return;
}
Item item = new Item(Item.ARROW, 0, 1);
PlayerInventory playerInventory = player.getInventory();
if(player.isSurvival() && playerInventory.canAddItem(item)) {
return;
}
InventoryPickupArrowEvent ev;
this.server.getPluginManager().callEvent(ev = new InventoryPickupArrowEvent(playerInventory, this));
if(ev.isCancelled()) {
return;
}
TakeItemEntityPacket pk = new TakeItemEntityPacket();
pk.entityRuntimeId = player.getId();
pk.target = this.getId();
Server.broadcastPacket(this.getViewers().values(), pk);
playerInventory.addItem(item);
this.kill();
}
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:28,代码来源:EntityArrow.java
示例4: sendAllInventories
import cn.nukkit.inventory.PlayerInventory; //导入依赖的package包/类
public void sendAllInventories() {
for (Inventory inv : this.windowIndex.values()) {
inv.sendContents(this);
if (inv instanceof PlayerInventory) {
((PlayerInventory) inv).sendArmorContents(this);
}
}
}
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:10,代码来源:Player.java
示例5: onPlayerItemHoldEvent
import cn.nukkit.inventory.PlayerInventory; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerItemHoldEvent(final PlayerItemHeldEvent event) {
Player nukkitPlayer = event.getPlayer();
if (nukkitPlayer.isSneaking()) {
return;
}
FawePlayer<Object> fp = FawePlayer.wrap(nukkitPlayer);
com.sk89q.worldedit.entity.Player player = fp.getPlayer();
LocalSession session = fp.getSession();
Tool tool = session.getTool(player);
if (tool instanceof ScrollTool) {
final int slot = event.getInventorySlot();
final int oldSlot = event.getSlot();
final int ri;
if ((((slot - oldSlot) <= 4) && ((slot - oldSlot) > 0)) || (((slot - oldSlot) < -4))) {
ri = 1;
} else {
ri = -1;
}
ScrollTool scrollable = (ScrollTool) tool;
if (scrollable.increment(player, ri)) {
final PlayerInventory inv = nukkitPlayer.getInventory();
final Item item = inv.getItem(slot);
final Item newItem = inv.getItem(oldSlot);
inv.setItem(slot, newItem);
inv.setItem(oldSlot, item);
inv.sendContents(nukkitPlayer);
}
}
}
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:31,代码来源:BrushListener.java
示例6: loadInventory
import cn.nukkit.inventory.PlayerInventory; //导入依赖的package包/类
/**
* Loads inventory on first use.
*/
private void loadInventory() {
if (items == null) {
PlayerInventory inv = player.getInventory();
items = inv.getContents();
this.size = inv.getSize();
}
}
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:11,代码来源:NukkitPlayerBlockBag.java
示例7: getBlockInHand
import cn.nukkit.inventory.PlayerInventory; //导入依赖的package包/类
@Override
public BaseBlock getBlockInHand() throws WorldEditException {
PlayerInventory inv = player.getInventory();
Item itemStack = inv.getItemInHand();
if (itemStack == null) {
return EditSession.nullBlock;
}
return new BaseBlock(itemStack.getId(), itemStack.getMaxDurability() != 0 ? 0 : itemStack.getDamage());
}
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:10,代码来源:NukkitPlayer.java
示例8: getItems
import cn.nukkit.inventory.PlayerInventory; //导入依赖的package包/类
@Override
public PlotItemStack[] getItems(PlotPlayer player) {
NukkitPlayer bp = (NukkitPlayer) player;
PlayerInventory inv = bp.player.getInventory();
PlotItemStack[] items = new PlotItemStack[36];
for (int i = 0; i < 36; i++) {
items[i] = getItem(inv.getItem(i));
}
return items;
}
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:11,代码来源:NukkitInventoryUtil.java
示例9: getInventory
import cn.nukkit.inventory.PlayerInventory; //导入依赖的package包/类
@Override
public PlayerInventory getInventory() {
return inventory;
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:5,代码来源:EntityHumanType.java
示例10: initEntity
import cn.nukkit.inventory.PlayerInventory; //导入依赖的package包/类
@Override
protected void initEntity() {
this.setDataFlag(DATA_PLAYER_FLAGS, DATA_PLAYER_FLAG_SLEEP, false);
this.setDataProperty(new PositionEntityData(DATA_PLAYER_BED_POSITION, 0, 0, 0), false);
this.inventory = new PlayerInventory(this);
if (this instanceof Player) {
((Player) this).addWindow(this.inventory, 0);
}
if (!(this instanceof Player)) {
if (this.namedTag.contains("NameTag")) {
this.setNameTag(this.namedTag.getString("NameTag"));
}
if (this.namedTag.contains("Skin") && this.namedTag.get("Skin") instanceof CompoundTag) {
if (!this.namedTag.getCompound("Skin").contains("Transparent")) {
this.namedTag.getCompound("Skin").putBoolean("Transparent", false);
}
this.setSkin(new Skin(this.namedTag.getCompound("Skin").getByteArray("Data"), this.namedTag.getCompound("Skin").getString("ModelId")));
}
this.uuid = Utils.dataToUUID(String.valueOf(this.getId()).getBytes(StandardCharsets.UTF_8), this.getSkin()
.getData(), this.getNameTag().getBytes(StandardCharsets.UTF_8));
}
if (this.namedTag.contains("Inventory") && this.namedTag.get("Inventory") instanceof ListTag) {
ListTag<CompoundTag> inventoryList = this.namedTag.getList("Inventory", CompoundTag.class);
for (CompoundTag item : inventoryList.getAll()) {
int slot = item.getByte("Slot");
if (slot >= 0 && slot < 9) {
this.inventory.setHotbarSlotIndex(slot, item.contains("TrueSlot") ? item.getByte("TrueSlot") : -1);
} else if (slot >= 100 && slot < 104) {
this.inventory.setItem(this.inventory.getSize() + slot - 100, NBTIO.getItemHelper(item));
} else {
this.inventory.setItem(slot - 9, NBTIO.getItemHelper(item));
}
}
}
super.initEntity();
}
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:44,代码来源:EntityHuman.java
示例11: getItemInHand
import cn.nukkit.inventory.PlayerInventory; //导入依赖的package包/类
@Override
public int getItemInHand() {
PlayerInventory inv = player.getInventory();
Item itemStack = inv.getItemInHand();
return itemStack != null ? itemStack.getId() : 0;
}
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:7,代码来源:NukkitPlayer.java
注:本文中的cn.nukkit.inventory.PlayerInventory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论