diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 8a250f790..b7b70294f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -2424,6 +2424,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, if (dx2 + dz2 > radiusSq) { continue; } +<<<<<<< HEAD outer: for (int y = maxY; y >= 1; --y) { BlockType type = getBlockType(x, y, z); @@ -2441,6 +2442,29 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, case JUNGLE_LEAVES: case OAK_LEAVES: case SPRUCE_LEAVES: +======= + + for (int y = world.getMaxY(); y >= 1; --y) { + Vector pt = new Vector(x, y, z); + BlockType id = getBlock(pt).getBlockType(); + + if (id.getMaterial().isAir()) { + continue; + } + + // Ice! + if (id == BlockTypes.WATER) { + if (setBlock(pt, ice)) { + ++affected; + } + break; + } + + // Snow should not cover these blocks + if (id.getMaterial().isTranslucent()) { + // Add snow on leaves + if (!BlockCategories.LEAVES.contains(id)) { +>>>>>>> refs/remotes/sk89q/master break; default: if (type.getMaterial().isTranslucent()) { @@ -2545,6 +2569,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of trees created * @throws MaxChangedBlocksException thrown if too many blocks are changed */ +<<<<<<< HEAD public int makeForest(final Vector basePosition, final int size, final double density, TreeGenerator.TreeType treeType) { try { for (int x = basePosition.getBlockX() - size; x <= (basePosition.getBlockX() + size); ++x) { @@ -2576,6 +2601,35 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, default: break; } +======= + public int makeForest(Vector basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException { + int affected = 0; + + 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 (!getBlock(new Vector(x, basePosition.getBlockY(), z)).getBlockType().getMaterial().isAir()) { + continue; + } + // The gods don't want a tree here + if (Math.random() >= density) { + continue; + } // def 0.05 + + for (int y = basePosition.getBlockY(); y >= basePosition.getBlockY() - 10; --y) { + // Check if we hit the ground + BlockType t = getBlock(new Vector(x, y, z)).getBlockType(); + if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) { + treeType.generate(this, new Vector(x, y + 1, z)); + ++affected; + break; + } else if (t == BlockTypes.SNOW) { + setBlock(new Vector(x, y, z), BlockTypes.AIR.getDefaultState()); + } else if (!t.getMaterial().isAir()) { // Trees won't grow on this! + break; +>>>>>>> refs/remotes/sk89q/master } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockMaterial.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockMaterial.java index 72a1b59f0..86b010819 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockMaterial.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockMaterial.java @@ -25,8 +25,9 @@ package com.sk89q.worldedit.blocks; public interface BlockMaterial { /** - * Get if this block is air - * @return + * Gets if this block is a type of air. + * + * @return If it's air */ boolean isAir(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java index 31020914a..bfa5a6b14 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java @@ -62,7 +62,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo if (applied.getBlockType().getMaterial().isAir()) { eS.setBlock(pos.toVector(), secondary); } else { - eS.setBlock(pos.getDirection(), secondary); + eS.setBlock(pos.add(pos.getDirection()), secondary); } return true; } @@ -76,7 +76,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo if (applied.getBlockType().getMaterial().isAir()) { eS.setBlock(pos.toVector(), primary); } else { - eS.setBlock(pos.getDirection(), primary); + eS.setBlock(pos.add(pos.getDirection()), primary); } return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java index 7f7b5d90c..bf18c49f9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java @@ -156,7 +156,7 @@ public class OldChunk implements Chunk { @Override public BlockState getBlock(Vector position) throws DataException { - if(position.getBlockY() >= 128) return BlockTypes.AIR.getDefaultState(); + if(position.getBlockY() >= 128) return BlockTypes.VOID_AIR.getDefaultState(); int id, dataVal; int x = position.getBlockX() - rootX * 16; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/SimpleBlockMaterial.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/SimpleBlockMaterial.java index 0358444dc..40ff55364 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/SimpleBlockMaterial.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/SimpleBlockMaterial.java @@ -23,6 +23,7 @@ import com.sk89q.worldedit.blocks.BlockMaterial; class SimpleBlockMaterial implements BlockMaterial { + private boolean isAir; private boolean fullCube; private boolean opaque; private boolean powerSource; @@ -72,6 +73,15 @@ class SimpleBlockMaterial implements BlockMaterial { this.lightOpacity = lightOpacity; } + @Override + public boolean isAir() { + return this.isAir; + } + + public void setIsAir(boolean isAir) { + this.isAir = isAir; + } + @Override public boolean isFullCube() { return fullCube;