Skip to content

Commit

Permalink
1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
char3210 committed Jan 6, 2023
1 parent 1b9a5c0 commit 7b44da3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation files('lib/atum-1.1.3+1.18.2.jar')
modImplementation files('lib/atum-1.1.3+1.19.2.jar')
}

processResources {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.4
loader_version=0.14.9
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
loader_version=0.14.12
# Mod Properties
mod_version=1.3.1+1.18+
mod_version=1.3.2+1.19
maven_group=me.char321
archives_base_name=chunkcacher
# MCSR
mod_id=chunkcacher
supported_versions=1.18-1.18.2
supported_versions=1.19
5 changes: 2 additions & 3 deletions src/main/java/me/char321/chunkcacher/WorldCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import me.voidxwalker.autoreset.Atum;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.RegistryKey;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
Expand Down Expand Up @@ -46,8 +46,7 @@ public static NbtCompound getChunkNbt(ChunkPos chunkPos, ServerWorld world) {
public static void checkGeneratorOptions(GeneratorOptions generatorOptions) {
if (lastGeneratorOptions == null ||
lastGeneratorOptions.getSeed() != generatorOptions.getSeed() ||
lastGeneratorOptions.shouldGenerateStructures() != generatorOptions.shouldGenerateStructures() ||
lastGeneratorOptions.isFlatWorld() != generatorOptions.isFlatWorld()
lastGeneratorOptions.shouldGenerateStructures() != generatorOptions.shouldGenerateStructures()
) {
clearCache();
lastGeneratorOptions = generatorOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
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.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Optional;
import java.util.concurrent.CompletableFuture;

@Mixin(ThreadedAnvilChunkStorage.class)
Expand All @@ -39,11 +40,17 @@ private void addToCache(CallbackInfoReturnable<CompletableFuture<Either<Chunk, C
1.19 changes the return type of getUpdatedChunkNbt to a CompletableFuture, so instead we
modify the nbtCompound a bit later in loadChunk to keep compatibility
*/
@ModifyVariable(method = "method_17256", at = @At("STORE"), remap = false)
private NbtCompound loadFromCache(NbtCompound nbtCompound, ChunkPos pos) {
if (WorldCache.shouldCache() && nbtCompound == null) {
return WorldCache.getChunkNbt(pos, world);
}
return nbtCompound;


// @ModifyVariable(method = "method_17256", at = @At("STORE"), remap = false)
// private NbtCompound loadFromCache(NbtCompound nbtCompound, ChunkPos pos) {
// if (WorldCache.shouldCache() && nbtCompound == null) {
// return WorldCache.getChunkNbt(pos, world);
// }
// return nbtCompound;
// }
@Redirect(method="getUpdatedChunkNbt", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ThreadedAnvilChunkStorage;getNbt(Lnet/minecraft/util/math/ChunkPos;)Ljava/util/concurrent/CompletableFuture;"))
private CompletableFuture<Optional<NbtCompound>> loadFromCache(ThreadedAnvilChunkStorage instance, ChunkPos chunkPos) {
return instance.getNbt(chunkPos).thenApply(op -> op.isPresent() ? op : Optional.ofNullable(WorldCache.getChunkNbt(chunkPos, world)));
}
}
1 change: 0 additions & 1 deletion src/main/resources/chunkcacher.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"package": "me.char321.chunkcacher.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"ChunkGeneratorMixin",
"ChunkSerializerMixin",
"MinecraftServerMixin",
"ThreadedAnvilChunkStorageMixin"
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"depends": {
"fabricloader": ">=0.12.2",
"minecraft": "1.18.x",
"minecraft": ">=1.19",
"atum": "*"
},
"breaks": {
Expand Down

0 comments on commit 7b44da3

Please sign in to comment.