remove server side debug
This commit is contained in:
parent
f4c024cde7
commit
374e0c4617
22 changed files with 1084 additions and 801 deletions
|
@ -121,7 +121,6 @@ public final class Server implements IThreadListener {
|
|||
private final List<Dimension> unload = Lists.<Dimension>newArrayList();
|
||||
private final Map<String, Position> warps = Maps.<String, Position>newTreeMap();
|
||||
private final CommandEnvironment scriptEnv = new CommandEnvironment(this);
|
||||
private final boolean debug;
|
||||
|
||||
private KeyPair keyPair;
|
||||
private WorldServer space;
|
||||
|
@ -158,8 +157,7 @@ public final class Server implements IThreadListener {
|
|||
UniverseRegistry.register();
|
||||
RotationRegistry.register();
|
||||
ReorderRegistry.register();
|
||||
boolean debug = System.getProperty("server.debug", null) != null;
|
||||
final Server server = new Server(debug);
|
||||
final Server server = new Server();
|
||||
Registry.addShutdownHook(new Runnable() {
|
||||
public void run() {
|
||||
server.stopServer();
|
||||
|
@ -240,8 +238,7 @@ public final class Server implements IThreadListener {
|
|||
return World.START_TIME;
|
||||
}
|
||||
|
||||
private Server(boolean debug) {
|
||||
this.debug = debug;
|
||||
private Server() {
|
||||
Config.setCallback(new Runnable() {
|
||||
public void run() {
|
||||
for(WorldServer world : Server.this.getWorlds()) {
|
||||
|
@ -277,7 +274,7 @@ public final class Server implements IThreadListener {
|
|||
}
|
||||
|
||||
public List<String> getPlayerFilenames() {
|
||||
String[] list = this.debug ? null : new File("players").list();
|
||||
String[] list = new File("players").list();
|
||||
if(list == null)
|
||||
return Lists.newArrayList();
|
||||
List<String> names = Lists.newArrayList();
|
||||
|
@ -292,14 +289,12 @@ public final class Server implements IThreadListener {
|
|||
}
|
||||
|
||||
public void saveWorldInfo() {
|
||||
if(!this.debug) {
|
||||
saveServerConfig(this.space.getDayTime(), this);
|
||||
WorldServer.saveWarps(this.warps);
|
||||
}
|
||||
saveServerConfig(this.space.getDayTime(), this);
|
||||
WorldServer.saveWarps(this.warps);
|
||||
}
|
||||
|
||||
public TagObject loadPlayerData(String user) {
|
||||
if(this.debug || !IPlayer.isValidUser(user))
|
||||
if(!IPlayer.isValidUser(user))
|
||||
return null;
|
||||
TagObject tag = null;
|
||||
try {
|
||||
|
@ -316,7 +311,7 @@ public final class Server implements IThreadListener {
|
|||
}
|
||||
|
||||
public void writePlayerData(String user, TagObject tag) {
|
||||
if(this.debug || !IPlayer.isValidUser(user))
|
||||
if(!IPlayer.isValidUser(user))
|
||||
return;
|
||||
try {
|
||||
File tmp = new File(new File("players"), user + ".cdt.tmp");
|
||||
|
@ -346,8 +341,6 @@ public final class Server implements IThreadListener {
|
|||
}
|
||||
|
||||
public void saveAllWorlds(boolean message) {
|
||||
if(this.debug)
|
||||
return;
|
||||
if(message)
|
||||
Log.TICK.info("Speichere Welt");
|
||||
this.saveWorldInfo();
|
||||
|
@ -372,22 +365,20 @@ public final class Server implements IThreadListener {
|
|||
}
|
||||
|
||||
public void run(long time) {
|
||||
if(!this.debug) {
|
||||
Converter.convert();
|
||||
long wtime = this.loadServerConfig();
|
||||
if(this.keyPair == null) {
|
||||
Log.SYSTEM.info("Generiere neues Schlüsselpaar");
|
||||
this.keyPair = EncryptUtil.createKeypair();
|
||||
}
|
||||
User.loadDatabase(this.users);
|
||||
Converter.convert();
|
||||
long wtime = this.loadServerConfig();
|
||||
if(this.keyPair == null) {
|
||||
Log.SYSTEM.info("Generiere neues Schlüsselpaar");
|
||||
this.keyPair = EncryptUtil.createKeypair();
|
||||
}
|
||||
User.loadDatabase(this.users);
|
||||
// if(dtime == -1L) // {
|
||||
// dtime = World.START_TIME;
|
||||
//// Config.set("spawnDim", "1", null);
|
||||
//// }
|
||||
this.worlds.add(this.space = new WorldServer(this, wtime,
|
||||
Space.INSTANCE, false));
|
||||
this.dimensions.put(this.space.dimension.getDimensionId(), this.space);
|
||||
new File("players").mkdirs();
|
||||
this.worlds.add(this.space = new WorldServer(this, wtime, Space.INSTANCE));
|
||||
this.dimensions.put(this.space.dimension.getDimensionId(), this.space);
|
||||
new File("players").mkdirs();
|
||||
// if(Config.spawnY < 0) {
|
||||
// WorldServer world = this.getWorld(Config.spawnDim);
|
||||
// world = world == null ? this.space : world;
|
||||
|
@ -410,28 +401,12 @@ public final class Server implements IThreadListener {
|
|||
// Config.set("spawnYaw", "" + (-180.0f + rand.floatv() * 360.0f), null);
|
||||
// Config.set("spawnPitch", "0.0", null);
|
||||
// }
|
||||
}
|
||||
else {
|
||||
Log.SYSTEM.info("Generiere temporäres Schlüsselpaar");
|
||||
this.keyPair = EncryptUtil.createKeypair();
|
||||
Config.clear();
|
||||
UniverseRegistry.clear();
|
||||
Config.set("daylightCycle", "false", false);
|
||||
Config.set("weatherChanges", "false", false);
|
||||
Config.set("mobSpawning", "false", false);
|
||||
Config.set("spawnRadius", "0", false);
|
||||
this.worlds.add(this.space = new WorldServer(this, World.START_TIME,
|
||||
Space.INSTANCE, true));
|
||||
this.dimensions.put(this.space.dimension.getDimensionId(), this.space);
|
||||
}
|
||||
this.setTpsTarget(20.0f);
|
||||
if(!this.debug) {
|
||||
for(Dimension dim : UniverseRegistry.getDimensions()) {
|
||||
if(WorldServer.needsLoading(dim)) {
|
||||
this.getWorld(dim.getDimensionId()).loadForcedChunks();
|
||||
}
|
||||
WorldServer.loadWarps(dim, this.warps);
|
||||
for(Dimension dim : UniverseRegistry.getDimensions()) {
|
||||
if(WorldServer.needsLoading(dim)) {
|
||||
this.getWorld(dim.getDimensionId()).loadForcedChunks();
|
||||
}
|
||||
WorldServer.loadWarps(dim, this.warps);
|
||||
}
|
||||
if(Config.port >= 0)
|
||||
this.bind(Config.port);
|
||||
|
@ -626,8 +601,7 @@ public final class Server implements IThreadListener {
|
|||
Dimension dim = UniverseRegistry.getDimension(dimension);
|
||||
if(dim == null)
|
||||
return null;
|
||||
world = new WorldServer(this, this.space.getDayTime(),
|
||||
dim, this.debug);
|
||||
world = new WorldServer(this, this.space.getDayTime(), dim);
|
||||
this.worlds.add(world);
|
||||
this.dimensions.put(dimension, world);
|
||||
}
|
||||
|
@ -786,7 +760,7 @@ public final class Server implements IThreadListener {
|
|||
}
|
||||
});
|
||||
}
|
||||
connection.sendPacket(new RPacketLoginSuccess(this.debug));
|
||||
connection.sendPacket(new RPacketLoginSuccess());
|
||||
connection.setNetHandler(conn);
|
||||
this.players.add(conn);
|
||||
User user = this.users.remove(loginUser);
|
||||
|
@ -861,8 +835,6 @@ public final class Server implements IThreadListener {
|
|||
}
|
||||
|
||||
private TagObject readPlayer(String user) {
|
||||
if(this.debug)
|
||||
return null;
|
||||
TagObject tag = null;
|
||||
try {
|
||||
File dat = new File(new File("players"), user + ".cdt");
|
||||
|
@ -878,8 +850,6 @@ public final class Server implements IThreadListener {
|
|||
}
|
||||
|
||||
private void writePlayer(Player conn) {
|
||||
if(this.debug)
|
||||
return;
|
||||
try {
|
||||
TagObject tag = new TagObject();
|
||||
EntityNPC entity = conn.getPresentEntity();
|
||||
|
@ -1107,8 +1077,6 @@ public final class Server implements IThreadListener {
|
|||
}
|
||||
|
||||
public void saveAllPlayerData(boolean message) {
|
||||
if(this.debug)
|
||||
return;
|
||||
if(message) {
|
||||
Log.TICK.info("Speichere Spielerdaten");
|
||||
}
|
||||
|
|
|
@ -93,7 +93,6 @@ import server.worldgen.FeatureLakes;
|
|||
import server.worldgen.FeatureLiquids;
|
||||
import server.worldgen.FeatureOres;
|
||||
import server.worldgen.GeneratorCavern;
|
||||
import server.worldgen.GeneratorDebug;
|
||||
import server.worldgen.GeneratorDestroyed;
|
||||
import server.worldgen.GeneratorFlat;
|
||||
import server.worldgen.GeneratorIsland;
|
||||
|
@ -283,78 +282,52 @@ public final class WorldServer extends AWorldServer {
|
|||
return gens;
|
||||
}
|
||||
|
||||
public WorldServer(Server server, long dtime, Dimension dim, boolean debug) {
|
||||
super(dim, debug);
|
||||
public WorldServer(Server server, long dtime, Dimension dim) {
|
||||
super(dim);
|
||||
this.server = server;
|
||||
// this.time = time;
|
||||
this.daytime = dtime;
|
||||
this.updateViewRadius();
|
||||
this.chunkDir = new File(new File("chunk"), dim.getDimensionName());
|
||||
if(!debug) {
|
||||
this.chunkDir.mkdirs();
|
||||
if(!Config.seed.isEmpty())
|
||||
this.rand.setSeed((long)Config.seed.hashCode() ^ ~((long)dim.getDimensionName().hashCode()));
|
||||
this.seed = this.rand.longv();
|
||||
this.dimension.setSeed(this.seed);
|
||||
TagObject tag = null;
|
||||
try {
|
||||
File dat = new File(this.chunkDir, "data.cdt");
|
||||
if(dat.exists() && dat.isFile())
|
||||
tag = TagObject.readGZip(dat);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Weltdaten nicht laden");
|
||||
}
|
||||
if(tag != null) {
|
||||
this.exterminated = tag.getBool("Exterminated");
|
||||
this.time = tag.getLong("Time");
|
||||
if(tag.hasObject("Generator")) {
|
||||
this.dimension.fromTags(tag.getObject("Generator"));
|
||||
if(this.dimension.getType().weather && !this.exterminated)
|
||||
this.weather = this.dimension.getWeather();
|
||||
this.seed = this.dimension.getSeed();
|
||||
}
|
||||
if(this.dimension.getType().weather && !this.exterminated)
|
||||
this.weather = Weather.getByName(tag.getString("Weather"));
|
||||
if(this.weather == null) {
|
||||
this.weather = this.dimension.getWeather();
|
||||
// this.dataModified = true;
|
||||
}
|
||||
// ...
|
||||
}
|
||||
else {
|
||||
Log.TICK.info("Startwert für %s: %d" + (Config.seed.isEmpty() ? "" : " von Basiswert '%s'"), this.dimension.getFormattedName(false), this.seed, Config.seed);
|
||||
}
|
||||
if(this.exterminated)
|
||||
this.weather = Weather.CLEAR;
|
||||
this.chunkDir.mkdirs();
|
||||
if(!Config.seed.isEmpty())
|
||||
this.rand.setSeed((long)Config.seed.hashCode() ^ ~((long)dim.getDimensionName().hashCode()));
|
||||
this.seed = this.rand.longv();
|
||||
this.dimension.setSeed(this.seed);
|
||||
TagObject tag = null;
|
||||
try {
|
||||
File dat = new File(this.chunkDir, "data.cdt");
|
||||
if(dat.exists() && dat.isFile())
|
||||
tag = TagObject.readGZip(dat);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Weltdaten nicht laden");
|
||||
}
|
||||
if(tag != null) {
|
||||
this.exterminated = tag.getBool("Exterminated");
|
||||
this.time = tag.getLong("Time");
|
||||
if(tag.hasObject("Generator")) {
|
||||
this.dimension.fromTags(tag.getObject("Generator"));
|
||||
if(this.dimension.getType().weather && !this.exterminated)
|
||||
this.weather = this.dimension.getWeather();
|
||||
this.seed = this.dimension.getSeed();
|
||||
}
|
||||
if(this.dimension.getType().weather && !this.exterminated)
|
||||
this.weather = Weather.getByName(tag.getString("Weather"));
|
||||
if(this.weather == null) {
|
||||
this.weather = this.dimension.getWeather();
|
||||
// this.dataModified = true;
|
||||
}
|
||||
// ...
|
||||
}
|
||||
else {
|
||||
Log.TICK.info("Startwert für %s: %d" + (Config.seed.isEmpty() ? "" : " von Basiswert '%s'"), this.dimension.getFormattedName(false), this.seed, Config.seed);
|
||||
}
|
||||
if(this.exterminated)
|
||||
this.weather = Weather.CLEAR;
|
||||
this.grng = new Random(this.seed);
|
||||
// GeneratorSettings settings = !debug && !this.exterminated ? dim.getSettings() : null;
|
||||
if(debug) {
|
||||
this.liquid = Blocks.air.getState();
|
||||
this.biomeGen = new BiomeGenSingle(Biome.NONE);
|
||||
this.generator = new GeneratorDebug();
|
||||
this.replacer = null;
|
||||
this.populate = false;
|
||||
this.caveGen = null;
|
||||
this.bigCaveGen = null;
|
||||
this.ravineGen = null;
|
||||
this.base = false;
|
||||
this.ceil = false;
|
||||
this.mobs = false;
|
||||
this.snow = false;
|
||||
this.strongholdGen = null;
|
||||
this.villageGen = null;
|
||||
this.mineshaftGen = null;
|
||||
this.scatteredGen = null;
|
||||
this.bridgeGen = null;
|
||||
this.seaLevel = 0;
|
||||
this.ores = null;
|
||||
this.lakes = null;
|
||||
this.liquids = null;
|
||||
this.dungeons = null;
|
||||
}
|
||||
else if(this.exterminated) {
|
||||
if(this.exterminated) {
|
||||
this.setExterminatedGen();
|
||||
}
|
||||
// else if(settings != null) {
|
||||
|
@ -440,36 +413,34 @@ public final class WorldServer extends AWorldServer {
|
|||
this.calculateInitialSkylight();
|
||||
this.calculateInitialWeather();
|
||||
this.updatePhysics();
|
||||
if(!debug) {
|
||||
TagObject tag = null;
|
||||
tag = null;
|
||||
try {
|
||||
File dat = new File(this.chunkDir, "loaders.cdt");
|
||||
if(dat.exists() && dat.isFile())
|
||||
tag = TagObject.readGZip(dat);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Ladeliste nicht laden");
|
||||
}
|
||||
if(tag != null && tag.hasList("Loaders")) {
|
||||
List<TagObject> list = tag.getList("Loaders");
|
||||
for(int z = 0; z < list.size(); z++) {
|
||||
TagObject pos = list.get(z);
|
||||
this.addLoader(new BlockPos(pos.getInt("X"), pos.getInt("Y"), pos.getInt("Z")));
|
||||
}
|
||||
this.loadersModified = false;
|
||||
}
|
||||
if(this.villageGen != null) {
|
||||
tag = null;
|
||||
try {
|
||||
File dat = new File(this.chunkDir, "loaders.cdt");
|
||||
File dat = new File(this.chunkDir, "villages.cdt");
|
||||
if(dat.exists() && dat.isFile())
|
||||
tag = TagObject.readGZip(dat);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Ladeliste nicht laden");
|
||||
}
|
||||
if(tag != null && tag.hasList("Loaders")) {
|
||||
List<TagObject> list = tag.getList("Loaders");
|
||||
for(int z = 0; z < list.size(); z++) {
|
||||
TagObject pos = list.get(z);
|
||||
this.addLoader(new BlockPos(pos.getInt("X"), pos.getInt("Y"), pos.getInt("Z")));
|
||||
}
|
||||
this.loadersModified = false;
|
||||
}
|
||||
if(this.villageGen != null) {
|
||||
tag = null;
|
||||
try {
|
||||
File dat = new File(this.chunkDir, "villages.cdt");
|
||||
if(dat.exists() && dat.isFile())
|
||||
tag = TagObject.readGZip(dat);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Dorfliste nicht laden");
|
||||
}
|
||||
this.villageStorage = new VillageCollection(tag);
|
||||
Log.IO.error(e, "Konnte Dorfliste nicht laden");
|
||||
}
|
||||
this.villageStorage = new VillageCollection(tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,23 +457,21 @@ public final class WorldServer extends AWorldServer {
|
|||
this.updateWeather(false);
|
||||
this.biomeGen.cleanupCache();
|
||||
// this.profiler.start("mobSpawner");
|
||||
if(this.mobs && Config.mobs && Config.tickSpawn && !this.debug) {
|
||||
if(this.mobs && Config.mobs && Config.tickSpawn) {
|
||||
Spawner.spawn(this);
|
||||
}
|
||||
// this.profiler.next("chunkSource");
|
||||
if(!this.debug) {
|
||||
for(int i = 0; i < 100; ++i) {
|
||||
if(!this.dropped.isEmpty()) {
|
||||
Long v = (Long)this.dropped.iterator().next();
|
||||
ChunkServer chunk = this.chunks.getValueByKey(v.longValue());
|
||||
if(chunk != null) {
|
||||
chunk.onChunkUnload();
|
||||
this.saveChunkData(chunk);
|
||||
this.chunks.remove(v.longValue());
|
||||
this.loaded.remove(chunk);
|
||||
}
|
||||
this.dropped.remove(v);
|
||||
for(int i = 0; i < 100; ++i) {
|
||||
if(!this.dropped.isEmpty()) {
|
||||
Long v = (Long)this.dropped.iterator().next();
|
||||
ChunkServer chunk = this.chunks.getValueByKey(v.longValue());
|
||||
if(chunk != null) {
|
||||
chunk.onChunkUnload();
|
||||
this.saveChunkData(chunk);
|
||||
this.chunks.remove(v.longValue());
|
||||
this.loaded.remove(chunk);
|
||||
}
|
||||
this.dropped.remove(v);
|
||||
}
|
||||
}
|
||||
int light = this.calculateSkylightSubtracted(true);
|
||||
|
@ -611,113 +580,105 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
|
||||
public void setItemData(String dataID, WorldSavedData worldSavedDataIn) {
|
||||
if(!this.debug)
|
||||
this.setData(dataID, worldSavedDataIn);
|
||||
this.setData(dataID, worldSavedDataIn);
|
||||
}
|
||||
|
||||
public WorldSavedData loadItemData(String dataID) {
|
||||
return this.debug ? null : this.loadData(dataID);
|
||||
return this.loadData(dataID);
|
||||
}
|
||||
|
||||
protected void updateBlocks() {
|
||||
this.setActivePlayerChunksAndCheckLight(Config.distance);
|
||||
|
||||
if(this.debug) {
|
||||
for(ChunkPos chunkcoordintpair1 : this.active) {
|
||||
this.getChunk(chunkcoordintpair1.x, chunkcoordintpair1.z).update(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
for(ChunkPos chunkcoordintpair : this.active) {
|
||||
int k = chunkcoordintpair.x * 16;
|
||||
int l = chunkcoordintpair.z * 16;
|
||||
for(ChunkPos chunkcoordintpair : this.active) {
|
||||
int k = chunkcoordintpair.x * 16;
|
||||
int l = chunkcoordintpair.z * 16;
|
||||
// this.profiler.start("getChunk");
|
||||
ChunkServer chunk = this.getChunk(chunkcoordintpair.x, chunkcoordintpair.z);
|
||||
ChunkServer chunk = this.getChunk(chunkcoordintpair.x, chunkcoordintpair.z);
|
||||
// this.profiler.next("moodSound");
|
||||
// this.playMoodSound(k, l, chunk);
|
||||
// this.profiler.next("checkLight");
|
||||
chunk.enqueueRelight();
|
||||
chunk.enqueueRelight();
|
||||
// this.profiler.next("tickChunk");
|
||||
chunk.update(false);
|
||||
chunk.update(false);
|
||||
// this.profiler.next("thunder");
|
||||
int l2 = Config.boltChance;
|
||||
int l2 = Config.boltChance;
|
||||
|
||||
if(l2 > 0 && this.rand.zrange(l2) == 0 && this.isThundering()) {
|
||||
this.updateLCG = this.updateLCG * 3 + 1013904223;
|
||||
int i1 = this.updateLCG >> 2;
|
||||
BlockPos blockpos = this.adjustPosToNearbyEntity(new BlockPos(k + (i1 & 15), 0, l + (i1 >> 8 & 15)));
|
||||
if(l2 > 0 && this.rand.zrange(l2) == 0 && this.isThundering()) {
|
||||
this.updateLCG = this.updateLCG * 3 + 1013904223;
|
||||
int i1 = this.updateLCG >> 2;
|
||||
BlockPos blockpos = this.adjustPosToNearbyEntity(new BlockPos(k + (i1 & 15), 0, l + (i1 >> 8 & 15)));
|
||||
|
||||
if(this.canStrikeAt(blockpos)) {
|
||||
this.strikeLightning((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), 0x737380, 120, true, null);
|
||||
}
|
||||
if(this.canStrikeAt(blockpos)) {
|
||||
this.strikeLightning((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), 0x737380, 120, true, null);
|
||||
}
|
||||
}
|
||||
|
||||
// this.profiler.next("iceandsnow");
|
||||
l2 = Config.weatherTick;
|
||||
l2 = Config.weatherTick;
|
||||
|
||||
for(int z = 0; z < l2; z++) {
|
||||
if(this.rand.zrange(16) == 0) {
|
||||
this.updateLCG = this.updateLCG * 3 + 1013904223;
|
||||
int k2 = this.updateLCG >> 2;
|
||||
BlockPos blockpos2 = this.getPrecipitationHeight(new BlockPos(k + (k2 & 15), 0, l + (k2 >> 8 & 15)));
|
||||
BlockPos blockpos1 = blockpos2.down();
|
||||
for(int z = 0; z < l2; z++) {
|
||||
if(this.rand.zrange(16) == 0) {
|
||||
this.updateLCG = this.updateLCG * 3 + 1013904223;
|
||||
int k2 = this.updateLCG >> 2;
|
||||
BlockPos blockpos2 = this.getPrecipitationHeight(new BlockPos(k + (k2 & 15), 0, l + (k2 >> 8 & 15)));
|
||||
BlockPos blockpos1 = blockpos2.down();
|
||||
|
||||
if(this.canBlockFreeze(blockpos1, true)) {
|
||||
this.setState(blockpos1, Blocks.ice.getState());
|
||||
}
|
||||
if(this.canBlockFreeze(blockpos1, true)) {
|
||||
this.setState(blockpos1, Blocks.ice.getState());
|
||||
}
|
||||
|
||||
if(this.snow && this.isRaining() && this.canSnowAt(blockpos2, true, Config.snowStack)) {
|
||||
State layer = Config.snowStack ? this.getState(blockpos2) : null;
|
||||
this.setState(blockpos2, Config.snowStack && layer.getBlock() == Blocks.snow_layer
|
||||
? (Blocks.snow_layer.getState().withProperty(BlockSnow.LAYERS,
|
||||
Math.min(layer.getValue(BlockSnow.LAYERS) + 1, 2))) : Blocks.snow_layer.getState());
|
||||
}
|
||||
if(this.snow && this.isRaining() && this.canSnowAt(blockpos2, true, Config.snowStack)) {
|
||||
State layer = Config.snowStack ? this.getState(blockpos2) : null;
|
||||
this.setState(blockpos2, Config.snowStack && layer.getBlock() == Blocks.snow_layer
|
||||
? (Blocks.snow_layer.getState().withProperty(BlockSnow.LAYERS,
|
||||
Math.min(layer.getValue(BlockSnow.LAYERS) + 1, 2))) : Blocks.snow_layer.getState());
|
||||
}
|
||||
|
||||
if(this.isRaining()) { // && this.getBiomeGenForCoords(blockpos1).canRain()) {
|
||||
this.getState(blockpos1).getBlock().fillWithRain(this, blockpos1);
|
||||
}
|
||||
if(this.isRaining()) { // && this.getBiomeGenForCoords(blockpos1).canRain()) {
|
||||
this.getState(blockpos1).getBlock().fillWithRain(this, blockpos1);
|
||||
}
|
||||
|
||||
if(Config.igniteChance > 0 && Config.fire && !this.isRaining() &&
|
||||
this.rand.chance(this.hasDownfall() ? Math.max(1, Config.igniteChance / 3) : Config.igniteChance)
|
||||
&& this.canPlaceFireAt(blockpos2)) {
|
||||
this.setState(blockpos2, Blocks.fire.getState());
|
||||
}
|
||||
if(Config.igniteChance > 0 && Config.fire && !this.isRaining() &&
|
||||
this.rand.chance(this.hasDownfall() ? Math.max(1, Config.igniteChance / 3) : Config.igniteChance)
|
||||
&& this.canPlaceFireAt(blockpos2)) {
|
||||
this.setState(blockpos2, Blocks.fire.getState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this.profiler.next("tickBlocks");
|
||||
l2 = Config.randomTick;
|
||||
l2 = Config.randomTick;
|
||||
|
||||
if(l2 > 0) {
|
||||
this.toTick.addAll(chunk.getStorage());
|
||||
for(BlockArray extendedblockstorage : this.toTick) {
|
||||
if(extendedblockstorage != null && extendedblockstorage.isTicked()) {
|
||||
for(int j1 = 0; j1 < l2; ++j1) {
|
||||
this.updateLCG = this.updateLCG * 3 + 1013904223;
|
||||
int k1 = this.updateLCG >> 2;
|
||||
int l1 = k1 & 15;
|
||||
int i2 = k1 >> 8 & 15;
|
||||
int j2 = k1 >> 16 & 15;
|
||||
++j;
|
||||
State iblockstate = extendedblockstorage.get(l1, j2, i2);
|
||||
Block block = iblockstate.getBlock();
|
||||
if(l2 > 0) {
|
||||
this.toTick.addAll(chunk.getStorage());
|
||||
for(BlockArray extendedblockstorage : this.toTick) {
|
||||
if(extendedblockstorage != null && extendedblockstorage.isTicked()) {
|
||||
for(int j1 = 0; j1 < l2; ++j1) {
|
||||
this.updateLCG = this.updateLCG * 3 + 1013904223;
|
||||
int k1 = this.updateLCG >> 2;
|
||||
int l1 = k1 & 15;
|
||||
int i2 = k1 >> 8 & 15;
|
||||
int j2 = k1 >> 16 & 15;
|
||||
++j;
|
||||
State iblockstate = extendedblockstorage.get(l1, j2, i2);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
if(block.getTickRandomly()) {
|
||||
++i;
|
||||
block.randomTick(this, new BlockPos(l1 + k, j2 + extendedblockstorage.getY(), i2 + l), iblockstate,
|
||||
this.rand);
|
||||
}
|
||||
if(block.getTickRandomly()) {
|
||||
++i;
|
||||
block.randomTick(this, new BlockPos(l1 + k, j2 + extendedblockstorage.getY(), i2 + l), iblockstate,
|
||||
this.rand);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.toTick.clear();
|
||||
}
|
||||
this.toTick.clear();
|
||||
}
|
||||
|
||||
// this.profiler.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -813,60 +774,55 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
|
||||
public boolean tickUpdates(boolean p_72955_1_) {
|
||||
if(this.debug) {
|
||||
return false;
|
||||
int i = this.ticksNext.size();
|
||||
|
||||
if(i != this.ticks.size()) {
|
||||
throw new IllegalStateException("TickNextTick list out of synch");
|
||||
}
|
||||
else {
|
||||
int i = this.ticksNext.size();
|
||||
|
||||
if(i != this.ticks.size()) {
|
||||
throw new IllegalStateException("TickNextTick list out of synch");
|
||||
if(i > 1000) {
|
||||
i = 1000;
|
||||
}
|
||||
else {
|
||||
if(i > 1000) {
|
||||
i = 1000;
|
||||
}
|
||||
|
||||
// this.profiler.start("cleaning");
|
||||
|
||||
for(int j = 0; j < i; ++j) {
|
||||
NextTickListEntry nextticklistentry = (NextTickListEntry)this.ticksNext.first();
|
||||
for(int j = 0; j < i; ++j) {
|
||||
NextTickListEntry nextticklistentry = (NextTickListEntry)this.ticksNext.first();
|
||||
|
||||
if(!p_72955_1_ && nextticklistentry.scheduledTime > this.time) {
|
||||
break;
|
||||
}
|
||||
|
||||
this.ticksNext.remove(nextticklistentry);
|
||||
this.ticks.remove(nextticklistentry);
|
||||
this.ticksNow.add(nextticklistentry);
|
||||
if(!p_72955_1_ && nextticklistentry.scheduledTime > this.time) {
|
||||
break;
|
||||
}
|
||||
|
||||
this.ticksNext.remove(nextticklistentry);
|
||||
this.ticks.remove(nextticklistentry);
|
||||
this.ticksNow.add(nextticklistentry);
|
||||
}
|
||||
|
||||
// this.profiler.end();
|
||||
// this.profiler.start("ticking");
|
||||
Iterator<NextTickListEntry> iterator = this.ticksNow.iterator();
|
||||
Iterator<NextTickListEntry> iterator = this.ticksNow.iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
NextTickListEntry nextticklistentry1 = (NextTickListEntry)iterator.next();
|
||||
iterator.remove();
|
||||
int k = 0;
|
||||
while(iterator.hasNext()) {
|
||||
NextTickListEntry nextticklistentry1 = (NextTickListEntry)iterator.next();
|
||||
iterator.remove();
|
||||
int k = 0;
|
||||
|
||||
if(this.isAreaLoaded(nextticklistentry1.position.add(-k, -k, -k), nextticklistentry1.position.add(k, k, k))) {
|
||||
State iblockstate = this.getState(nextticklistentry1.position);
|
||||
if(this.isAreaLoaded(nextticklistentry1.position.add(-k, -k, -k), nextticklistentry1.position.add(k, k, k))) {
|
||||
State iblockstate = this.getState(nextticklistentry1.position);
|
||||
|
||||
if(iblockstate.getBlock() != Blocks.air
|
||||
&& Block.isEqualTo(iblockstate.getBlock(), nextticklistentry1.getBlock())) {
|
||||
iblockstate.getBlock().updateTick(this, nextticklistentry1.position, iblockstate, this.rand);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.scheduleUpdate(nextticklistentry1.position, nextticklistentry1.getBlock(), 0);
|
||||
if(iblockstate.getBlock() != Blocks.air
|
||||
&& Block.isEqualTo(iblockstate.getBlock(), nextticklistentry1.getBlock())) {
|
||||
iblockstate.getBlock().updateTick(this, nextticklistentry1.position, iblockstate, this.rand);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.scheduleUpdate(nextticklistentry1.position, nextticklistentry1.getBlock(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
// this.profiler.end();
|
||||
this.ticksNow.clear();
|
||||
return !this.ticksNext.isEmpty();
|
||||
}
|
||||
this.ticksNow.clear();
|
||||
return !this.ticksNext.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1008,84 +964,82 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
|
||||
public void saveAllChunks() {
|
||||
if(/* (force || !this.disableSaving) && */ !this.debug) {
|
||||
// if(this.primary) {
|
||||
//
|
||||
// }
|
||||
if(this.loadersModified) {
|
||||
this.loadersModified = false;
|
||||
TagObject loaders = new TagObject();
|
||||
List<TagObject> list = Lists.newArrayList();
|
||||
for(BlockPos pos : this.loaderList) {
|
||||
TagObject loader = new TagObject();
|
||||
loader.setInt("X", pos.getX());
|
||||
loader.setInt("Y", pos.getY());
|
||||
loader.setInt("Z", pos.getZ());
|
||||
list.add(loader);
|
||||
if(this.loadersModified) {
|
||||
this.loadersModified = false;
|
||||
TagObject loaders = new TagObject();
|
||||
List<TagObject> list = Lists.newArrayList();
|
||||
for(BlockPos pos : this.loaderList) {
|
||||
TagObject loader = new TagObject();
|
||||
loader.setInt("X", pos.getX());
|
||||
loader.setInt("Y", pos.getY());
|
||||
loader.setInt("Z", pos.getZ());
|
||||
list.add(loader);
|
||||
}
|
||||
loaders.setList("Loaders", list);
|
||||
File file = new File(this.chunkDir, "loaders.cdt");
|
||||
if(list.isEmpty()) {
|
||||
file.delete();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
TagObject.writeGZip(loaders, file);
|
||||
}
|
||||
loaders.setList("Loaders", list);
|
||||
File file = new File(this.chunkDir, "loaders.cdt");
|
||||
if(list.isEmpty()) {
|
||||
file.delete();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
TagObject.writeGZip(loaders, file);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Ladeliste nicht speichern");
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Ladeliste nicht speichern");
|
||||
}
|
||||
}
|
||||
}
|
||||
// if(this.warpsModified) {
|
||||
// this.warpsModified = false;
|
||||
// }
|
||||
// if(this.dataModified) {
|
||||
// this.dataModified = false;
|
||||
TagObject data = new TagObject();
|
||||
TagObject data = new TagObject();
|
||||
// data.setLong("Seed", this.seed);
|
||||
data.setObject("Generator", this.dimension.toTags(true));
|
||||
data.setLong("Time", this.time);
|
||||
data.setBool("Exterminated", this.exterminated);
|
||||
data.setString("Weather", this.weather.getName());
|
||||
// ...
|
||||
File file = new File(this.chunkDir, "data.cdt");
|
||||
data.setObject("Generator", this.dimension.toTags(true));
|
||||
data.setLong("Time", this.time);
|
||||
data.setBool("Exterminated", this.exterminated);
|
||||
data.setString("Weather", this.weather.getName());
|
||||
// ...
|
||||
File file = new File(this.chunkDir, "data.cdt");
|
||||
try {
|
||||
TagObject.writeGZip(data, file);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Weltdaten nicht speichern");
|
||||
}
|
||||
// }
|
||||
for(int i = 0; i < this.dataList.size(); ++i) {
|
||||
WorldSavedData wdata = this.dataList.get(i);
|
||||
if(wdata.dirty) {
|
||||
this.saveData(wdata);
|
||||
wdata.dirty = false;
|
||||
}
|
||||
}
|
||||
if(this.villageStorage != null && this.villageStorage.isDirty()) {
|
||||
TagObject tag = this.villageStorage.toTags();
|
||||
File dat = new File(this.chunkDir, "villages.cdt");
|
||||
try {
|
||||
TagObject.writeGZip(data, file);
|
||||
TagObject.writeGZip(tag, dat);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Weltdaten nicht speichern");
|
||||
Log.IO.error(e, "Konnte Dorfliste nicht speichern");
|
||||
}
|
||||
// }
|
||||
for(int i = 0; i < this.dataList.size(); ++i) {
|
||||
WorldSavedData wdata = this.dataList.get(i);
|
||||
if(wdata.dirty) {
|
||||
this.saveData(wdata);
|
||||
wdata.dirty = false;
|
||||
}
|
||||
}
|
||||
List<ChunkServer> list = Lists.newArrayList(this.loaded);
|
||||
for(int n = 0; n < list.size(); ++n) {
|
||||
ChunkServer chunk = list.get(n);
|
||||
if(chunk.isDirty(this.time)) {
|
||||
this.saveChunkData(chunk);
|
||||
chunk.setModified(false);
|
||||
}
|
||||
if(this.villageStorage != null && this.villageStorage.isDirty()) {
|
||||
TagObject tag = this.villageStorage.toTags();
|
||||
File dat = new File(this.chunkDir, "villages.cdt");
|
||||
try {
|
||||
TagObject.writeGZip(tag, dat);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Dorfliste nicht speichern");
|
||||
}
|
||||
}
|
||||
List<ChunkServer> list = Lists.newArrayList(this.loaded);
|
||||
for(int n = 0; n < list.size(); ++n) {
|
||||
ChunkServer chunk = list.get(n);
|
||||
if(chunk.isDirty(this.time)) {
|
||||
this.saveChunkData(chunk);
|
||||
chunk.setModified(false);
|
||||
}
|
||||
}
|
||||
for(ChunkServer chunk : Lists.newArrayList(this.loaded)) {
|
||||
if(chunk != null && !this.hasPlayerInstance(chunk.xPos, chunk.zPos)) {
|
||||
this.dropChunk(chunk.xPos, chunk.zPos);
|
||||
}
|
||||
}
|
||||
for(ChunkServer chunk : Lists.newArrayList(this.loaded)) {
|
||||
if(chunk != null && !this.hasPlayerInstance(chunk.xPos, chunk.zPos)) {
|
||||
this.dropChunk(chunk.xPos, chunk.zPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1368,8 +1322,7 @@ public final class WorldServer extends AWorldServer {
|
|||
ChunkServer chunk = this.chunks.getValueByKey(id);
|
||||
|
||||
if(chunk == null) {
|
||||
if(!this.debug)
|
||||
chunk = this.loadChunkFromFile(x, z);
|
||||
chunk = this.loadChunkFromFile(x, z);
|
||||
|
||||
if(chunk == null) {
|
||||
chunk = this.generate(x, z);
|
||||
|
@ -1645,8 +1598,6 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
|
||||
public boolean exterminate() {
|
||||
if(this.debug)
|
||||
return true;
|
||||
if(this.exterminated)
|
||||
return false;
|
||||
this.setWeather(Weather.CLEAR);
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package server.worldgen;
|
||||
|
||||
import common.world.DebugStates;
|
||||
import common.world.State;
|
||||
import server.world.WorldServer;
|
||||
|
||||
public class GeneratorDebug implements ChunkGenerator
|
||||
{
|
||||
public int getMaximumHeight() {
|
||||
return 72;
|
||||
}
|
||||
|
||||
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
|
||||
{
|
||||
for(int bx = 0; bx < 16; ++bx) {
|
||||
for(int bz = 0; bz < 16; ++bz) {
|
||||
int sx = x * 16 + bx;
|
||||
int sz = z * 16 + bz;
|
||||
// primer.set(bx, 60, bz, Blocks.glass.getDefaultState());
|
||||
State state = DebugStates.getState(sx, sz);
|
||||
if(state != null) {
|
||||
primer.set(bx, 1, bz, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue