add NewMaterialPopulator
This commit is contained in:
parent
3cda4fb985
commit
c0adadf14f
|
@ -812,6 +812,15 @@ public class Settings implements WorldSettings
|
|||
return numberOfBlockGenerationTries;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the newMaterialGenerator value.
|
||||
* @return the value of newMaterialGenerator.
|
||||
*/
|
||||
public boolean isNewMaterialGenerator()
|
||||
{
|
||||
return newMaterialGenerator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
@ -1647,6 +1656,17 @@ public class Settings implements WorldSettings
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method sets the newMaterialGenerator value.
|
||||
* @param newMaterialGenerator the numberOfBlockGenerationTries new value.
|
||||
*
|
||||
*/
|
||||
public void setNewMaterialGenerator(boolean newMaterialGenerator)
|
||||
{
|
||||
this.newMaterialGenerator = newMaterialGenerator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the debug
|
||||
*/
|
||||
|
@ -2198,6 +2218,12 @@ public class Settings implements WorldSettings
|
|||
@ConfigEntry(path = "world.generation-tries", needsReset = true)
|
||||
private int numberOfBlockGenerationTries = 1;
|
||||
|
||||
@ConfigComment("Should we use the new material generator ?")
|
||||
@ConfigComment("This will generate ores and blocks similar to how vanilla does,")
|
||||
@ConfigComment("but it will override the blocks settings of each world.")
|
||||
@ConfigEntry(path = "world.use-new-material-generator", needsReset = true)
|
||||
private boolean newMaterialGenerator = false;
|
||||
|
||||
@ConfigComment("")
|
||||
@ConfigComment("Make over world roof of bedrock, if false, it will be made from stone")
|
||||
@ConfigEntry(path = "world.normal.roof", needsReset = true)
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
package world.bentobox.caveblock.generators;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BiomeProvider;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import org.bukkit.generator.WorldInfo;
|
||||
import world.bentobox.caveblock.CaveBlock;
|
||||
import world.bentobox.caveblock.Settings;
|
||||
import world.bentobox.caveblock.generators.populators.EntitiesPopulator;
|
||||
import world.bentobox.caveblock.generators.populators.FlatBiomeProvider;
|
||||
import world.bentobox.caveblock.generators.populators.MaterialPopulator;
|
||||
import world.bentobox.caveblock.generators.populators.NewMaterialPopulator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Class ChunkGeneratorWorld ...
|
||||
|
@ -118,7 +116,11 @@ public class ChunkGeneratorWorld extends ChunkGenerator
|
|||
public void reload() {
|
||||
this.blockPopulators.clear();
|
||||
|
||||
this.blockPopulators.add(new MaterialPopulator(this.addon));
|
||||
if (this.settings.isNewMaterialGenerator()) {
|
||||
this.blockPopulators.add(new NewMaterialPopulator());
|
||||
} else {
|
||||
this.blockPopulators.add(new MaterialPopulator(this.addon));
|
||||
}
|
||||
this.blockPopulators.add(new EntitiesPopulator(this.addon));
|
||||
|
||||
this.biomeProvider = new FlatBiomeProvider(this.addon);
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
package world.bentobox.caveblock.generators.populators;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import world.bentobox.caveblock.generators.Ore;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class NewMaterialPopulator extends BlockPopulator {
|
||||
private final Map<World.Environment, List<Ore>> ores = new EnumMap<>(World.Environment.class);
|
||||
|
||||
public NewMaterialPopulator() {
|
||||
// Source https://minecraft.fandom.com/wiki/Blob
|
||||
List<Ore> worldOres = new ArrayList<>();
|
||||
worldOres.add(new Ore(-64, 16, Material.DIAMOND_ORE, 1, 10, true));
|
||||
worldOres.add(new Ore(-64, 64, Material.LAPIS_ORE, 1, 7, true));
|
||||
worldOres.add(new Ore(-64, 30, Material.GOLD_ORE, 2, 9, true));
|
||||
worldOres.add(new Ore(0, 16, Material.TUFF, 2, 33, false));
|
||||
worldOres.add(new Ore(-64, 16, Material.REDSTONE_ORE, 8, 8, true));
|
||||
worldOres.add(new Ore(0, 16, Material.GRAVEL, 8, 33, false));
|
||||
worldOres.add(new Ore(0, 79, Material.GRANITE, 5, 33, false));
|
||||
worldOres.add(new Ore(0, 79, Material.ANDESITE, 5, 33, false));
|
||||
worldOres.add(new Ore(0, 79, Material.DIORITE, 5, 33, false));
|
||||
worldOres.add(new Ore(32, 320, Material.EMERALD_ORE, 11, 1, true));
|
||||
worldOres.add(new Ore(95, 136, Material.COAL_ORE, 20, 17, false));
|
||||
worldOres.add(new Ore(0, 96, Material.COPPER_ORE, 20, 9, true));
|
||||
worldOres.add(new Ore(-64, 320, Material.IRON_ORE, 20, 9, true));
|
||||
worldOres.add(new Ore(-64, 320, Material.CAVE_AIR, 8, 33, false));
|
||||
ores.put(World.Environment.NORMAL, worldOres);
|
||||
List<Ore> netherOres = new ArrayList<>();
|
||||
netherOres.add(new Ore(1, 22, Material.ANCIENT_DEBRIS, 1, 5, true));
|
||||
netherOres.add(new Ore(-64, 30, Material.NETHER_GOLD_ORE, 2, 9, true));
|
||||
netherOres.add(new Ore(0, 16, Material.GRAVEL, 8, 33, false));
|
||||
netherOres.add(new Ore(0, 320, Material.BASALT, 8, 33, false));
|
||||
netherOres.add(new Ore(0, 320, Material.BLACKSTONE, 8, 33, false));
|
||||
netherOres.add(new Ore(0, 320, Material.FIRE, 8, 33, false));
|
||||
netherOres.add(new Ore(200, 320, Material.GLOWSTONE, 8, 33, false));
|
||||
netherOres.add(new Ore(-64, 320, Material.CAVE_AIR, 8, 33, false));
|
||||
netherOres.add(new Ore(-64, 320, Material.LAVA, 8, 33, false));
|
||||
netherOres.add(new Ore(0, 16, Material.MAGMA_BLOCK, 8, 33, false));
|
||||
netherOres.add(new Ore(0, 320, Material.CRIMSON_FUNGUS, 8, 33, false));
|
||||
netherOres.add(new Ore(0, 320, Material.WARPED_FUNGUS, 8, 33, false));
|
||||
netherOres.add(new Ore(0, 320, Material.CRIMSON_NYLIUM, 8, 33, false));
|
||||
netherOres.add(new Ore(0, 320, Material.WARPED_NYLIUM, 8, 33, false));
|
||||
netherOres.add(new Ore(0, 320, Material.SHROOMLIGHT, 8, 33, false));
|
||||
netherOres.add(new Ore(0, 320, Material.CRIMSON_STEM, 8, 33, false));
|
||||
netherOres.add(new Ore(0, 320, Material.WARPED_STEM, 8, 33, false));
|
||||
netherOres.add(new Ore(-64, 34, Material.SOUL_SOIL, 20, 17, false));
|
||||
netherOres.add(new Ore(0, 96, Material.NETHER_QUARTZ_ORE, 20, 9, true));
|
||||
netherOres.add(new Ore(-64, 320, Material.BONE_BLOCK, 20, 9, true));
|
||||
ores.put(World.Environment.NETHER, netherOres);
|
||||
List<Ore> endOres = new ArrayList<>();
|
||||
endOres.add(new Ore(32, 320, Material.PURPUR_BLOCK, 11, 1, true));
|
||||
endOres.add(new Ore(95, 136, Material.OBSIDIAN, 20, 17, false));
|
||||
endOres.add(new Ore(-64, 320, Material.CAVE_AIR, 8, 33, false));
|
||||
ores.put(World.Environment.THE_END, endOres);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(World world, Random random, Chunk source) {
|
||||
for (int y = world.getMinHeight(); y < world.getMaxHeight(); y++) {
|
||||
for (Ore o : ores.get(world.getEnvironment())) {
|
||||
if (y > o.minY() && y < o.maxY() && random.nextInt(100) <= o.chance()) {
|
||||
pasteBlob(source, random, y, o);
|
||||
if (o.cont()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void pasteBlob(Chunk chunk, Random random, int y, Ore o) {
|
||||
//int blobSize = (int) (((double)random.nextInt(o.blob()) / 3) + 1);
|
||||
int blobSize = 1;
|
||||
World world = chunk.getWorld();
|
||||
int offset = random.nextInt(16);
|
||||
for (int x = Math.max(0, offset - blobSize); x < Math.min(16, offset + blobSize); x++) {
|
||||
for (int z = Math.max(0, offset - blobSize); z < Math.min(16, offset + blobSize); z++) {
|
||||
for (int yy = Math.max(world.getMinHeight(), y - blobSize); yy < Math.min(world.getMaxHeight(), y + blobSize); yy++) {
|
||||
Block bd = chunk.getBlock(x, yy, z);
|
||||
if (bd.getType().isSolid() && random.nextBoolean()) {
|
||||
bd.setType(o.material());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -93,6 +93,10 @@ world:
|
|||
# This indicate how many times block should be tried to generate.
|
||||
# /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds.
|
||||
generation-tries: 2
|
||||
# Should we use the new material generator ?
|
||||
# This will generate ores and blocks similar to how vanilla does,
|
||||
# but it will override the blocks settings of each world.
|
||||
use-new-material-generator: false
|
||||
normal:
|
||||
#
|
||||
# Make over world roof of bedrock, if false, it will be made from stone
|
||||
|
|
Loading…
Reference in New Issue