-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'AlexModGuy:main' into main
- Loading branch information
Showing
133 changed files
with
4,593 additions
and
705 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/com/github/alexmodguy/alexscaves/mixin/BiomeSourceMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.github.alexmodguy.alexscaves.mixin; | ||
|
||
import com.github.alexmodguy.alexscaves.server.level.biome.BiomeSourceAccessor; | ||
import com.google.common.base.Suppliers; | ||
import com.google.common.collect.ImmutableSet; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.world.level.biome.Biome; | ||
import net.minecraft.world.level.biome.BiomeSource; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.function.Supplier; | ||
|
||
@Mixin(BiomeSource.class) | ||
public class BiomeSourceMixin implements BiomeSourceAccessor { | ||
|
||
@Shadow | ||
public Supplier<Set<Holder<Biome>>> possibleBiomes; | ||
private boolean expanded; | ||
private Map<ResourceKey<Biome>, Holder<Biome>> map = new HashMap<>(); | ||
|
||
@Override | ||
public void setResourceKeyMap(Map<ResourceKey<Biome>, Holder<Biome>> map) { | ||
this.map = map; | ||
} | ||
|
||
@Override | ||
public Map<ResourceKey<Biome>, Holder<Biome>> getResourceKeyMap() { | ||
return map; | ||
} | ||
|
||
@Override | ||
public void expandBiomesWith(Set<Holder<Biome>> newGenBiomes) { | ||
if(!expanded){ | ||
ImmutableSet.Builder<Holder<Biome>> builder = ImmutableSet.builder(); | ||
builder.addAll(this.possibleBiomes.get()); | ||
builder.addAll(newGenBiomes); | ||
possibleBiomes = Suppliers.memoize(builder::build); | ||
expanded = true; | ||
} | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/github/alexmodguy/alexscaves/mixin/ChunkStatusMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.github.alexmodguy.alexscaves.mixin; | ||
|
||
import com.github.alexmodguy.alexscaves.server.level.biome.MultiNoiseBiomeSourceAccessor; | ||
import com.mojang.datafixers.util.Either; | ||
import net.minecraft.server.level.ChunkHolder; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.server.level.ThreadedLevelLightEngine; | ||
import net.minecraft.world.level.chunk.ChunkAccess; | ||
import net.minecraft.world.level.chunk.ChunkGenerator; | ||
import net.minecraft.world.level.chunk.ChunkStatus; | ||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.Executor; | ||
import java.util.function.Function; | ||
|
||
@Mixin(ChunkStatus.class) | ||
public class ChunkStatusMixin { | ||
|
||
@Inject(at = @At("HEAD"), | ||
method = "Lnet/minecraft/world/level/chunk/ChunkStatus;generate(Ljava/util/concurrent/Executor;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkGenerator;Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager;Lnet/minecraft/server/level/ThreadedLevelLightEngine;Ljava/util/function/Function;Ljava/util/List;)Ljava/util/concurrent/CompletableFuture;") | ||
private void citadel_fillFromNoise(Executor p_283276_, ServerLevel serverLevel, ChunkGenerator chunkGenerator, StructureTemplateManager p_281305_, ThreadedLevelLightEngine p_282570_, Function<ChunkAccess, CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>> p_283114_, List<ChunkAccess> p_282723_, CallbackInfoReturnable<CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>> cir) { | ||
if(chunkGenerator.getBiomeSource() instanceof MultiNoiseBiomeSourceAccessor multiNoiseBiomeSourceAccessor){ | ||
multiNoiseBiomeSourceAccessor.setLastSampledSeed(serverLevel.getSeed()); | ||
multiNoiseBiomeSourceAccessor.setLastSampledDimension(serverLevel.dimension()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/com/github/alexmodguy/alexscaves/mixin/MultiNoiseBiomeSourceMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.github.alexmodguy.alexscaves.mixin; | ||
|
||
import com.github.alexmodguy.alexscaves.server.config.BiomeGenerationConfig; | ||
import com.github.alexmodguy.alexscaves.server.config.BiomeGenerationNoiseCondition; | ||
import com.github.alexmodguy.alexscaves.server.level.biome.ACBiomeRarity; | ||
import com.github.alexmodguy.alexscaves.server.level.biome.BiomeSourceAccessor; | ||
import com.github.alexmodguy.alexscaves.server.level.biome.MultiNoiseBiomeSourceAccessor; | ||
import com.github.alexmodguy.alexscaves.server.misc.VoronoiGenerator; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.biome.Biome; | ||
import net.minecraft.world.level.biome.Climate; | ||
import net.minecraft.world.level.biome.MultiNoiseBiomeSource; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.Map; | ||
|
||
@Mixin(value = MultiNoiseBiomeSource.class, priority = -69420) | ||
public class MultiNoiseBiomeSourceMixin implements MultiNoiseBiomeSourceAccessor { | ||
|
||
private long lastSampledWorldSeed; | ||
|
||
private ResourceKey<Level> lastSampledDimension; | ||
|
||
@Inject(at = @At("HEAD"), | ||
method = "Lnet/minecraft/world/level/biome/MultiNoiseBiomeSource;getNoiseBiome(IIILnet/minecraft/world/level/biome/Climate$Sampler;)Lnet/minecraft/core/Holder;", | ||
cancellable = true | ||
) | ||
private void citadel_getNoiseBiomeCoords(int x, int y, int z, Climate.Sampler sampler, CallbackInfoReturnable<Holder<Biome>> cir) { | ||
VoronoiGenerator.VoronoiInfo voronoiInfo = ACBiomeRarity.getRareBiomeInfoForQuad(lastSampledWorldSeed, x, z); | ||
if(voronoiInfo != null){ | ||
float unquantizedDepth = Climate.unquantizeCoord(sampler.sample(x, y, z).depth()); | ||
int foundRarityOffset = ACBiomeRarity.getRareBiomeOffsetId(voronoiInfo); | ||
for (Map.Entry<ResourceKey<Biome>, BiomeGenerationNoiseCondition> condition : BiomeGenerationConfig.BIOMES.entrySet()) { | ||
if (foundRarityOffset == condition.getValue().getRarityOffset() && condition.getValue().test(x, y, z, unquantizedDepth, sampler, lastSampledDimension, voronoiInfo)) { | ||
cir.setReturnValue(((BiomeSourceAccessor)this).getResourceKeyMap().get(condition.getKey())); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void setLastSampledSeed(long seed) { | ||
lastSampledWorldSeed = seed; | ||
} | ||
|
||
@Override | ||
public void setLastSampledDimension(ResourceKey<Level> dimension) { | ||
lastSampledDimension = dimension; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.