fix flat world floor, replace read/writeState
This commit is contained in:
parent
1dea7e9645
commit
47021f9e49
3 changed files with 42 additions and 41 deletions
|
@ -222,7 +222,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
|
||||
private long seed = 0L;
|
||||
|
||||
public static void toIdName(TagObject tag, String name, String dname, State state) {
|
||||
public static void writeState(TagObject tag, String name, String dname, State state) {
|
||||
if(state == null)
|
||||
return;
|
||||
tag.setString(name, BlockRegistry.getNameFromBlock(state.getBlock()));
|
||||
|
@ -230,15 +230,15 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
tag.setByte(dname, (byte)state.getBlock().getMetaFromState(state));
|
||||
}
|
||||
|
||||
public static void toIdName(TagObject tag, String name, State state) {
|
||||
toIdName(tag, name, name + "Data", state);
|
||||
public static void writeState(TagObject tag, String name, State state) {
|
||||
writeState(tag, name, name + "Data", state);
|
||||
}
|
||||
|
||||
public static void toIdName(TagObject tag, State state) {
|
||||
toIdName(tag, "Block", "Data", state);
|
||||
public static void writeState(TagObject tag, State state) {
|
||||
writeState(tag, "Block", "Data", state);
|
||||
}
|
||||
|
||||
public static State getFromIdName(TagObject tag, String name, String dname, State def) {
|
||||
public static State readState(TagObject tag, String name, String dname, State def) {
|
||||
if(!tag.hasString(name))
|
||||
return def;
|
||||
Block block = BlockRegistry.getRegisteredBlock(tag.getString(name));
|
||||
|
@ -249,12 +249,12 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
return block.getState();
|
||||
}
|
||||
|
||||
public static State getFromIdName(TagObject tag, String name, State def) {
|
||||
return getFromIdName(tag, name, name + "Data", def);
|
||||
public static State readState(TagObject tag, String name, State def) {
|
||||
return readState(tag, name, name + "Data", def);
|
||||
}
|
||||
|
||||
public static State getFromIdName(TagObject tag, State def) {
|
||||
return getFromIdName(tag, "Block", "Data", def);
|
||||
public static State readState(TagObject tag, State def) {
|
||||
return readState(tag, "Block", "Data", def);
|
||||
}
|
||||
|
||||
public Dimension(int id, String name) {
|
||||
|
@ -901,8 +901,8 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
this.seed = tag.getLong("Seed");
|
||||
if(partialGen || all || this.id >= UniverseRegistry.MORE_DIM_ID) {
|
||||
this.seaLevel = tag.getInt("SeaLevel");
|
||||
this.filler = getFromIdName(tag, "FillerBlock", Blocks.stone.getState());
|
||||
this.liquid = getFromIdName(tag, "LiquidBlock", Blocks.water.getState());
|
||||
this.filler = readState(tag, "FillerBlock", Blocks.stone.getState());
|
||||
this.liquid = readState(tag, "LiquidBlock", Blocks.water.getState());
|
||||
}
|
||||
}
|
||||
if(generator) {
|
||||
|
@ -949,11 +949,11 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
this.defaultWeather = this.defaultWeather == null ? Weather.CLEAR : this.defaultWeather;
|
||||
this.defaultLeaves = LeavesType.getByName(tag.getString("DefaultLeaves"));
|
||||
this.defaultLeaves = this.defaultLeaves == null ? LeavesType.SPRING : this.defaultLeaves;
|
||||
this.top = getFromIdName(tag, "TopBlock", Blocks.dirt.getState());
|
||||
this.surface = getFromIdName(tag, "SurfaceBlock", Blocks.grass.getState());
|
||||
this.alt1 = getFromIdName(tag, "AltBlock1", Blocks.gravel.getState());
|
||||
this.alt2 = getFromIdName(tag, "AltBlock2", Blocks.sand.getState());
|
||||
this.caveFiller = getFromIdName(tag, "CaveFillBlock", Blocks.lava.getState());
|
||||
this.top = readState(tag, "TopBlock", Blocks.dirt.getState());
|
||||
this.surface = readState(tag, "SurfaceBlock", Blocks.grass.getState());
|
||||
this.alt1 = readState(tag, "AltBlock1", Blocks.gravel.getState());
|
||||
this.alt2 = readState(tag, "AltBlock2", Blocks.sand.getState());
|
||||
this.caveFiller = readState(tag, "CaveFillBlock", Blocks.lava.getState());
|
||||
if(tag.hasStringArray("Layers")) {
|
||||
String[] list = tag.getStringArray("Layers");
|
||||
byte[] data = tag.hasByteArray("LayerData") ? tag.getByteArray("LayerData") : null;
|
||||
|
@ -1047,7 +1047,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
List<TagObject> list = tag.getList("Ores");
|
||||
for(int z = 0; z < list.size(); z++) {
|
||||
TagObject gen = list.get(z);
|
||||
this.ores.add(new Ore(getFromIdName(gen, "Block", "Data", Blocks.iron_ore.getState()),
|
||||
this.ores.add(new Ore(readState(gen, Blocks.iron_ore.getState()),
|
||||
gen.getInt("Count"), gen.getInt("Add"), gen.getInt("Size"),
|
||||
gen.getInt("MinC"), gen.getInt("MaxS"), gen.getBool("Distrib")));
|
||||
}
|
||||
|
@ -1058,8 +1058,8 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
for(int z = 0; z < list.size(); z++) {
|
||||
TagObject gen = list.get(z);
|
||||
this.lakes.add(new Lake(
|
||||
getFromIdName(gen, "Block", "Data", Blocks.iron_ore.getState()),
|
||||
getFromIdName(gen, "Filler", null), getFromIdName(gen, "Top", null),
|
||||
readState(gen, Blocks.water.getState()),
|
||||
readState(gen, "Filler", null), readState(gen, "Top", null),
|
||||
gen.getInt("Chance"), gen.getInt("Min"), gen.getInt("Max"), gen.getBool("Ratiod")));
|
||||
}
|
||||
}
|
||||
|
@ -1069,7 +1069,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
for(int z = 0; z < list.size(); z++) {
|
||||
TagObject gen = list.get(z);
|
||||
this.liquids.add(new Liquid(
|
||||
getFromIdName(gen, "Block", "Data", Blocks.iron_ore.getState()),
|
||||
readState(gen, Blocks.flowing_water.getState()),
|
||||
gen.getInt("Chance"), gen.getInt("Min"), gen.getInt("Max"), gen.getBool("Lower")));
|
||||
}
|
||||
}
|
||||
|
@ -1143,8 +1143,8 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
tag.setLong("Seed", this.seed);
|
||||
if(partialGen || all || this.id >= UniverseRegistry.MORE_DIM_ID) {
|
||||
tag.setInt("SeaLevel", this.seaLevel);
|
||||
toIdName(tag, "FillerBlock", this.filler);
|
||||
toIdName(tag, "LiquidBlock", this.liquid);
|
||||
writeState(tag, "FillerBlock", this.filler);
|
||||
writeState(tag, "LiquidBlock", this.liquid);
|
||||
}
|
||||
}
|
||||
if(generator) {
|
||||
|
@ -1191,11 +1191,11 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
tag.setBool("SemiFixed", this.semiFixed);
|
||||
tag.setString("DefaultWeather", this.defaultWeather.getName());
|
||||
tag.setString("DefaultLeaves", this.defaultLeaves.getName());
|
||||
toIdName(tag, "TopBlock", this.top);
|
||||
toIdName(tag, "SurfaceBlock", this.surface);
|
||||
toIdName(tag, "AltBlock1", this.alt1);
|
||||
toIdName(tag, "AltBlock2", this.alt2);
|
||||
toIdName(tag, "CaveFillBlock", this.caveFiller);
|
||||
writeState(tag, "TopBlock", this.top);
|
||||
writeState(tag, "SurfaceBlock", this.surface);
|
||||
writeState(tag, "AltBlock1", this.alt1);
|
||||
writeState(tag, "AltBlock2", this.alt2);
|
||||
writeState(tag, "CaveFillBlock", this.caveFiller);
|
||||
if(this.layers != null) {
|
||||
boolean dataUsed = false;
|
||||
String[] list = new String[this.layers.length];
|
||||
|
@ -1249,7 +1249,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
List<TagObject> list = Lists.newArrayList();
|
||||
for(Ore gen : this.ores) {
|
||||
TagObject ore = new TagObject();
|
||||
toIdName(ore, "Block", "Data", gen.state());
|
||||
writeState(ore, gen.state());
|
||||
ore.setBool("Distrib", gen.dist());
|
||||
ore.setInt("Size", gen.size());
|
||||
ore.setInt("Count", gen.count());
|
||||
|
@ -1264,9 +1264,9 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
List<TagObject> list = Lists.newArrayList();
|
||||
for(Lake gen : this.lakes) {
|
||||
TagObject lake = new TagObject();
|
||||
toIdName(lake, "Block", "Data", gen.state());
|
||||
toIdName(lake, "Filler", gen.filler());
|
||||
toIdName(lake, "Top", gen.top());
|
||||
writeState(lake, gen.state());
|
||||
writeState(lake, "Filler", gen.filler());
|
||||
writeState(lake, "Top", gen.top());
|
||||
lake.setBool("Ratiod", gen.ratiod());
|
||||
lake.setInt("Chance", gen.chance());
|
||||
lake.setInt("Min", gen.minHeight());
|
||||
|
@ -1279,7 +1279,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
|
|||
List<TagObject> list = Lists.newArrayList();
|
||||
for(Liquid gen : this.liquids) {
|
||||
TagObject liquid = new TagObject();
|
||||
toIdName(liquid, "Block", "Data", gen.state());
|
||||
writeState(liquid, gen.state());
|
||||
liquid.setBool("Lower", gen.lower());
|
||||
liquid.setInt("Chance", gen.chance());
|
||||
liquid.setInt("Min", gen.minHeight());
|
||||
|
|
|
@ -742,13 +742,13 @@ public abstract class UniverseRegistry {
|
|||
dtag.setBool("SemiFixed", false);
|
||||
// dtag.setString("DefaultWeather", Weather.CLEAR.getName());
|
||||
dtag.setString("DefaultLeaves", LeavesType.SPRING.getName());
|
||||
Dimension.toIdName(dtag, "FillerBlock", Blocks.air.getState());
|
||||
Dimension.toIdName(dtag, "TopBlock", Blocks.air.getState());
|
||||
Dimension.toIdName(dtag, "SurfaceBlock", Blocks.air.getState());
|
||||
Dimension.toIdName(dtag, "AltBlock1", Blocks.air.getState());
|
||||
Dimension.toIdName(dtag, "AltBlock2", Blocks.air.getState());
|
||||
Dimension.toIdName(dtag, "LiquidBlock", Blocks.air.getState());
|
||||
Dimension.toIdName(dtag, "CaveFillBlock", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "FillerBlock", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "TopBlock", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "SurfaceBlock", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "AltBlock1", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "AltBlock2", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "LiquidBlock", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "CaveFillBlock", Blocks.air.getState());
|
||||
}
|
||||
dtag.merge(ptag);
|
||||
dim.fromTags(dtag);
|
||||
|
|
|
@ -24,6 +24,7 @@ import common.collect.Lists;
|
|||
import common.collect.Maps;
|
||||
import common.collect.Sets;
|
||||
import common.dimension.Dimension;
|
||||
import common.dimension.Dimension.GeneratorType;
|
||||
import common.dimension.Lake;
|
||||
import common.dimension.Liquid;
|
||||
import common.dimension.Ore;
|
||||
|
@ -393,7 +394,7 @@ public final class WorldServer extends AWorldServer {
|
|||
this.caveGen = this.createCaveGenerator();
|
||||
this.bigCaveGen = this.createBigCaveGenerator();
|
||||
this.ravineGen = this.createRavineGenerator();
|
||||
this.base = this.dimension.getFiller().getBlock() != Blocks.air;
|
||||
this.base = this.dimension.getFiller().getBlock() != Blocks.air && this.dimension.getGeneratorType() != GeneratorType.FLAT;
|
||||
this.ceil = this.dimension.hasWorldCeiling();
|
||||
this.mobs = this.dimension.hasMobs();
|
||||
this.snow = this.dimension.hasSnow();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue