This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
generated from MeteorDevelopment/meteor-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Fake Cordinates in F3 and in Meteor Client Gui
- Loading branch information
Showing
11 changed files
with
398 additions
and
97 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
103 changes: 103 additions & 0 deletions
103
src/main/java/nekiplay/meteorplus/features/modules/misc/CordinateProtector.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,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++; | ||
} | ||
} | ||
} | ||
} | ||
} |
145 changes: 145 additions & 0 deletions
145
src/main/java/nekiplay/meteorplus/mixin/meteorclient/WBlockPosEditMixin.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,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(); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.