Compare commits

...

9 Commits

Author SHA1 Message Date
Spottedleaf
9a16a91fb8 Set version to 0.1.0-beta.12 2025-02-24 20:52:25 -08:00
Jason Penilla
580041a1a1 Clear lastSection on game event listener removal (fixes #87) (backport of #99) 2025-02-24 17:40:26 -07:00
Spottedleaf
fb31d0e1f7 Set version to 0.1.0-SNAPSHOT 2025-01-27 08:20:45 -08:00
Spottedleaf
0b2070d781 Set version to 0.1.0-beta.11 2025-01-27 08:12:17 -08:00
Spottedleaf
30a79469e3 Correctly retrun true for empty input shapes in EntityGetter#isUnobstructed
Vanilla will return true for empty shapes, so we should as well.
2025-01-27 07:59:20 -08:00
Jason Penilla
254b331259 Exclude transitive deps provided by Minecraft 2024-12-04 10:19:20 -07:00
Jason Penilla
a21c44ad31 Use libraries from Paper repo (#82)
* Use YamlConfig from Paper repo

* Add comment to settings

* Use ConcurrentUtil from Paper repo and use release of YamlConfig

* Use ConcurrentUtil release
2024-12-03 20:33:24 -07:00
Spottedleaf
77ba4a4584 Throw when sync loading chunks after shutdown
The caller would block indefinitely if a sync load is requested
during shutdown. Rather than block indefinitely, we should throw
an exception to indicate to the caller that the chunk system is
unable to process requests.
2024-12-03 20:32:14 -07:00
Spottedleaf
a510acbd78 Set version to 0.1.0-SNAPSHOT 2024-12-01 15:57:47 -08:00
17 changed files with 69 additions and 36 deletions

View File

@@ -31,8 +31,6 @@ jobs:
key: ${{ runner.os }}-project-local-gradle-caches-${{ hashFiles('**/libs.versions.toml', '**/*.gradle*', '**/gradle-wrapper.properties') }} key: ${{ runner.os }}-project-local-gradle-caches-${{ hashFiles('**/libs.versions.toml', '**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: | restore-keys: |
${{ runner.os }}-project-local-gradle-caches- ${{ runner.os }}-project-local-gradle-caches-
- name: "setup dependencies"
run: ./install_deps.sh
- name: "execute gradle build" - name: "execute gradle build"
run: ./gradlew build run: ./gradlew build
- name: Determine Snapshot Status - name: Determine Snapshot Status

6
.gitmodules vendored
View File

@@ -1,6 +0,0 @@
[submodule "ConcurrentUtil"]
path = ConcurrentUtil
url = https://github.com/Spottedleaf/ConcurrentUtil.git
[submodule "YamlConfig"]
path = YamlConfig
url = https://github.com/Spottedleaf/YamlConfig.git

Submodule ConcurrentUtil deleted from 08d3ca3241

Submodule YamlConfig deleted from 67552e7707

View File

@@ -22,8 +22,8 @@ def getGitCommit = { ->
dependencies { dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
api("ca.spottedleaf:concurrentutil:${rootProject.concurrentutil_version}") api("ca.spottedleaf:concurrentutil:${rootProject.concurrentutil_version}") { setTransitive(false) }
api("ca.spottedleaf:yamlconfig:${rootProject.yamlconfig_version}") api("ca.spottedleaf:yamlconfig:${rootProject.yamlconfig_version}") { setTransitive(false) }
api("org.yaml:snakeyaml:${rootProject.snakeyaml_version}") api("org.yaml:snakeyaml:${rootProject.snakeyaml_version}")
modImplementation "me.shedaniel.cloth:cloth-config:${rootProject.cloth_version}" modImplementation "me.shedaniel.cloth:cloth-config:${rootProject.cloth_version}"
@@ -46,10 +46,10 @@ allprojects {
} }
repositories { repositories {
mavenLocal { maven {
url "https://repo.papermc.io/repository/maven-public/"
mavenContent { mavenContent {
includeModule("ca.spottedleaf", "concurrentutil") includeGroup("ca.spottedleaf")
includeModule("ca.spottedleaf", "yamlconfig")
} }
} }
maven { maven {

View File

@@ -17,8 +17,8 @@ dependencies {
runtimeOnly(project(":").sourceSets.main.output) runtimeOnly(project(":").sourceSets.main.output)
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
libs("ca.spottedleaf:concurrentutil:${rootProject.concurrentutil_version}") libs("ca.spottedleaf:concurrentutil:${rootProject.concurrentutil_version}") { setTransitive(false) }
libs("ca.spottedleaf:yamlconfig:${rootProject.yamlconfig_version}") libs("ca.spottedleaf:yamlconfig:${rootProject.yamlconfig_version}") { setTransitive(false) }
libs("org.yaml:snakeyaml:${rootProject.snakeyaml_version}") libs("org.yaml:snakeyaml:${rootProject.snakeyaml_version}")
modImplementation "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_version}" modImplementation "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_version}"

View File

@@ -8,13 +8,13 @@ supported_minecraft_versions=1.21,1.21.1
loader_version=0.16.5 loader_version=0.16.5
neoforge_version=21.1.79 neoforge_version=21.1.79
snakeyaml_version=2.3 snakeyaml_version=2.3
concurrentutil_version=0.0.2-SNAPSHOT concurrentutil_version=0.0.2
yamlconfig_version=1.0.2-SNAPSHOT yamlconfig_version=1.0.2
cloth_version=15.0.128 cloth_version=15.0.128
# version ids from modrinth # version ids from modrinth
fabric_lithium_version=frXUdgvL fabric_lithium_version=frXUdgvL
neo_lithium_version=KhdehJ6l neo_lithium_version=KhdehJ6l
# Mod Properties # Mod Properties
mod_version=0.1.0-beta.10 mod_version=0.1.0-beta.12
maven_group=ca.spottedleaf.moonrise maven_group=ca.spottedleaf.moonrise
archives_base_name=moonrise archives_base_name=moonrise

View File

@@ -1,12 +0,0 @@
#!/bin/bash
set -eou pipefail
git submodule update --init --recursive
cd ConcurrentUtil
mvn install
cd ..
cd YamlConfig
mvn install

View File

@@ -21,8 +21,8 @@ dependencies {
add('shadow', project([path: ":", configuration: "namedElements"])) add('shadow', project([path: ":", configuration: "namedElements"]))
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}" neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"
shadow("ca.spottedleaf:concurrentutil:${rootProject.concurrentutil_version}") shadow("ca.spottedleaf:concurrentutil:${rootProject.concurrentutil_version}") { setTransitive(false) }
shadow("ca.spottedleaf:yamlconfig:${rootProject.yamlconfig_version}") shadow("ca.spottedleaf:yamlconfig:${rootProject.yamlconfig_version}") { setTransitive(false) }
shadow("org.yaml:snakeyaml:${rootProject.snakeyaml_version}") shadow("org.yaml:snakeyaml:${rootProject.snakeyaml_version}")
forgeExtra("org.yaml:snakeyaml:${rootProject.snakeyaml_version}") forgeExtra("org.yaml:snakeyaml:${rootProject.snakeyaml_version}")

View File

@@ -48,3 +48,6 @@ include("fabric")
findProject(":fabric").name = "Moonrise-Fabric" findProject(":fabric").name = "Moonrise-Fabric"
include("neoforge") include("neoforge")
findProject(":neoforge").name = "Moonrise-NeoForge" findProject(":neoforge").name = "Moonrise-NeoForge"
// includeBuild("../YamlConfig") // Uncomment to use local YamlConfig
// includeBuild("../ConcurrentUtil") // Uncomment to use local ConcurrentUtil

View File

@@ -0,0 +1,25 @@
package ca.spottedleaf.moonrise.mixin.chunk_system;
import net.minecraft.core.SectionPos;
import net.minecraft.world.level.gameevent.DynamicGameEventListener;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(DynamicGameEventListener.class)
abstract class DynamicGameEventListenerMixin {
@Shadow @Nullable private SectionPos lastSection;
@Inject(method = "remove", at = @At("RETURN"))
private void onRemove(final CallbackInfo ci) {
// We need to unset the last section when removed, otherwise if the same instance is re-added at the same position it
// will assume there was no change and fail to re-register.
// In vanilla, chunks rarely unload and re-load quickly enough to trigger this issue. However, our chunk system has a
// quirk where fast chunk reload cycles will often occur on player login (see PR #22).
// So we fix this vanilla oversight as our changes cause it to manifest in bugs much more often (see issue #87).
this.lastSection = null;
}
}

View File

@@ -81,6 +81,13 @@ abstract class ServerChunkCacheMixin extends ChunkSource implements ChunkSystemS
completable::complete completable::complete
); );
if (!completable.isDone() && chunkTaskScheduler.hasShutdown()) {
throw new IllegalStateException(
"Chunk system has shut down, cannot process chunk requests in world '" + ca.spottedleaf.moonrise.common.util.WorldUtil.getWorldName(this.level) + "' at "
+ "(" + chunkX + "," + chunkZ + ") status: " + toStatus
);
}
if (TickThread.isTickThreadFor(this.level, chunkX, chunkZ)) { if (TickThread.isTickThreadFor(this.level, chunkX, chunkZ)) {
ChunkTaskScheduler.pushChunkWait(this.level, chunkX, chunkZ); ChunkTaskScheduler.pushChunkWait(this.level, chunkX, chunkZ);
this.mainThreadProcessor.managedBlock(completable::isDone); this.mainThreadProcessor.managedBlock(completable::isDone);

View File

@@ -74,7 +74,7 @@ interface EntityGetterMixin {
@Overwrite @Overwrite
default boolean isUnobstructed(final Entity entity, final VoxelShape voxel) { default boolean isUnobstructed(final Entity entity, final VoxelShape voxel) {
if (voxel.isEmpty()) { if (voxel.isEmpty()) {
return false; return true;
} }
final AABB singleAABB = ((CollisionVoxelShape)voxel).moonrise$getSingleAABBRepresentation(); final AABB singleAABB = ((CollisionVoxelShape)voxel).moonrise$getSingleAABBRepresentation();

View File

@@ -55,7 +55,7 @@ abstract class LevelMixin implements LevelAccessor, AutoCloseable {
public boolean isUnobstructed(final Entity entity) { public boolean isUnobstructed(final Entity entity) {
final AABB boundingBox = entity.getBoundingBox(); final AABB boundingBox = entity.getBoundingBox();
if (CollisionUtil.isEmpty(boundingBox)) { if (CollisionUtil.isEmpty(boundingBox)) {
return false; return true;
} }
final List<Entity> entities = this.getEntities( final List<Entity> entities = this.getEntities(

View File

@@ -219,6 +219,8 @@ public final class ChunkHolderManager {
LOGGER.error("Failed to close '" + type.name() + "' regionfile cache for world '" + WorldUtil.getWorldName(this.world) + "'", ex); LOGGER.error("Failed to close '" + type.name() + "' regionfile cache for world '" + WorldUtil.getWorldName(this.world) + "'", ex);
} }
} }
this.taskScheduler.setShutdown(true);
} }
void ensureInAutosave(final NewChunkHolder holder) { void ensureInAutosave(final NewChunkHolder holder) {

View File

@@ -271,6 +271,16 @@ public final class ChunkTaskScheduler {
return this.lockShift; return this.lockShift;
} }
private volatile boolean shutdown;
public boolean hasShutdown() {
return this.shutdown;
}
public void setShutdown(final boolean shutdown) {
this.shutdown = shutdown;
}
public ChunkTaskScheduler(final ServerLevel world) { public ChunkTaskScheduler(final ServerLevel world) {
this.world = world; this.world = world;
// must be >= region shift (in paper, doesn't exist) and must be >= ticket propagator section shift // must be >= region shift (in paper, doesn't exist) and must be >= ticket propagator section shift
@@ -524,6 +534,13 @@ public final class ChunkTaskScheduler {
return loaded; return loaded;
} }
if (this.hasShutdown()) {
throw new IllegalStateException(
"Chunk system has shut down, cannot process chunk requests in world '" + ca.spottedleaf.moonrise.common.util.WorldUtil.getWorldName(this.world) + "' at "
+ "(" + chunkX + "," + chunkZ + ") status: " + status
);
}
final Long ticketId = getNextNonFullLoadId(); final Long ticketId = getNextNonFullLoadId();
final int ticketLevel = getTicketLevel(status); final int ticketLevel = getTicketLevel(status);
this.chunkHolderManager.addTicketAtLevel(NON_FULL_CHUNK_LOAD, chunkX, chunkZ, ticketLevel, ticketId); this.chunkHolderManager.addTicketAtLevel(NON_FULL_CHUNK_LOAD, chunkX, chunkZ, ticketLevel, ticketId);

View File

@@ -30,6 +30,7 @@
"chunk_system.ChunkStepMixin", "chunk_system.ChunkStepMixin",
"chunk_system.ChunkStorageMixin", "chunk_system.ChunkStorageMixin",
"chunk_system.DistanceManagerMixin", "chunk_system.DistanceManagerMixin",
"chunk_system.DynamicGameEventListenerMixin",
"chunk_system.EntityGetterMixin", "chunk_system.EntityGetterMixin",
"chunk_system.EntityMixin", "chunk_system.EntityMixin",
"chunk_system.EntityTickListMixin", "chunk_system.EntityTickListMixin",