Compare commits

..

4 Commits

Author SHA1 Message Date
Jim C K Flaten b0e7c31964 Comment 2026-01-05 21:32:41 +01:00
Jim C K Flaten 2e906b57c4 Channel name should be 20 chars or shorter for compatibility with old version of Minecraft. 2026-01-03 23:36:46 +01:00
s809 505dbe2f62 Replace the failure state with future exceptions 2025-12-27 00:51:30 +05:00
James Seibel 48c5828e8f up version number 2.4.5 -> 2.4.6-dev 2025-12-24 22:41:27 -06:00
8 changed files with 22 additions and 32 deletions
@@ -32,13 +32,15 @@ public final class ModInfo
/** Incremented every time any packets are added, changed or removed, with a few exceptions. */
public static final int PROTOCOL_VERSION = 13;
public static final String WRAPPER_PACKET_PATH = "message";
/** The full plugin channel name (RESOURCE_NAMESPACE:WRAPPER_PACKET_PATH) must be 20 characters or fewer for compatibility with <1.13. */
public static final String WRAPPER_PACKET_PATH = "msg";
/** The internal mod name */
public static final String NAME = "DistantHorizons";
/** Human-readable version of NAME */
public static final String READABLE_NAME = "Distant Horizons";
public static final String VERSION = "2.4.5-b";
public static final String VERSION = "2.4.6-b-dev";
/** Returns true if the current build is an unstable developer build, false otherwise. */
public static final boolean IS_DEV_BUILD = VERSION.toLowerCase().contains("dev");
@@ -44,6 +44,7 @@ import com.seibel.distanthorizons.core.util.threading.PriorityTaskPicker;
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
import it.unimi.dsi.fastutil.bytes.ByteArrayList;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
@@ -116,26 +117,22 @@ public class GeneratedFullDataSourceProvider extends FullDataSourceProviderV2 im
// events //
//========//
private void onWorldGenTaskComplete(DataSourceRetrievalResult genTaskResult, Throwable exception)
private void onWorldGenTaskComplete(@NotNull Long genPos, @Nullable DataSourceRetrievalResult genTaskResult, @Nullable Throwable exception)
{
try
{
if (exception != null)
{
return;
}
if (genTaskResult.state == ERetrievalResultState.FAIL)
{
LodUtil.assertTrue(genTaskResult.dataSource == null, "Errored retrieval object should not have a datasource.");
// don't log shutdown exceptions
if (!ExceptionUtil.isInterruptOrReject(exception))
{
LOGGER.error("Uncaught Gen Task Exception at [" + genTaskResult.pos + "], error: [" + exception.getMessage() + "].", exception);
LOGGER.error("Uncaught Gen Task Exception at [" + genPos + "], error: [" + exception.getMessage() + "].", exception);
}
return;
}
else if (genTaskResult.state == ERetrievalResultState.SUCCESS)
Objects.requireNonNull(genTaskResult);
if (genTaskResult.state == ERetrievalResultState.SUCCESS)
{
LodUtil.assertTrue(genTaskResult.dataSource != null, "Successful retrieval object should have a datasource.");
@@ -310,7 +307,7 @@ public class GeneratedFullDataSourceProvider extends FullDataSourceProviderV2 im
}
CompletableFuture<DataSourceRetrievalResult> worldGenFuture = worldGenQueue.submitRetrievalTask(genPos, (byte) (DhSectionPos.getDetailLevel(genPos) - DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL));
worldGenFuture.whenComplete(this::onWorldGenTaskComplete);
worldGenFuture.whenComplete((r, e) -> this.onWorldGenTaskComplete(genPos, r, e));
return worldGenFuture;
}
@@ -157,9 +157,9 @@ public class PregenManager
else
{
this.fullDataSourceProvider.queuePositionForRetrieval(fullDataSource.getPos())
.thenAccept((DataSourceRetrievalResult result) ->
.whenComplete((DataSourceRetrievalResult result, Throwable throwable) ->
{
if (result.state == ERetrievalResultState.FAIL)
if (throwable != null)
{
LOGGER.warn("Failed to generate section " + DhSectionPos.toString(result.pos));
}
@@ -92,7 +92,7 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
private int estimatedRemainingChunkCount = 0;
private final RollingAverage rollingAverageChunkGenTimeInMs = new RollingAverage(Runtime.getRuntime().availableProcessors() * 500);
public RollingAverage getRollingAverageChunkGenTimeInMs() { return this.rollingAverageChunkGenTimeInMs; }
@Override public RollingAverage getRollingAverageChunkGenTimeInMs() { return this.rollingAverageChunkGenTimeInMs; }
@@ -128,7 +128,9 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
// the generator is shutting down, don't add new tasks
if (this.generatorClosingFuture != null)
{
return CompletableFuture.completedFuture(DataSourceRetrievalResult.CreateFail());
CompletableFuture<DataSourceRetrievalResult> f = new CompletableFuture<>();
f.completeExceptionally(new CancellationException());
return f;
}
// use the existing task if present
@@ -362,7 +364,7 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
}
LodUtil.assertTrue(fullDataSource == null);
worldGenTask.future.complete(DataSourceRetrievalResult.CreateFail());
worldGenTask.future.completeExceptionally(exception);
}
else
{
@@ -40,7 +40,6 @@ public class DataSourceRetrievalResult
//==============//
public static DataSourceRetrievalResult CreateSplit() { return new DataSourceRetrievalResult(ERetrievalResultState.REQUIRES_SPLITTING, 0, null); }
public static DataSourceRetrievalResult CreateFail() { return new DataSourceRetrievalResult(ERetrievalResultState.FAIL, 0, null); }
public static DataSourceRetrievalResult CreateSuccess(long pos, FullDataSourceV2 generatedDataSource) { return new DataSourceRetrievalResult(ERetrievalResultState.SUCCESS, pos, generatedDataSource); }
private DataSourceRetrievalResult(ERetrievalResultState state, long pos, @Nullable FullDataSourceV2 dataSource)
{
@@ -3,7 +3,6 @@ package com.seibel.distanthorizons.core.generation.tasks;
/**
* SUCCESS <br>
* REQUIRES_SPLITTING <br>
* FAIL <br>
*
* @see DataSourceRetrievalResult
*/
@@ -11,5 +10,4 @@ public enum ERetrievalResultState
{
SUCCESS,
REQUIRES_SPLITTING,
FAIL,
}
@@ -139,9 +139,6 @@ public abstract class AbstractFullDataNetworkRequestQueue implements IDebugRende
break;
case REQUIRES_SPLITTING:
break;
case FAIL:
this.failedRequests.incrementAndGet();
break;
}
});
@@ -269,7 +266,7 @@ public abstract class AbstractFullDataNetworkRequestQueue implements IDebugRende
catch (RequestRejectedException e)
{
LOGGER.info("Request rejected by the server, message: [" + e.getMessage() + "].");
requestTask.future.complete(DataSourceRetrievalResult.CreateFail());
requestTask.future.completeExceptionally(e);
}
catch (RateLimitedException e)
{
@@ -298,7 +295,7 @@ public abstract class AbstractFullDataNetworkRequestQueue implements IDebugRende
}
else
{
requestTask.future.complete(DataSourceRetrievalResult.CreateFail());
requestTask.future.completeExceptionally(e);
}
}
}
@@ -622,12 +622,7 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
// task finished
this.queuedGenerationPosSet.remove(missingPos);
// if the task failed re-queue so we can try again
if (result.state == ERetrievalResultState.FAIL)
{
this.missingGenerationPosSet.add(missingPos);
}
else if (result.state == ERetrievalResultState.REQUIRES_SPLITTING)
if (result.state == ERetrievalResultState.REQUIRES_SPLITTING)
{
DhSectionPos.forEachChild(missingPos, (long childPos) ->
{