Skip to content

Commit

Permalink
Make Freecam work with F3+G (chunk borders)
Browse files Browse the repository at this point in the history
  • Loading branch information
MineGame159 committed Oct 25, 2023
1 parent 67b8753 commit 3e1df83
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.Freecam;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.debug.ChunkBorderDebugRenderer;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.ChunkSectionPos;
import net.minecraft.util.math.MathHelper;
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;

@Mixin(ChunkBorderDebugRenderer.class)
public class ChunkBorderDebugRendererMixin {
@Shadow
@Final
private MinecraftClient client;

@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getChunkPos()Lnet/minecraft/util/math/ChunkPos;"))
private ChunkPos render$getChunkPos(ChunkPos chunkPos) {
Freecam freecam = Modules.get().get(Freecam.class);
if (!freecam.isActive()) return chunkPos;

float delta = client.getTickDelta();

return new ChunkPos(
ChunkSectionPos.getSectionCoord(MathHelper.floor(freecam.getX(delta))),
ChunkSectionPos.getSectionCoord(MathHelper.floor(freecam.getZ(delta)))
);
}
}
1 change: 1 addition & 0 deletions src/main/resources/meteor-client.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"ChatInputSuggestorMixin",
"ChatScreenMixin",
"ChunkAccessor",
"ChunkBorderDebugRendererMixin",
"ChunkOcclusionDataBuilderMixin",
"ChunkSkyLightProviderMixin",
"ClientChunkManagerAccessor",
Expand Down

0 comments on commit 3e1df83

Please sign in to comment.