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