Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
Improve Fake Cordinates in F3 and in Meteor Client Gui
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekiplay committed Apr 5, 2024
1 parent 6e26827 commit 3528918
Show file tree
Hide file tree
Showing 11 changed files with 398 additions and 97 deletions.
18 changes: 18 additions & 0 deletions src/main/java/nekiplay/meteorplus/MeteorPlusAddon.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package nekiplay.meteorplus;

import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.addons.GithubRepo;
import meteordevelopment.meteorclient.commands.Commands;
import meteordevelopment.meteorclient.gui.tabs.Tabs;
Expand All @@ -24,6 +25,7 @@
import nekiplay.meteorplus.features.modules.integrations.MapIntegration;
import nekiplay.meteorplus.features.modules.world.timer.TimerPlus;
import nekiplay.meteorplus.items.ModItems;
import nekiplay.meteorplus.settings.ConfigModifier;
import net.fabricmc.loader.api.FabricLoader;
import meteordevelopment.meteorclient.addons.MeteorAddon;
import meteordevelopment.meteorclient.systems.modules.Category;
Expand Down Expand Up @@ -67,6 +69,9 @@ public void onInitialize() {
if (!isBaritonePresent) {
LOG.warn(LOGPREFIX + " [Baritone] not found, disabling Xaero's World Map improvement");
}
else {
LOG.info(LOGPREFIX + " [Baritone] found, enabling Xaero's World Map improvement");
}
}
else {
LOG.warn(LOGPREFIX + " [Xaero's World Map] not found, disabling Xaero's World Map improvement");
Expand All @@ -75,16 +80,29 @@ public void onInitialize() {
if (!isBaritonePresent) {
LOG.warn(LOGPREFIX + " [Baritone] not found, disabling Journey Map improvement");
}
else {
LOG.info(LOGPREFIX + " [Baritone] found, enabling Journey Map improvement");
}
}
else {
LOG.warn(LOGPREFIX + " [Journey Map] not found, disabling Journey Map improvement");
}
if (!isBaritonePresent) {
LOG.warn(LOGPREFIX + " [Baritone] not found, disabling Freecam and Waypoints improvement");
}
else {
LOG.info(LOGPREFIX + " [Baritone] found, enabling Freecam and Waypoints improvement");
}

if (!isWhereIsIt) {
LOG.warn(LOGPREFIX + " [Where is it] not found, disabling ChestTracker improvement");
}
else {
LOG.info(LOGPREFIX + " [Where is it] found, enabling ChestTracker improvement");
}

MeteorClient.EVENT_BUS.subscribe(new CordinateProtector());
ConfigModifier.get();

//region Commands
LOG.info(LOGPREFIX + " Initializing commands...");
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/nekiplay/meteorplus/MixinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ else if (mixinClassName.startsWith(mixinPackage + ".meteorclient")) {
else if (mixinClassName.startsWith(mixinPackage + ".journeymap")) {
return isBaritonePresent && isJourneyMapPresent;
}
else if (mixinClassName.startsWith(mixinPackage + ".xaero")) {
else if (mixinClassName.startsWith(mixinPackage + ".xaero.minimap")) {
return isXaeroWorldMapresent;
}
else if (mixinClassName.startsWith(mixinPackage + ".xaero.worldmap")) {
return isBaritonePresent && isXaeroWorldMapresent;
}
else if (mixinClassName.startsWith(mixinPackage + ".whereisit")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package nekiplay.meteorplus.features.modules.misc;

import meteordevelopment.orbit.EventHandler;
import nekiplay.meteorplus.events.hud.DebugDrawTextEvent;
import nekiplay.meteorplus.mixinclasses.SpoofMode;
import nekiplay.meteorplus.settings.ConfigModifier;
import net.minecraft.util.Formatting;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.ChunkSectionPos;

import java.util.List;
import java.util.Locale;

import static meteordevelopment.meteorclient.MeteorClient.mc;

public class CordinateProtector {
@EventHandler
private void onDebugF3RenderText(DebugDrawTextEvent event) {
List<String> lines = event.getLines();

if (ConfigModifier.get().positionProtection.get()) {
if (event.isLeft()) {
int index = 0;
for (Object obj : lines.toArray()) {
String str = obj.toString();

if (str.startsWith("XYZ:")) {
String xyz = String.format(Locale.ROOT, "XYZ: %.3f / %.5f / %.3f", mc.getCameraEntity().getX() + ConfigModifier.get().x_spoof.get(), mc.getCameraEntity().getY(), mc.getCameraEntity().getZ() + ConfigModifier.get().z_spoof.get());
if (ConfigModifier.get().spoofMode.get() == SpoofMode.Fake) {
lines.set(index, xyz);
}
else if (ConfigModifier.get().spoofMode.get() == SpoofMode.Sensor) {
lines.set(index, "XYZ: *** / *** / ***");
}
} else if (str.startsWith("Block: ")) {
BlockPos blockPos = mc.getCameraEntity().getBlockPos();
blockPos = blockPos.add(ConfigModifier.get().x_spoof.get(), 0, ConfigModifier.get().z_spoof.get());

String block = String.format(Locale.ROOT, "Block: %d %d %d [%d %d %d]", blockPos.getX(), blockPos.getY(), blockPos.getZ(), blockPos.getX() & 15, blockPos.getY() & 15, blockPos.getZ() & 15);
if (ConfigModifier.get().spoofMode.get() == SpoofMode.Fake) {
lines.set(index, block);
}
else if (ConfigModifier.get().spoofMode.get() == SpoofMode.Sensor) {
lines.set(index, "Block: *** *** *** [*** *** ***]");
}
} else if (str.startsWith("Chunk:")) {
BlockPos blockPos = mc.getCameraEntity().getBlockPos();
blockPos = blockPos.add(ConfigModifier.get().x_spoof.get(), 0, ConfigModifier.get().z_spoof.get());
ChunkPos chunkPos = new ChunkPos(blockPos);

String chunk = String.format(Locale.ROOT, "Chunk: %d %d %d [%d %d in r.%d.%d.mca]", chunkPos.x, ChunkSectionPos.getSectionCoord(blockPos.getY()), chunkPos.z, chunkPos.getRegionRelativeX(), chunkPos.getRegionRelativeZ(), chunkPos.getRegionX(), chunkPos.getRegionZ());
if (ConfigModifier.get().spoofMode.get() == SpoofMode.Fake) {
lines.set(index, chunk);
}
else if (ConfigModifier.get().spoofMode.get() == SpoofMode.Sensor) {
lines.set(index, "Chunk: *** *** *** [*** *** in *****.mca]");
}
}
index++;
}
} else {
int index = 0;
for (Object obj : lines.toArray()) {
String str = obj.toString();

if (str.contains("Targeted Block:")) {
HitResult blockHitResult = event.blockHit();
if (blockHitResult != null && blockHitResult.getType() == HitResult.Type.BLOCK) {
Formatting var10001 = Formatting.UNDERLINE;

BlockPos blockPos = ((BlockHitResult) blockHitResult).getBlockPos();
blockPos = blockPos.add(ConfigModifier.get().x_spoof.get(), 0, ConfigModifier.get().z_spoof.get());
if (ConfigModifier.get().spoofMode.get() == SpoofMode.Fake) {
lines.set(index, "" + var10001 + "Targeted Block: " + blockPos.getX() + ", " + blockPos.getY() + ", " + blockPos.getZ());
}
else if (ConfigModifier.get().spoofMode.get() == SpoofMode.Sensor) {
lines.set(index, var10001 + "Targeted Block: *** *** ***");
}
}
} else if (str.contains("Targeted Fluid:")) {
HitResult blockHitResult = event.fluidHit();
if (blockHitResult != null && blockHitResult.getType() == HitResult.Type.BLOCK) {
Formatting var10001 = Formatting.UNDERLINE;

BlockPos blockPos = ((BlockHitResult) blockHitResult).getBlockPos();
blockPos = blockPos.add(ConfigModifier.get().x_spoof.get(), 0, ConfigModifier.get().z_spoof.get());
if (ConfigModifier.get().spoofMode.get() == SpoofMode.Fake) {
lines.set(index, "" + var10001 + "Targeted Fluid: " + blockPos.getX() + ", " + blockPos.getY() + ", " + blockPos.getZ());
}
else if (ConfigModifier.get().spoofMode.get() == SpoofMode.Sensor) {
lines.set(index, var10001 + "Targeted Fluid: *** *** ***");
}
}
}
index++;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
package nekiplay.meteorplus.mixin.meteorclient;

import meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList;
import meteordevelopment.meteorclient.gui.widgets.input.WBlockPosEdit;
import meteordevelopment.meteorclient.gui.widgets.input.WTextBox;
import nekiplay.meteorplus.mixinclasses.SpoofMode;
import nekiplay.meteorplus.settings.ConfigModifier;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.math.BlockPos;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = WBlockPosEdit.class, remap = false, priority = 1001)
public class WBlockPosEditMixin extends WHorizontalList {
@Shadow
public Runnable action;
@Shadow
public Runnable actionOnRelease;
@Shadow
private WTextBox textBoxX;
@Shadow
private WTextBox textBoxY;
@Shadow
private WTextBox textBoxZ;
@Shadow
private Screen previousScreen;
@Shadow
private BlockPos value;
@Shadow
private BlockPos lastValue;
@Shadow
private boolean clicking;
@Inject(method = "addTextBox", at = @At("HEAD"), cancellable = true)
private void addTextBox(CallbackInfo ci) {
this.textBoxX = (WTextBox)this.add(this.theme.textBox(Integer.toString(this.value.getX()), this::filter)).minWidth(75.0).widget();
this.textBoxY = (WTextBox)this.add(this.theme.textBox(Integer.toString(this.value.getY()), this::filter)).minWidth(75.0).widget();
this.textBoxZ = (WTextBox)this.add(this.theme.textBox(Integer.toString(this.value.getZ()), this::filter)).minWidth(75.0).widget();
this.textBoxX.actionOnUnfocused = () -> {
try {
this.lastValue = this.value;
if (this.textBoxX.get().isEmpty()) {
this.set(new BlockPos(0, 0, 0));
} else {
this.set(new BlockPos(Integer.parseInt(this.textBoxX.get()) - ConfigModifier.get().x_spoof.get(), this.value.getY(), this.value.getZ()));
}

this.newValueCheck();
}
catch (NumberFormatException ignore) { }
};
this.textBoxY.actionOnUnfocused = () -> {
try {
this.lastValue = this.value;
if (this.textBoxY.get().isEmpty()) {
this.set(new BlockPos(0, 0, 0));
} else {
this.set(new BlockPos(this.value.getX(), Integer.parseInt(this.textBoxY.get()), this.value.getZ()));
}

this.newValueCheck();
}
catch (NumberFormatException ignore) { }
};
this.textBoxZ.actionOnUnfocused = () -> {
try {
this.lastValue = this.value;
if (this.textBoxZ.get().isEmpty()) {
this.set(new BlockPos(0, 0, 0));
} else {
if (ConfigModifier.get().spoofMode.get() == SpoofMode.Fake) {
this.set(new BlockPos(this.value.getX(), this.value.getY(), Integer.parseInt(this.textBoxZ.get())));
}
else {
this.set(new BlockPos(this.value.getX(), this.value.getY(), Integer.parseInt(this.textBoxZ.get()) - ConfigModifier.get().z_spoof.get()));
}
}

this.newValueCheck();
}
catch (NumberFormatException ignore) { }
};



if (ConfigModifier.get().positionProtection.get()) {
if (ConfigModifier.get().spoofMode.get() == SpoofMode.Fake) {
textBoxX.set(String.valueOf(value.add(ConfigModifier.get().x_spoof.get(), 0, 0).getX()));
textBoxZ.set(String.valueOf(value.add(0, 0, ConfigModifier.get().z_spoof.get()).getZ()));
}
else if (ConfigModifier.get().spoofMode.get() == SpoofMode.Sensor) {
textBoxX.set("***");
textBoxZ.set("***");
textBoxY.set("***");
}
}
ci.cancel();
}
@Shadow
private boolean filter(String text, char c) {
boolean validate = true;
boolean good;
if (c == '-' && text.isEmpty()) {
good = true;
validate = false;
} else {
good = Character.isDigit(c);
}

if (good && validate) {
try {
Integer.parseInt(text + c);
} catch (NumberFormatException var6) {
good = false;
}
}

return good;
}
@Shadow
public BlockPos get() {
return this.value;
}
@Shadow
public void set(BlockPos value) {
this.value = value;
}
@Shadow
private void newValueCheck() {
if (this.value != this.lastValue) {
if (this.action != null) {
this.action.run();
}

if (this.actionOnRelease != null) {
this.actionOnRelease.run();
}
}

}

}
Loading

0 comments on commit 3528918

Please sign in to comment.