Skip to content

Commit

Permalink
Update protocol to v554 (#72)
Browse files Browse the repository at this point in the history
* Bump version to 0.5.9
  • Loading branch information
hhhxiao authored Oct 9, 2022
1 parent aca0f4f commit c9ccb3e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Minecraft Bedrock Edition 假人客户端
* JavaScript API

## 支持的版本
* 理论上支持1.7.0到1.19.22之间的所有版本
* 理论上支持1.7.0到1.19.30之间的所有版本

## WebSocket API
* FakePlayer提供WebSocket API以供其他插件/程序与FakePlayer进行通信,目前支持的操作有添加/删除假人,获取假人列表等
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group 'com.ddf.fakeplayer'
version '0.5.8-alpha'
version '0.5.9-alpha'

repositories {
maven {
Expand All @@ -31,7 +31,7 @@ repositories {
}

dependencies {
implementation 'com.nukkitx.protocol:bedrock-v545:2.9.11-SNAPSHOT'
implementation 'com.nukkitx.protocol:bedrock-v554:2.9.12-SNAPSHOT'
implementation 'com.google.code.gson:gson:2.8.7'
implementation 'org.yaml:snakeyaml:1.29'
implementation 'com.formdev:flatlaf:1.5'
Expand Down
6 changes: 4 additions & 2 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 更新内容
* 支持1.19.21-22版本(协议版本545)

* 支持1.19.30版本(协议版本554)

## Change Log
* Support MC v1.19.21-22 (Protocol 545)

* Support MC v1.19.30 (Protocol 554)
20 changes: 11 additions & 9 deletions src/main/java/com/ddf/fakeplayer/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ private void connect(String address, int port, boolean isReconnect) {
level.getGlobalBlockPalette().initFromNbtMapList(ProtocolVersionUtil.getBlockPalette(packetCodec));
}

bedrockClient.connect(addressToConnect, 1, TimeUnit.SECONDS).whenComplete((session, throwable) -> runOnClientThread(() -> {
bedrockClient.connect(addressToConnect, 1, TimeUnit.SECONDS).whenComplete((session, throwable) -> runOnClientThread(() -> {
if (throwable != null) {
return;
}
setState(State.CONNECTED);
session.addDisconnectHandler(disconnectReason -> runOnClientThread(() -> {
session.addDisconnectHandler(disconnectReason -> runOnClientThread(() -> {
setState(State.DISCONNECTED);
logger.logI18N("log.client.disconnected", playerName, disconnectReason.name());
reconnectOrStop(address, port);
Expand Down Expand Up @@ -177,16 +177,16 @@ public PacketSender getPacketSender() {
return this.packetSender;
}

public String getHostAddress(){
public String getHostAddress() {
return session.getAddress().getAddress().getHostAddress();
}

public int getPort(){
public int getPort() {
return session.getAddress().getPort();
}

public boolean isConnected(){
return session!= null && !session.isClosed();
public boolean isConnected() {
return session != null && !session.isClosed();
}

public void disconnect() {
Expand Down Expand Up @@ -229,7 +229,8 @@ public void stop(boolean wait) {
if (wait) {
try {
latch.await();
} catch (InterruptedException ignored) {}
} catch (InterruptedException ignored) {
}
}
}

Expand All @@ -254,7 +255,7 @@ public ExtraData createExtraData() {
return extraData;
}

public SkinData createSkinData(){
public SkinData createSkinData() {
SkinData skin = SkinData.createFromSkinJson(skinType.getSkinDataJson());
skin.setClientRandomId(ThreadLocalRandom.current().nextLong());
skin.setCurrentInputMode(1);
Expand Down Expand Up @@ -567,7 +568,8 @@ public void run() {
}
try {
Thread.sleep(MIN_TICK_TIME - time);
} catch (InterruptedException ignored) {}
} catch (InterruptedException ignored) {
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.nukkitx.protocol.bedrock.v534.Bedrock_v534;
import com.nukkitx.protocol.bedrock.v544.Bedrock_v544;
import com.nukkitx.protocol.bedrock.v545.Bedrock_v545;
import com.nukkitx.protocol.bedrock.v554.Bedrock_v554;

import java.io.IOException;
import java.util.Collections;
Expand Down Expand Up @@ -66,6 +67,7 @@ public class ProtocolVersionUtil {
registerPacketCodec(Bedrock_v534.V534_CODEC, 10, null);
registerPacketCodec(Bedrock_v544.V544_CODEC, 10, null);
registerPacketCodec(Bedrock_v545.V545_CODEC, 10, null);
registerPacketCodec(Bedrock_v554.V554_CODEC, 11, null);
codecMap = Collections.unmodifiableMap(codecMap);
rakNetVersionMap = Collections.unmodifiableMap(rakNetVersionMap);
blockPaletteMap = Collections.unmodifiableMap(blockPaletteMap);
Expand All @@ -80,7 +82,8 @@ private static void registerPacketCodec(BedrockPacketCodec codec, int rakNetProt
if (tag instanceof NbtMap) {
blockPaletteMap.put(codec, ((NbtMap) tag).getList("blocks", NbtType.COMPOUND));
}
} catch (IOException ignored) {}
} catch (IOException ignored) {
}
}
latestPacketCodec = codec;
}
Expand Down

0 comments on commit c9ccb3e

Please sign in to comment.