本文整理汇总了Java中org.spongepowered.api.block.BlockTypes.AIR属性的典型用法代码示例。如果您正苦于以下问题:Java BlockTypes.AIR属性的具体用法?Java BlockTypes.AIR怎么用?Java BlockTypes.AIR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.spongepowered.api.block.BlockTypes
的用法示例。
在下文中一共展示了BlockTypes.AIR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: highestY
private int highestY(int x, int z, boolean ignoreLeaves) {
int y;
for (y = snapshots[0].length - 1; y > 0; y--) {
BlockSnapshot block = this.snapshots[x][y][z];
if (block.getState().getType() != BlockTypes.AIR &&
!(ignoreLeaves && block.getState().getType() == BlockTypes.SNOW) &&
!(ignoreLeaves && block.getState().getType() == BlockTypes.LEAVES) &&
!(block.getState().getType() == BlockTypes.WATER) &&
!(block.getState().getType() == BlockTypes.FLOWING_WATER) &&
!(block.getState().getType() == BlockTypes.LAVA) &&
!(block.getState().getType() == BlockTypes.FLOWING_LAVA)) {
return y;
}
}
return y;
}
示例2: getBlockSelectionBox
@Override
public Optional<AABB> getBlockSelectionBox(int x, int y, int z) {
final BlockState block = getBlock(x, y, z);
if (block.getType() == BlockTypes.AIR) {
return Optional.empty();
}
final ObjectProvider<AABB> aabbObjectProvider = ((LanternBlockType) block.getType()).getBoundingBoxProvider();
if (aabbObjectProvider == null) {
return Optional.empty();
}
final AABB aabb;
if (aabbObjectProvider instanceof ConstantObjectProvider || aabbObjectProvider instanceof CachedSimpleObjectProvider
|| aabbObjectProvider instanceof SimpleObjectProvider) {
aabb = aabbObjectProvider.get(block, null, null);
} else {
aabb = aabbObjectProvider.get(block, new Location<>(this.world, x, y, z), null);
}
return aabb == null ? Optional.empty() : Optional.of(aabb.offset(x, y, z));
}
示例3: populate
@Override
public void populate(World world, MutableBlockVolume buffer, ImmutableBiomeVolume biomes) {
final Vector3i min = buffer.getBlockMin();
final Vector3i max = buffer.getBlockMax();
final int height = this.blockStateCache.length;
for (int y = min.getY(); y < height; y++) {
if (this.blockStateCache[y] == BlockTypes.AIR) {
continue;
}
for (int x = min.getX(); x <= max.getX(); x++) {
for (int z = min.getZ(); z <= max.getZ(); z++) {
buffer.setBlock(x, y, z, this.blockStateCache[y]);
}
}
}
}
示例4: probeArea
public void probeArea() {
spawnPts.clear();
Vector3i min = getRegion().getMinimumPoint();
Vector3i max = getRegion().getMaximumPoint();
int minX = min.getX();
int minZ = min.getZ();
int minY = min.getY();
int maxX = max.getX();
int maxZ = max.getZ();
int maxY = max.getY();
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
for (int y = maxY; y >= minY; --y) {
BlockType type = getRegion().getExtent().getBlockType(x, y, z);
if (type == BlockTypes.GOLD_BLOCK) {
Location<World> target = new Location<>(getRegion().getExtent(), x, y + 2, z);
if (target.getBlockType() == BlockTypes.AIR) {
spawnPts.add(target);
}
}
}
}
}
}
示例5: getSafeDest
public static Optional<Location<World>> getSafeDest(Location<World> dest) {
// Move down through the air, if we hit a non-air block stop
int blocksMoved;
for (blocksMoved = 0; dest.getY() > 0 && dest.getBlockType() == BlockTypes.AIR; ++blocksMoved) {
dest = dest.add(0, -1, 0);
}
// Move one back up to account for air if the player was moved
if (blocksMoved > 0) {
dest = dest.add(0, 1, 0);
}
// Check the blocks where the player model would be located
// If both blocks are not safe passable block types, we failed
if (!isSafePassableBlock(dest.getBlockType()) || !isSafePassableBlock(dest.add(0, 1, 0).getBlockType())) {
return Optional.empty();
}
// Check the block immediately below the player, if it's blacklisted, we failed
if (isBlacklistedBlock(dest.add(0, -1, 0).getBlockType())) {
return Optional.empty();
}
return Optional.of(dest);
}
示例6: onBlockPlace
@Listener(order = Order.POST)
public void onBlockPlace(ChangeBlockEvent.Place e, @Root Player p) {
long time = new Date().getTime();
for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
UUID id = p.getUniqueId();
if (transaction.getOriginal().getState().getType() != BlockTypes.AIR) {
db.addToQueue(new BlockQueueEntry(transaction.getOriginal(), ActionType.DESTROY, id.toString(), time));
}
db.addToQueue(new BlockQueueEntry(transaction.getFinal(), ActionType.PLACE, id.toString(), time));
}
}
示例7: onBlockPlace
@Listener(order = Order.POST)
public void onBlockPlace(ChangeBlockEvent.Place e, @Root Agent a) {
if (a instanceof Player) return;
long time = new Date().getTime();
for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
String type = a.getType().getName();
if (transaction.getOriginal().getState().getType() != BlockTypes.AIR) {
db.addToQueue(new BlockQueueEntry(transaction.getOriginal(), ActionType.MOB_DESTROY, type, time));
}
db.addToQueue(new BlockQueueEntry(transaction.getFinal(), ActionType.MOB_PLACE, type, time));
}
}
示例8: onBlockPlace
@Listener(order = Order.POST)
public void onBlockPlace(ChangeBlockEvent.Place e, @Root Entity ent) {
if (ent instanceof Player || ent instanceof Agent) return;
long time = new Date().getTime();
for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
String name = ent.getType().getName();
if (transaction.getOriginal().getState().getType() != BlockTypes.AIR) {
db.addToQueue(new BlockQueueEntry(transaction.getOriginal(), ActionType.MOB_DESTROY, name, time));
}
db.addToQueue(new BlockQueueEntry(transaction.getFinal(), ActionType.MOB_PLACE, name, time));
}
}
示例9: findNearbyClaim
private GPClaim findNearbyClaim(Player player) {
int maxDistance = GriefPreventionPlugin.instance.maxInspectionDistance;
BlockRay<World> blockRay = BlockRay.from(player).distanceLimit(maxDistance).build();
GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
GPClaim claim = null;
int count = 0;
while (blockRay.hasNext()) {
BlockRayHit<World> blockRayHit = blockRay.next();
Location<World> location = blockRayHit.getLocation();
claim = this.dataStore.getClaimAt(location);
if (claim != null && !claim.isWilderness() && (playerData.visualBlocks == null || (claim.id != playerData.visualClaimId))) {
playerData.lastValidInspectLocation = location;
return claim;
}
BlockType blockType = location.getBlockType();
if (blockType != BlockTypes.AIR && blockType != BlockTypes.TALLGRASS) {
break;
}
count++;
}
if (count == maxDistance) {
GriefPreventionPlugin.sendMessage(player, GriefPreventionPlugin.instance.messageData.claimTooFar.toText());
} else if (claim != null && claim.isWilderness()){
GriefPreventionPlugin.sendMessage(player, GriefPreventionPlugin.instance.messageData.blockNotClaimed.toText());
}
return claim;
}
示例10: getTargetBlock
public static Optional<Location<World>> getTargetBlock(Player player, GPPlayerData playerData, int maxDistance, boolean ignoreAir) throws IllegalStateException {
BlockRay<World> blockRay = BlockRay.from(player).distanceLimit(maxDistance).build();
GPClaim claim = null;
if (playerData.visualClaimId != null) {
claim = (GPClaim) GriefPreventionPlugin.instance.dataStore.getClaim(player.getWorld().getProperties(), playerData.visualClaimId);
}
while (blockRay.hasNext()) {
BlockRayHit<World> blockRayHit = blockRay.next();
if (claim != null) {
for (Vector3i corner : claim.getVisualizer().getVisualCorners()) {
if (corner.equals(blockRayHit.getBlockPosition())) {
return Optional.of(blockRayHit.getLocation());
}
}
}
if (ignoreAir) {
if (blockRayHit.getLocation().getBlockType() != BlockTypes.TALLGRASS) {
return Optional.of(blockRayHit.getLocation());
}
} else {
if (blockRayHit.getLocation().getBlockType() != BlockTypes.AIR &&
blockRayHit.getLocation().getBlockType() != BlockTypes.TALLGRASS) {
return Optional.of(blockRayHit.getLocation());
}
}
}
return Optional.empty();
}
示例11: removeSandstone
private void removeSandstone() {
for (int x = 1; x < snapshots.length - 1; x++) {
for (int z = 1; z < snapshots[0][0].length - 1; z++) {
for (int y = snapshots[0].length - 2; y > miny; y--) {
if (snapshots[x][y][z].getState().getType() != BlockTypes.SANDSTONE) {
continue;
}
BlockSnapshot leftBlock = this.snapshots[x + 1][y][z];
BlockSnapshot rightBlock = this.snapshots[x - 1][y][z];
BlockSnapshot upBlock = this.snapshots[x][y][z + 1];
BlockSnapshot downBlock = this.snapshots[x][y][z - 1];
BlockSnapshot underBlock = this.snapshots[x][y - 1][z];
BlockSnapshot aboveBlock = this.snapshots[x][y + 1][z];
// skip blocks which may cause a cave-in
if (aboveBlock.getState().getType() == BlockTypes.SAND && underBlock.getState().getType() == BlockTypes.AIR) {
continue;
}
// count adjacent non-air/non-leaf blocks
if (leftBlock.getState().getType() == BlockTypes.SAND ||
rightBlock.getState().getType() == BlockTypes.SAND ||
upBlock.getState().getType() == BlockTypes.SAND ||
downBlock.getState().getType() == BlockTypes.SAND ||
aboveBlock.getState().getType() == BlockTypes.SAND ||
underBlock.getState().getType() == BlockTypes.SAND) {
snapshots[x][y][z] = snapshots[x][y][z].withState(BlockTypes.SAND.getDefaultState());
} else {
snapshots[x][y][z] = snapshots[x][y][z].withState(BlockTypes.AIR.getDefaultState());
}
}
}
}
}
示例12: onApply
@Override
public void onApply() {
super.onApply();
Location<World> location = getConsumer().getEntity().getLocation();
Vector3d position = location.getPosition();
int floorY = position.getFloorY();
BlockState build = BlockState.builder().blockType(BlockTypes.WEB).build();
int b = 0;
for (int i = -1; i <= 1; i++) {
for (int x = -1; x <= 1; x++) {
Vector3i vector3i = new Vector3i(
position.getFloorX() + i,
floorY,
position.getFloorZ() + x);
vector3is[b] = vector3i;
b++;
if (location.getExtent().getBlock(vector3i).getType() == BlockTypes.AIR) {
location.getExtent().setBlock(
vector3i,
build,
BlockChangeFlag.NONE
);
}
}
}
}
示例13: solidify
private void solidify(Location l) {
if (l.getBlock().getType() != BlockTypes.AIR) {
return;
}
l.setBlock(STONE_BLOCK_STATE, Cause.source(SkreePlugin.container()).build());
}
示例14: outOfBoundsCheck
private void outOfBoundsCheck() {
for (Player player : getPlayers(PARTICIPANT)) {
if (contains(player)) {
continue;
}
if (player.getLocation().add(0, -1, 0).getBlockType() == BlockTypes.AIR) {
continue;
}
remove(player);
}
}
示例15: spawnNormalWave
private void spawnNormalWave() {
Vector3i min = getRegion().getMinimumPoint();
Vector3i max = getRegion().getMaximumPoint();
int minX = min.getX();
int minZ = min.getZ();
int maxX = max.getX();
int maxZ = max.getZ();
final int y = min.getY() + 2;
int needed = getSpawnCount(wave);
for (int i = needed; i > 0; --i) {
int x;
int z;
BlockType type;
BlockType aboveType;
do {
x = Probability.getRangedRandom(minX, maxX);
z = Probability.getRangedRandom(minZ, maxZ);
type = getRegion().getExtent().getBlockType(x, y, z);
aboveType = getRegion().getExtent().getBlockType(x, y + 1, z);
} while (type != BlockTypes.AIR || aboveType != BlockTypes.AIR);
spawnWaveMob(new Location<>(getRegion().getExtent(), x + .5, y, z + .5));
}
}