Add CometIslandGenerator.java
This commit is contained in:
parent
087f25b23a
commit
36642c2b0a
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.alttd.cometskyblock.worldgenerator;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.generator.BlockPopulator;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CometIslandGenerator extends CometVoidGenerator {
|
||||||
|
@Override
|
||||||
|
public @NotNull List<BlockPopulator> getDefaultPopulators(World world) {
|
||||||
|
List<BlockPopulator> populators = new ArrayList<>(1);
|
||||||
|
populators.add(new IslandGenerator());
|
||||||
|
return populators;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -61,6 +61,8 @@ public class IslandGenerator extends BlockPopulator {
|
||||||
// try to add a tree
|
// try to add a tree
|
||||||
if (limitedRegion.isInRegion(startX + treeX, startY + 1, startX + treeZ)) {
|
if (limitedRegion.isInRegion(startX + treeX, startY + 1, startX + treeZ)) {
|
||||||
Location location = new Location(null, startX + treeX, startY + 1, startX + treeZ);
|
Location location = new Location(null, startX + treeX, startY + 1, startX + treeZ);
|
||||||
|
// Force air above to clear any flora preventing tree from growing
|
||||||
|
limitedRegion.setType(location.clone().add(0, +1, 0), Material.AIR);
|
||||||
// always set a dirt block under the tree location
|
// always set a dirt block under the tree location
|
||||||
limitedRegion.setType(location.clone().add(0, -1, 0), Material.DIRT);
|
limitedRegion.setType(location.clone().add(0, -1, 0), Material.DIRT);
|
||||||
if (!limitedRegion.generateTree(location, random, TreeType.TREE)) {
|
if (!limitedRegion.generateTree(location, random, TreeType.TREE)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user