本文整理汇总了Java中com.sk89q.worldedit.blocks.BlockID.AIR属性的典型用法代码示例。如果您正苦于以下问题:Java BlockID.AIR属性的具体用法?Java BlockID.AIR怎么用?Java BlockID.AIR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sk89q.worldedit.blocks.BlockID
的用法示例。
在下文中一共展示了BlockID.AIR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actPrimary
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
World world = (World) clicked.getExtent();
int initialType = world.getBlockType(clicked.toVector());
if (initialType == BlockID.AIR) {
return true;
}
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
return true;
}
EditSession editSession = session.createEditSession(player);
try {
recurse(server, editSession, world, clicked.toVector().toBlockVector(),
clicked.toVector(), range, initialType, new HashSet<BlockVector>());
} catch (WorldEditException e) {
throw new RuntimeException(e);
}
editSession.flushQueue();
session.remember(editSession);
return true;
}
示例2: removeNear
/**
* Remove blocks of a certain type nearby a given position.
*
* @param position center position of cuboid
* @param blockType the block type to match
* @param apothem an apothem of the cuboid, where the minimum is 1
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
@SuppressWarnings("deprecation")
public int removeNear(final Vector position, final int blockType, final int apothem) {
checkNotNull(position);
checkArgument(apothem >= 1, "apothem >= 1");
final Mask mask = new FuzzyBlockMask(this, new BaseBlock(blockType, -1));
final Vector adjustment = new Vector(1, 1, 1).multiply(apothem - 1);
final Region region = new CuboidRegion(this.getWorld(), // Causes clamping of Y range
position.add(adjustment.multiply(-1)), position.add(adjustment));
final Pattern pattern = (new BaseBlock(BlockID.AIR));
return this.replaceBlocks(region, mask, pattern);
}
示例3: makeForest
/**
* Makes a forest.
*
* @param basePosition a position
* @param size a size
* @param density between 0 and 1, inclusive
* @param treeGenerator the tree genreator
* @return number of trees created
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int makeForest(final Vector basePosition, final int size, final double density, final TreeGenerator treeGenerator) {
try {
for (int x = basePosition.getBlockX() - size; x <= (basePosition.getBlockX() + size); ++x) {
for (int z = basePosition.getBlockZ() - size; z <= (basePosition.getBlockZ() + size); ++z) {
// Don't want to be in the ground
if (!this.getLazyBlock(x, basePosition.getBlockY(), z).isAir()) {
continue;
}
// The gods don't want a tree here
if (FaweCache.RANDOM.random(65536) >= (density * 65536)) {
continue;
} // def 0.05
this.changes++;
for (int y = basePosition.getBlockY(); y >= (basePosition.getBlockY() - 10); --y) {
final int t = getLazyBlock(x, y, z).getType();
if ((t == BlockID.GRASS) || (t == BlockID.DIRT)) {
treeGenerator.generate(EditSession.this, mutable.setComponents(x, y + 1, z));
break;
} else if (t == BlockID.SNOW) {
setBlock(x, y, z, nullBlock);
} else if (t != BlockID.AIR) { // Trees won't grow on this!
break;
}
}
}
}
} catch (MaxChangedBlocksException ignore) {
}
return this.changes;
}
示例4: actPrimary
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
World world = (World) clicked.getExtent();
final Vector pos = clicked.toVector();
EditSession editSession = session.createEditSession(player);
BaseBlock block = editSession.getBlock(pos);
int initialType = block.getType();
if (initialType == BlockID.AIR || (initialType == BlockID.BEDROCK && !player.canDestroyBedrock())) {
editSession.flushQueue();
return true;
}
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
final int radius = (int) range;
final BlockReplace replace = new BlockReplace(editSession, (editSession.nullBlock));
editSession.setMask((Mask) null);
RecursiveVisitor visitor = new RecursiveVisitor(new IdMask(editSession), replace, radius, editSession);
visitor.visit(pos);
Operations.completeBlindly(visitor);
editSession.flushQueue();
session.remember(editSession);
return true;
}
示例5: drainArea
/**
* Drain nearby pools of water or lava.
*
* @param origin the origin to drain from, which will search a 3x3 area
* @param radius the radius of the removal, where a value should be 0 or greater
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int drainArea(final Vector origin, final double radius) {
checkNotNull(origin);
checkArgument(radius >= 0, "radius >= 0 required");
Mask liquidMask;
// Not thread safe, use hardcoded liquidmask
// if (getWorld() != null) {
// liquidMask = getWorld().createLiquidMask();
// } else {
liquidMask = new BlockMask(this,
new BaseBlock(BlockID.STATIONARY_LAVA, -1),
new BaseBlock(BlockID.LAVA, -1),
new BaseBlock(BlockID.STATIONARY_WATER, -1),
new BaseBlock(BlockID.WATER, -1));
// }
final MaskIntersection mask = new MaskIntersection(
new BoundedHeightMask(0, EditSession.this.getMaximumPoint().getBlockY()),
new RegionMask(
new EllipsoidRegion(null, origin,
new Vector(radius, radius, radius))), liquidMask);
final BlockReplace replace = new BlockReplace(EditSession.this, new BaseBlock(BlockID.AIR));
final RecursiveVisitor visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1), this);
// Around the origin in a 3x3 block
for (final BlockVector position : CuboidRegion.fromCenter(origin, 1)) {
if (mask.test(position)) {
visitor.visit(position);
}
}
Operations.completeBlindly(visitor);
return this.changes = visitor.getAffected();
}
示例6: removeAbove
/**
* Remove a cuboid above the given position with a given apothem and a given height.
*
* @param position base position
* @param apothem an apothem of the cuboid (on the XZ plane), where the minimum is 1
* @param height the height of the cuboid, where the minimum is 1
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
@SuppressWarnings("deprecation")
public int removeAbove(final Vector position, final int apothem, final int height) {
checkNotNull(position);
checkArgument(apothem >= 1, "apothem >= 1");
checkArgument(height >= 1, "height >= 1");
final Region region = new CuboidRegion(this.getWorld(), // Causes clamping of Y range
position.add(-apothem + 1, 0, -apothem + 1), position.add(apothem - 1, height - 1, apothem - 1));
final Pattern pattern = (new BaseBlock(BlockID.AIR));
return this.setBlocks(region, pattern);
}
示例7: fetchItem
@Override
public void fetchItem(BaseItem item) throws BlockBagException {
final int id = item.getType();
final int damage = item.getData();
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
assert(amount == 1);
boolean usesDamageValue = ItemType.usesDamageValue(id);
if (id == BlockID.AIR) {
throw new IllegalArgumentException("Can't fetch air block");
}
loadInventory();
boolean found = false;
for (int slot = 0; slot < items.length; ++slot) {
ItemStack forgeItem = items[slot];
if (forgeItem == null) {
continue;
}
int itemId = Item.getIdFromItem(forgeItem.getItem());
if (itemId != id) {
// Type id doesn't fit
continue;
}
if (usesDamageValue && forgeItem.getItemDamage() != damage) {
// Damage value doesn't fit.
continue;
}
int currentAmount = forgeItem.stackSize;
if (currentAmount < 0) {
// Unlimited
return;
}
changed = true;
if (currentAmount > 1) {
forgeItem.stackSize--;
found = true;
} else {
items[slot] = null;
found = true;
}
break;
}
if (!found) {
throw new OutOfBlocksException();
}
}
示例8: storeItem
@Override
public void storeItem(BaseItem item) throws BlockBagException {
final int id = item.getType();
final int damage = item.getData();
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
assert(amount <= 64);
boolean usesDamageValue = ItemType.usesDamageValue(id);
if (id == BlockID.AIR) {
throw new IllegalArgumentException("Can't store air block");
}
loadInventory();
int freeSlot = -1;
for (int slot = 0; slot < items.length; ++slot) {
ItemStack forgeItem = items[slot];
if (forgeItem == null) {
// Delay using up a free slot until we know there are no stacks
// of this item to merge into
if (freeSlot == -1) {
freeSlot = slot;
}
continue;
}
int itemId = Item.getIdFromItem(forgeItem.getItem());
if (itemId != id) {
// Type id doesn't fit
continue;
}
if (usesDamageValue && forgeItem.getItemDamage() != damage) {
// Damage value doesn't fit.
continue;
}
int currentAmount = forgeItem.stackSize;
if (currentAmount < 0) {
// Unlimited
return;
}
if (currentAmount >= 64) {
// Full stack
continue;
}
changed = true;
int spaceLeft = 64 - currentAmount;
if (spaceLeft >= amount) {
forgeItem.stackSize += amount;
return;
}
forgeItem.stackSize = (64);
amount -= spaceLeft;
}
if (freeSlot > -1) {
changed = true;
items[freeSlot] = new ItemStack(Item.getItemById(id), amount);
return;
}
throw new OutOfSpaceException(id);
}
示例9: simulateSnow
/**
* Make snow in a radius.
*
* @param position a position
* @param radius a radius
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int simulateSnow(final Vector position, final double radius) {
final double radiusSq = radius * radius;
final int ox = position.getBlockX();
final int oy = position.getBlockY();
final int oz = position.getBlockZ();
final BaseBlock ice = new BaseBlock(BlockID.ICE);
final BaseBlock snow = new BaseBlock(BlockID.SNOW);
final int ceilRadius = (int) Math.ceil(radius);
for (int x = ox - ceilRadius; x <= (ox + ceilRadius); ++x) {
int dx = x - ox;
int dx2 = dx * dx;
for (int z = oz - ceilRadius; z <= (oz + ceilRadius); ++z) {
int dz = z - oz;
int dz2 = dz * dz;
if (dx2 + dz2 > radiusSq) {
continue;
}
outer:
for (int y = maxY; y >= 1; --y) {
final int id = FaweCache.getId(queue.getCombinedId4Data(x, y, z));
if (id == BlockID.AIR) {
continue;
}
// Ice!
if ((id == BlockID.WATER) || (id == BlockID.STATIONARY_WATER)) {
this.setBlock(x, y, z, ice);
break;
}
// Snow should not cover these blocks
if (BlockType.isTranslucent(id)) {
switch (id) {
case BlockID.LEAVES:
case BlockID.LEAVES2:
break;
default:
break outer;
}
}
// Too high?
if (y == maxY) {
break;
}
// add snow cover
this.setBlock(x, y + 1, z, snow);
break;
}
}
}
return changes;
}
示例10: fetchItem
@Override
public void fetchItem(BaseItem item) throws BlockBagException {
final int id = item.getType();
final int damage = item.getData();
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
assert(amount == 1);
boolean usesDamageValue = ItemType.usesDamageValue(id);
if (id == BlockID.AIR) {
throw new IllegalArgumentException("Can't fetch air block");
}
loadInventory();
boolean found = false;
for (int slot = 0; slot < items.length; ++slot) {
ItemStack bukkitItem = items[slot];
if (bukkitItem == null) {
continue;
}
if (bukkitItem.getTypeId() != id) {
// Type id doesn't fit
continue;
}
if (usesDamageValue && bukkitItem.getDurability() != damage) {
// Damage value doesn't fit.
continue;
}
int currentAmount = bukkitItem.getAmount();
if (currentAmount < 0) {
// Unlimited
return;
}
if (currentAmount > 1) {
bukkitItem.setAmount(currentAmount - 1);
found = true;
} else {
bukkitItem.setAmount(0);
items[slot] = null;
found = true;
}
break;
}
if (!found) {
throw new OutOfBlocksException();
}
}
示例11: isEmpty
@Override
public boolean isEmpty(int x, int y, int z) {
return editSession.getBlock(x, y, z).getId() == BlockID.AIR;
}
示例12: thaw
/**
* Thaw blocks in a radius.
*
* @param position the position
* @param radius the radius
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int thaw(final Vector position, final double radius) {
final double radiusSq = radius * radius;
final int ox = position.getBlockX();
final int oy = position.getBlockY();
final int oz = position.getBlockZ();
final BaseBlock air = new BaseBlock(0);
final BaseBlock water = new BaseBlock(BlockID.STATIONARY_WATER);
final int ceilRadius = (int) Math.ceil(radius);
for (int x = ox - ceilRadius; x <= (ox + ceilRadius); ++x) {
int dx = x - ox;
int dx2 = dx * dx;
for (int z = oz - ceilRadius; z <= (oz + ceilRadius); ++z) {
int dz = z - oz;
int dz2 = dz * dz;
if (dx2 + dz2 > radiusSq) {
continue;
}
for (int y = maxY; y >= 1; --y) {
final int id = FaweCache.getId(queue.getCombinedId4Data(x, y, z));
switch (id) {
case BlockID.ICE:
this.setBlock(x, y, z, water);
break;
case BlockID.SNOW:
this.setBlock(x, y, z, air);
break;
case BlockID.AIR:
continue;
default:
break;
}
break;
}
}
}
return changes;
}
示例13: storeItem
@Override
public void storeItem(BaseItem item) throws BlockBagException {
final int id = item.getType();
final int damage = item.getData();
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
assert(amount <= 64);
boolean usesDamageValue = ItemType.usesDamageValue(id);
if (id == BlockID.AIR) {
throw new IllegalArgumentException("Can't store air block");
}
loadInventory();
int freeSlot = -1;
for (int slot = 0; slot < size; ++slot) {
Item nukkitItem = items.get(slot);
if (nukkitItem == null) {
// Delay using up a free slot until we know there are no stacks
// of this item to merge into
if (freeSlot == -1) {
freeSlot = slot;
}
continue;
}
if (nukkitItem.getId() != id) {
// Type id doesn't fit
continue;
}
if (usesDamageValue && nukkitItem.getDamage() != damage) {
// Damage value doesn't fit.
continue;
}
int currentCount = nukkitItem.getCount();
if (currentCount < 0) {
// Unlimited
return;
}
if (currentCount >= 64) {
// Full stack
continue;
}
int spaceLeft = 64 - currentCount;
if (spaceLeft >= amount) {
nukkitItem.setCount(currentCount + amount);
return;
}
nukkitItem.setCount(64);
amount -= spaceLeft;
}
if (freeSlot > -1) {
items.put(freeSlot, new Item(id, 0, amount));
return;
}
throw new OutOfSpaceException(id);
}
示例14: fetchItem
@Override
public void fetchItem(BaseItem item) throws BlockBagException {
final int id = item.getType();
final int damage = item.getData();
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
assert(amount == 1);
boolean usesDamageValue = ItemType.usesDamageValue(id);
if (id == BlockID.AIR) {
throw new IllegalArgumentException("Can't fetch air block");
}
loadInventory();
boolean found = false;
for (int slot = 0; slot < items.length; ++slot) {
ItemStack forgeItem = items[slot];
if (forgeItem == null) {
continue;
}
int itemId = Item.getIdFromItem(forgeItem.getItem());
if (itemId != id) {
// Type id doesn't fit
continue;
}
if (usesDamageValue && forgeItem.getItemDamage() != damage) {
// Damage value doesn't fit.
continue;
}
int currentAmount = forgeItem.getCount();
if (currentAmount < 0) {
// Unlimited
return;
}
changed = true;
if (currentAmount > 1) {
forgeItem.setCount(forgeItem.getCount() - 1);;
found = true;
} else {
items[slot] = null;
found = true;
}
break;
}
if (!found) {
throw new OutOfBlocksException();
}
}
示例15: storeItem
@Override
public void storeItem(BaseItem item) throws BlockBagException {
final int id = item.getType();
final int damage = item.getData();
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
assert(amount <= 64);
boolean usesDamageValue = ItemType.usesDamageValue(id);
if (id == BlockID.AIR) {
throw new IllegalArgumentException("Can't store air block");
}
loadInventory();
int freeSlot = -1;
for (int slot = 0; slot < items.length; ++slot) {
ItemStack forgeItem = items[slot];
if (forgeItem == null) {
// Delay using up a free slot until we know there are no stacks
// of this item to merge into
if (freeSlot == -1) {
freeSlot = slot;
}
continue;
}
int itemId = Item.getIdFromItem(forgeItem.getItem());
if (itemId != id) {
// Type id doesn't fit
continue;
}
if (usesDamageValue && forgeItem.getItemDamage() != damage) {
// Damage value doesn't fit.
continue;
}
int currentAmount = forgeItem.getCount();
if (currentAmount < 0) {
// Unlimited
return;
}
if (currentAmount >= 64) {
// Full stack
continue;
}
changed = true;
int spaceLeft = 64 - currentAmount;
if (spaceLeft >= amount) {
forgeItem.setCount(forgeItem.getCount() + amount);
return;
}
forgeItem.setCount(64);
amount -= spaceLeft;
}
if (freeSlot > -1) {
changed = true;
items[freeSlot] = new ItemStack(Item.getItemById(id), amount);
return;
}
throw new OutOfSpaceException(id);
}