Skip to content

Commit f77cf5a

Browse files
committed
Anti afk routine
1 parent e62fd7e commit f77cf5a

File tree

2 files changed

+65
-7
lines changed

2 files changed

+65
-7
lines changed

.github/workflows/build.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ name: build
22
on:
33
push:
44
branches:
5-
- main
6-
tags:
7-
- 'v*' # Sadece "v1.0.0" gibi tag'lerde release tetiklenir
5+
- main # Sadece main branch'e push yapıldığında çalışır
86
pull_request:
97

108
jobs:
119
build:
1210
strategy:
1311
matrix:
14-
java: [21] # Java 21 kullanılıyor
12+
java: [21]
1513
runs-on: ubuntu-22.04
1614
steps:
1715
- name: Checkout repository
@@ -33,20 +31,43 @@ jobs:
3331
run: ./gradlew build
3432

3533
- name: Capture build artifacts
36-
if: ${{ matrix.java == '21' }}
3734
uses: actions/upload-artifact@v4
3835
with:
3936
name: Artifacts
4037
path: build/libs/
4138

42-
release:
39+
tag-and-release:
4340
needs: build
44-
if: startsWith(github.ref, 'refs/tags/v') # Sadece v* ile başlayan tag'lerde çalışır
4541
runs-on: ubuntu-22.04
4642
steps:
4743
- name: Checkout repository
4844
uses: actions/checkout@v4
4945

46+
- name: Fetch all tags
47+
run: git fetch --tags
48+
49+
- name: Determine latest version and build number
50+
id: version
51+
run: |
52+
LATEST_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+:build\.[0-9]+$' | head -n 1 || echo "")
53+
54+
if [[ -z "$LATEST_TAG" ]]; then
55+
NEW_TAG="v1.0.0:build.1"
56+
else
57+
BASE_VERSION=$(echo "$LATEST_TAG" | cut -d':' -f1)
58+
BUILD_NUMBER=$(echo "$LATEST_TAG" | cut -d'.' -f2)
59+
NEW_BUILD_NUMBER=$((BUILD_NUMBER + 1))
60+
NEW_TAG="${BASE_VERSION}:build.${NEW_BUILD_NUMBER}"
61+
fi
62+
63+
echo "new_tag=$NEW_TAG" >> $GITHUB_ENV
64+
echo "New Tag: $NEW_TAG"
65+
66+
- name: Create and push new tag
67+
run: |
68+
git tag ${{ env.new_tag }}
69+
git push origin ${{ env.new_tag }}
70+
5071
- name: Download build artifacts
5172
uses: actions/download-artifact@v4
5273
with:
@@ -56,6 +77,7 @@ jobs:
5677
- name: Create GitHub Release
5778
uses: softprops/action-gh-release@v2
5879
with:
80+
tag_name: ${{ env.new_tag }}
5981
files: build/libs/*.jar
6082
env:
6183
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

src/main/java/dev/luxotick/_2blc.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.minecraft.client.network.PlayerListEntry;
88

99
import java.util.Collection;
10+
import java.util.concurrent.atomic.AtomicInteger;
1011

1112
public class _2blc implements ModInitializer {
1213
private TCPChatServer tcpServer;
@@ -15,6 +16,13 @@ public void onInitialize() {
1516
tcpServer = new TCPChatServer(9090);
1617
new Thread(tcpServer).start();
1718

19+
final int ANTI_AFK_INTERVAL_TICKS = 2 * 10;
20+
// Number of ticks to simulate forward movement.
21+
final int MOVE_TICKS = 5;
22+
23+
// Counter used to simulate holding the forward key.
24+
AtomicInteger antiAfkMoveTicks = new AtomicInteger();
25+
1826
ClientReceiveMessageEvents.CHAT.register(
1927
( message, signedMessage, sender, params, receptionTimestamp) -> {
2028
String chatText = message.getString();
@@ -59,5 +67,33 @@ public void onInitialize() {
5967
}
6068
}
6169
}).start();
70+
71+
// Anti-AFK routine:
72+
// Every ANTI_AFK_INTERVAL_TICKS, perform a small action (jump + slight rotate)
73+
// and simulate forward movement for a few ticks to prevent the server from marking
74+
// the client as idle.
75+
ClientTickEvents.END_CLIENT_TICK.register(client -> {
76+
if (client.player != null) {
77+
if (client.player.age % ANTI_AFK_INTERVAL_TICKS == 0) {
78+
client.execute(() -> {
79+
client.player.jump();
80+
// Rotate the player's view slightly (by 10 degrees).
81+
float newYaw = client.player.getYaw() + 10.0F;
82+
client.player.setYaw(newYaw);
83+
antiAfkMoveTicks.set(MOVE_TICKS);
84+
System.out.println("Performed anti-AFK action (jump, rotate, and move forward).");
85+
});
86+
}
87+
88+
if (antiAfkMoveTicks.get() > 0) {
89+
// Mark the forward key as pressed.
90+
client.options.forwardKey.setPressed(true);
91+
antiAfkMoveTicks.getAndDecrement();
92+
if (antiAfkMoveTicks.get() == 0) {
93+
client.options.forwardKey.setPressed(false);
94+
}
95+
}
96+
}
97+
});
6298
}
6399
}

0 commit comments

Comments
 (0)