Add tp
This commit is contained in:
d1gress 2019-11-26 21:13:16 +08:00 committed by Bella Who
parent c889458a95
commit 6b391d9e45
3 changed files with 121 additions and 0 deletions

View File

@ -30,6 +30,14 @@ public abstract class Command {
public static void sendChatMessage(String message){
sendRawChatMessage("&7[&a" + KamiMod.KAMI_KANJI + "&7] &r" + message);
}
public static void sendErrorMessage(String message){
sendRawChatMessage("&7[&4" + KamiMod.KAMI_KANJI + "&7] &r" + message);
}
public static void sendWarningMessage(String message){
sendRawChatMessage("&7[&6" + KamiMod.KAMI_KANJI + "&7] &r" + message);
}
public static void sendStringChatMessage(String[] messages) {
sendChatMessage("");

View File

@ -0,0 +1,61 @@
package me.zeroeightsix.kami.command.commands;
import me.zeroeightsix.kami.command.Command;
import me.zeroeightsix.kami.command.syntax.ChunkBuilder;
import me.zeroeightsix.kami.command.syntax.parsers.ModuleParser;
import me.zeroeightsix.kami.module.ModuleManager;
import me.zeroeightsix.kami.module.modules.hidden.Teleport;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.Vec3d;
import java.text.DecimalFormat;
/**
* Created by d1gress/Qther on 26/11/2019.
*/
public class TeleportCommand extends Command {
Minecraft mc = Minecraft.getMinecraft();
DecimalFormat df = new DecimalFormat("#.###");
public TeleportCommand() {
super("tp", new ChunkBuilder()
.append("x/stop", true, new ModuleParser())
.append("y", true)
.append("z", true)
.append("blocks per tp", false)
.build());
}
@Override
public void call(String[] args) {
if (args[0].equalsIgnoreCase("stop")) {
Command.sendChatMessage("Teleport Cancelled!");
ModuleManager.getModuleByName("Teleport").disable();
return;
}
if (args.length >= 4 && args[3] != null) {
Teleport.blocksPerTeleport = Double.valueOf(args[3]);
} else {
Teleport.blocksPerTeleport = 10000.0d;
}
if (args.length >= 3) {
try {
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 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);
ModuleManager.getModuleByName("Teleport").enable();
Command.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.");
}
catch (NullPointerException e){
Command.sendErrorMessage("Null Pointer Exception Caught!");
}
}
}
}

View File

@ -0,0 +1,52 @@
package me.zeroeightsix.kami.module.modules.hidden;
import me.zeroeightsix.kami.command.Command;
import me.zeroeightsix.kami.module.Module;
import net.minecraft.util.math.Vec3d;
/**
* Created by d1gress/Qther on 26/11/2019.
*/
@Module.Info(name = "Teleport", description = "you aren't supposed to see this.", 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) {
Command.sendErrorMessage("Position not set, use .tp");
this.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) {
Command.sendChatMessage("Teleport Finished!");
this.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);
this.disable();
}
lastTp = System.currentTimeMillis();
} else if (lastTp + 2000L > System.currentTimeMillis()) {
mc.player.setPosition(lastPos.x, lastPos.y, lastPos.z);
}
}
}