Basic island generation occurring.
This commit is contained in:
parent
823c139d2d
commit
66480084d7
@ -0,0 +1,32 @@
|
||||
package ca.recrown.islandsurvivalcraft;
|
||||
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import ca.recrown.islandsurvivalcraft.worldgen.IslandBaseTerrainGenerator;
|
||||
import nl.rutgerkok.worldgeneratorapi.WorldGeneratorApi;
|
||||
import nl.rutgerkok.worldgeneratorapi.WorldRef;
|
||||
|
||||
public class IslandSurvivalCraft extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onDisable();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
||||
WorldGeneratorApi worldGenAPI = WorldGeneratorApi.getInstance(this, 0, 1);
|
||||
|
||||
return worldGenAPI.createCustomGenerator(WorldRef.ofName(worldName), gen -> {
|
||||
gen.setBaseTerrainGenerator(new IslandBaseTerrainGenerator(getServer().getWorld(worldName).getSeed(), 63, 20, 73));
|
||||
});
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package ca.recrown.islandsurvivalcraft;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class IslandSurvivalCraftPlugin extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onDisable();
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package ca.recrown.islandsurvivalcraft.worldgen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||
import org.bukkit.util.noise.PerlinOctaveGenerator;
|
||||
|
||||
import nl.rutgerkok.worldgeneratorapi.BaseTerrainGenerator;
|
||||
|
||||
public class IslandBaseTerrainGenerator implements BaseTerrainGenerator {
|
||||
private int seaLevel;
|
||||
private int minimumHeight;
|
||||
private int maximumHeight;
|
||||
|
||||
private PerlinOctaveGenerator noiseGenerator;
|
||||
|
||||
public IslandBaseTerrainGenerator(long seed, int seaLevel, int seaFloor, int maximumHeight) {
|
||||
Random random = new Random(seed);
|
||||
this.seaLevel = seaLevel;
|
||||
this.minimumHeight = seaFloor;
|
||||
this.maximumHeight = maximumHeight;
|
||||
|
||||
this.noiseGenerator = new PerlinOctaveGenerator(random, 8);
|
||||
noiseGenerator.setScale(0.025D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlocksInChunk(GeneratingChunk chunk) {
|
||||
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int worldX = 16 * chunk.getChunkX() + x;
|
||||
int worldZ = 16 * chunk.getChunkZ() + z;
|
||||
|
||||
int height = baseHeight(worldX, worldZ);
|
||||
fillChunkColumn(x, z, height, chunk.getBlocksForChunk());
|
||||
}
|
||||
}
|
||||
|
||||
private void fillChunkColumn(int x, int z, int height, ChunkData chunkData) {
|
||||
if (height <= seaLevel) {
|
||||
chunkData.setRegion(x, height, z, x+1, seaLevel, z+1, Material.WATER);
|
||||
chunkData.setRegion(x, 0, z, x+1, height, z+1, Material.STONE);
|
||||
} else {
|
||||
chunkData.setRegion(x, 0, z, x+1, height, z+1, Material.STONE);
|
||||
}
|
||||
}
|
||||
|
||||
private int baseHeight(int x, int z) {
|
||||
return (int) ((noiseGenerator.noise(x, z, 0.5D, 0.5D, true) + 1D) * maximumHeight/2D) + minimumHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(int x, int z, HeightType type) {
|
||||
int baseHeight = baseHeight(x, z);
|
||||
if (baseHeight <= seaLevel && type == HeightType.WORLD_SURFACE) {
|
||||
return seaLevel;
|
||||
}
|
||||
return baseHeight;
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package ca.recrown.islandsurvivalcraft.worldgen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.util.noise.PerlinOctaveGenerator;
|
||||
|
||||
public class IslandsChunkGenerator extends ChunkGenerator {
|
||||
private double maxGenHeight;
|
||||
private double minGenHeight;
|
||||
|
||||
public IslandsChunkGenerator(int maxGenHeight, int minGenHeight) {
|
||||
this.maxGenHeight = maxGenHeight;
|
||||
this.minGenHeight = minGenHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
|
||||
ChunkData chunk = world.getGenerator().generateChunkData(world, random, chunkX, chunkZ, biome);
|
||||
PerlinOctaveGenerator nGenerator = new PerlinOctaveGenerator(random, 8);
|
||||
nGenerator.setScale(0.003D);
|
||||
|
||||
for (int X = 0; X < 16; chunkX++) {
|
||||
for (int Z = 0; Z < 16; Z++) {
|
||||
int currentHeight = (int) ((nGenerator.noise(chunkX*16+X, chunkZ*16+Z, 0.5D, 0.5D, true) + 1D) * maxGenHeight + minGenHeight);
|
||||
|
||||
}
|
||||
}
|
||||
return super.generateChunkData(world, random, chunkX, chunkZ, biome);
|
||||
}
|
||||
}
|
BIN
test-server/plugins/WorldGuard/cache/profiles.sqlite
vendored
BIN
test-server/plugins/WorldGuard/cache/profiles.sqlite
vendored
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
#Minecraft server properties
|
||||
#Sat Apr 18 22:11:44 CDT 2020
|
||||
#Sat Apr 18 23:17:38 CDT 2020
|
||||
spawn-protection=16
|
||||
max-tick-time=60000
|
||||
query.port=25565
|
||||
@ -38,10 +38,10 @@ spawn-animals=true
|
||||
white-list=false
|
||||
rcon.password=
|
||||
generate-structures=true
|
||||
online-mode=true
|
||||
max-build-height=256
|
||||
online-mode=true
|
||||
level-seed=
|
||||
prevent-proxy-connections=false
|
||||
use-native-transport=true
|
||||
motd=A Minecraft Server
|
||||
prevent-proxy-connections=false
|
||||
enable-rcon=false
|
||||
motd=A Minecraft Server
|
||||
|
@ -1 +1 @@
|
||||
[{"name":"Reslate","uuid":"590105fb-53a3-486d-9f07-655e50e04af9","expiresOn":"2020-05-18 20:11:43 -0500"}]
|
||||
[{"name":"Reslate","uuid":"590105fb-53a3-486d-9f07-655e50e04af9","expiresOn":"2020-05-18 23:18:56 -0500"}]
|
Loading…
Reference in New Issue
Block a user