string dimension names on save
parent
8338801b13
commit
5889397521
|
@ -36,7 +36,7 @@ public final class LitecraftSave
|
||||||
public boolean saveChunk(Chunk chunk)
|
public boolean saveChunk(Chunk chunk)
|
||||||
{
|
{
|
||||||
StringBuilder fileLocBuilder = new StringBuilder(this.file.getPath())
|
StringBuilder fileLocBuilder = new StringBuilder(this.file.getPath())
|
||||||
.append('/').append(chunk.dimension)
|
.append('/').append(Dimension.getById(chunk.dimension).saveIdentifier)
|
||||||
.append('/').append(chunk.chunkX)
|
.append('/').append(chunk.chunkX)
|
||||||
.append('/').append(chunk.chunkZ);
|
.append('/').append(chunk.chunkZ);
|
||||||
File chunkDir = new File(fileLocBuilder.toString());
|
File chunkDir = new File(fileLocBuilder.toString());
|
||||||
|
@ -61,7 +61,7 @@ public final class LitecraftSave
|
||||||
{
|
{
|
||||||
// format: <save dir>/<dim>/<chunkX>/<chunkZ>/<chunkY>.sod
|
// format: <save dir>/<dim>/<chunkX>/<chunkZ>/<chunkY>.sod
|
||||||
File chunkFile = new File(new StringBuilder(this.file.getPath())
|
File chunkFile = new File(new StringBuilder(this.file.getPath())
|
||||||
.append('/').append(dimension)
|
.append('/').append(Dimension.getById(dimension).saveIdentifier)
|
||||||
.append('/').append(chunkX)
|
.append('/').append(chunkX)
|
||||||
.append('/').append(chunkZ)
|
.append('/').append(chunkZ)
|
||||||
.append('/').append(chunkY).append(".sod").toString());
|
.append('/').append(chunkY).append(".sod").toString());
|
||||||
|
|
|
@ -10,10 +10,12 @@ public abstract class Dimension<T extends ChunkGenerator>
|
||||||
{
|
{
|
||||||
public List<WorldModifier> worldModifiers = new ArrayList<>();
|
public List<WorldModifier> worldModifiers = new ArrayList<>();
|
||||||
public final int id;
|
public final int id;
|
||||||
|
public final String saveIdentifier;
|
||||||
|
|
||||||
public Dimension(int id)
|
public Dimension(int id, String saveIdentifier)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
this.saveIdentifier = saveIdentifier;
|
||||||
ID_TO_DIMENSION.put(id, this);
|
ID_TO_DIMENSION.put(id, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,5 +30,8 @@ public abstract class Dimension<T extends ChunkGenerator>
|
||||||
|
|
||||||
public abstract T createChunkGenerator(long seed);
|
public abstract T createChunkGenerator(long seed);
|
||||||
|
|
||||||
|
public static Dimension<?> getById(int id)
|
||||||
|
{ return ID_TO_DIMENSION.get(id); }
|
||||||
|
|
||||||
private static final Int2ObjectMap<Dimension<?>> ID_TO_DIMENSION = new Int2ObjectArrayMap<>();
|
private static final Int2ObjectMap<Dimension<?>> ID_TO_DIMENSION = new Int2ObjectArrayMap<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,5 +4,5 @@ import com.github.halotroop.litecraft.world.gen.*;
|
||||||
|
|
||||||
public final class Dimensions
|
public final class Dimensions
|
||||||
{
|
{
|
||||||
public static final Dimension<OverworldChunkGenerator> OVERWORLD = new OverworldDimension(0);
|
public static final Dimension<EarthChunkGenerator> OVERWORLD = new EarthDimension(0, "earth");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.github.halotroop.litecraft.world.dimension;
|
||||||
|
|
||||||
|
import com.github.halotroop.litecraft.world.gen.EarthChunkGenerator;
|
||||||
|
|
||||||
|
class EarthDimension extends Dimension<EarthChunkGenerator>
|
||||||
|
{
|
||||||
|
public EarthDimension(int id, String saveIdentifier)
|
||||||
|
{ super(id, saveIdentifier); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EarthChunkGenerator createChunkGenerator(long seed)
|
||||||
|
{ return new EarthChunkGenerator(seed, this.id); }
|
||||||
|
}
|
|
@ -6,9 +6,9 @@ import com.github.halotroop.litecraft.types.block.*;
|
||||||
import com.github.halotroop.litecraft.util.noise.OctaveSimplexNoise;
|
import com.github.halotroop.litecraft.util.noise.OctaveSimplexNoise;
|
||||||
import com.github.halotroop.litecraft.world.Chunk;
|
import com.github.halotroop.litecraft.world.Chunk;
|
||||||
|
|
||||||
public class OverworldChunkGenerator implements ChunkGenerator, WorldGenConstants
|
public class EarthChunkGenerator implements ChunkGenerator, WorldGenConstants
|
||||||
{
|
{
|
||||||
public OverworldChunkGenerator(long seed, int dimension)
|
public EarthChunkGenerator(long seed, int dimension)
|
||||||
{
|
{
|
||||||
Random rand = new Random(seed);
|
Random rand = new Random(seed);
|
||||||
this.noise = new OctaveSimplexNoise(rand, 3, 250.0, 35.0, 10.0);
|
this.noise = new OctaveSimplexNoise(rand, 3, 250.0, 35.0, 10.0);
|
|
@ -1,13 +0,0 @@
|
||||||
package com.github.halotroop.litecraft.world.gen;
|
|
||||||
|
|
||||||
import com.github.halotroop.litecraft.world.dimension.Dimension;
|
|
||||||
|
|
||||||
public class OverworldDimension extends Dimension<OverworldChunkGenerator>
|
|
||||||
{
|
|
||||||
public OverworldDimension(int id)
|
|
||||||
{ super(id); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OverworldChunkGenerator createChunkGenerator(long seed)
|
|
||||||
{ return new OverworldChunkGenerator(seed, this.id); }
|
|
||||||
}
|
|
Loading…
Reference in New Issue