Compare commits

..

9 Commits

Author SHA1 Message Date
Spottedleaf
bad5cae4d8 0.2.0-beta.3 2024-11-02 16:50:24 -07:00
Spottedleaf
e3b1502bb6 0.2.0-beta.9 2024-11-02 16:48:24 -07:00
Spottedleaf
54fc964987 Handle corrupt light data gracefully
First, if the light data is not marked as correct, we should not be
parsing it in the first place. This will eliminate errors from
parsing possibly different versioned light data.

Secondly, if parsing the light data throws an exception (from
the SWMRNibbleArray constructor), then we can simply mark
the returned chunk as having incorrect light data - rather than
propagating the exception and causing the chunk to be re-generated.
2024-11-02 16:14:05 -07:00
Spottedleaf
0cbc9aa1a1 Update README to reflect official nature of the patches 2024-10-31 12:05:59 -07:00
Jason Penilla
19e2136ae1 Use declaration order for state holder property iteration
Mostly an aesthetic change for serialization, should not have any impact on performance or correctness.
2024-10-27 18:32:04 -07:00
Jason Penilla
126cc03747 Back to 0.2.0-SNAPSHOT 2024-10-26 11:02:43 -07:00
Jason Penilla
ceb4936d9d 0.2.0-beta.2 2024-10-26 10:58:58 -07:00
Jason Penilla
3cb888e894 Update Fabric API and call ServerChunkEvents.CHUNK_GENERATE 2024-10-26 09:51:34 -07:00
Jason Penilla
7bedc1a7de Back to 0.2.0-SNAPSHOT 2024-10-24 11:54:52 -07:00
5 changed files with 52 additions and 31 deletions

View File

