Skip to content

Commit

Permalink
Clone chunk biome container
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Sep 18, 2024
1 parent 1ae9897 commit 7bc7707
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package me.jellysquid.mods.sodium.client.world;

import net.minecraft.world.level.chunk.ChunkBiomeContainer;

public interface ChunkBiomeContainerExtended {
static ChunkBiomeContainer clone(ChunkBiomeContainer container) {
return container != null ? ((ChunkBiomeContainerExtended)container).embeddium$copy() : null;
}

ChunkBiomeContainer embeddium$copy();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import it.unimi.dsi.fastutil.ints.Int2ReferenceMap;
import it.unimi.dsi.fastutil.ints.Int2ReferenceMaps;
import it.unimi.dsi.fastutil.ints.Int2ReferenceOpenHashMap;
import me.jellysquid.mods.sodium.client.world.ChunkBiomeContainerExtended;
import me.jellysquid.mods.sodium.client.world.ReadableContainerExtended;
import me.jellysquid.mods.sodium.client.world.WorldSlice;
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachmentBlockEntity;
Expand Down Expand Up @@ -86,7 +87,7 @@ public ClonedChunkSection(Level world, LevelChunk chunk, @Nullable LevelChunkSec
}
}

biomeData = chunk.getBiomes();
biomeData = ChunkBiomeContainerExtended.clone(chunk.getBiomes());

this.blockData = blockData;
this.biomeData = biomeData;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package me.jellysquid.mods.sodium.mixin.core.world.chunk;

import me.jellysquid.mods.sodium.client.world.ChunkBiomeContainerExtended;
import net.minecraft.core.IdMap;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.chunk.ChunkBiomeContainer;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(ChunkBiomeContainer.class)
public class ChunkBiomeContainerMixin implements ChunkBiomeContainerExtended {
@Shadow
@Final
private IdMap<Biome> biomeRegistry;

@Shadow
@Final
private Biome[] biomes;

@Override
public ChunkBiomeContainer embeddium$copy() {
return new ChunkBiomeContainer(this.biomeRegistry, this.biomes.clone());
}
}

0 comments on commit 7bc7707

Please sign in to comment.