This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*Sort code *Improved methods *Fixed FakePlayer (-> FakePlayerUtils) *Updated icon.png
- Loading branch information
Showing
13 changed files
with
233 additions
and
130 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
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
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,7 @@ | ||
package net.i_no_am.freecamera.client; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
|
||
public interface Global { | ||
MinecraftClient mc = MinecraftClient.getInstance(); | ||
} |
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
13 changes: 7 additions & 6 deletions
13
src/main/java/net/i_no_am/freecamera/mixin/MixinClientConnection.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 |
---|---|---|
@@ -1,21 +1,22 @@ | ||
package net.i_no_am.freecamera.mixin; | ||
|
||
import net.i_no_am.freecamera.FreeCamera; | ||
import net.i_no_am.freecamera.utils.ConfigUtils; | ||
import net.i_no_am.freecamera.utils.PlayerUtils; | ||
import net.minecraft.network.ClientConnection; | ||
import net.minecraft.network.packet.Packet; | ||
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ClientConnection.class) | ||
public class MixinClientConnection { | ||
@Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;)V", cancellable = true) | ||
private void sendPacket(Packet<?> packet, CallbackInfo ci) { | ||
if (FreeCamera.isCameraActive() && packet instanceof PlayerMoveC2SPacket) { | ||
@Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true) | ||
private void onSendPacket(Packet<?> packet, CallbackInfo ci) { | ||
if (PlayerUtils.notNull() && ConfigUtils.isCameraActive() && packet instanceof PlayerMoveC2SPacket) { | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/net/i_no_am/freecamera/mixin/MixinInGameHud.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,37 @@ | ||
package net.i_no_am.freecamera.mixin; | ||
|
||
import net.i_no_am.freecamera.client.Global; | ||
import net.i_no_am.freecamera.utils.ConfigUtils; | ||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.client.gui.hud.InGameHud; | ||
import net.minecraft.client.render.RenderTickCounter; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.text.TextColor; | ||
import net.minecraft.text.MutableText; | ||
import net.minecraft.text.Style; | ||
|
||
@Mixin(InGameHud.class) | ||
public class MixinInGameHud implements Global { | ||
|
||
@Inject(method = "renderOverlayMessage", at = @At(value = "HEAD")) | ||
private void onRenderOverlayMessage(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { | ||
if (ConfigUtils.isCameraActive()) { | ||
|
||
MutableText msgP1 = Text.literal("Free Camera is "); | ||
MutableText msgP2 = Text.literal("ON").setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0x00FF00))); | ||
|
||
MutableText fullMsg = msgP1.append(msgP2); | ||
|
||
int messageWidth = mc.textRenderer.getWidth(fullMsg); | ||
int x = (mc.getWindow().getScaledWidth() / 2) - (messageWidth / 2); | ||
int y = mc.getWindow().getScaledHeight() - 51; | ||
|
||
context.drawText(mc.textRenderer, fullMsg, x, y, 0xFFFFFF, true); | ||
} | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
src/main/java/net/i_no_am/freecamera/utils/ConfigUtils.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,12 @@ | ||
package net.i_no_am.freecamera.utils; | ||
|
||
import net.i_no_am.freecamera.FreeCamera; | ||
|
||
public class ConfigUtils { | ||
public static boolean isCameraActive() { | ||
return FreeCamera.isCameraActive; | ||
} | ||
public static void toggleCamera() { | ||
FreeCamera.isCameraActive = !FreeCamera.isCameraActive; | ||
} | ||
} |
69 changes: 0 additions & 69 deletions
69
src/main/java/net/i_no_am/freecamera/utils/FakePlayer.java
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
src/main/java/net/i_no_am/freecamera/utils/FakePlayerUtils.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,54 @@ | ||
package net.i_no_am.freecamera.utils; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import net.i_no_am.freecamera.client.Global; | ||
import net.minecraft.client.network.OtherClientPlayerEntity; | ||
import net.minecraft.client.network.ClientPlayerEntity; | ||
import net.minecraft.client.world.ClientWorld; | ||
|
||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
public class FakePlayerUtils extends OtherClientPlayerEntity implements Global { | ||
|
||
private final ClientPlayerEntity p = mc.player; | ||
private final ClientWorld w = mc.world; | ||
|
||
public FakePlayerUtils() { | ||
super(Objects.requireNonNull(mc.world), new GameProfile(UUID.fromString("66123666-6666-6666-6666-666666666600"), mc.player.getName().getString())); | ||
copyPositionAndRotation(mc.player); | ||
copyInventory(); | ||
copyPlayerModel(); | ||
copyRotation(); | ||
resetCapeMovement(); | ||
spawn(); | ||
} | ||
|
||
private void copyInventory() { | ||
getInventory().clone(p.getInventory()); | ||
} | ||
|
||
private void copyPlayerModel() { | ||
dataTracker.set(PLAYER_MODEL_PARTS, mc.player.getDataTracker().get(PLAYER_MODEL_PARTS)); | ||
} | ||
|
||
private void copyRotation() { | ||
headYaw = p.headYaw; | ||
bodyYaw = p.bodyYaw; | ||
} | ||
|
||
private void resetCapeMovement() { | ||
capeX = getX(); | ||
capeY = getY(); | ||
capeZ = getZ(); | ||
} | ||
|
||
private void spawn() { | ||
w.addEntity(this); | ||
} | ||
|
||
public void despawn() { | ||
p.refreshPositionAndAngles(getX(), getY(), getZ(), getYaw(), getPitch()); | ||
discard(); | ||
} | ||
} |
Oops, something went wrong.