mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-02 07:55:28 +00:00
attach caching biome provider to protochunk
This commit is contained in:
parent
47d2b66046
commit
aac16414d9
@ -0,0 +1,10 @@
|
||||
package com.dfsek.terra.fabric.generation;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
public interface BiomeProviderHolder {
|
||||
void setBiomeProvider(BiomeProvider biomeProvider);
|
||||
|
||||
BiomeProvider getBiomeProvider();
|
||||
}
|
@ -88,6 +88,17 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
this.biomeSource = biomeSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Chunk> populateBiomes(Registry<Biome> biomeRegistry, Executor executor, NoiseConfig noiseConfig,
|
||||
Blender blender, StructureAccessor structureAccessor, Chunk chunk) {
|
||||
if(chunk instanceof net.minecraft.world.chunk.ProtoChunk) {
|
||||
((BiomeProviderHolder) chunk)
|
||||
.setBiomeProvider(pack.getBiomeProvider()
|
||||
.caching((ProtoWorld) ((StructureAccessorAccessor) structureAccessor).getWorld()));
|
||||
}
|
||||
return super.populateBiomes(biomeRegistry, executor, noiseConfig, blender, structureAccessor, chunk);
|
||||
}
|
||||
|
||||
public Registry<StructureSet> getNoiseRegistry() {
|
||||
return noiseRegistry;
|
||||
}
|
||||
@ -124,7 +135,12 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
StructureAccessor structureAccessor, Chunk chunk) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ProtoWorld world = (ProtoWorld) ((StructureAccessorAccessor) structureAccessor).getWorld();
|
||||
BiomeProvider biomeProvider = pack.getBiomeProvider().caching(world);
|
||||
BiomeProvider biomeProvider;
|
||||
if(chunk instanceof net.minecraft.world.chunk.ProtoChunk) {
|
||||
biomeProvider = ((BiomeProviderHolder) chunk).getBiomeProvider();
|
||||
} else {
|
||||
biomeProvider = pack.getBiomeProvider().caching(world);
|
||||
}
|
||||
delegate.generateChunkData((ProtoChunk) chunk, world, biomeProvider, chunk.getPos().x, chunk.getPos().z);
|
||||
|
||||
PreLoadCompatibilityOptions compatibilityOptions = pack.getContext().get(PreLoadCompatibilityOptions.class);
|
||||
|
@ -17,23 +17,34 @@
|
||||
|
||||
package com.dfsek.terra.fabric.mixin.implementations.chunk.data;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ProtoChunk;
|
||||
import com.dfsek.terra.fabric.generation.BiomeProviderHolder;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.HeightLimitView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ProtoChunk;
|
||||
|
||||
|
||||
@Mixin(net.minecraft.world.chunk.ProtoChunk.class)
|
||||
@Implements(@Interface(iface = ProtoChunk.class, prefix = "terra$"))
|
||||
@Implements(value = {
|
||||
@Interface(iface = ProtoChunk.class, prefix = "terra$"),
|
||||
@Interface(iface = BiomeProviderHolder.class, prefix = "provider$")
|
||||
})
|
||||
public abstract class ProtoChunkMixin {
|
||||
@Shadow
|
||||
public abstract net.minecraft.block.BlockState getBlockState(BlockPos pos);
|
||||
|
||||
@Shadow
|
||||
public abstract HeightLimitView getHeightLimitView();
|
||||
|
||||
private BiomeProvider biomeProvider;
|
||||
|
||||
public void terra$setBlock(int x, int y, int z, @NotNull BlockState blockState) {
|
||||
((net.minecraft.world.chunk.Chunk) (Object) this).setBlockState(new BlockPos(x, y, z), (net.minecraft.block.BlockState) blockState,
|
||||
false);
|
||||
@ -44,6 +55,17 @@ public abstract class ProtoChunkMixin {
|
||||
}
|
||||
|
||||
public int terra$getMaxHeight() {
|
||||
return 255; // TODO: 1.17 - Implement dynamic height.
|
||||
return getHeightLimitView().getTopY();
|
||||
}
|
||||
|
||||
public void provider$setBiomeProvider(BiomeProvider provider) {
|
||||
if(this.biomeProvider != null) {
|
||||
throw new IllegalStateException("Already set biome provider for chunk " + this);
|
||||
}
|
||||
this.biomeProvider = provider;
|
||||
}
|
||||
|
||||
public BiomeProvider provider$getBiomeProvider() {
|
||||
return biomeProvider;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user