Skip to content

Commit

Permalink
Fix crash with level wrappers
Browse files Browse the repository at this point in the history
- Use the passed RegistryAccess instead of retrieving it from the level ourselves, this fixes an issue with mods like create that wrap levels, as this mixin injects into the super call, and they set the level after the super call, which results in their stored/wrapped level being null when Level#registryAccess is called
  • Loading branch information
IThundxr authored and 2No2Name committed Jan 19, 2025
1 parent c17bb28 commit 567e7ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.caffeinemc.mods.lithium.common.tracking.block.SectionedBlockChangeTracker;
import net.caffeinemc.mods.lithium.common.tracking.entity.SectionedEntityMovementTracker;
import net.caffeinemc.mods.lithium.common.util.deduplication.LithiumInterner;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.entity.ai.navigation.PathNavigation;
Expand Down Expand Up @@ -35,10 +36,10 @@ record Data(
// Block ChunkSection listeners
Long2ReferenceOpenHashMap<ChunkSectionChangeCallback> chunkSectionChangeCallbacks
) {
public Data(Level world) {
public Data(HolderLookup.Provider registries) {
this(
new GameEventDispatcherStorage(),
Objects.requireNonNullElse(world.registryAccess(), RegistryAccess.EMPTY).lookup(Registries.BANNER_PATTERN).map(Raid::getLeaderBannerInstance).orElse(null),
Objects.requireNonNullElse(registries, RegistryAccess.EMPTY).lookup(Registries.BANNER_PATTERN).map(Raid::getLeaderBannerInstance).orElse(null),
new ReferenceOpenHashSet<>(),
new LithiumInterner<>(),
new LithiumInterner<>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class LevelMixin implements LithiumData {

@Inject(method = "<init>", at = @At("RETURN"))
private void initLithiumData(WritableLevelData properties, ResourceKey<?> registryRef, RegistryAccess registryManager, Holder<?> dimensionEntry, Supplier<?> profiler, boolean isClient, boolean debugWorld, long biomeAccess, int maxChainedNeighborUpdates, CallbackInfo ci) {
this.storage = new Data((Level) (Object) this);
this.storage = new Data(registryManager);
}

@Override
Expand Down

0 comments on commit 567e7ff

Please sign in to comment.