mirror of https://github.com/kami-blue/client
Merged Teleport and TeleportCommand and close #830
This commit is contained in:
parent
fbf7d1e20c
commit
1f357f8e7c
|
@ -3,12 +3,12 @@ package me.zeroeightsix.kami.command.commands;
|
||||||
import me.zeroeightsix.kami.command.Command;
|
import me.zeroeightsix.kami.command.Command;
|
||||||
import me.zeroeightsix.kami.command.syntax.ChunkBuilder;
|
import me.zeroeightsix.kami.command.syntax.ChunkBuilder;
|
||||||
import me.zeroeightsix.kami.command.syntax.parsers.ModuleParser;
|
import me.zeroeightsix.kami.command.syntax.parsers.ModuleParser;
|
||||||
import me.zeroeightsix.kami.module.modules.hidden.Teleport;
|
import me.zeroeightsix.kami.util.Wrapper;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import static me.zeroeightsix.kami.KamiMod.MODULE_MANAGER;
|
|
||||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendChatMessage;
|
import static me.zeroeightsix.kami.util.MessageSendHelper.sendChatMessage;
|
||||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendErrorMessage;
|
import static me.zeroeightsix.kami.util.MessageSendHelper.sendErrorMessage;
|
||||||
|
|
||||||
|
@ -16,10 +16,14 @@ import static me.zeroeightsix.kami.util.MessageSendHelper.sendErrorMessage;
|
||||||
* Robeart is cool and made potentia
|
* Robeart is cool and made potentia
|
||||||
* Updated by d1gress/Qther on 8/12/2019.
|
* Updated by d1gress/Qther on 8/12/2019.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class TeleportCommand extends Command {
|
public class TeleportCommand extends Command {
|
||||||
|
|
||||||
private DecimalFormat df = new DecimalFormat("#.###");
|
private DecimalFormat df = new DecimalFormat("#.###");
|
||||||
|
private long lastTp;
|
||||||
|
private Vec3d lastPos;
|
||||||
|
public static Vec3d finalPos;
|
||||||
|
public static double blocksPerTeleport;
|
||||||
|
boolean disable = false;
|
||||||
|
|
||||||
public TeleportCommand() {
|
public TeleportCommand() {
|
||||||
super("teleport", new ChunkBuilder()
|
super("teleport", new ChunkBuilder()
|
||||||
|
@ -31,18 +35,49 @@ public class TeleportCommand extends Command {
|
||||||
setDescription("Potentia teleport exploit");
|
setDescription("Potentia teleport exploit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void teleport(Minecraft mc) {
|
||||||
|
Vec3d tpDirectionVec = finalPos.subtract(mc.player.posX, mc.player.posY, mc.player.posZ).normalize();
|
||||||
|
|
||||||
|
if (mc.world.isBlockLoaded(mc.player.getPosition())) {
|
||||||
|
lastPos = new Vec3d(mc.player.posX, mc.player.posY, mc.player.posZ);
|
||||||
|
if (finalPos.distanceTo(new Vec3d(mc.player.posX, mc.player.posY, mc.player.posZ)) < 0.3 || blocksPerTeleport == 0) {
|
||||||
|
sendChatMessage("Teleport Finished!");
|
||||||
|
disable = true;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
mc.player.setVelocity(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disable) return;
|
||||||
|
|
||||||
|
if (finalPos.distanceTo(new Vec3d(mc.player.posX, mc.player.posY, mc.player.posZ)) >= blocksPerTeleport) {
|
||||||
|
final Vec3d vec = tpDirectionVec.scale(blocksPerTeleport);
|
||||||
|
mc.player.setPosition(mc.player.posX + vec.x, mc.player.posY + vec.y, mc.player.posZ + vec.z);
|
||||||
|
} else {
|
||||||
|
final Vec3d vec = tpDirectionVec.scale(finalPos.distanceTo(new Vec3d(mc.player.posX, mc.player.posY, mc.player.posZ)));
|
||||||
|
mc.player.setPosition(mc.player.posX + vec.x, mc.player.posY + vec.y, mc.player.posZ + vec.z);
|
||||||
|
disable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disable) return;
|
||||||
|
lastTp = System.currentTimeMillis();
|
||||||
|
} else if (lastTp + 2000L > System.currentTimeMillis()) {
|
||||||
|
mc.player.setPosition(lastPos.x, lastPos.y, lastPos.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(String[] args) {
|
public void call(String[] args) {
|
||||||
if (args[0].equalsIgnoreCase("stop")) {
|
if (args[0].equalsIgnoreCase("stop")) {
|
||||||
sendChatMessage("Teleport Cancelled!");
|
sendChatMessage("Teleport Cancelled!");
|
||||||
MODULE_MANAGER.getModule(Teleport.class).disable();
|
disable = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length >= 4 && args[3] != null) {
|
if (args.length >= 4 && args[3] != null) {
|
||||||
Teleport.blocksPerTeleport = Double.parseDouble(args[3]);
|
blocksPerTeleport = Double.parseDouble(args[3]);
|
||||||
} else {
|
} else {
|
||||||
Teleport.blocksPerTeleport = 10000.0d;
|
blocksPerTeleport = 10000.0d;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length >= 3) {
|
if (args.length >= 3) {
|
||||||
|
@ -50,9 +85,10 @@ public class TeleportCommand extends Command {
|
||||||
final double x = args[0].equals("~") ? mc.player.posX : args[0].charAt(0) == '~' ? Double.parseDouble(args[0].substring(1)) + mc.player.posX : Double.parseDouble(args[0]);
|
final double x = args[0].equals("~") ? mc.player.posX : args[0].charAt(0) == '~' ? Double.parseDouble(args[0].substring(1)) + mc.player.posX : Double.parseDouble(args[0]);
|
||||||
final double y = args[1].equals("~") ? mc.player.posY : args[1].charAt(0) == '~' ? Double.parseDouble(args[1].substring(1)) + mc.player.posY : Double.parseDouble(args[1]);
|
final double y = args[1].equals("~") ? mc.player.posY : args[1].charAt(0) == '~' ? Double.parseDouble(args[1].substring(1)) + mc.player.posY : Double.parseDouble(args[1]);
|
||||||
final double z = args[2].equals("~") ? mc.player.posZ : args[2].charAt(0) == '~' ? Double.parseDouble(args[2].substring(1)) + mc.player.posZ : Double.parseDouble(args[2]);
|
final double z = args[2].equals("~") ? mc.player.posZ : args[2].charAt(0) == '~' ? Double.parseDouble(args[2].substring(1)) + mc.player.posZ : Double.parseDouble(args[2]);
|
||||||
Teleport.finalPos = new Vec3d(x, y, z);
|
finalPos = new Vec3d(x, y, z);
|
||||||
MODULE_MANAGER.getModule(Teleport.class).enable();
|
disable = false;
|
||||||
sendChatMessage("\n&aTeleporting to \n&cX: &b" + df.format(x) + "&a, \n&cY: &b" + df.format(y) + "&a, \n&cZ: &b" + df.format(z) + "\n&aat &b" + df.format(Teleport.blocksPerTeleport) + "&c blocks per teleport.");
|
teleport(Wrapper.getMinecraft());
|
||||||
|
sendChatMessage("\n&aTeleporting to \n&cX: &b" + df.format(x) + "&a, \n&cY: &b" + df.format(y) + "&a, \n&cZ: &b" + df.format(z) + "\n&aat &b" + df.format(blocksPerTeleport) + "&c blocks per teleport.");
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
sendErrorMessage("Null Pointer Exception Caught!");
|
sendErrorMessage("Null Pointer Exception Caught!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
package me.zeroeightsix.kami.module.modules.hidden;
|
|
||||||
|
|
||||||
import me.zeroeightsix.kami.module.Module;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
|
||||||
|
|
||||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendChatMessage;
|
|
||||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendErrorMessage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by d1gress/Qther on 26/11/2019.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Module.Info(
|
|
||||||
name = "Teleport",
|
|
||||||
description = "Library for teleport command",
|
|
||||||
category = Module.Category.HIDDEN
|
|
||||||
)
|
|
||||||
public class Teleport extends Module {
|
|
||||||
|
|
||||||
private long lastTp;
|
|
||||||
private Vec3d lastPos;
|
|
||||||
public static Vec3d finalPos;
|
|
||||||
public static double blocksPerTeleport;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdate() {
|
|
||||||
if (finalPos == null) {
|
|
||||||
sendErrorMessage("Position not set, use .tp");
|
|
||||||
disable();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec3d tpDirectionVec = finalPos.subtract(mc.player.posX, mc.player.posY, mc.player.posZ).normalize();
|
|
||||||
|
|
||||||
if (mc.world.isBlockLoaded(mc.player.getPosition())) {
|
|
||||||
lastPos = new Vec3d(mc.player.posX, mc.player.posY, mc.player.posZ);
|
|
||||||
if (finalPos.distanceTo(new Vec3d(mc.player.posX, mc.player.posY, mc.player.posZ)) < 0.3 || blocksPerTeleport == 0) {
|
|
||||||
sendChatMessage("Teleport Finished!");
|
|
||||||
disable();
|
|
||||||
} else {
|
|
||||||
mc.player.setVelocity(0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (finalPos.distanceTo(new Vec3d(mc.player.posX, mc.player.posY, mc.player.posZ)) >= blocksPerTeleport) {
|
|
||||||
final Vec3d vec = tpDirectionVec.scale(blocksPerTeleport);
|
|
||||||
mc.player.setPosition(mc.player.posX + vec.x, mc.player.posY + vec.y, mc.player.posZ + vec.z);
|
|
||||||
} else {
|
|
||||||
final Vec3d vec = tpDirectionVec.scale(finalPos.distanceTo(new Vec3d(mc.player.posX, mc.player.posY, mc.player.posZ)));
|
|
||||||
mc.player.setPosition(mc.player.posX + vec.x, mc.player.posY + vec.y, mc.player.posZ + vec.z);
|
|
||||||
disable();
|
|
||||||
}
|
|
||||||
lastTp = System.currentTimeMillis();
|
|
||||||
} else if (lastTp + 2000L > System.currentTimeMillis()) {
|
|
||||||
mc.player.setPosition(lastPos.x, lastPos.y, lastPos.z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue