Skip to content

Commit

Permalink
Fixed freecam having buggy movements.
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishisherewithhh committed Aug 26, 2024
1 parent 9aefa64 commit f7cf9af
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/main/java/dev/heliosclient/util/player/FreeCamEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
import dev.heliosclient.HeliosClient;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.OtherClientPlayerEntity;
import net.minecraft.client.option.GameOptions;
import net.minecraft.entity.Entity;
import net.minecraft.entity.MovementType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;

import java.util.UUID;


public class FreeCamEntity extends OtherClientPlayerEntity {
public class FreeCamEntity extends ClientPlayerEntity {
public static float moveSpeed = 1.0f;
public static FreeCamEntity camEntity;
private boolean ghost;
Expand All @@ -30,17 +28,25 @@ public FreeCamEntity(PlayerEntity player) {
this(player, player.getX(), player.getY(), player.getZ());
}


public FreeCamEntity(PlayerEntity player, double x, double y, double z) {
super(HeliosClient.MC.world, player.getGameProfile());
super(mc, mc.world, mc.player.networkHandler, mc.player.getStatHandler(), mc.player.getRecipeBook(),false,false);
this.noClip = true;


copyFrom(player);
copyPositionAndRotation(player);
this.copyFrom(player);
this.copyPositionAndRotation(player);
this.setRotations(player.getYaw(), player.getPitch());
this.setPos(x,y,z);
this.input = mc.player.input;


// Cache the player textures, then switch to a random uuid
// because the world doesn't allow duplicate uuids in 1.17+
dataTracker.set(PLAYER_MODEL_PARTS, player.getDataTracker().get(PLAYER_MODEL_PARTS));
setUuid(UUID.randomUUID());
this.refreshPosition();

camEntity = this;
}

Expand Down Expand Up @@ -97,7 +103,12 @@ public static void movementTick() {
}
}

private static double getMoveSpeed() {
@Override
public boolean isUsingItem() {
return HeliosClient.MC.player.isUsingItem();
}

public static double getMoveSpeed() {
return moveSpeed;
}

Expand Down

0 comments on commit f7cf9af

Please sign in to comment.