Skip to content

Commit

Permalink
feat: Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveplays28 committed Jun 20, 2024
1 parent 51c4173 commit abd8116
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 48 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ subprojects {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.layered {
it.mappings("net.fabricmc:yarn:${project.yarn_mappings}:v2")
it.mappings("dev.architectury:yarn-mappings-patch-neoforge:1.20.5+build.3")
it.mappings("dev.architectury:yarn-mappings-patch-neoforge:1.21+build.4")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

@Mixin(NoiseChunkGenerator.class)
public abstract class NoiseChunkGeneratorMixin extends ChunkGenerator {
Expand Down Expand Up @@ -51,24 +50,33 @@ public NoiseChunkGeneratorMixin(BiomeSource biomeSource) {
return blockState;
}

@Inject(method = "populateNoise(Ljava/util/concurrent/Executor;Lnet/minecraft/world/gen/chunk/Blender;Lnet/minecraft/world/gen/noise/NoiseConfig;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/chunk/Chunk;)Ljava/util/concurrent/CompletableFuture;", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/chunk/Chunk;getSectionIndex(I)I", ordinal = 1), cancellable = true)
private void noisium$populateNoiseInject(Executor executor, Blender blender, NoiseConfig noiseConfig, StructureAccessor structureAccessor, Chunk chunk, CallbackInfoReturnable<CompletableFuture<Chunk>> cir, @Local(ordinal = 1) int minimumYFloorDiv, @Local(ordinal = 2) int generationShapeHeightFloorDiv, @Local(ordinal = 3) int startingChunkSectionIndex, @Local(ordinal = 4) int minimumYChunkSectionIndex) {
var chunkSections = chunk.getSectionArray();
for (int chunkSectionIndex = startingChunkSectionIndex; chunkSectionIndex >= minimumYChunkSectionIndex; --chunkSectionIndex) {
chunkSections[chunkSectionIndex].lock();
@Inject(method = "populateNoise(Lnet/minecraft/world/gen/chunk/Blender;Lnet/minecraft/world/gen/noise/NoiseConfig;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/chunk/Chunk;)Ljava/util/concurrent/CompletableFuture;", at = @At(value = "RETURN", shift = At.Shift.BEFORE), cancellable = true)
private void noisium$populateNoiseInject(Blender blender, NoiseConfig noiseConfig, StructureAccessor structureAccessor, Chunk chunk, CallbackInfoReturnable<CompletableFuture<Chunk>> cir, @Local GenerationShapeConfig generationShapeConfig, @Local(ordinal = 0) int minimumY, @Local(ordinal = 1) int minimumYFloorDiv, @Local(ordinal = 2) int generationShapeHeightFloorDiv) {
if (generationShapeHeightFloorDiv <= 0) {
cir.setReturnValue(CompletableFuture.completedFuture(chunk));
return;
}

cir.setReturnValue(CompletableFuture.supplyAsync(
Util.debugSupplier(
"wgen_fill_noise",
() -> this.populateNoise(blender, structureAccessor, noiseConfig, chunk, minimumYFloorDiv,
generationShapeHeightFloorDiv
)
), Util.getMainWorkerExecutor()).whenCompleteAsync((chunk2, throwable) -> {
// Replace an enhanced for loop with a fori loop
cir.setReturnValue(CompletableFuture.supplyAsync(Util.debugSupplier("wgen_fill_noise", () -> {
int startingChunkSectionIndex = chunk.getSectionIndex(
generationShapeHeightFloorDiv * generationShapeConfig.verticalCellBlockCount() - 1 + minimumY);
int minimumYChunkSectionIndex = chunk.getSectionIndex(minimumY);
var chunkSections = chunk.getSectionArray();
for (int chunkSectionIndex = startingChunkSectionIndex; chunkSectionIndex >= minimumYChunkSectionIndex; --chunkSectionIndex) {
chunkSections[chunkSectionIndex].unlock();
chunkSections[chunkSectionIndex].lock();
}
}, executor));

Chunk chunkWithNoise;
try {
chunkWithNoise = this.populateNoise(
blender, structureAccessor, noiseConfig, chunk, minimumYFloorDiv, generationShapeHeightFloorDiv);
} finally {
for (int chunkSectionIndex = startingChunkSectionIndex; chunkSectionIndex >= minimumYChunkSectionIndex; --chunkSectionIndex) {
chunkSections[chunkSectionIndex].unlock();
}
}

return chunkWithNoise;
}), Util.getMainWorkerExecutor()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.Blender;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.chunk.GenerationShapeConfig;
import net.minecraft.world.gen.chunk.NoiseChunkGenerator;
import net.minecraft.world.gen.noise.NoiseConfig;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -19,7 +20,6 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

@Mixin(NoiseChunkGenerator.class)
public abstract class LithiumNoiseChunkGeneratorMixin extends ChunkGenerator {
Expand All @@ -42,28 +42,38 @@ public LithiumNoiseChunkGeneratorMixin(BiomeSource biomeSource) {
return blockState;
}

@Inject(method = "populateNoise(Ljava/util/concurrent/Executor;Lnet/minecraft/world/gen/chunk/Blender;Lnet/minecraft/world/gen/noise/NoiseConfig;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/chunk/Chunk;)Ljava/util/concurrent/CompletableFuture;", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/chunk/Chunk;getSectionIndex(I)I", ordinal = 1), cancellable = true)
private void noisium$populateNoiseInject(Executor executor, Blender blender, NoiseConfig noiseConfig, StructureAccessor structureAccessor, Chunk chunk, CallbackInfoReturnable<CompletableFuture<Chunk>> cir, @Local(ordinal = 1) int minimumYFloorDiv, @Local(ordinal = 2) int generationShapeHeightFloorDiv, @Local(ordinal = 3) int startingChunkSectionIndex, @Local(ordinal = 4) int minimumYChunkSectionIndex) {
var chunkSections = chunk.getSectionArray();
for (int chunkSectionIndex = startingChunkSectionIndex; chunkSectionIndex >= minimumYChunkSectionIndex; --chunkSectionIndex) {
chunkSections[chunkSectionIndex].lock();
@Inject(method = "populateNoise(Lnet/minecraft/world/gen/chunk/Blender;Lnet/minecraft/world/gen/noise/NoiseConfig;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/chunk/Chunk;)Ljava/util/concurrent/CompletableFuture;", at = @At(value = "RETURN", shift = At.Shift.BEFORE), cancellable = true)
private void noisium$populateNoiseInject(Blender blender, NoiseConfig noiseConfig, StructureAccessor structureAccessor, Chunk chunk, CallbackInfoReturnable<CompletableFuture<Chunk>> cir, @Local GenerationShapeConfig generationShapeConfig, @Local(ordinal = 0) int minimumY, @Local(ordinal = 1) int minimumYFloorDiv, @Local(ordinal = 2) int generationShapeHeightFloorDiv) {
if (generationShapeHeightFloorDiv <= 0) {
cir.setReturnValue(CompletableFuture.completedFuture(chunk));
return;
}

cir.setReturnValue(CompletableFuture.supplyAsync(
Util.debugSupplier(
"wgen_fill_noise",
() -> this.populateNoise(blender, structureAccessor, noiseConfig, chunk, minimumYFloorDiv,
generationShapeHeightFloorDiv
)
), Util.getMainWorkerExecutor()).whenCompleteAsync((chunk2, throwable) -> {
// Replace an enhanced for loop with a fori loop
// Also run calculateCounts() on every chunk section to add Lithium compatibility
cir.setReturnValue(CompletableFuture.supplyAsync(Util.debugSupplier("wgen_fill_noise", () -> {
int startingChunkSectionIndex = chunk.getSectionIndex(
generationShapeHeightFloorDiv * generationShapeConfig.verticalCellBlockCount() - 1 + minimumY);
int minimumYChunkSectionIndex = chunk.getSectionIndex(minimumY);
var chunkSections = chunk.getSectionArray();
for (int chunkSectionIndex = startingChunkSectionIndex; chunkSectionIndex >= minimumYChunkSectionIndex; --chunkSectionIndex) {
var chunkSection = chunkSections[chunkSectionIndex];
chunkSections[chunkSectionIndex].lock();
}

Chunk chunkWithNoise;
try {
chunkWithNoise = this.populateNoise(
blender, structureAccessor, noiseConfig, chunk, minimumYFloorDiv, generationShapeHeightFloorDiv);
} finally {
// Replace an enhanced for loop with a fori loop
// Also run calculateCounts() on every chunk section to add Lithium compatibility
for (int chunkSectionIndex = startingChunkSectionIndex; chunkSectionIndex >= minimumYChunkSectionIndex; --chunkSectionIndex) {
var chunkSection = chunkSections[chunkSectionIndex];

chunkSection.calculateCounts();
chunkSection.unlock();
chunkSection.calculateCounts();
chunkSection.unlock();
}
}
}, executor));

return chunkWithNoise;
}), Util.getMainWorkerExecutor()));
}
}
2 changes: 1 addition & 1 deletion common/src/main/resources/noisium-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "io.github.steveplays28.noisium.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"plugin": "io.github.steveplays28.noisium.mixin.NoisiumMixinPlugin",
"mixins": [
"ChainedBlockSourceMixin",
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ mod_name=Noisium
mod_description=Optimises worldgen performance for a better gameplay experience.
mod_license=LGPL-3.0
mod_version=2.1.0
supported_minecraft_version=>=1.20.5 <=1.20.6
supported_minecraft_version_name=1.20.5-1.20.6
supported_minecraft_version=1.21
supported_minecraft_version_name=1.21

# Multiloader properties
architectury_plugin_version=3.4-SNAPSHOT
architectury_loom_version=1.6-SNAPSHOT
shadow_plugin_version=7.1.2
forgix_plugin_version=1.2.6
minecraft_version=1.20.5
minecraft_version=1.21
java_version=21
enabled_platforms=fabric,neoforge

Expand All @@ -31,13 +31,13 @@ modrinth_project_id=KuNKN7d2

# Fabric properties
# Check these on https://modmuss50.me/fabric.html
yarn_mappings=1.20.5+build.1
fabric_loader_version=0.15.6
yarn_mappings=1.21+build.2
fabric_loader_version=0.15.11

# NeoForge properties
neoforge_version=20.5.21-beta
neoforge_version=21.0.20-beta

# Dependencies
mixin_extras_version=0.3.5
fabric_api_version=0.97.8+1.20.5
mod_menu_version=10.0.0-beta.1
fabric_api_version=0.100.1+1.21
mod_menu_version=11.0.0-beta.2
3 changes: 0 additions & 3 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ configurations {
dependencies {
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"

// Mixin Extras
implementation(annotationProcessor("io.github.llamalad7:mixinextras-forge:${project.mixin_extras_version}"))

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false }
}
Expand Down

0 comments on commit abd8116

Please sign in to comment.