some stuff lol
This commit is contained in:
parent
0a493b4466
commit
540c9b1056
4 changed files with 57 additions and 4 deletions
|
@ -16,7 +16,6 @@ import org.apache.commons.lang3.RandomStringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class CorePlugin extends PositionPlugin.Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runPlaceBlock (String command) {
|
public void runPlaceBlock (String command) {
|
||||||
if (!ready) return;
|
if (!ready || !bot.options().useCore()) return;
|
||||||
|
|
||||||
final CompoundTag tag = new CompoundTag("");
|
final CompoundTag tag = new CompoundTag("");
|
||||||
final CompoundTag blockEntityTag = new CompoundTag("BlockEntityTag");
|
final CompoundTag blockEntityTag = new CompoundTag("BlockEntityTag");
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package land.chipmunk.chayapak.chomens_bot.plugins;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket;
|
||||||
|
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||||
|
import land.chipmunk.chayapak.chomens_bot.chatParsers.data.MutablePlayerListEntry;
|
||||||
|
import land.chipmunk.chayapak.chomens_bot.data.Rotation;
|
||||||
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
|
|
||||||
|
public class MabePlugin extends PositionPlugin.Listener {
|
||||||
|
private final Bot bot;
|
||||||
|
|
||||||
|
public MabePlugin (Bot bot) {
|
||||||
|
this.bot = bot;
|
||||||
|
bot.position().addListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playerMoved (MutablePlayerListEntry player, Vector3f position, Rotation rotation) {
|
||||||
|
// final String name = player.profile().getName();
|
||||||
|
|
||||||
|
// if (!name.equals("chayapak")) return;
|
||||||
|
|
||||||
|
// Author: ChatGPT
|
||||||
|
final double dx = bot.position().position().getX() - position.getX();
|
||||||
|
final double dy = bot.position().position().getY() - position.getY();
|
||||||
|
final double dz = bot.position().position().getZ() - position.getZ();
|
||||||
|
final double distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||||
|
|
||||||
|
final double pitchRadians = Math.asin(dy / distance);
|
||||||
|
final double pitchDegrees = Math.toDegrees(pitchRadians);
|
||||||
|
|
||||||
|
bot.session().send(
|
||||||
|
new ServerboundMovePlayerPosRotPacket(
|
||||||
|
false,
|
||||||
|
bot.position().position().getX(),
|
||||||
|
bot.position().position().getY(),
|
||||||
|
bot.position().position().getZ(),
|
||||||
|
rotation.yaw - 180,
|
||||||
|
(float) pitchDegrees
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -84,7 +84,11 @@ public class PositionPlugin extends Bot.Listener {
|
||||||
|
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
rotationMap.put(packet.getEntityId(), new Rotation(packet.getYaw(), packet.getPitch()));
|
final Rotation rotation = new Rotation(packet.getYaw(), packet.getPitch());
|
||||||
|
|
||||||
|
rotationMap.put(packet.getEntityId(), rotation);
|
||||||
|
|
||||||
|
for (Listener listener : listeners) listener.playerMoved(player, getPlayerPosition(player.profile().getName()), rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void packetReceived (ClientboundMoveEntityPosPacket packet) {
|
public void packetReceived (ClientboundMoveEntityPosPacket packet) {
|
||||||
|
@ -103,6 +107,8 @@ public class PositionPlugin extends Bot.Listener {
|
||||||
);
|
);
|
||||||
|
|
||||||
positionMap.put(packet.getEntityId(), position);
|
positionMap.put(packet.getEntityId(), position);
|
||||||
|
|
||||||
|
for (Listener listener : listeners) listener.playerMoved(player, position, getPlayerRotation(player.profile().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void packetReceived (ClientboundMoveEntityPosRotPacket packet) {
|
public void packetReceived (ClientboundMoveEntityPosRotPacket packet) {
|
||||||
|
@ -121,8 +127,12 @@ public class PositionPlugin extends Bot.Listener {
|
||||||
packet.getMoveZ() + lastPosition.getZ()
|
packet.getMoveZ() + lastPosition.getZ()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final Rotation rotation = new Rotation(packet.getYaw(), packet.getPitch());
|
||||||
|
|
||||||
positionMap.put(packet.getEntityId(), position);
|
positionMap.put(packet.getEntityId(), position);
|
||||||
rotationMap.put(packet.getEntityId(), new Rotation(packet.getYaw(), packet.getPitch()));
|
rotationMap.put(packet.getEntityId(), rotation);
|
||||||
|
|
||||||
|
for (Listener listener : listeners) listener.playerMoved(player, position, rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3f getPlayerPosition (String playerName) {
|
public Vector3f getPlayerPosition (String playerName) {
|
||||||
|
@ -159,5 +169,6 @@ public class PositionPlugin extends Bot.Listener {
|
||||||
|
|
||||||
public static class Listener {
|
public static class Listener {
|
||||||
public void positionChange (Vector3i position) {}
|
public void positionChange (Vector3i position) {}
|
||||||
|
public void playerMoved (MutablePlayerListEntry player, Vector3f position, Rotation rotation) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue