mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 16:35:50 +00:00
pass caching provider through all stages
This commit is contained in:
parent
dbadef5672
commit
db61729e11
@ -136,8 +136,8 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ProtoWorld world = (ProtoWorld) ((StructureAccessorAccessor) structureAccessor).getWorld();
|
||||
BiomeProvider biomeProvider;
|
||||
if(chunk instanceof net.minecraft.world.chunk.ProtoChunk) {
|
||||
biomeProvider = ((BiomeProviderHolder) chunk).getBiomeProvider();
|
||||
if(chunk instanceof BiomeProviderHolder providerHolder) {
|
||||
biomeProvider = providerHolder.getBiomeProvider();
|
||||
if(biomeProvider == null) {
|
||||
biomeProvider = pack.getBiomeProvider().caching(world);
|
||||
}
|
||||
|
48
platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/cache/ChunkRegionMixin.java
vendored
Normal file
48
platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/cache/ChunkRegionMixin.java
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
package com.dfsek.terra.fabric.mixin.cache;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
import com.dfsek.terra.fabric.generation.BiomeProviderHolder;
|
||||
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.ChunkRegion;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
import net.minecraft.world.chunk.ProtoChunk;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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 org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mixin(ChunkRegion.class)
|
||||
@Implements(@Interface(iface = BiomeProviderHolder.class, prefix = "provider$"))
|
||||
public class ChunkRegionMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private net.minecraft.world.chunk.Chunk centerPos;
|
||||
private BiomeProvider biomeProvider;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void addProvider(ServerWorld world, List<Chunk> chunks, ChunkStatus status, int placementRadius, CallbackInfo ci) {
|
||||
if(centerPos instanceof BiomeProviderHolder providerHolder) {
|
||||
biomeProvider = providerHolder.getBiomeProvider();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
27
platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/cache/ProtoChunkMixin.java
vendored
Normal file
27
platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/cache/ProtoChunkMixin.java
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
package com.dfsek.terra.fabric.mixin.cache;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.fabric.generation.BiomeProviderHolder;
|
||||
|
||||
import net.minecraft.world.chunk.ProtoChunk;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
|
||||
@Mixin(ProtoChunk.class)
|
||||
@Implements(@Interface(iface = BiomeProviderHolder.class, prefix = "provider$"))
|
||||
public class ProtoChunkMixin {
|
||||
private BiomeProvider biomeProvider;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -32,10 +32,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
|
||||
@Mixin(net.minecraft.world.chunk.ProtoChunk.class)
|
||||
@Implements(value = {
|
||||
@Interface(iface = ProtoChunk.class, prefix = "terra$"),
|
||||
@Interface(iface = BiomeProviderHolder.class, prefix = "provider$")
|
||||
})
|
||||
@Implements(@Interface(iface = ProtoChunk.class, prefix = "terra$"))
|
||||
public abstract class ProtoChunkMixin {
|
||||
@Shadow
|
||||
public abstract net.minecraft.block.BlockState getBlockState(BlockPos pos);
|
||||
@ -43,8 +40,6 @@ public abstract class ProtoChunkMixin {
|
||||
@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);
|
||||
@ -57,15 +52,4 @@ public abstract class ProtoChunkMixin {
|
||||
public int terra$getMaxHeight() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
||||
import com.dfsek.terra.fabric.generation.BiomeProviderHolder;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.generation.TerraBiomeSource;
|
||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
@ -130,6 +131,10 @@ public abstract class ChunkRegionMixin {
|
||||
}
|
||||
|
||||
public BiomeProvider terraWorld$getBiomeProvider() {
|
||||
BiomeProvider provider = ((BiomeProviderHolder) this).getBiomeProvider();
|
||||
if(provider != null) {
|
||||
return provider;
|
||||
}
|
||||
return caching.value();
|
||||
}
|
||||
|
||||
|
@ -1,51 +1,53 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.dfsek.terra.fabric.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"ReloadCommandMixin",
|
||||
"access.MobSpawnerLogicAccessor",
|
||||
"access.StateAccessor",
|
||||
"access.StructureAccessorAccessor",
|
||||
"compat.GenerationSettingsFloraFeaturesMixin",
|
||||
"implementations.BiomeMixin",
|
||||
"implementations.HandleImplementationMixin",
|
||||
"implementations.block.BlockMixin",
|
||||
"implementations.block.entity.BlockEntityMixin",
|
||||
"implementations.block.entity.LootableContainerBlockEntityMixin",
|
||||
"implementations.block.entity.MobSpawnerBlockEntityMixin",
|
||||
"implementations.block.entity.SignBlockEntityMixin",
|
||||
"implementations.block.state.BlockStateMixin",
|
||||
"implementations.block.state.PropertyMixin",
|
||||
"implementations.chunk.ChunkRegionMixin",
|
||||
"implementations.chunk.WorldChunkMixin",
|
||||
"implementations.chunk.data.ProtoChunkMixin",
|
||||
"implementations.entity.EntityMixin",
|
||||
"implementations.entity.EntityTypeMixin",
|
||||
"implementations.entity.PlayerEntityMixin",
|
||||
"implementations.entity.ServerCommandSourceMixin",
|
||||
"implementations.inventory.LockableContainerBlockEntityMixin",
|
||||
"implementations.inventory.item.ItemMixin",
|
||||
"implementations.inventory.item.ItemStackMixin",
|
||||
"implementations.inventory.meta.EnchantmentMixin",
|
||||
"implementations.inventory.meta.ItemStackDamageableMixin",
|
||||
"implementations.inventory.meta.ItemStackMetaMixin",
|
||||
"implementations.world.ChunkRegionMixin",
|
||||
"implementations.world.ServerWorldMixin",
|
||||
"lifecycle.DataPackContentsMixin",
|
||||
"lifecycle.MinecraftServerMixin",
|
||||
"lifecycle.NoiseConfigMixin",
|
||||
"lifecycle.RegistryMixin"
|
||||
],
|
||||
"client": [
|
||||
"lifecycle.client.MinecraftClientMixin"
|
||||
],
|
||||
"server": [
|
||||
"lifecycle.server.ServerMainMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"refmap": "terra-refmap.json"
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.dfsek.terra.fabric.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"ReloadCommandMixin",
|
||||
"access.MobSpawnerLogicAccessor",
|
||||
"access.StateAccessor",
|
||||
"access.StructureAccessorAccessor",
|
||||
"cache.ChunkRegionMixin",
|
||||
"cache.ProtoChunkMixin",
|
||||
"compat.GenerationSettingsFloraFeaturesMixin",
|
||||
"implementations.BiomeMixin",
|
||||
"implementations.HandleImplementationMixin",
|
||||
"implementations.block.BlockMixin",
|
||||
"implementations.block.entity.BlockEntityMixin",
|
||||
"implementations.block.entity.LootableContainerBlockEntityMixin",
|
||||
"implementations.block.entity.MobSpawnerBlockEntityMixin",
|
||||
"implementations.block.entity.SignBlockEntityMixin",
|
||||
"implementations.block.state.BlockStateMixin",
|
||||
"implementations.block.state.PropertyMixin",
|
||||
"implementations.chunk.ChunkRegionMixin",
|
||||
"implementations.chunk.WorldChunkMixin",
|
||||
"implementations.chunk.data.ProtoChunkMixin",
|
||||
"implementations.entity.EntityMixin",
|
||||
"implementations.entity.EntityTypeMixin",
|
||||
"implementations.entity.PlayerEntityMixin",
|
||||
"implementations.entity.ServerCommandSourceMixin",
|
||||
"implementations.inventory.LockableContainerBlockEntityMixin",
|
||||
"implementations.inventory.item.ItemMixin",
|
||||
"implementations.inventory.item.ItemStackMixin",
|
||||
"implementations.inventory.meta.EnchantmentMixin",
|
||||
"implementations.inventory.meta.ItemStackDamageableMixin",
|
||||
"implementations.inventory.meta.ItemStackMetaMixin",
|
||||
"implementations.world.ChunkRegionMixin",
|
||||
"implementations.world.ServerWorldMixin",
|
||||
"lifecycle.DataPackContentsMixin",
|
||||
"lifecycle.MinecraftServerMixin",
|
||||
"lifecycle.NoiseConfigMixin",
|
||||
"lifecycle.RegistryMixin"
|
||||
],
|
||||
"client": [
|
||||
"lifecycle.client.MinecraftClientMixin"
|
||||
],
|
||||
"server": [
|
||||
"lifecycle.server.ServerMainMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"refmap": "terra-refmap.json"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user