feat: option to simulate gravity
This commit is contained in:
1 parent
32d760e9eb
commit
22c05d18db
3 files changed
+59
No files matched your search
@@ -35,6 +35,7 @@ When running, you can write a chat message to the terminal to send it by all bot
|
|||||||
`-x` The most minimal run - No listeners, no control, no chat - useful for large amounts of bots for better performance
|
`-x` The most minimal run - No listeners, no control, no chat - useful for large amounts of bots for better performance
|
||||||
`-t` Set proxy type - SOCKS4 or SOCKS5
|
`-t` Set proxy type - SOCKS4 or SOCKS5
|
||||||
`-l` Set proxy list file
|
`-l` Set proxy list file
|
||||||
|
`-g` Try to simulate gravity by falling down
|
||||||
`-nicks` Set nicknames file
|
`-nicks` Set nicknames file
|
||||||
|
|
||||||
## ⚠ DISCLAIMER
|
## ⚠ DISCLAIMER
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ package me.creepermaxcz.mcbots;
|
|||||||
|
|
||||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.*;
|
||||||
import com.github.steveice10.packetlib.ProxyInfo;
|
import com.github.steveice10.packetlib.ProxyInfo;
|
||||||
import com.github.steveice10.packetlib.Session;
|
import com.github.steveice10.packetlib.Session;
|
||||||
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
||||||
@@ -22,6 +25,10 @@ public class Bot extends Thread {
|
|||||||
private Session client;
|
private Session client;
|
||||||
private boolean hasMainListener;
|
private boolean hasMainListener;
|
||||||
|
|
||||||
|
private double lastX, lastY, lastZ = -1;
|
||||||
|
|
||||||
|
private boolean connected;
|
||||||
|
|
||||||
public Bot(String nickname, InetSocketAddress address, ProxyInfo proxy) {
|
public Bot(String nickname, InetSocketAddress address, ProxyInfo proxy) {
|
||||||
this.nickname = nickname;
|
this.nickname = nickname;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
@@ -41,15 +48,26 @@ public class Bot extends Thread {
|
|||||||
@Override
|
@Override
|
||||||
public void packetReceived(Session session, Packet packet) {
|
public void packetReceived(Session session, Packet packet) {
|
||||||
if (packet instanceof ClientboundLoginPacket) {
|
if (packet instanceof ClientboundLoginPacket) {
|
||||||
|
connected = true;
|
||||||
Log.info(nickname + " connected");
|
Log.info(nickname + " connected");
|
||||||
if (Main.joinMessage != null) {
|
if (Main.joinMessage != null) {
|
||||||
sendChat(Main.joinMessage);
|
sendChat(Main.joinMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (packet instanceof ClientboundPlayerPositionPacket) {
|
||||||
|
ClientboundPlayerPositionPacket p = (ClientboundPlayerPositionPacket) packet;
|
||||||
|
|
||||||
|
lastX = p.getX();
|
||||||
|
lastY = p.getY();
|
||||||
|
lastZ = p.getZ();
|
||||||
|
|
||||||
|
client.send(new ServerboundAcceptTeleportationPacket(p.getTeleportId()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected(DisconnectedEvent event) {
|
public void disconnected(DisconnectedEvent event) {
|
||||||
|
connected = false;
|
||||||
Log.info();
|
Log.info();
|
||||||
Log.info(nickname + " disconnected");
|
Log.info(nickname + " disconnected");
|
||||||
Log.info(" -> " + event.getReason());
|
Log.info(" -> " + event.getReason());
|
||||||
@@ -83,4 +101,28 @@ public class Bot extends Thread {
|
|||||||
public boolean hasMainListener() {
|
public boolean hasMainListener() {
|
||||||
return hasMainListener;
|
return hasMainListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fallDown()
|
||||||
|
{
|
||||||
|
if (connected && lastY > 0) {
|
||||||
|
move(0, -0.5, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void move(double x, double y, double z)
|
||||||
|
{
|
||||||
|
lastX += x;
|
||||||
|
lastY += y;
|
||||||
|
lastZ += z;
|
||||||
|
moveTo(lastX, lastY, lastZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveTo(double x, double y, double z)
|
||||||
|
{
|
||||||
|
client.send(new ServerboundMovePlayerPosPacket(true, x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConnected() {
|
||||||
|
return connected;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,8 @@ import java.net.*;
|
|||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
@@ -35,6 +37,8 @@ public class Main {
|
|||||||
private static int proxyCount = 0;
|
private static int proxyCount = 0;
|
||||||
private static ProxyInfo.Type proxyType;
|
private static ProxyInfo.Type proxyType;
|
||||||
|
|
||||||
|
private static Timer timer = new Timer();
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
@@ -61,6 +65,8 @@ public class Main {
|
|||||||
|
|
||||||
options.addOption("nicks", true, "Path to nicks file with nick on every line");
|
options.addOption("nicks", true, "Path to nicks file with nick on every line");
|
||||||
|
|
||||||
|
options.addOption("g", "gravity", false, "Try to simulate gravity by falling down");
|
||||||
|
|
||||||
CommandLineParser parser = new DefaultParser();
|
CommandLineParser parser = new DefaultParser();
|
||||||
CommandLine cmd = null;
|
CommandLine cmd = null;
|
||||||
|
|
||||||
@@ -283,6 +289,16 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
|
//gravity timer
|
||||||
|
if (cmd.hasOption("g")) {
|
||||||
|
timer.scheduleAtFixedRate(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
bots.forEach(Bot::fallDown);
|
||||||
|
}
|
||||||
|
}, 1000L, 500L);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user