当前位置: 首页>>代码示例>>Java>>正文


Java BlockAir类代码示例

本文整理汇总了Java中cn.nukkit.block.BlockAir的典型用法代码示例。如果您正苦于以下问题:Java BlockAir类的具体用法?Java BlockAir怎么用?Java BlockAir使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BlockAir类属于cn.nukkit.block包,在下文中一共展示了BlockAir类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setArmorContents

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
public void setArmorContents(Item[] items) {
    if (items.length < 4) {
        Item[] newItems = new Item[4];
        System.arraycopy(items, 0, newItems, 0, items.length);
        items = newItems;
    }

    for (int i = 0; i < 4; ++i) {
        if (items[i] == null) {
            items[i] = new ItemBlock(new BlockAir(), null, 0);
        }

        if (items[i].getId() == Item.AIR) {
            this.clear(this.getSize() + i);
        } else {
            this.setItem(this.getSize() + i, items[i]);
        }
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:20,代码来源:PlayerInventory.java

示例2: getSpawnCompound

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
@Override
public CompoundTag getSpawnCompound() {
    if (!this.namedTag.contains("Item")) {
        this.setItem(new ItemBlock(new BlockAir()), false);
    }
    CompoundTag NBTItem = namedTag.getCompound("Item").copy();
    NBTItem.setName("Item");
    boolean item = NBTItem.getShort("id") == Item.AIR;
    return new CompoundTag()
            .putString("id", BlockEntity.ITEM_FRAME)
            .putInt("x", (int) this.x)
            .putInt("y", (int) this.y)
            .putInt("z", (int) this.z)
            .putCompound("Item", item ? NBTIO.putItemHelper(new ItemBlock(new BlockAir())) : NBTItem)
            .putByte("ItemRotation", item ? 0 : this.getItemRotation());
    // TODO: This crashes the client, why?
    // .putFloat("ItemDropChance", this.getItemDropChance());
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:19,代码来源:BlockEntityItemFrame.java

示例3: getSpawnCompound

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
@Override
public CompoundTag getSpawnCompound() {
    if (!this.namedTag.contains("Item")) {
        this.setItem(new ItemBlock(new BlockAir()), false);
    }
    CompoundTag NBTItem = namedTag.getCompound("Item").copy();
    NBTItem.setName("Item");
    boolean item = NBTItem.getShort("id") == Item.AIR;
    return new CompoundTag()
            .putString("id", BlockEntity.ITEM_FRAME)
            .putInt("x", (int) this.x)
            .putInt("y", (int) this.y)
            .putInt("z", (int) this.z)
            .putCompound("Item", item ? NBTIO.putItemHelper(new ItemBlock(new BlockAir())) : NBTItem)
            .putByte("ItemRotation", item ? 0 : this.getItemRotation());
            // TODO: This crashes the client, why?
            // .putFloat("ItemDropChance", this.getItemDropChance());
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:19,代码来源:BlockEntityItemFrame.java

示例4: setArmorContents

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
public void setArmorContents(Item[] items) {
    if (items.length < 4) {
        Item[] newItems = new Item[4];
        System.arraycopy(items, 0, newItems, 0, items.length);
        items = newItems;
    }

    for (int i = 0; i < 4; ++i) {
        if (items[i] == null) {
            items[i] = new ItemBlock(new BlockAir(), null, 0);
        }

        if (items[i].getId() == Item.AIR) {
            this.clear(this.getSize() + i);
        } else {
            this.setItem(this.getSize() + 1, items[i]);
        }
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:20,代码来源:PlayerInventory.java

示例5: checkFuel

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
protected void checkFuel(Item fuel) {

        FurnaceBurnEvent ev = new FurnaceBurnEvent(this, fuel, fuel.getFuelTime() == null ? 0 : fuel.getFuelTime());

        if (ev.isCancelled()) {
            return;
        }

        this.namedTag.putShort("MaxTime", ev.getBurnTime());
        this.namedTag.putShort("BurnTime", ev.getBurnTime());
        this.namedTag.putShort("BurnDuration", 0);
        if (this.getBlock().getId() == Item.FURNACE) {
            this.getLevel().setBlock(this, new BlockFurnaceBurning(this.getBlock().getDamage()), true);
        }

        if (this.namedTag.getShort("BurnTime") > 0 && ev.isBurning()) {
            fuel.setCount(fuel.getCount() - 1);
            if (fuel.getCount() == 0) {
                fuel = new ItemBlock(new BlockAir(), 0, 0);
            }
            this.inventory.setFuel(fuel);
        }
    }
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:24,代码来源:BlockEntityFurnace.java

示例6: getSpawnCompound

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
@Override
public CompoundTag getSpawnCompound() {
    if (!this.namedTag.contains("Item")) {
        this.setItem(new ItemBlock(new BlockAir()), false);
    }
    CompoundTag NBTItem = namedTag.getCompound("Item").copy();
    NBTItem.setName("Item");
    boolean item = NBTItem.getShort("id") == Item.AIR;
    return new CompoundTag()
            .putString("id", BlockEntity.ITEM_FRAME)
            .putInt("x", (int) this.x)
            .putInt("y", (int) this.y)
            .putInt("z", (int) this.z)
            .putCompound("Item", item ? NBTIO.putItemHelper(new ItemBlock(new BlockAir())) : NBTItem)
            .putByte("ItemRotation", item ? 0 : this.getItemRotation())
            .putFloat("ItemDropChance", this.getItemDropChance());

}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:19,代码来源:BlockEntityItemFrame.java

示例7: checkFuel

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
protected void checkFuel(Item fuel) {

        FurnaceBurnEvent ev = new FurnaceBurnEvent(this, fuel, fuel.getFuelTime() == null ? 0 : fuel.getFuelTime());

        if (ev.isCancelled()) {
            return;
        }

        maxTime = ev.getBurnTime();
        burnTime = ev.getBurnTime();
        burnDuration = 0;
        if (this.getBlock().getId() == Item.FURNACE) {
            this.getLevel().setBlock(this, new BlockFurnaceBurning(this.getBlock().getDamage()), true);
        }

        if (burnTime > 0 && ev.isBurning()) {
            fuel.setCount(fuel.getCount() - 1);
            if (fuel.getCount() == 0) {
                fuel = new ItemBlock(new BlockAir(), 0, 0);
            }
            this.inventory.setFuel(fuel);
        }
    }
 
开发者ID:NycuRO,项目名称:Apollo-OLD,代码行数:24,代码来源:BlockEntityFurnace.java

示例8: execute

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
public boolean execute(CommandSender sender, String label, String[] args) {
    if (!this.testPermission(sender)) {
        return false;
    }
    if (!this.testIngame(sender)) {
        return false;
    }
    if (args.length != 0) {
        this.sendUsage(sender);
        return false;
    }
    Player player = (Player) sender;
    Block block = player.getTargetBlock(120, new Integer[]{Block.AIR});
    if (block == null) {
        sender.sendMessage(TextFormat.RED + lang.translateString("commands.break.unreachable"));
        return false;
    }
    if (block.getId() == Block.BEDROCK && !sender.hasPermission("essentialsnk.break.bedrock")) {
        sender.sendMessage(TextFormat.RED + lang.translateString("commands.break.bedrock"));
        return false;
    }
    player.getLevel().setBlock(block, new BlockAir(), true, true);
    return true;
}
 
开发者ID:yescallop,项目名称:EssentialsNK,代码行数:25,代码来源:BreakCommand.java

示例9: getBlock

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
public Block getBlock() {
    if (this.block != null) {
        return this.block.clone();
    } else {
        return new BlockAir();
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:8,代码来源:Item.java

示例10: getItemInHand

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
public Item getItemInHand() {
    Item item = this.getItem(this.getHeldItemIndex());
    if (item != null) {
        return item;
    } else {
        return new ItemBlock(new BlockAir(), 0, 0);
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:9,代码来源:PlayerInventory.java

示例11: clear

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
@Override
public boolean clear(int index, boolean send) {
    if (this.slots.containsKey(index)) {
        Item item = new ItemBlock(new BlockAir(), null, 0);
        Item old = this.slots.get(index);
        InventoryHolder holder = this.getHolder();
        if (holder instanceof Entity) {
            EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent((Entity) holder, old, item, index);
            Server.getInstance().getPluginManager().callEvent(ev);
            if (ev.isCancelled()) {
                this.sendSlot(index, this.getViewers());
                return false;
            }
            item = ev.getNewItem();
        }

        if (item.getId() != Item.AIR) {
            this.slots.put(index, item.clone());
        } else {
            this.slots.remove(index);
        }

        this.onSlotChange(index, old, send);
    }

    return true;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:28,代码来源:BaseInventory.java

示例12: getItem

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
@Override
public Item getItem(int index) {
    int i = this.getSlotIndex(index);
    if (i < 0) {
        return new ItemBlock(new BlockAir(), 0, 0);
    } else {
        CompoundTag data = (CompoundTag) this.namedTag.getList("Items").get(i);
        return NBTIO.getItemHelper(data);
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:11,代码来源:BlockEntityHopper.java

示例13: BlockEntityItemFrame

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
public BlockEntityItemFrame(FullChunk chunk, CompoundTag nbt) {
    super(chunk, nbt);
    if (!nbt.contains("Item")) {
        nbt.putCompound("Item", NBTIO.putItemHelper(new ItemBlock(new BlockAir())));
    }
    if (!nbt.contains("ItemRotation")) {
        nbt.putByte("ItemRotation", 0);
    }
    if (!nbt.contains("ItemDropChance")) {
        nbt.putFloat("ItemDropChance", 1.0f);
    }

    this.level.updateComparatorOutputLevel(this);
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:15,代码来源:BlockEntityItemFrame.java

示例14: clear

import cn.nukkit.block.BlockAir; //导入依赖的package包/类
@Override
public boolean clear(int index, boolean send) {
    if (this.slots.containsKey(index)) {
        Item item = new ItemBlock(new BlockAir(), null, 0);
        Item old = this.slots.get(index);
        InventoryHolder holder = this.getHolder();
        if (holder instanceof Entity) {
            EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent((Entity) holder, this, old, item, index);
            Server.getInstance().getPluginManager().callEvent(ev);
            if (ev.isCancelled()) {
                this.sendSlot(index, this.getViewers());
                return false;
            }
            item = ev.getNewItem();
        }

        if (item.getId() != Item.AIR) {
            this.slots.put(index, item.clone());
        } else {
            this.slots.remove(index);
        }

        this.onSlotChange(index, old, send);
    }

    return true;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:28,代码来源:BaseInventory.java


注:本文中的cn.nukkit.block.BlockAir类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。