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


Java Player.addWindow方法代碼示例

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


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

示例1: onActivate

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onActivate(Item item, Player player) {
    BlockEntity blockEntity = this.level.getBlockEntity(this);

    if (blockEntity instanceof BlockEntityHopper) {
        return player.addWindow(((BlockEntityHopper) blockEntity).getInventory()) != -1;
    }

    return false;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:11,代碼來源:BlockHopper.java

示例2: onActivate

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onActivate(Item item, Player player) {
    if (player != null) {
        player.addWindow(new AnvilInventory(this), Player.ANVIL_WINDOW_ID);
    }
    return true;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:8,代碼來源:BlockAnvil.java

示例3: onActivate

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onActivate(Item item, Player player) {
    if (player != null) {
        BlockEntity t = getLevel().getBlockEntity(this);
        BlockEntityDispenser dispenser;
        if (t instanceof BlockEntityDispenser) {
            dispenser = (BlockEntityDispenser) t;
        } else {
            CompoundTag nbt = new CompoundTag()
                    .putList(new ListTag<>("Items"))
                    .putString("id", BlockEntity.DISPENSER)
                    .putInt("x", (int) this.x)
                    .putInt("y", (int) this.y)
                    .putInt("z", (int) this.z);
            dispenser = new BlockEntityDispenser(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt);
        }

        if (dispenser.namedTag.contains("Lock") && dispenser.namedTag.get("Lock") instanceof StringTag) {
            if (!dispenser.namedTag.getString("Lock").equals(item.getCustomName())) {
                return false;
            }
        }

        player.addWindow(dispenser.getInventory());
    }

    return true;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:29,代碼來源:BlockDispenser.java

示例4: onActivate

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onActivate(Item item, Player player) {
    if (player != null) {
        Block top = up();
        if (!top.isTransparent()) {
            return true;
        }

        BlockEntity t = this.getLevel().getBlockEntity(this);
        BlockEntityShulkerBox shulkerBox;
        if (t instanceof BlockEntityShulkerBox) {
            shulkerBox = (BlockEntityShulkerBox) t;
        } else {
            CompoundTag nbt = new CompoundTag("")
                    .putString("id", BlockEntity.SHULKER_BOX)
                    .putInt("x", (int) this.x)
                    .putInt("y", (int) this.y)
                    .putInt("z", (int) this.z);
            shulkerBox = new BlockEntityShulkerBox(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt);
        }

        if (shulkerBox.namedTag.contains("Lock") && shulkerBox.namedTag.get("Lock") instanceof StringTag) {
            if (!shulkerBox.namedTag.getString("Lock").equals(item.getCustomName())) {
                return true;
            }
        }

        player.addWindow(shulkerBox.getInventory());
    }

    return true;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:33,代碼來源:BlockShulkerBoxUndyed.java

示例5: onActivate

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onActivate(Item item, Player player) {
    if (player != null) {
        BlockEntity t = getLevel().getBlockEntity(this);
        BlockEntityDropper dropper;
        if (t instanceof BlockEntityDropper) {
            dropper = (BlockEntityDropper) t;
        } else {
            CompoundTag nbt = new CompoundTag()
                    .putList(new ListTag<>("Items"))
                    .putString("id", BlockEntity.DROPPER)
                    .putInt("x", (int) this.x)
                    .putInt("y", (int) this.y)
                    .putInt("z", (int) this.z);
            dropper = new BlockEntityDropper(this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt);
        }

        if (dropper.namedTag.contains("Lock") && dropper.namedTag.get("Lock") instanceof StringTag) {
            if (!dropper.namedTag.getString("Lock").equals(item.getCustomName())) {
                return false;
            }
        }

        player.addWindow(dropper.getInventory());
    }

    return true;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:29,代碼來源:BlockDropper.java

示例6: onActivate

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onActivate(Item item, Player player) {
    if (player != null) {
        player.addWindow(new AnvilInventory(this));
    }
    return true;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:8,代碼來源:BlockAnvil.java

示例7: onInteract

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onInteract(Player player, Item item) {
    player.addWindow(this.getInventory());
    return true;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:6,代碼來源:EntityVillager.java

示例8: onActivate

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onActivate(Item item, Player player) {
    player.addWindow(new BeaconInventory(this));
    return true;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:6,代碼來源:BlockBeacon.java


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