@@ -12,13 +12,13 @@ Fabric/NeoForge mod for optimising performance of the integrated (singleplayer/L
Moonrise aims to optimise the game *without changing Vanilla behavior*. If you find that there are changes to Vanilla behavior,
please open an issue.
Moonrise ports several important [Paper](https://github.com/PaperMC/Paper/)
Moonrise is an official port of several important [Paper](https://github.com/PaperMC/Paper/)
patches. Listed below are notable patches:
- [Starlight](https://github.com/PaperMC/Starlight/)
- Chunk system rewrite
- Collision optimisations
- Entity tracker optimisations
- Random ticking optimisations
- [Starlight](https://github.com/PaperMC/Starlight/)
## Known Compatibility Issues
| Mod | Status |

View File

@@ -20,6 +20,7 @@ import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ImposterProtoChunk;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.ProtoChunk;
import net.minecraft.world.level.chunk.status.ChunkStatusTasks;
@@ -69,6 +70,9 @@ public final class FabricHooks implements PlatformHooks {
public void chunkFullStatusComplete(final LevelChunk newChunk, final ProtoChunk original) {
if (HAS_FABRIC_LIFECYCLE_EVENTS) {
ServerChunkEvents.CHUNK_LOAD.invoker().onChunkLoad((ServerLevel)newChunk.getLevel(), newChunk);
if (!(original instanceof ImposterProtoChunk)) {
ServerChunkEvents.CHUNK_GENERATE.invoker().onChunkGenerate((ServerLevel)newChunk.getLevel(), newChunk);
}
}
}

View File

@@ -7,7 +7,7 @@ minecraft_version=1.21.3
loader_version=0.16.7
supported_minecraft_versions=1.21.3
neoforge_version=21.3.0-beta
fabric_api_version=0.106.1+1.21.3
fabric_api_version=0.107.0+1.21.3
snakeyaml_version=2.2
concurrentutil_version=0.0.2-SNAPSHOT
cloth_version=16.0.141
@@ -16,6 +16,6 @@ modmenu_version=12.0.0-beta.1
fabric_lithium_version=mc1.21.1-0.14.0-beta.1
neo_lithium_version=BrMIoIMv
# Mod Properties
mod_version=0.2.0-beta.1
mod_version=0.2.0-beta.3
maven_group=ca.spottedleaf.moonrise
archives_base_name=moonrise

View File

@@ -21,6 +21,7 @@ import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.level.chunk.storage.RegionStorageInfo;
import net.minecraft.world.level.chunk.storage.SerializableChunkData;
import net.minecraft.world.level.lighting.LevelLightEngine;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -46,6 +47,10 @@ abstract class SerializableChunkDataMixin {
@Final
private List<SerializableChunkData.SectionData> sectionData;
@Shadow
@Final
private static Logger LOGGER;
/**
* @reason Replace light correctness check with our own
* Our light check is versioned in case we change the light format OR fix a bug
@@ -116,33 +121,45 @@ abstract class SerializableChunkDataMixin {
final SWMRNibbleArray[] blockNibbles = StarLightEngine.getFilledEmptyLight(world);
final SWMRNibbleArray[] skyNibbles = StarLightEngine.getFilledEmptyLight(world);
for (final SerializableChunkData.SectionData sectionData : this.sectionData) {
final int y = sectionData.y();
final DataLayer blockLight = sectionData.blockLight();
final DataLayer skyLight = sectionData.skyLight();
final int blockState = ((StarlightSectionData)(Object)sectionData).starlight$getBlockLightState();
final int skyState = ((StarlightSectionData)(Object)sectionData).starlight$getSkyLightState();
if (blockState >= 0) {
if (blockLight != null) {
blockNibbles[y - minSection] = new SWMRNibbleArray(MixinWorkarounds.clone(blockLight.getData()), blockState); // clone for data safety
} else {
blockNibbles[y - minSection] = new SWMRNibbleArray(null, blockState);
}
}
if (skyState >= 0 && hasSkyLight) {
if (skyLight != null) {
skyNibbles[y - minSection] = new SWMRNibbleArray(MixinWorkarounds.clone(skyLight.getData()), skyState); // clone for data safety
} else {
skyNibbles[y - minSection] = new SWMRNibbleArray(null, skyState);
}
}
if (!this.lightCorrect) {
((StarlightChunk)ret).starlight$setBlockNibbles(blockNibbles);
((StarlightChunk)ret).starlight$setSkyNibbles(skyNibbles);
return;
}
((StarlightChunk)ret).starlight$setBlockNibbles(blockNibbles);
((StarlightChunk)ret).starlight$setSkyNibbles(skyNibbles);
try {
for (final SerializableChunkData.SectionData sectionData : this.sectionData) {
final int y = sectionData.y();
final DataLayer blockLight = sectionData.blockLight();
final DataLayer skyLight = sectionData.skyLight();
final int blockState = ((StarlightSectionData)(Object)sectionData).starlight$getBlockLightState();
final int skyState = ((StarlightSectionData)(Object)sectionData).starlight$getSkyLightState();
if (blockState >= 0) {
if (blockLight != null) {
blockNibbles[y - minSection] = new SWMRNibbleArray(MixinWorkarounds.clone(blockLight.getData()), blockState); // clone for data safety
} else {
blockNibbles[y - minSection] = new SWMRNibbleArray(null, blockState);
}
}
if (skyState >= 0 && hasSkyLight) {
if (skyLight != null) {
skyNibbles[y - minSection] = new SWMRNibbleArray(MixinWorkarounds.clone(skyLight.getData()), skyState); // clone for data safety
} else {
skyNibbles[y - minSection] = new SWMRNibbleArray(null, skyState);
}
}
}
((StarlightChunk)ret).starlight$setBlockNibbles(blockNibbles);
((StarlightChunk)ret).starlight$setSkyNibbles(skyNibbles);
} catch (final Throwable thr) {
ret.setLightCorrect(false);
LOGGER.error("Failed to parse light data for chunk " + ret.getPos() + " in world '" + WorldUtil.getWorldName(world) + "'", thr);
}
}
/**

View File

@@ -9,7 +9,7 @@ import it.unimi.dsi.fastutil.objects.AbstractReference2ObjectMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
import it.unimi.dsi.fastutil.objects.ObjectSet;
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -27,7 +27,7 @@ public final class ZeroCollidingReferenceStateTable<O, S> {
public ZeroCollidingReferenceStateTable(final Collection<Property<?>> properties) {
this.propertyToIndexer = new Int2ObjectOpenHashMap<>(properties.size());
this.properties = new ReferenceOpenHashSet<>(properties);
this.properties = new ReferenceArrayList<>(properties);
final List<Property<?>> sortedProperties = new ArrayList<>(properties);