-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automaticly ingest chunks created by chunky
- Loading branch information
mcrcortex
authored and
mcrcortex
committed
Jul 20, 2024
1 parent
086a7ee
commit a9c0796
Showing
3 changed files
with
57 additions
and
3 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
44 changes: 44 additions & 0 deletions
44
src/main/java/me/cortex/voxy/client/mixin/chunky/MixinFabricWorld.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,44 @@ | ||
package me.cortex.voxy.client.mixin.chunky; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import me.cortex.voxy.client.Voxy; | ||
import me.cortex.voxy.client.config.VoxyConfig; | ||
import me.cortex.voxy.client.core.IGetVoxelCore; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.server.world.ChunkHolder; | ||
import net.minecraft.server.world.OptionalChunk; | ||
import net.minecraft.server.world.ServerChunkLoadingManager; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.world.chunk.Chunk; | ||
import net.minecraft.world.chunk.ChunkStatus; | ||
import net.minecraft.world.chunk.WorldChunk; | ||
import org.joml.Matrix4f; | ||
import org.popcraft.chunky.platform.FabricWorld; | ||
import org.spongepowered.asm.mixin.Final; | ||
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.Redirect; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.Executor; | ||
import java.util.function.BiConsumer; | ||
|
||
@Mixin(FabricWorld.class) | ||
public class MixinFabricWorld { | ||
@WrapOperation(method = "getChunkAtAsync", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ChunkHolder;load(Lnet/minecraft/world/chunk/ChunkStatus;Lnet/minecraft/server/world/ServerChunkLoadingManager;)Ljava/util/concurrent/CompletableFuture;")) | ||
private CompletableFuture<OptionalChunk<Chunk>> captureGeneratedChunk(ChunkHolder instance, ChunkStatus chunkStatus, ServerChunkLoadingManager serverChunkLoadingManager, Operation<CompletableFuture<OptionalChunk<Chunk>>> original) { | ||
var future = original.call(instance, chunkStatus, serverChunkLoadingManager); | ||
return future.thenApplyAsync(res->{ | ||
res.ifPresent(chunk -> { | ||
var core = ((IGetVoxelCore)(MinecraftClient.getInstance().worldRenderer)).getVoxelCore(); | ||
if (core != null && VoxyConfig.CONFIG.ingestEnabled) { | ||
core.enqueueIngest((WorldChunk) chunk); | ||
} | ||
}); | ||
return res; | ||
}); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -15,5 +15,8 @@ | |
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
}, | ||
"mixins": [ | ||
"chunky.MixinFabricWorld" | ||
] | ||
} |