mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-03-01 15:51:03 +01:00
Added bordering and not-bordering options to worldgen templates
This commit is contained in:
parent
ca93b6aa10
commit
b998972e38
@ -7,6 +7,7 @@ import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class WorldGenTemplate {
|
||||
@ -15,6 +16,8 @@ public class WorldGenTemplate {
|
||||
private final int minDepth, maxDepth, veinSize, veinCount;
|
||||
|
||||
private final List<Material> replaceable = new ArrayList<>();
|
||||
private final List<Material> bordering = new ArrayList<>();
|
||||
private final List<Material> notBordering = new ArrayList<>();
|
||||
private final List<String> worldWhitelist = new ArrayList<>(), worldBlacklist = new ArrayList<>();
|
||||
private final List<String> biomeWhitelist = new ArrayList<>(), biomeBlacklist = new ArrayList<>();
|
||||
private final boolean slimeChunk;
|
||||
@ -24,13 +27,15 @@ public class WorldGenTemplate {
|
||||
|
||||
id = config.getName().toLowerCase().replace(" ", "-").replace("_", "-");
|
||||
config.getStringList("replace").forEach(str -> replaceable.add(Material.valueOf(str.toUpperCase().replace("-", "_").replace(" ", "_"))));
|
||||
|
||||
for (String world : config.getStringList("worlds"))
|
||||
config.getStringList("bordering").forEach(str -> bordering.add(Material.valueOf(str.toUpperCase().replace("-", "_").replace(" ", "_"))));
|
||||
config.getStringList("not-bordering").forEach(str -> notBordering.add(Material.valueOf(str.toUpperCase().replace("-", "_").replace(" ", "_"))));
|
||||
|
||||
for (String world : config.getStringList("worlds")) {
|
||||
(world.startsWith("!") ? worldBlacklist : worldWhitelist).add(world.toLowerCase().replace("_", "-"));
|
||||
|
||||
for (String biome : config.getStringList("biomes"))
|
||||
}
|
||||
for (String biome : config.getStringList("biomes")) {
|
||||
(biome.startsWith("!") ? biomeBlacklist : biomeWhitelist).add(biome.toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
|
||||
}
|
||||
chunkChance = config.getDouble("chunk-chance");
|
||||
slimeChunk = config.getBoolean("slime-chunk", false);
|
||||
|
||||
@ -82,15 +87,30 @@ public class WorldGenTemplate {
|
||||
|
||||
// check biome list
|
||||
Biome biome = pos.getWorld().getBiome(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
if (!biomeWhitelist.isEmpty() && !biomeWhitelist.contains(biome.name()))
|
||||
if (!biomeWhitelist.isEmpty() && !biomeWhitelist.contains(biome.name())) {
|
||||
return false;
|
||||
if (!biomeBlacklist.isEmpty() && biomeBlacklist.contains(biome.name()))
|
||||
}
|
||||
if (!biomeBlacklist.isEmpty() && biomeBlacklist.contains(biome.name())) {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// check extra options
|
||||
if (slimeChunk && !pos.getChunk().isSlimeChunk())
|
||||
if (slimeChunk && !pos.getChunk().isSlimeChunk()) {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if(!bordering.isEmpty()) {
|
||||
if(!checkIfBorderingBlocks(pos)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!notBordering.isEmpty()) {
|
||||
if(!checkIfNotBorderingBlocks(pos)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// can generate if no restrictions applied
|
||||
return true;
|
||||
}
|
||||
@ -98,4 +118,56 @@ public class WorldGenTemplate {
|
||||
public boolean canReplace(Material type) {
|
||||
return replaceable.isEmpty() || replaceable.contains(type);
|
||||
}
|
||||
|
||||
public boolean canBorder(Material type) {
|
||||
return bordering.isEmpty() || bordering.contains(type);
|
||||
}
|
||||
|
||||
public boolean checkIfBorderingBlocks(Location pos) {
|
||||
if(!canBorder(pos.getBlock().getRelative(BlockFace.NORTH).getType())) {
|
||||
return false;
|
||||
}
|
||||
if(!canBorder(pos.getBlock().getRelative(BlockFace.EAST).getType())) {
|
||||
return false;
|
||||
}
|
||||
if(!canBorder(pos.getBlock().getRelative(BlockFace.SOUTH).getType())) {
|
||||
return false;
|
||||
}
|
||||
if(!canBorder(pos.getBlock().getRelative(BlockFace.WEST).getType())) {
|
||||
return false;
|
||||
}
|
||||
if(!canBorder(pos.getBlock().getRelative(BlockFace.UP).getType())) {
|
||||
return false;
|
||||
}
|
||||
if(!canBorder(pos.getBlock().getRelative(BlockFace.DOWN).getType())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canNotBorder(Material type) {
|
||||
return !notBordering.isEmpty() && notBordering.contains(type);
|
||||
}
|
||||
|
||||
public boolean checkIfNotBorderingBlocks(Location pos) {
|
||||
if(canNotBorder(pos.getBlock().getRelative(BlockFace.NORTH).getType())) {
|
||||
return false;
|
||||
}
|
||||
if(canNotBorder(pos.getBlock().getRelative(BlockFace.EAST).getType())) {
|
||||
return false;
|
||||
}
|
||||
if(canNotBorder(pos.getBlock().getRelative(BlockFace.SOUTH).getType())) {
|
||||
return false;
|
||||
}
|
||||
if(canNotBorder(pos.getBlock().getRelative(BlockFace.WEST).getType())) {
|
||||
return false;
|
||||
}
|
||||
if(canNotBorder(pos.getBlock().getRelative(BlockFace.UP).getType())) {
|
||||
return false;
|
||||
}
|
||||
if(canNotBorder(pos.getBlock().getRelative(BlockFace.DOWN).getType())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user