Send scaled generation bounds coordinates
This commit is contained in:
+2
-2
@@ -113,8 +113,8 @@ public class RemoteWorldRetrievalQueue extends AbstractFullDataNetworkRequestQue
|
||||
if (this.networkState.sessionConfig.getGenerationBoundsRadius() > 0)
|
||||
{
|
||||
if (DhSectionPos.getChebyshevSignedBlockDistance(sectionPos, new DhBlockPos2D(
|
||||
(int) (this.networkState.sessionConfig.getGenerationBoundsX() / this.level.levelWrapper.getDimensionType().getCoordinateScale()),
|
||||
(int) (this.networkState.sessionConfig.getGenerationBoundsZ() / this.level.levelWrapper.getDimensionType().getCoordinateScale())
|
||||
this.networkState.sessionConfig.getGenerationBoundsX(),
|
||||
this.networkState.sessionConfig.getGenerationBoundsZ()
|
||||
)) > this.networkState.sessionConfig.getGenerationBoundsRadius())
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -151,10 +151,9 @@ public abstract class AbstractDhServerLevel extends AbstractDhLevel implements I
|
||||
|
||||
if (Config.Server.generationBoundsRadius.get() > 0)
|
||||
{
|
||||
double coordinateScale = this.serverLevelWrapper.getDimensionType().getCoordinateScale();
|
||||
if (DhSectionPos.getChebyshevSignedBlockDistance(message.sectionPos, new DhBlockPos2D(
|
||||
(int) (Config.Server.generationBoundsX.get() / coordinateScale),
|
||||
(int) (Config.Server.generationBoundsZ.get() / coordinateScale)
|
||||
serverPlayerState.sessionConfig.getGenerationBoundsX(),
|
||||
serverPlayerState.sessionConfig.getGenerationBoundsZ()
|
||||
)) > Config.Server.generationBoundsRadius.get())
|
||||
{
|
||||
message.sendResponse(new RequestOutOfRangeException("Section out of allowed bounds"));
|
||||
|
||||
+4
-4
@@ -33,9 +33,9 @@ public class SessionConfig implements INetworkObject
|
||||
|
||||
registerConfigEntry(Config.Common.WorldGenerator.enableDistantGeneration, Boolean::logicalAnd);
|
||||
registerConfigEntry(Config.Server.maxGenerationRequestDistance, Math::min);
|
||||
registerConfigEntry(Config.Server.generationBoundsX, (x, y) -> x);
|
||||
registerConfigEntry(Config.Server.generationBoundsZ, (x, y) -> x);
|
||||
registerConfigEntry(Config.Server.generationBoundsRadius, (x, y) -> x);
|
||||
registerConfigEntry(Config.Server.generationBoundsX, (x, y) -> y);
|
||||
registerConfigEntry(Config.Server.generationBoundsZ, (x, y) -> y);
|
||||
registerConfigEntry(Config.Server.generationBoundsRadius, (x, y) -> y);
|
||||
registerConfigEntry(Config.Server.generationRequestRateLimit, Math::min);
|
||||
|
||||
registerConfigEntry(Config.Server.enableRealTimeUpdates, Boolean::logicalAnd);
|
||||
@@ -119,7 +119,7 @@ public class SessionConfig implements INetworkObject
|
||||
}
|
||||
|
||||
return (this.constrainingConfig != null
|
||||
? (T) entry.valueConstrainer.apply(value, this.constrainingConfig.getValue(name))
|
||||
? (T) entry.valueConstrainer.apply(this.constrainingConfig.getValue(name), value)
|
||||
: value);
|
||||
}
|
||||
|
||||
|
||||
+11
-3
@@ -24,7 +24,7 @@ public class ServerPlayerState implements Closeable
|
||||
{
|
||||
private final ConfigChangeListener<String> levelKeyPrefixChangeListener
|
||||
= new ConfigChangeListener<>(Config.Server.levelKeyPrefix, this::onLevelKeyPrefixConfigChanged);
|
||||
private final SessionConfig.AnyChangeListener configAnyChangeListener = new SessionConfig.AnyChangeListener(this::onSessionConfigChanged);
|
||||
private final SessionConfig.AnyChangeListener configAnyChangeListener = new SessionConfig.AnyChangeListener(this::sendConfigMessage);
|
||||
|
||||
|
||||
private String lastLevelKey = "";
|
||||
@@ -56,8 +56,9 @@ public class ServerPlayerState implements Closeable
|
||||
this.networkSession.registerHandler(SessionConfigMessage.class, (sessionConfigMessage) ->
|
||||
{
|
||||
this.sessionConfig.constrainingConfig = sessionConfigMessage.config;
|
||||
|
||||
this.sendLevelKey();
|
||||
this.networkSession.sendMessage(new SessionConfigMessage(this.sessionConfig));
|
||||
this.sendConfigMessage();
|
||||
});
|
||||
|
||||
this.networkSession.registerHandler(CloseInternalEvent.class, event -> {
|
||||
@@ -93,7 +94,14 @@ public class ServerPlayerState implements Closeable
|
||||
}
|
||||
}
|
||||
|
||||
private void onSessionConfigChanged() { this.networkSession.sendMessage(new SessionConfigMessage(this.sessionConfig)); }
|
||||
private void sendConfigMessage()
|
||||
{
|
||||
double coordinateScale = this.getServerPlayer().getLevel().getDimensionType().getCoordinateScale();
|
||||
this.sessionConfig.constrainValue(Config.Server.generationBoundsX, (int) (Config.Server.generationBoundsX.get() / coordinateScale));
|
||||
this.sessionConfig.constrainValue(Config.Server.generationBoundsZ, (int) (Config.Server.generationBoundsZ.get() / coordinateScale));
|
||||
|
||||
this.networkSession.sendMessage(new SessionConfigMessage(this.sessionConfig));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user