Skip to content

Commit

Permalink
fix: Call correct methods for biome access on chunks
Browse files Browse the repository at this point in the history
Fixes #3955
  • Loading branch information
gabizou committed May 13, 2024
1 parent b909c1e commit 8404dcb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.SectionPos;
import net.minecraft.core.registries.Registries;
Expand All @@ -44,6 +45,7 @@
import net.minecraft.world.level.chunk.ImposterProtoChunk;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.PalettedContainer;
import net.minecraft.world.level.chunk.ProtoChunk;
import net.minecraft.world.level.entity.EntitySection;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
Expand Down Expand Up @@ -176,7 +178,10 @@ public static boolean setBiomeOnNativeChunk(final int x, final int y, final int
final int maskedX = x & 3;
final int maskedY = y & 3;
final int maskedZ = z & 3;
// TODO section.getBiomes().set(maskedX, maskedY, maskedZ, Holder.direct((Biome) (Object) biome));
final var old = ((PalettedContainer<Holder<Biome>>) section.getBiomes()).getAndSet(maskedX, maskedY, maskedZ, Holder.direct((Biome) (Object) biome));
if (old.value() == (Object) biome) {
return false;
}

finalizer.run();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,12 @@ public Biome biome(final int x, final int y, final int z) {
if (!this.contains(x, y, z)) {
throw new PositionOutOfBoundsException(new Vector3i(x, y, z), Constants.World.BLOCK_MIN, Constants.World.BLOCK_MAX);
}
return (Biome) (Object) this.level.getBiome(new BlockPos(x, y, z));
return (Biome) (Object) this.level.getBiome(new BlockPos(x, y, z)).value();
}

@Override
public boolean setBiome(final int x, final int y, final int z, final Biome biome) {
// TODO ChunkBiomeContainerAccessor is dead
//return VolumeStreamUtils.setBiomeOnNativeChunk(x, y, z, biome, () -> (ChunkBiomeContainerAccessor) this.biomes, () -> this.setUnsaved(true));
return false;
return VolumeStreamUtils.setBiomeOnNativeChunk(x, y, z, biome, () -> this.getSection(this.getSectionIndex(y)), () -> this.setUnsaved(true));
}

@Intrinsic
Expand Down

0 comments on commit 8404dcb

Please sign in to comment.