Actually works! Kind of buggy rebuilding of chunks
This commit is contained in:
parent
b538995e69
commit
9d731b8273
@ -1,36 +0,0 @@
|
||||
package cc.flogi.dev.smoothchunks.mixin;
|
||||
|
||||
import cc.flogi.dev.smoothchunks.client.SmoothChunksClient;
|
||||
import net.minecraft.client.render.BuiltChunkStorage;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
import net.minecraft.client.render.chunk.ChunkBuilder;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
/**
|
||||
* @author Caden Kriese (flogic)
|
||||
*
|
||||
* Created on 09/29/2020
|
||||
*/
|
||||
@Mixin(BuiltChunkStorage.class)
|
||||
public abstract class BuiltChunkStorageMixin {
|
||||
@Shadow public ChunkBuilder.BuiltChunk[] chunks;
|
||||
@Final @Shadow protected WorldRenderer worldRenderer;
|
||||
|
||||
@Inject(method = "updateCameraPosition", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/render/chunk/ChunkBuilder$BuiltChunk;setOrigin(III)V"),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void updateChunkOrigin(double x, double z, CallbackInfo info, int i, int j, int k, int l, int m, int n,
|
||||
int o, int p, int q, int r, int s, int t, ChunkBuilder.BuiltChunk builtChunk) {
|
||||
// if (builtChunk.rebuildFrame == -1 || worldRenderer.frame - builtChunk.rebuildFrame > 2) {
|
||||
// System.out.println("Chunk became visible, adding to queue.");
|
||||
// SmoothChunksClient.get().getChunkAnimationHandler().addChunk(builtChunk);
|
||||
// }
|
||||
}
|
||||
}
|
@ -1,35 +1,39 @@
|
||||
package cc.flogi.dev.smoothchunks.mixin;
|
||||
|
||||
import cc.flogi.dev.smoothchunks.client.SmoothChunksClient;
|
||||
import net.minecraft.client.render.chunk.BlockBufferBuilderStorage;
|
||||
import net.minecraft.client.render.chunk.ChunkBuilder;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* @author Caden Kriese (flogic)
|
||||
*
|
||||
* Created on 10/07/2020
|
||||
*/
|
||||
@Mixin(ChunkBuilder.BuiltChunk.class)
|
||||
@SuppressWarnings("rawtypes") @Mixin(ChunkBuilder.BuiltChunk.RebuildTask.class)
|
||||
public abstract class ChunkBuilderMixin {
|
||||
@SuppressWarnings("ShadowTarget") @Shadow private ChunkBuilder.BuiltChunk field_20839;
|
||||
|
||||
@Inject(
|
||||
method = "setOrigin",
|
||||
method = "run",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
// args = "log=true",
|
||||
target = "Lnet/minecraft/client/render/chunk/ChunkBuilder$BuiltChunk;clear()V"
|
||||
args = "log=true",
|
||||
target = "Ljava/util/Set;forEach(Ljava/util/function/Consumer;)V"
|
||||
),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD
|
||||
)
|
||||
)
|
||||
public void onSetOrigin(int x, int y, int z, CallbackInfo info) {
|
||||
ChunkBuilder.BuiltChunk chunk = (ChunkBuilder.BuiltChunk) (Object) this;
|
||||
|
||||
// System.out.println("Running animation on chunk @ (" + x + ", " + y + ", " + z + ").");
|
||||
// String xBehind = chunk.getOrigin().getX() < Objects.requireNonNull(MinecraftClient.getInstance().getCameraEntity()).getBlockPos().getX() ? "behind" : "in-front of";
|
||||
// String zBehind = chunk.getOrigin().getZ() < Objects.requireNonNull(MinecraftClient.getInstance().getCameraEntity()).getBlockPos().getZ() ? "behind" : "in-front of";
|
||||
|
||||
// System.out.printf("Animating chunk %s you on the x-axis and %s you on the z-axis.\n", xBehind, zBehind);
|
||||
SmoothChunksClient.get().getChunkAnimationHandler().addChunk(chunk);
|
||||
public void onSetOrigin(BlockBufferBuilderStorage buffers, CallbackInfoReturnable<CompletableFuture> cir, Vec3d vec3d,
|
||||
float f, float g, float h, ChunkBuilder.ChunkData chunkData, List list) {
|
||||
SmoothChunksClient.get().getChunkAnimationHandler().addChunk(field_20839);
|
||||
}
|
||||
}
|
||||
|
@ -3,30 +3,23 @@ package cc.flogi.dev.smoothchunks.mixin;
|
||||
import cc.flogi.dev.smoothchunks.client.SmoothChunksClient;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
|
||||
import net.minecraft.client.gl.VertexBuffer;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
import net.minecraft.client.render.chunk.ChunkBuilder;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.Queue;
|
||||
|
||||
/**
|
||||
* @author Caden Kriese (flogic)
|
||||
*
|
||||
* Created on 09/25/2020
|
||||
*/
|
||||
@Mixin(WorldRenderer.class)
|
||||
@SuppressWarnings("rawtypes") @Mixin(WorldRenderer.class)
|
||||
public abstract class WorldRendererMixin {
|
||||
@Shadow private BuiltChunkStorage chunks;
|
||||
|
||||
@Inject(
|
||||
method = "renderLayer",
|
||||
at = @At(
|
||||
@ -39,22 +32,4 @@ public abstract class WorldRendererMixin {
|
||||
WorldRenderer.ChunkInfo chunkInfo2, ChunkBuilder.BuiltChunk builtChunk, VertexBuffer vertexBuffer) {
|
||||
SmoothChunksClient.get().getChunkAnimationHandler().updateChunk((WorldRenderer) (Object) this, chunkInfo2, builtChunk, matrixStack);
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "setupTerrain",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
// ordinal = 1,
|
||||
// args = "log=true",
|
||||
target = "Lit/unimi/dsi/fastutil/objects/ObjectList;add(Ljava/lang/Object;)Z"),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void chunkBecomesVisible(Camera camera, Frustum frustum, boolean hasForcedFrustum, int frame, boolean spectator,
|
||||
CallbackInfo ci, Vec3d vec3d, BlockPos blockPos, ChunkBuilder.BuiltChunk builtChunk, int i,
|
||||
BlockPos blockPos2, float g, float h, Queue queue, boolean bl, WorldRenderer.ChunkInfo chunkInfo,
|
||||
ChunkBuilder.BuiltChunk builtChunk3, Direction direction) {
|
||||
// if (!Arrays.asList(chunks.chunks).contains(builtChunk3)) {
|
||||
// System.out.println("Chunk became visible, adding to queue.");
|
||||
// SmoothChunksClient.get().getChunkAnimationHandler().addChunk(builtChunk3);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user