本文整理汇总了Java中org.spongepowered.api.block.BlockTypes.WATER属性的典型用法代码示例。如果您正苦于以下问题:Java BlockTypes.WATER属性的具体用法?Java BlockTypes.WATER怎么用?Java BlockTypes.WATER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.spongepowered.api.block.BlockTypes
的用法示例。
在下文中一共展示了BlockTypes.WATER属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeHanging
private void removeHanging() {
int miny = this.miny;
if (miny < 1) {
miny = 1;
}
for (int x = 1; x < snapshots.length - 1; x++) {
for (int z = 1; z < snapshots[0][0].length - 1; z++) {
for (int y = miny; y < snapshots[0].length - 1; y++) {
BlockSnapshot block = snapshots[x][y][z];
BlockSnapshot underBlock = snapshots[x][y - 1][z];
if (underBlock.getState().getType() == BlockTypes.AIR || underBlock.getState().getType() == BlockTypes.WATER
|| underBlock.getState().getType() == BlockTypes.LAVA || underBlock.getState().getType() == BlockTypes.LEAVES) {
if (this.notAllowedToHang.contains(block.getState().getType())) {
snapshots[x][y][z] = block.withState(BlockTypes.AIR.getDefaultState());
}
}
}
}
}
}
示例2: removeDumpedFluids
private void removeDumpedFluids() {
if (this.seaLevel < 1) {
return;
}
// remove any surface water or lava above sea level, presumed to be
// placed by players
// sometimes, this is naturally generated. but replacing it is very easy
// with a bucket, so overall this is a good plan
if (this.environment.equals(DimensionTypes.NETHER)) {
return;
}
for (int x = 1; x < snapshots.length - 1; x++) {
for (int z = 1; z < snapshots[0][0].length - 1; z++) {
for (int y = this.seaLevel - 1; y < snapshots[0].length - 1; y++) {
BlockSnapshot block = snapshots[x][y][z];
if (block.getState().getType() == BlockTypes.WATER || block.getState().getType() == BlockTypes.LAVA ||
block.getState().getType() == BlockTypes.WATER || block.getState().getType() == BlockTypes.LAVA) {
snapshots[x][y][z] = block.withState(BlockTypes.AIR.getDefaultState());
}
}
}
}
}
示例3: 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;
}
示例4: freezeEntities
private void freezeEntities() {
Zombie boss = getBoss().get();
double total = 0;
for (Living entity : getContained(Living.class)) {
if (entity.equals(boss)) {
continue;
}
BlockType curType = entity.getLocation().getBlockType();
if (curType != BlockTypes.WATER && curType != BlockTypes.FLOWING_WATER) {
continue;
}
if (entity instanceof Zombie) {
entity.offer(Keys.HEALTH, 0D);
EntityHealthUtil.heal(boss, 1);
total += .02;
} else if (!Probability.getChance(5)) {
entity.damage(Probability.getRandom(25), EntityDamageSource.builder().entity(boss).type(DamageTypes.MAGIC).build());
}
}
modifyDifficulty(-total);
}
示例5: hasSurfaceFluids
boolean hasSurfaceFluids() {
Location<World> lesser = this.getLesserBoundaryCorner();
Location<World> greater = this.getGreaterBoundaryCorner();
// don't bother for very large claims, too expensive
if (this.getClaimBlocks() > MAX_AREA) {
return false;
}
int seaLevel = 0; // clean up all fluids in the end
// respect sea level in normal worlds
if (lesser.getExtent().getDimension().getType().equals(DimensionTypes.OVERWORLD)) {
seaLevel = GriefPreventionPlugin.instance.getSeaLevel(lesser.getExtent());
}
for (int x = lesser.getBlockX(); x <= greater.getBlockX(); x++) {
for (int z = lesser.getBlockZ(); z <= greater.getBlockZ(); z++) {
for (int y = seaLevel - 1; y < lesser.getExtent().getDimension().getBuildHeight(); y++) {
// dodge the exclusion claim
BlockState block = lesser.getExtent().getBlock(x, y, z);
if (block.getType() == BlockTypes.WATER || block.getType() == BlockTypes.FLOWING_WATER
|| block.getType() == BlockTypes.LAVA || block.getType() == BlockTypes.FLOWING_LAVA) {
return true;
}
}
}
}
return false;
}
示例6: getByBlock
static PortalState getByBlock(BlockState state) {
BlockType type = state.getType();
if (type == BlockTypes.LAVA || type == BlockTypes.FLOWING_LAVA) {
return LAVA;
}
if (type == BlockTypes.WATER || type == BlockTypes.FLOWING_WATER) {
return WATER;
}
return INITIALIZED;
}
示例7: damagePlayers
private void damagePlayers() {
for (Player player : getPlayers(PARTICIPANT)) {
BlockType blockType = player.getLocation().getBlockType();
if (blockType == BlockTypes.WATER || blockType == BlockTypes.FLOWING_WATER) {
// If the game is in progress, damage, otherwise return to the spawn point
if (state == SkyWarsState.IN_PROGRESS) {
player.damage(Probability.getRandom(3), DamageSource.builder().type(DamageTypes.DROWN).build());
} else {
player.setLocation(startingLocation);
}
}
}
}
示例8: plantTree
private void plantTree(ExplosionEvent.Pre event) {
Location explosionLocation = event.getExplosion().getLocation();
int x = (int) explosionLocation.getX();
int y = (int) explosionLocation.getY();
int z = (int) explosionLocation.getZ();
//Evaluating the tree type, based on biome
World world = event.getTargetWorld();
BiomeType biome = world.getBiome(x, z);
BiomeGenerationSettings biomeSettings = world.getWorldGenerator().getBiomeSettings(biome);
List<Forest> forestPopulators = biomeSettings.getPopulators(Forest.class);
PopulatorObject populator;
try {
//There may be multiple tree types in one Biome. Get one per weighted random
populator = forestPopulators.isEmpty() ? fallbackTreePopulator : forestPopulators.get(0).getTypes().get(random).get(0);
} catch (Exception e) {
populator = fallbackTreePopulator;
}
//if the explosion happened on level 0, set it to 1, so we can place a dirt block below
if (y == 0) {
y = 1;
}
Vector3i pos = new Vector3i(x, y, z);
Vector3i below = new Vector3i(x, y - 1, z);
Cause genericCause = Cause.of(NamedCause.owner(container));
//set Dirt block below if possible (Trees cannot be placed without)
BlockState blockBelow = world.containsBlock(below) ? world.getBlock(below) : null;
if (blockBelow != null) {
BlockState blockState = BlockState.builder().blockType(BlockTypes.DIRT).build();
world.setBlock(below, blockState, genericCause);
}
//Remove Grass, redstone, etc.
BlockState blockOnPosition = world.getBlock(pos);
Optional<PassableProperty> passableProperty_Op = blockOnPosition.getProperty(PassableProperty.class);
boolean blockPassable = passableProperty_Op.isPresent() && passableProperty_Op.get().getValue();
boolean passableBlockRemoved = false;
if (blockPassable) {
world.setBlock(pos, BlockState.builder().blockType(BlockTypes.AIR).build(), BlockChangeFlag.NEIGHBOR, genericCause);
passableBlockRemoved = true;
}
boolean treePlaced = false;
//is the tree placeable?
if (populator.canPlaceAt(world, x, y, z)) {
//Place the tree
populator.placeObject(world, random, x, y, z);
treePlaced = true;
} else if (passableBlockRemoved) {
//Reset passable Block
world.setBlock(pos, blockOnPosition, genericCause);
}
//Replace block below with original Block (unless the tree was placed in mid-air or water)
if (blockBelow != null && !(treePlaced && (blockBelow.getType() == BlockTypes.AIR ||
blockBelow.getType() == BlockTypes.WATER ||
blockBelow.getType() == BlockTypes.FLOWING_WATER))) {
world.setBlock(below, blockBelow, genericCause);
}
}
示例9: removeSurfaceFluids
public void removeSurfaceFluids(GPClaim exclusionClaim) {
// don't do this for administrative claims
if (this.isAdminClaim()) {
return;
}
// don't do it for very large claims
if (this.getClaimBlocks() > MAX_AREA) {
return;
}
// only in creative mode worlds
if (!GriefPreventionPlugin.instance.claimModeIsActive(this.lesserBoundaryCorner.getExtent().getProperties(), ClaimsMode.Creative)) {
return;
}
Location<World> lesser = this.getLesserBoundaryCorner();
Location<World> greater = this.getGreaterBoundaryCorner();
if (lesser.getExtent().getDimension().getType().equals(DimensionTypes.NETHER)) {
return; // don't clean up lava in the nether
}
int seaLevel = 0; // clean up all fluids in the end
// respect sea level in normal worlds
if (lesser.getExtent().getDimension().getType().equals(DimensionTypes.OVERWORLD)) {
seaLevel = GriefPreventionPlugin.instance.getSeaLevel(lesser.getExtent());
}
for (int x = lesser.getBlockX(); x <= greater.getBlockX(); x++) {
for (int z = lesser.getBlockZ(); z <= greater.getBlockZ(); z++) {
for (int y = seaLevel - 1; y < lesser.getExtent().getDimension().getBuildHeight(); y++) {
// dodge the exclusion claim
BlockSnapshot block = lesser.getExtent().createSnapshot(x, y, z);
if (exclusionClaim != null && exclusionClaim.contains(block.getLocation().get(), false)) {
continue;
}
if (block.getState().getType() == BlockTypes.LAVA || block.getState().getType() == BlockTypes.FLOWING_WATER
|| block.getState().getType() == BlockTypes.WATER || block.getState().getType() == BlockTypes.FLOWING_LAVA) {
block.withState(BlockTypes.AIR.getDefaultState()).restore(true, BlockChangeFlags.PHYSICS);
}
}
}
}
}