Compare commits
No commits in common. "0ddf042311272efd7c4023294ef4ddc14364301f" and "b3615770dcabbbb249f01ea0df765e58ab81089e" have entirely different histories.
0ddf042311
...
b3615770dc
2 changed files with 6 additions and 66 deletions
|
@ -374,8 +374,6 @@ public class CorePlugin extends PositionPlugin.Listener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void positionChange (Vector3i position) {
|
public void positionChange (Vector3i position) {
|
||||||
if (bot.position.isGoingDownFromHeightLimit) return;
|
|
||||||
|
|
||||||
from = Vector3i.from(
|
from = Vector3i.from(
|
||||||
(int) (fromSize.getX() + Math.floor((double) bot.position.position.getX() / 16) * 16),
|
(int) (fromSize.getX() + Math.floor((double) bot.position.position.getX() / 16) * 16),
|
||||||
MathUtilities.clamp(fromSize.getY(), bot.world.minY, bot.world.maxY),
|
MathUtilities.clamp(fromSize.getY(), bot.world.minY, bot.world.maxY),
|
||||||
|
|
|
@ -30,8 +30,6 @@ public class PositionPlugin extends Bot.Listener {
|
||||||
|
|
||||||
public Vector3i position = Vector3i.from(0, 0, 0);
|
public Vector3i position = Vector3i.from(0, 0, 0);
|
||||||
|
|
||||||
public boolean isGoingDownFromHeightLimit = false; // cool variable name
|
|
||||||
|
|
||||||
private final Map<Integer, PlayerEntry> entityIdMap = new HashMap<>();
|
private final Map<Integer, PlayerEntry> entityIdMap = new HashMap<>();
|
||||||
private final Map<Integer, Vector3f> positionMap = new HashMap<>();
|
private final Map<Integer, Vector3f> positionMap = new HashMap<>();
|
||||||
private final Map<Integer, Rotation> rotationMap = new HashMap<>();
|
private final Map<Integer, Rotation> rotationMap = new HashMap<>();
|
||||||
|
@ -42,23 +40,12 @@ public class PositionPlugin extends Bot.Listener {
|
||||||
bot.addListener(this);
|
bot.addListener(this);
|
||||||
|
|
||||||
// notchian clients also does this, sends the position packet every second
|
// notchian clients also does this, sends the position packet every second
|
||||||
bot.executor.scheduleAtFixedRate(() -> {
|
bot.executor.scheduleAtFixedRate(() -> bot.session.send(new ServerboundMovePlayerPosPacket(
|
||||||
if (isGoingDownFromHeightLimit) return;
|
false,
|
||||||
|
position.getX(),
|
||||||
bot.session.send(new ServerboundMovePlayerPosPacket(
|
position.getY(),
|
||||||
false,
|
position.getZ()
|
||||||
position.getX(),
|
)), 0, 1, TimeUnit.SECONDS);
|
||||||
position.getY(),
|
|
||||||
position.getZ()
|
|
||||||
));
|
|
||||||
}, 0, 1, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
bot.tick.addListener(new TickPlugin.Listener() {
|
|
||||||
@Override
|
|
||||||
public void onTick() {
|
|
||||||
handleHeightLimit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -158,51 +145,6 @@ public class PositionPlugin extends Bot.Listener {
|
||||||
for (Listener listener : listeners) listener.playerMoved(player, position, rotation);
|
for (Listener listener : listeners) listener.playerMoved(player, position, rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for now this is used in CorePlugin when placing the command block
|
|
||||||
private void handleHeightLimit () {
|
|
||||||
final int y = position.getY();
|
|
||||||
final int maxY = bot.world.maxY;
|
|
||||||
|
|
||||||
if (y < maxY) {
|
|
||||||
if (isGoingDownFromHeightLimit) {
|
|
||||||
isGoingDownFromHeightLimit = false;
|
|
||||||
|
|
||||||
for (Listener listener : listeners) { listener.positionChange(position); }
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
isGoingDownFromHeightLimit = true;
|
|
||||||
|
|
||||||
final Vector3i newPosition = Vector3i.from(
|
|
||||||
position.getX(),
|
|
||||||
position.getY() - 2,
|
|
||||||
position.getZ()
|
|
||||||
);
|
|
||||||
|
|
||||||
position = newPosition;
|
|
||||||
|
|
||||||
if (position.getY() > maxY + 500) {
|
|
||||||
String command = "/";
|
|
||||||
|
|
||||||
if (bot.serverPluginsManager.hasPlugin(ServerPluginsManagerPlugin.ESSENTIALS)) command += "essentials:";
|
|
||||||
|
|
||||||
command += String.format("tp %s %s %s", position.getX(), maxY - 1, position.getZ());
|
|
||||||
|
|
||||||
bot.chat.send(command);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bot.session.send(new ServerboundMovePlayerPosPacket(
|
|
||||||
false,
|
|
||||||
newPosition.getX(),
|
|
||||||
newPosition.getY(),
|
|
||||||
newPosition.getZ()
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3f getPlayerPosition (String playerName) {
|
public Vector3f getPlayerPosition (String playerName) {
|
||||||
int entityId = -1;
|
int entityId = -1;
|
||||||
for (Map.Entry<Integer, PlayerEntry> entry : entityIdMap.entrySet()) {
|
for (Map.Entry<Integer, PlayerEntry> entry : entityIdMap.entrySet()) {
|
||||||
|
|
Loading…
Reference in a new issue