renme config class, add blocks/items devmode startup check

This commit is contained in:
Sen 2025-06-01 14:51:22 +02:00
parent 141c1b1f5c
commit ee3bf79c4c
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
98 changed files with 1463 additions and 928 deletions

View file

@ -39,7 +39,6 @@ import common.future.Futures;
import common.future.ListenableFuture;
import common.future.ListenableFutureTask;
import common.future.ThreadFactoryBuilder;
import common.init.Config;
import common.init.EntityRegistry;
import common.init.Registry;
import common.init.UniverseRegistry;
@ -91,6 +90,7 @@ import common.util.Position;
import common.util.Util;
import common.util.Var;
import common.util.WorldPos;
import common.vars.Vars;
import common.world.World;
import server.biome.GenBiome;
import server.clipboard.ReorderRegistry;
@ -100,8 +100,8 @@ import server.command.FixedExecutor;
import server.network.HandshakeHandler;
import server.network.Player;
import server.network.User;
import server.util.SVar;
import server.util.ServerConfig;
import server.vars.SVar;
import server.vars.SVars;
import server.world.Converter;
import server.world.Region;
import server.world.WorldServer;
@ -258,7 +258,7 @@ public final class Server implements IThreadListener {
}
private Server() {
for(Class<?> clazz : new Class[] {Config.class, ServerConfig.class}) {
for(Class<?> clazz : new Class[] {Vars.class, SVars.class}) {
for(Field field : clazz.getDeclaredFields()) {
if(field.isAnnotationPresent(Var.class)) {
if(!Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers()))
@ -277,7 +277,7 @@ public final class Server implements IThreadListener {
for(WorldServer world : Server.this.getWorlds()) {
world.updatePhysics();
}
Server.this.sendPacket(new SPacketWorld(WorldServer.clampGravity(), ServerConfig.dayCycle, ServerConfig.timeFlow));
Server.this.sendPacket(new SPacketWorld(WorldServer.clampGravity(), SVars.dayCycle, SVars.timeFlow));
}
}, "daylightCycle", "timeFlow", "gravity");
this.setCallback(new Runnable() {
@ -289,12 +289,12 @@ public final class Server implements IThreadListener {
}, "viewDistance");
this.setCallback(new Runnable() {
public void run() {
Server.this.bind(ServerConfig.port);
Server.this.bind(SVars.port);
}
}, "port");
this.setCallback(new Runnable() {
public void run() {
if((!ServerConfig.password.isEmpty() && ServerConfig.password.length() < 8) || ServerConfig.password.length() > IPlayer.MAX_PASS_LENGTH)
if((!SVars.password.isEmpty() && SVars.password.length() < 8) || SVars.password.length() > IPlayer.MAX_PASS_LENGTH)
Log.IO.warn("Passwort muss aus 8-" + IPlayer.MAX_PASS_LENGTH + " Zeichen bestehen, Login wird nicht möglich sein");
}
}, "password");
@ -439,11 +439,11 @@ public final class Server implements IThreadListener {
}
WorldServer.loadWarps(dim, this.warps);
}
if(ServerConfig.port >= 0)
this.bind(ServerConfig.port);
if(SVars.port >= 0)
this.bind(SVars.port);
else
Log.SYSTEM.warn("Kein Port definiert, verwende 'sv port <1024-32767>' um einen Hosting-Port festzulegen");
if(ServerConfig.accessRequired && ServerConfig.password.length() < 8)
if(SVars.accessRequired && SVars.password.length() < 8)
Log.SYSTEM.warn("Kein Passwort definiert, verwende 'sv password <8-" + IPlayer.MAX_PASS_LENGTH + " Zeichen>' um ein Zugangspasswort festzulegen");
Thread con = new Thread(new Runnable() {
private final BufferedReader reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(System.in)));
@ -515,7 +515,7 @@ public final class Server implements IThreadListener {
public void preload(WorldServer world, int bx, int bz) {
int done = 0;
int total = ServerConfig.distance * 2 + 1;
int total = SVars.distance * 2 + 1;
total *= total;
Log.TICK.info("Generiere und lade Welt");
// WorldServer world = this.getWorld(Config.spawnDim);
@ -523,8 +523,8 @@ public final class Server implements IThreadListener {
bx = bx >> 4;
bz = bz >> 4;
long last = System.currentTimeMillis();
for(int x = -ServerConfig.distance; x <= ServerConfig.distance; x++) {
for(int z = -ServerConfig.distance; z <= ServerConfig.distance; z++) {
for(int x = -SVars.distance; x <= SVars.distance; x++) {
for(int z = -SVars.distance; z <= SVars.distance; z++) {
long time = System.currentTimeMillis();
if(time - last > 1000L) {
Log.TICK.info("Bereite Spawnbereich vor" + ": " + (done * 100 / total) + "%");
@ -610,7 +610,7 @@ public final class Server implements IThreadListener {
this.sendPacket(new SPacketPlayerListItem((List)this.getPlayers()));
this.pingTimer = 0;
}
if(ServerConfig.saveInterval > 0 && ++this.saveTimer >= ServerConfig.saveInterval) {
if(SVars.saveInterval > 0 && ++this.saveTimer >= SVars.saveInterval) {
this.saveAllPlayerData(false);
this.saveAllWorlds(false);
this.saveTimer = 0;
@ -761,7 +761,7 @@ public final class Server implements IThreadListener {
WorldServer world = this.getWorld(origin.getDimension());
world = world == null ? this.space : world;
BlockPos pos = origin;
int radius = ServerConfig.spawnRadius;
int radius = SVars.spawnRadius;
if(radius > 0) {
pos = world.getTopSolidOrLiquidBlock(pos.add(
ExtMath.clampi(world.rand.excl(-radius, radius), -World.MAX_SIZE + 1, World.MAX_SIZE - 1), 0,
@ -782,10 +782,10 @@ public final class Server implements IThreadListener {
Player conn = new Player(this, connection, loginUser);
if(tag != null)
conn.readTags(tag);
if(ServerConfig.compression >= 0) {
connection.sendPacket(new RPacketEnableCompression(ServerConfig.compression), new ChannelFutureListener() {
if(SVars.compression >= 0) {
connection.sendPacket(new RPacketEnableCompression(SVars.compression), new ChannelFutureListener() {
public void operationComplete(ChannelFuture future) throws Exception {
connection.setCompressionTreshold(ServerConfig.compression);
connection.setCompressionTreshold(SVars.compression);
}
});
}
@ -817,7 +817,7 @@ public final class Server implements IThreadListener {
conn.sendPacket(new SPacketJoinGame(player.getId(), world.dimension, EntityRegistry.getEntityID(player), tag == null));
conn.sendPacket(new SPacketHeldItemChange(player.inventory.currentItem));
conn.sendPacket(new SPacketWorld(WorldServer.clampGravity(),
ServerConfig.dayCycle, ServerConfig.timeFlow));
SVars.dayCycle, SVars.timeFlow));
// conn.initializeStats();
this.sendPacket(new SPacketPlayerListItem(false, conn));
@ -948,7 +948,7 @@ public final class Server implements IThreadListener {
// this.movePlayerToSpawn(nplayer);
}
world.loadChunk((int)nplayer.posX >> 4, (int)nplayer.posZ >> 4);
if(bed != null ? ServerConfig.checkBed : ServerConfig.spawnRadius >= 0) {
if(bed != null ? SVars.checkBed : SVars.spawnRadius >= 0) {
while(!world.getCollidingBoundingBoxes(nplayer, nplayer.getEntityBoundingBox()).isEmpty() && nplayer.posY < 512.0D) {
nplayer.setPosition(nplayer.posX, nplayer.posY + 1.0D, nplayer.posZ);
}
@ -1205,7 +1205,7 @@ public final class Server implements IThreadListener {
if(this.endpoint != null)
this.terminateEndpoint("Wechsele auf Port " + port);
// throw new IllegalStateException("Eingangspunkt bereits gesetzt");
Log.NETWORK.info("Öffne Port %d auf 0.0.0.0 (Timeout %ds)", port, ServerConfig.timeout);
Log.NETWORK.info("Öffne Port %d auf 0.0.0.0 (Timeout %ds)", port, SVars.timeout);
this.endpoint = ((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(NioServerSocketChannel.class)).childHandler(new ChannelInitializer<Channel>() {
protected void initChannel(Channel channel) throws Exception {
try {
@ -1213,7 +1213,7 @@ public final class Server implements IThreadListener {
}
catch(ChannelException e) {
}
channel.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(ServerConfig.timeout)))
channel.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(SVars.timeout)))
.addLast((String)"splitter", (ChannelHandler)(new PacketSplitter()))
.addLast((String)"decoder", (ChannelHandler)(new PacketDecoder(true)))
.addLast((String)"prepender", (ChannelHandler)(new PacketPrepender()))

View file

@ -368,11 +368,8 @@ public abstract class GenBiome implements IBiome {
BlockFlower.EnumFlowerType blockflower$enumflowertype = this.pickRandomFlower(rand, blockpos1);
BlockFlower blockflower = blockflower$enumflowertype.getBlockType().getBlock();
if (blockflower != Blocks.air)
{
this.yellowFlowerGen.setGeneratedBlock(blockflower, blockflower$enumflowertype);
this.yellowFlowerGen.generate(world, rand, blockpos1);
}
this.yellowFlowerGen.setGeneratedBlock(blockflower, blockflower$enumflowertype);
this.yellowFlowerGen.generate(world, rand, blockpos1);
}
}

View file

@ -13,7 +13,7 @@ import server.command.UserPolicy;
import server.network.Player;
import server.network.User;
import server.util.Form;
import server.util.ServerConfig;
import server.vars.SVars;
public class CommandPasswd extends Command {
public CommandPasswd() {
@ -39,8 +39,8 @@ public class CommandPasswd extends Command {
protected void init() {
this.checkField = user != exec ? null : this.addPassword("Aktuelles Passwort", 0, IPlayer.MAX_PASS_LENGTH, "");
this.passwordField = this.addPassword("Neues Passwort", ServerConfig.minPassLength, IPlayer.MAX_PASS_LENGTH, "");
this.confirmField = this.addPassword("Passwort bestätigen", ServerConfig.minPassLength, IPlayer.MAX_PASS_LENGTH, "");
this.passwordField = this.addPassword("Neues Passwort", SVars.minPassLength, IPlayer.MAX_PASS_LENGTH, "");
this.confirmField = this.addPassword("Passwort bestätigen", SVars.minPassLength, IPlayer.MAX_PASS_LENGTH, "");
}
public String getTitle() {

View file

@ -10,7 +10,7 @@ import server.command.RunException;
import server.network.Player;
import server.network.User;
import server.util.Form;
import server.util.ServerConfig;
import server.vars.SVars;
public class CommandRegister extends Command {
public CommandRegister() {
@ -35,8 +35,8 @@ public class CommandRegister extends Command {
private Field confirmField;
protected void init() {
this.passwordField = this.addPassword("Passwort", ServerConfig.minPassLength, IPlayer.MAX_PASS_LENGTH, "");
this.confirmField = this.addPassword("Passwort bestätigen", ServerConfig.minPassLength, IPlayer.MAX_PASS_LENGTH, "");
this.passwordField = this.addPassword("Passwort", SVars.minPassLength, IPlayer.MAX_PASS_LENGTH, "");
this.confirmField = this.addPassword("Passwort bestätigen", SVars.minPassLength, IPlayer.MAX_PASS_LENGTH, "");
}
public String getTitle() {

View file

@ -11,8 +11,8 @@ import server.command.CommandEnvironment;
import server.command.Executor;
import server.command.RunException;
import server.command.StringCompleter;
import server.util.SVar;
import server.util.ValueType;
import server.vars.SVar;
import server.vars.ValueType;
public class CommandSv extends Command {
public CommandSv() {

View file

@ -27,7 +27,7 @@ import common.packet.RPacketResponse;
import common.packet.RPacketServerConfig;
import common.util.EncryptUtil;
import server.Server;
import server.util.ServerConfig;
import server.vars.SVars;
public class LoginHandler implements ILoginHandler
{
@ -100,12 +100,12 @@ public class LoginHandler implements ILoginHandler
if(this.server.getPlayer(this.loginUser) != null)
return "Nutzername '" + this.loginUser + "' ist bereits vergeben";
User user = this.server.getUser(this.loginUser);
if(ServerConfig.authenticate) {
if(SVars.authenticate) {
if(user == null) {
if(!ServerConfig.register)
if(!SVars.register)
return "Anmeldung neuer Accounts ist auf diesem Server deaktiviert (Whitelisted)";
if(ServerConfig.playerLimit > 0 && this.server.getPlayers().size() >= ServerConfig.playerLimit)
return String.format("Der Server ist voll (%d/%d)!", this.server.getPlayers().size(), ServerConfig.playerLimit);
if(SVars.playerLimit > 0 && this.server.getPlayers().size() >= SVars.playerLimit)
return String.format("Der Server ist voll (%d/%d)!", this.server.getPlayers().size(), SVars.playerLimit);
if(this.loginKey != null) {
this.server.addUser(user = new User(this.loginUser));
user.setPubkey(this.loginKey);
@ -113,9 +113,9 @@ public class LoginHandler implements ILoginHandler
}
else {
if(this.loginPass == null || this.loginPass.length() == 0)
return "Ein neues Passwort ist erforderlich um diesen Server zu betreten (mindestens " + ServerConfig.minPassLength + " Zeichen)";
if(this.loginPass.length() < ServerConfig.minPassLength)
return "Passwort ist zu kurz, mindestens " + ServerConfig.minPassLength + " Zeichen";
return "Ein neues Passwort ist erforderlich um diesen Server zu betreten (mindestens " + SVars.minPassLength + " Zeichen)";
if(this.loginPass.length() < SVars.minPassLength)
return "Passwort ist zu kurz, mindestens " + SVars.minPassLength + " Zeichen";
this.server.addUser(user = new User(this.loginUser));
user.setPasswordHash(EncryptUtil.hashPassword(this.loginPass));
Log.NETWORK.info(this.loginUser + " registrierte sich mit Passwort");
@ -129,15 +129,15 @@ public class LoginHandler implements ILoginHandler
Log.NETWORK.info(this.loginUser + " loggte sich mit " + (this.loginKey != null ? "Pubkey" : "Passwort") + " ein");
}
}
if(ServerConfig.playerLimit > 0 && this.server.getPlayers().size() >= ServerConfig.playerLimit && (user == null || !user.isAdmin()))
return String.format("Der Server ist voll (%d/%d)!", this.server.getPlayers().size(), ServerConfig.playerLimit);
if(SVars.playerLimit > 0 && this.server.getPlayers().size() >= SVars.playerLimit && (user == null || !user.isAdmin()))
return String.format("Der Server ist voll (%d/%d)!", this.server.getPlayers().size(), SVars.playerLimit);
return null;
}
public void sendLoginPacket() {
if(this.state != LoginState.INIT)
throw new IllegalStateException("Unerwartetes Handshake-Paket");
if(ServerConfig.encrypt) {
if(SVars.encrypt) {
this.state = LoginState.ENCRYPT;
this.loginToken = new byte[4];
TOKEN_RNG.nextBytes(this.loginToken);
@ -145,7 +145,7 @@ public class LoginHandler implements ILoginHandler
}
else {
this.state = LoginState.PASSWORD;
this.netManager.sendPacket(new RPacketServerConfig(ServerConfig.accessRequired, ServerConfig.authenticate, ServerConfig.authenticate && ServerConfig.passwordAuth, false));
this.netManager.sendPacket(new RPacketServerConfig(SVars.accessRequired, SVars.authenticate, SVars.authenticate && SVars.passwordAuth, false));
}
}
@ -166,19 +166,19 @@ public class LoginHandler implements ILoginHandler
this.state = LoginState.PASSWORD;
this.netManager.sendPacket(new RPacketResponse(packet.getToken(this.server.getPrivateKey())), new GenericFutureListener < Future <? super Void >> () {
public void operationComplete(Future <? super Void > u) throws Exception {
LoginHandler.this.netManager.sendPacket(new RPacketServerConfig(ServerConfig.accessRequired, ServerConfig.authenticate, ServerConfig.authenticate && ServerConfig.passwordAuth,
ServerConfig.authenticate && ServerConfig.pubkeyAuth));
LoginHandler.this.netManager.sendPacket(new RPacketServerConfig(SVars.accessRequired, SVars.authenticate, SVars.authenticate && SVars.passwordAuth,
SVars.authenticate && SVars.pubkeyAuth));
}
});
}
private boolean checkAccess(String access) {
if(ServerConfig.accessRequired) {
if(ServerConfig.password.length() < 8) {
if(SVars.accessRequired) {
if(SVars.password.length() < 8) {
this.closeConnection("Es ist kein Zugangspasswort für diesen Server konfiguriert");
return false;
}
if(!ServerConfig.password.equals(access)) {
if(!SVars.password.equals(access)) {
this.closeConnection("Falsches Zugangspasswort");
return false;
}
@ -192,13 +192,13 @@ public class LoginHandler implements ILoginHandler
this.loginUser = packet.getUser();
if(this.loginUser.isEmpty() || !IPlayer.isValidUser(this.loginUser))
throw new IllegalStateException("Ungültiger Nutzername!");
if(!ServerConfig.passwordAuth && ServerConfig.authenticate) {
this.closeConnection("Dieser Server " + (ServerConfig.pubkeyAuth && ServerConfig.encrypt ? "benötigt einen öffentlichen Schlüssel zur Authentifizierung" : "hat keine Authentifizierungsmethode konfiguriert"));
if(!SVars.passwordAuth && SVars.authenticate) {
this.closeConnection("Dieser Server " + (SVars.pubkeyAuth && SVars.encrypt ? "benötigt einen öffentlichen Schlüssel zur Authentifizierung" : "hat keine Authentifizierungsmethode konfiguriert"));
return;
}
if(!this.checkAccess(packet.getAccess()))
return;
if(ServerConfig.authenticate)
if(SVars.authenticate)
this.loginPass = packet.getPassword();
this.state = LoginState.AUTHENTICATED;
}
@ -209,13 +209,13 @@ public class LoginHandler implements ILoginHandler
this.loginUser = packet.getUser();
if(this.loginUser.isEmpty() || !IPlayer.isValidUser(this.loginUser))
throw new IllegalStateException("Ungültiger Nutzername!");
if((!ServerConfig.pubkeyAuth || !ServerConfig.encrypt) && ServerConfig.authenticate) {
this.closeConnection("Dieser Server " + (ServerConfig.passwordAuth ? "benötigt ein Passwort zur Authentifizierung" : "hat keine Authentifizierungsmethode konfiguriert"));
if((!SVars.pubkeyAuth || !SVars.encrypt) && SVars.authenticate) {
this.closeConnection("Dieser Server " + (SVars.passwordAuth ? "benötigt ein Passwort zur Authentifizierung" : "hat keine Authentifizierungsmethode konfiguriert"));
return;
}
if(!this.checkAccess(packet.getAccess()))
return;
if(ServerConfig.authenticate) {
if(SVars.authenticate) {
this.loginKey = packet.getKey();
this.loginToken = new byte[32];
TOKEN_RNG.nextBytes(this.loginToken);

View file

@ -129,7 +129,7 @@ import server.clipboard.RotationValue;
import server.clipboard.Vector;
import server.command.Executor;
import server.util.Form;
import server.util.ServerConfig;
import server.vars.SVars;
import server.world.ChunkServer;
import server.world.Region;
import server.world.WorldServer;
@ -274,11 +274,11 @@ public class Player extends User implements ICrafting, Executor, IPlayer
public void onEntityDeath() {
this.entity.sendDeathMessage();
if (!ServerConfig.keepInventory && ServerConfig.playerDrop)
if (!SVars.keepInventory && SVars.playerDrop)
{
this.entity.inventory.dropAllItems();
}
if(ServerConfig.skullDrop) {
if(SVars.skullDrop) {
ItemStack stack = new ItemStack(Items.skull, 1, 0);
this.entity.dropItem(stack, true, false);
}
@ -303,8 +303,8 @@ public class Player extends User implements ICrafting, Executor, IPlayer
// this.removeStat(StatRegistry.timeSinceDeathStat);
this.entity.resetCombat();
if(ServerConfig.respawnTime > 0)
this.respawnTimer = ExtMath.clampi(ServerConfig.respawnTime, 2, 20);
if(SVars.respawnTime > 0)
this.respawnTimer = ExtMath.clampi(SVars.respawnTime, 2, 20);
}
public boolean isInEditor() {
@ -457,7 +457,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
public void clonePlayer(EntityNPC oldPlayer)
{
if(ServerConfig.keepInventory)
if(SVars.keepInventory)
this.entity.inventory.copyInventory(oldPlayer.inventory);
this.entity.experienceLevel = oldPlayer.experienceLevel;
this.entity.experienceTotal = oldPlayer.experienceTotal;
@ -2453,7 +2453,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.characters.add(new TagObject());
WorldServer world = this.server.getWorld(packetIn.getAuxData());
world = world == null ? this.server.getSpace() : world;
WorldPos origin = new WorldPos(world.rand.range(-ServerConfig.originRadius, ServerConfig.originRadius), 64, world.rand.range(-ServerConfig.originRadius, ServerConfig.originRadius),
WorldPos origin = new WorldPos(world.rand.range(-SVars.originRadius, SVars.originRadius), 64, world.rand.range(-SVars.originRadius, SVars.originRadius),
world.dimension.getDimensionId());
this.entity.setOrigin(origin);
Position pos = this.server.getRandomSpawnPosition(origin);

View file

@ -1,4 +1,4 @@
package server.util;
package server.vars;
import java.lang.reflect.Field;

View file

@ -1,9 +1,9 @@
package server.util;
package server.vars;
import common.init.Config;
import common.util.Var;
import common.vars.Vars;
public abstract class ServerConfig extends Config {
public abstract class SVars extends Vars {
@Var(name = "tickSpawning")
public static boolean tickSpawn = true;
@Var(name = "genSpawning")

View file

@ -1,4 +1,4 @@
package server.util;
package server.vars;
public enum ValueType {
STRING, BOOLEAN, INTEGER, FLOAT;

View file

@ -16,7 +16,7 @@ import common.util.ExtMath;
import common.world.World;
import server.biome.GenBiome;
import server.biome.RngSpawn;
import server.util.ServerConfig;
import server.vars.SVars;
public abstract class Spawner {
private static final int MOB_COUNT_DIV = (int)Math.pow(17.0D, 2.0D);
@ -53,7 +53,7 @@ public abstract class Spawner {
// }
CHUNKS.clear();
int locs = 0;
int range = Math.max(ServerConfig.mobSpawnDist, 1);
int range = Math.max(SVars.mobSpawnDist, 1);
for(EntityNPC player : world.players) {
// if(Config.spectatorSpawning || !player.isSpectator()) {
int x = ExtMath.floord(player.posX / 16.0D);
@ -75,14 +75,14 @@ public abstract class Spawner {
}
// boolean animals = (time % Math.max(Config.animalSpawnDelay, 1)) == 0;
int spawned = 0;
int mobSpread = Math.max(ServerConfig.spawnGroupDist, 1);
int mobSpread = Math.max(SVars.spawnGroupDist, 1);
// double spawnDist = (double)Config.mobSpawnDistance;
double playerDist = (double)ServerConfig.mobPlayerDist;
double playerDist = (double)SVars.mobPlayerDist;
// BlockPos spawn = world.isPrimary() ? Server.getSpawnPoint() : null;
// for(EnumCreatureType type : EnumCreatureType.values()) {
// if((!type.isPeaceful() || peaceful) && (type.isPeaceful() || hostile) && (!type.isAnimal() || animals)) {
int cur = world.countEntities(EntityLiving.class);
int max = ServerConfig.maxMobs * locs / MOB_COUNT_DIV;
int max = SVars.maxMobs * locs / MOB_COUNT_DIV;
if(cur <= max) {
typeLabel:
for(ChunkPos coord : CHUNKS) {
@ -98,7 +98,7 @@ public abstract class Spawner {
if(!block.isNormalCube()) {
int group = 0;
Object data = null;
for(int n = 0; n < ServerConfig.spawnGroups; ++n) {
for(int n = 0; n < SVars.spawnGroups; ++n) {
int mx = x;
int my = y;
int mz = z;

View file

@ -79,7 +79,7 @@ import server.biome.GenBiome;
import server.biome.RngSpawn;
import server.clipboard.ClipboardBlock;
import server.network.Player;
import server.util.ServerConfig;
import server.vars.SVars;
import server.village.VillageCollection;
import server.worldgen.BiomeGenLayered;
import server.worldgen.BiomeGenPerlin;
@ -180,7 +180,7 @@ public final class WorldServer extends AWorldServer {
private long time;
public static float clampGravity() {
return ExtMath.clampf(ServerConfig.gravity, -10.0f, 10.0f);
return ExtMath.clampf(SVars.gravity, -10.0f, 10.0f);
}
private BiomeGenerator createBiomeGenerator(Random rand) {
@ -290,8 +290,8 @@ public final class WorldServer extends AWorldServer {
this.updateViewRadius();
this.chunkDir = new File(new File("chunk"), dim.getDimensionName());
this.chunkDir.mkdirs();
if(!ServerConfig.seed.isEmpty())
this.rand.setSeed((long)ServerConfig.seed.hashCode() ^ ~((long)dim.getDimensionName().hashCode()));
if(!SVars.seed.isEmpty())
this.rand.setSeed((long)SVars.seed.hashCode() ^ ~((long)dim.getDimensionName().hashCode()));
this.seed = this.rand.longv();
this.dimension.setSeed(this.seed);
TagObject tag = null;
@ -321,7 +321,7 @@ public final class WorldServer extends AWorldServer {
// ...
}
else {
Log.TICK.info("Startwert für %s: %d" + (ServerConfig.seed.isEmpty() ? "" : " von Basiswert '%s'"), this.dimension.getFormattedName(false), this.seed, ServerConfig.seed);
Log.TICK.info("Startwert für %s: %d" + (SVars.seed.isEmpty() ? "" : " von Basiswert '%s'"), this.dimension.getFormattedName(false), this.seed, SVars.seed);
}
if(this.exterminated)
this.weather = Weather.CLEAR;
@ -449,7 +449,7 @@ public final class WorldServer extends AWorldServer {
}
public void updatePhysics() {
this.setTimeFactor(ServerConfig.timeFlow);
this.setTimeFactor(SVars.timeFlow);
this.setGravity(clampGravity());
}
@ -457,7 +457,7 @@ public final class WorldServer extends AWorldServer {
this.updateWeather(false);
this.biomeGen.cleanupCache();
// this.profiler.start("mobSpawner");
if(this.mobs && ServerConfig.mobs && ServerConfig.tickSpawn) {
if(this.mobs && SVars.mobs && SVars.tickSpawn) {
Spawner.spawn(this);
}
// this.profiler.next("chunkSource");
@ -481,7 +481,7 @@ public final class WorldServer extends AWorldServer {
// this.info.tick();
this.time += 1L;
// this.dataModified = true;
if(ServerConfig.dayCycle) // {
if(SVars.dayCycle) // {
this.daytime += this.timeFactor;
// if(this.dimension.getType().dayCycle)
// this.season = this.getSeasonByTime();
@ -588,7 +588,7 @@ public final class WorldServer extends AWorldServer {
}
protected void updateBlocks() {
this.setActivePlayerChunksAndCheckLight(ServerConfig.distance);
this.setActivePlayerChunksAndCheckLight(SVars.distance);
int i = 0;
int j = 0;
@ -605,7 +605,7 @@ public final class WorldServer extends AWorldServer {
// this.profiler.next("tickChunk");
chunk.update(false);
// this.profiler.next("thunder");
int l2 = ServerConfig.boltChance;
int l2 = SVars.boltChance;
if(l2 > 0 && this.rand.zrange(l2) == 0 && this.isThundering()) {
this.updateLCG = this.updateLCG * 3 + 1013904223;
@ -618,7 +618,7 @@ public final class WorldServer extends AWorldServer {
}
// this.profiler.next("iceandsnow");
l2 = ServerConfig.weatherTick;
l2 = SVars.weatherTick;
for(int z = 0; z < l2; z++) {
if(this.rand.zrange(16) == 0) {
@ -631,9 +631,9 @@ public final class WorldServer extends AWorldServer {
this.setState(blockpos1, Blocks.ice.getState());
}
if(this.snow && this.isRaining() && this.canSnowAt(blockpos2, true, ServerConfig.snowStack)) {
State layer = ServerConfig.snowStack ? this.getState(blockpos2) : null;
this.setState(blockpos2, ServerConfig.snowStack && layer.getBlock() == Blocks.snow_layer
if(this.snow && this.isRaining() && this.canSnowAt(blockpos2, true, SVars.snowStack)) {
State layer = SVars.snowStack ? this.getState(blockpos2) : null;
this.setState(blockpos2, SVars.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());
}
@ -642,8 +642,8 @@ public final class WorldServer extends AWorldServer {
this.getState(blockpos1).getBlock().fillWithRain(this, blockpos1);
}
if(ServerConfig.igniteChance > 0 && ServerConfig.fire && !this.isRaining() &&
this.rand.chance(this.hasDownfall() ? Math.max(1, ServerConfig.igniteChance / 3) : ServerConfig.igniteChance)
if(SVars.igniteChance > 0 && SVars.fire && !this.isRaining() &&
this.rand.chance(this.hasDownfall() ? Math.max(1, SVars.igniteChance / 3) : SVars.igniteChance)
&& this.canPlaceFireAt(blockpos2)) {
this.setState(blockpos2, Blocks.fire.getState());
}
@ -651,7 +651,7 @@ public final class WorldServer extends AWorldServer {
}
// this.profiler.next("tickBlocks");
l2 = ServerConfig.randomTick;
l2 = SVars.randomTick;
if(l2 > 0) {
this.toTick.addAll(chunk.getStorage());
@ -754,7 +754,7 @@ public final class WorldServer extends AWorldServer {
public void updateEntities() {
if(this.players.isEmpty()) {
if(this.emptyTicks++ >= ServerConfig.unloadTicks) {
if(this.emptyTicks++ >= SVars.unloadTicks) {
return;
}
}
@ -770,7 +770,7 @@ public final class WorldServer extends AWorldServer {
}
public boolean shouldUnload() {
return this.emptyTicks >= ServerConfig.unloadTicks && this.loaderList.isEmpty();
return this.emptyTicks >= SVars.unloadTicks && this.loaderList.isEmpty();
}
public boolean tickUpdates(boolean p_72955_1_) {
@ -1073,7 +1073,7 @@ public final class WorldServer extends AWorldServer {
this.effects.add(entity);
this.server.sendNear(entity.posX, entity.posY, entity.posZ, 512.0D, this.dimension.getDimensionId(),
new SPacketSpawnGlobalEntity(entity, 1, entity.color));
if(fire && ServerConfig.fire) {
if(fire && SVars.fire) {
BlockPos pos = new BlockPos(entity);
if(this.isAreaLoaded(pos, 10)) {
if(this.getState(pos).getBlock() == Blocks.air && Blocks.fire.canPlaceBlockAt(this, pos))
@ -1182,9 +1182,9 @@ public final class WorldServer extends AWorldServer {
float prevRain = this.rain;
float prevFog = this.fog;
if(ServerConfig.weather && ServerConfig.weatherChance > 0) {
if(SVars.weather && SVars.weatherChance > 0) {
// int time = dim.getWeatherTime();
if(this.rand.chance(ServerConfig.weatherChance)) {
if(this.rand.chance(SVars.weatherChance)) {
Weather nweather = Weather.pick(this.getBaseTemperature(), this.rand);
if(nweather != this.weather) {
// dim.setWeatherTime(this.rand.zrange(Config.weatherFlow) + Config.weatherFlow);
@ -1535,7 +1535,7 @@ public final class WorldServer extends AWorldServer {
liquid.generate(this, this.grng, pos);
}
}
if(this.mobs && ServerConfig.mobs && ServerConfig.genSpawn) {
if(this.mobs && SVars.mobs && SVars.genSpawn) {
Spawner.generate(this, biome, bx + 8, bz + 8, 16, 16, this.grng);
}
// if(this.snow) {
@ -1984,7 +1984,7 @@ public final class WorldServer extends AWorldServer {
}
public void updateViewRadius() {
int radius = ExtMath.clampi(ServerConfig.distance, 3, 128);
int radius = ExtMath.clampi(SVars.distance, 3, 128);
if(radius != this.viewRadius) {
int diff = radius - this.viewRadius;
@ -2018,7 +2018,7 @@ public final class WorldServer extends AWorldServer {
this.viewRadius = radius;
}
this.trackDistance = ServerConfig.distance * 16 - 16;
this.trackDistance = SVars.distance * 16 - 16;
}
public void trackEntity(Entity entityIn) {

View file

@ -16,7 +16,7 @@ import common.rng.Random;
import common.tags.TagObject;
import common.util.BlockPos;
import common.util.Facing;
import server.util.ServerConfig;
import server.vars.SVars;
import server.world.WorldServer;
import server.worldgen.LootConstants;
@ -671,7 +671,7 @@ public class StructureScattered
}
}
if (!this.hasMage && ServerConfig.mobs && ServerConfig.spawnHutMage)
if (!this.hasMage && SVars.mobs && SVars.spawnHutMage)
{
int l1 = this.getXWithOffset(2, 5);
int i2 = this.getYWithOffset(2);

View file

@ -20,7 +20,7 @@ import common.tags.TagObject;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import server.util.ServerConfig;
import server.vars.SVars;
import server.world.WorldServer;
import server.worldgen.BiomeGenerator;
import server.worldgen.LootConstants;
@ -1604,7 +1604,7 @@ public class StructureVillage
protected void spawnVillagers(WorldServer worldIn, StructureBoundingBox p_74893_2_, int p_74893_3_, int p_74893_4_, int p_74893_5_, int p_74893_6_)
{
if (this.villagersSpawned < p_74893_6_ && ServerConfig.mobs && ServerConfig.spawnVillager)
if (this.villagersSpawned < p_74893_6_ && SVars.mobs && SVars.spawnVillager)
{
for (int i = this.villagersSpawned; i < p_74893_6_; ++i)
{
@ -1921,7 +1921,7 @@ public class StructureVillage
protected void spawnVillager(WorldServer worldIn, StructureBoundingBox p_74893_2_, int x, int y, int z)
{
if (!this.villagerSpawned && ServerConfig.mobs && ServerConfig.spawnCagedVillager)
if (!this.villagerSpawned && SVars.mobs && SVars.spawnCagedVillager)
{
int j = this.getXWithOffset(x, z);
int k = this.getYWithOffset(y);