Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: MinecraftFreecam/Freecam
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.2.2
Choose a base ref
...
head repository: MinecraftFreecam/Freecam
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.2.3
Choose a head ref
  • 4 commits
  • 6 files changed
  • 2 contributors

Commits on Dec 14, 2021

  1. Create README.md

    hashalite authored Dec 14, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    71dbef7 View commit details
  2. Updated lang

    hashalite committed Dec 14, 2021
    Copy the full SHA
    9b7c6f2 View commit details
  3. Small fixes

    - Fixed dismounting vehicle when sneak is pressed while in freecam
    - Fixed weird behavior if freecam is entered while using an elytra
    - Fixed clone mounting old vehicle
    hashalite committed Dec 14, 2021
    Copy the full SHA
    6fffe5b View commit details
  4. Version bump

    hashalite committed Dec 14, 2021
    Copy the full SHA
    c9fdbc7 View commit details
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Freecam
This mod allows you to view your world from a spectator-like perspective. It can be useful for previewing builds and exploring your world. It works in multiplayer, but may be considered cheating on some servers, so use at your own risk.

The bind defaults to X, and can be changed in the vanilla options menu. Speed and various cosmetic options are configurable through the Mod Menu config page.

##
### Requirements
- Fabric API
- Mod Menu
- Cloth Config
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ minecraft_version=1.18.1
yarn_mappings=1.18.1+build.2
loader_version=0.12.11
# Mod Properties
mod_version=0.2.2
mod_version=0.2.3
maven_group=net.xolt
archives_base_name=freecam
# Dependencies
10 changes: 10 additions & 0 deletions src/main/java/net/xolt/freecam/Freecam.java
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ public class Freecam implements ClientModInitializer {
private static Vec3d pos;
private static float[] rot;
private static Entity riding;
private static boolean isFallFlying;
private static ClonePlayerEntity clone;

@Override
@@ -51,6 +52,7 @@ private static void onEnable() {
MC.chunkCullingEnabled = false;
pos = MC.player.getPos();
rot = new float[]{MC.player.getYaw(), MC.player.getPitch()};
isFallFlying = MC.player.isFallFlying();

if (!ModConfig.INSTANCE.showHand) {
MC.gameRenderer.setRenderHand(false);
@@ -69,6 +71,10 @@ private static void onEnable() {
}
}

if (isFallFlying) {
MC.player.stopFallFlying();
}

if (MC.player.isSprinting()) {
MC.player.networkHandler.sendPacket(new ClientCommandC2SPacket(MC.player, ClientCommandC2SPacket.Mode.STOP_SPRINTING));
}
@@ -83,6 +89,9 @@ private static void onDisable() {
MC.gameRenderer.setRenderHand(true);
MC.player.noClip = false;
MC.player.setVelocity(Vec3d.ZERO);
if (isFallFlying) {
MC.player.startFallFlying();
}

if (clone != null) {
MC.world.removeEntity(clone.getId(), Entity.RemovalReason.DISCARDED);
@@ -94,6 +103,7 @@ private static void onDisable() {

if (riding != null && MC.world.getEntityById(riding.getId()) != null) {
MC.player.startRiding(riding);
riding = null;
}

if (ModConfig.INSTANCE.notify) {
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import net.minecraft.network.Packet;
import net.minecraft.network.packet.c2s.play.PlayerInputC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket;
import net.xolt.freecam.Freecam;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -17,7 +18,7 @@ public class ClientConnectionMixin {

@Inject(method = "send(Lnet/minecraft/network/Packet;Lio/netty/util/concurrent/GenericFutureListener;)V", at = @At("HEAD"), cancellable = true)
public void send(Packet<?> packet, GenericFutureListener<? extends Future<? super Void>> callback, CallbackInfo ci) {
if((packet instanceof PlayerMoveC2SPacket || packet instanceof PlayerInputC2SPacket) && Freecam.isEnabled()) {
if((packet instanceof PlayerMoveC2SPacket || packet instanceof PlayerInputC2SPacket || packet instanceof ClientCommandC2SPacket) && Freecam.isEnabled()) {
ci.cancel();
}
}
Original file line number Diff line number Diff line change
@@ -9,13 +9,16 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import static net.xolt.freecam.Freecam.MC;

@Mixin(MinecraftClient.class)
public class MinecraftClientMixin {

@Inject(method = "tick", at = @At("HEAD"))
private void onTick(CallbackInfo ci) {
if (Freecam.isEnabled()) {
Motion.doMotion(ModConfig.INSTANCE.freecamHSpeed, ModConfig.INSTANCE.freecamVSpeed);
MC.player.setOnGround(true);
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/freecam/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"text.autoconfig.freecam.title": "Freecam Options",
"key.freecam.toggle": "Toggle Freecam",
"category.freecam.freecam": "Freecam",
"text.autoconfig.freecam.option.freecamHSpeed": "Freecam Horizontal Speed",