mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +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(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
ProtoWorld world = (ProtoWorld) ((StructureAccessorAccessor) structureAccessor).getWorld();
|
ProtoWorld world = (ProtoWorld) ((StructureAccessorAccessor) structureAccessor).getWorld();
|
||||||
BiomeProvider biomeProvider;
|
BiomeProvider biomeProvider;
|
||||||
if(chunk instanceof net.minecraft.world.chunk.ProtoChunk) {
|
if(chunk instanceof BiomeProviderHolder providerHolder) {
|
||||||
biomeProvider = ((BiomeProviderHolder) chunk).getBiomeProvider();
|
biomeProvider = providerHolder.getBiomeProvider();
|
||||||
if(biomeProvider == null) {
|
if(biomeProvider == null) {
|
||||||
biomeProvider = pack.getBiomeProvider().caching(world);
|
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)
|
@Mixin(net.minecraft.world.chunk.ProtoChunk.class)
|
||||||
@Implements(value = {
|
@Implements(@Interface(iface = ProtoChunk.class, prefix = "terra$"))
|
||||||
@Interface(iface = ProtoChunk.class, prefix = "terra$"),
|
|
||||||
@Interface(iface = BiomeProviderHolder.class, prefix = "provider$")
|
|
||||||
})
|
|
||||||
public abstract class ProtoChunkMixin {
|
public abstract class ProtoChunkMixin {
|
||||||
@Shadow
|
@Shadow
|
||||||
public abstract net.minecraft.block.BlockState getBlockState(BlockPos pos);
|
public abstract net.minecraft.block.BlockState getBlockState(BlockPos pos);
|
||||||
@ -43,8 +40,6 @@ public abstract class ProtoChunkMixin {
|
|||||||
@Shadow
|
@Shadow
|
||||||
public abstract HeightLimitView getHeightLimitView();
|
public abstract HeightLimitView getHeightLimitView();
|
||||||
|
|
||||||
private BiomeProvider biomeProvider;
|
|
||||||
|
|
||||||
public void terra$setBlock(int x, int y, int z, @NotNull BlockState blockState) {
|
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,
|
((net.minecraft.world.chunk.Chunk) (Object) this).setBlockState(new BlockPos(x, y, z), (net.minecraft.block.BlockState) blockState,
|
||||||
false);
|
false);
|
||||||
@ -57,15 +52,4 @@ public abstract class ProtoChunkMixin {
|
|||||||
public int terra$getMaxHeight() {
|
public int terra$getMaxHeight() {
|
||||||
return getHeightLimitView().getTopY();
|
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.biome.generation.BiomeProvider;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
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.FabricChunkGeneratorWrapper;
|
||||||
import com.dfsek.terra.fabric.generation.TerraBiomeSource;
|
import com.dfsek.terra.fabric.generation.TerraBiomeSource;
|
||||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||||
@ -130,6 +131,10 @@ public abstract class ChunkRegionMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BiomeProvider terraWorld$getBiomeProvider() {
|
public BiomeProvider terraWorld$getBiomeProvider() {
|
||||||
|
BiomeProvider provider = ((BiomeProviderHolder) this).getBiomeProvider();
|
||||||
|
if(provider != null) {
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
return caching.value();
|
return caching.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,51 +1,53 @@
|
|||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"package": "com.dfsek.terra.fabric.mixin",
|
"package": "com.dfsek.terra.fabric.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"ReloadCommandMixin",
|
"ReloadCommandMixin",
|
||||||
"access.MobSpawnerLogicAccessor",
|
"access.MobSpawnerLogicAccessor",
|
||||||
"access.StateAccessor",
|
"access.StateAccessor",
|
||||||
"access.StructureAccessorAccessor",
|
"access.StructureAccessorAccessor",
|
||||||
"compat.GenerationSettingsFloraFeaturesMixin",
|
"cache.ChunkRegionMixin",
|
||||||
"implementations.BiomeMixin",
|
"cache.ProtoChunkMixin",
|
||||||
"implementations.HandleImplementationMixin",
|
"compat.GenerationSettingsFloraFeaturesMixin",
|
||||||
"implementations.block.BlockMixin",
|
"implementations.BiomeMixin",
|
||||||
"implementations.block.entity.BlockEntityMixin",
|
"implementations.HandleImplementationMixin",
|
||||||
"implementations.block.entity.LootableContainerBlockEntityMixin",
|
"implementations.block.BlockMixin",
|
||||||
"implementations.block.entity.MobSpawnerBlockEntityMixin",
|
"implementations.block.entity.BlockEntityMixin",
|
||||||
"implementations.block.entity.SignBlockEntityMixin",
|
"implementations.block.entity.LootableContainerBlockEntityMixin",
|
||||||
"implementations.block.state.BlockStateMixin",
|
"implementations.block.entity.MobSpawnerBlockEntityMixin",
|
||||||
"implementations.block.state.PropertyMixin",
|
"implementations.block.entity.SignBlockEntityMixin",
|
||||||
"implementations.chunk.ChunkRegionMixin",
|
"implementations.block.state.BlockStateMixin",
|
||||||
"implementations.chunk.WorldChunkMixin",
|
"implementations.block.state.PropertyMixin",
|
||||||
"implementations.chunk.data.ProtoChunkMixin",
|
"implementations.chunk.ChunkRegionMixin",
|
||||||
"implementations.entity.EntityMixin",
|
"implementations.chunk.WorldChunkMixin",
|
||||||
"implementations.entity.EntityTypeMixin",
|
"implementations.chunk.data.ProtoChunkMixin",
|
||||||
"implementations.entity.PlayerEntityMixin",
|
"implementations.entity.EntityMixin",
|
||||||
"implementations.entity.ServerCommandSourceMixin",
|
"implementations.entity.EntityTypeMixin",
|
||||||
"implementations.inventory.LockableContainerBlockEntityMixin",
|
"implementations.entity.PlayerEntityMixin",
|
||||||
"implementations.inventory.item.ItemMixin",
|
"implementations.entity.ServerCommandSourceMixin",
|
||||||
"implementations.inventory.item.ItemStackMixin",
|
"implementations.inventory.LockableContainerBlockEntityMixin",
|
||||||
"implementations.inventory.meta.EnchantmentMixin",
|
"implementations.inventory.item.ItemMixin",
|
||||||
"implementations.inventory.meta.ItemStackDamageableMixin",
|
"implementations.inventory.item.ItemStackMixin",
|
||||||
"implementations.inventory.meta.ItemStackMetaMixin",
|
"implementations.inventory.meta.EnchantmentMixin",
|
||||||
"implementations.world.ChunkRegionMixin",
|
"implementations.inventory.meta.ItemStackDamageableMixin",
|
||||||
"implementations.world.ServerWorldMixin",
|
"implementations.inventory.meta.ItemStackMetaMixin",
|
||||||
"lifecycle.DataPackContentsMixin",
|
"implementations.world.ChunkRegionMixin",
|
||||||
"lifecycle.MinecraftServerMixin",
|
"implementations.world.ServerWorldMixin",
|
||||||
"lifecycle.NoiseConfigMixin",
|
"lifecycle.DataPackContentsMixin",
|
||||||
"lifecycle.RegistryMixin"
|
"lifecycle.MinecraftServerMixin",
|
||||||
],
|
"lifecycle.NoiseConfigMixin",
|
||||||
"client": [
|
"lifecycle.RegistryMixin"
|
||||||
"lifecycle.client.MinecraftClientMixin"
|
],
|
||||||
],
|
"client": [
|
||||||
"server": [
|
"lifecycle.client.MinecraftClientMixin"
|
||||||
"lifecycle.server.ServerMainMixin"
|
],
|
||||||
],
|
"server": [
|
||||||
"injectors": {
|
"lifecycle.server.ServerMainMixin"
|
||||||
"defaultRequire": 1
|
],
|
||||||
},
|
"injectors": {
|
||||||
"refmap": "terra-refmap.json"
|
"defaultRequire": 1
|
||||||
|
},
|
||||||
|
"refmap": "terra-refmap.json"
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user