本文整理汇总了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]);
}
}
}
示例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());
}
示例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());
}
示例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]);
}
}
}
示例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);
}
}
示例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());
}
示例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);
}
}
示例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;
}
示例9: getBlock
import cn.nukkit.block.BlockAir; //导入依赖的package包/类
public Block getBlock() {
if (this.block != null) {
return this.block.clone();
} else {
return new BlockAir();
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}