diff --git a/README.md b/README.md
index 02d9acf..f2216d7 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
- Java 11
- Minecraft: Java Edition v1.19.1/1.19.2
-- Bedrock Edition server v1.19.50
+- Bedrock Edition server v1.19.80
## Need implemented
diff --git a/pom.xml b/pom.xml
index 8c6e9c7..6dbc1dd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,24 +10,32 @@
- nukkitx-repo-release
- https://repo.nukkitx.com/maven-releases/
+ opencollab-repo-release
+ https://repo.opencollab.dev/maven-releases/
+
+ true
+
+
+ false
+
- nukkitx-repo-snapshot
- https://repo.nukkitx.com/maven-snapshots/
-
-
- opencollab
+ opencollab-repo-snapshot
https://repo.opencollab.dev/maven-snapshots/
+
+ false
+
+
+ true
+
- com.nukkitx.protocol
- bedrock-v567
- 2.9.17-SNAPSHOT
+ org.cloudburstmc.protocol
+ bedrock-connection
+ 3.0.0.Beta1-SNAPSHOT
compile
@@ -44,7 +52,7 @@
com.alibaba
fastjson
- 2.0.25
+ 2.0.32
org.projectlombok
diff --git a/src/main/java/org/barrelmc/barrel/math/Vector3.java b/src/main/java/org/barrelmc/barrel/math/Vector3.java
index 0502afe..b619680 100644
--- a/src/main/java/org/barrelmc/barrel/math/Vector3.java
+++ b/src/main/java/org/barrelmc/barrel/math/Vector3.java
@@ -1,9 +1,9 @@
package org.barrelmc.barrel.math;
-import com.nukkitx.math.GenericMath;
-import com.nukkitx.math.vector.Vector3f;
import lombok.Getter;
import lombok.Setter;
+import org.cloudburstmc.math.GenericMath;
+import org.cloudburstmc.math.vector.Vector3f;
public class Vector3 {
diff --git a/src/main/java/org/barrelmc/barrel/network/BedrockBatchHandler.java b/src/main/java/org/barrelmc/barrel/network/BedrockBatchHandler.java
index 515df5d..128552b 100644
--- a/src/main/java/org/barrelmc/barrel/network/BedrockBatchHandler.java
+++ b/src/main/java/org/barrelmc/barrel/network/BedrockBatchHandler.java
@@ -5,15 +5,12 @@
package org.barrelmc.barrel.network;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
-import com.nukkitx.protocol.bedrock.BedrockSession;
-import com.nukkitx.protocol.bedrock.handler.BatchHandler;
-import io.netty.buffer.ByteBuf;
import org.barrelmc.barrel.player.Player;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacketHandler;
+import org.cloudburstmc.protocol.common.PacketSignal;
-import java.util.Collection;
-
-public class BedrockBatchHandler implements BatchHandler {
+public class BedrockBatchHandler implements BedrockPacketHandler {
private final Player player;
@@ -22,10 +19,8 @@ public BedrockBatchHandler(Player player) {
}
@Override
- public void handle(BedrockSession bedrockSession, ByteBuf byteBuf, Collection collection) {
- for (BedrockPacket packet : collection) {
- //System.out.println("Received Bedrock " + packet.toString());
- player.getPacketTranslatorManager().translate(packet);
- }
+ public PacketSignal handlePacket(BedrockPacket packet) {
+ player.getPacketTranslatorManager().translate(packet);
+ return PacketSignal.HANDLED;
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/PacketTranslatorManager.java b/src/main/java/org/barrelmc/barrel/network/translator/PacketTranslatorManager.java
index 06d7e91..77bec65 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/PacketTranslatorManager.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/PacketTranslatorManager.java
@@ -7,8 +7,7 @@
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSeenAdvancementsPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.*;
import com.github.steveice10.packetlib.packet.Packet;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
-import com.nukkitx.protocol.bedrock.packet.*;
+import org.cloudburstmc.protocol.bedrock.packet.*;
import lombok.Getter;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.network.translator.interfaces.JavaPacketTranslator;
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/TranslatorUtils.java b/src/main/java/org/barrelmc/barrel/network/translator/TranslatorUtils.java
index 4dd12f9..9546cef 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/TranslatorUtils.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/TranslatorUtils.java
@@ -6,7 +6,7 @@
package org.barrelmc.barrel.network.translator;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
-import com.nukkitx.protocol.bedrock.data.GameType;
+import org.cloudburstmc.protocol.bedrock.data.GameType;
public class TranslatorUtils {
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/AddPlayerPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/AddPlayerPacket.java
index cd0a277..c273e37 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/AddPlayerPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/AddPlayerPacket.java
@@ -6,26 +6,26 @@
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerInfoPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddPlayerPacket;
-import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
-import com.nukkitx.protocol.bedrock.data.entity.EntityData;
import net.kyori.adventure.text.Component;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
import org.barrelmc.barrel.utils.Utils;
+import org.cloudburstmc.math.vector.Vector3f;
+import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
public class AddPlayerPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.AddPlayerPacket packet = (com.nukkitx.protocol.bedrock.packet.AddPlayerPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.AddPlayerPacket packet = (org.cloudburstmc.protocol.bedrock.packet.AddPlayerPacket) pk;
Vector3f position = packet.getPosition();
Vector3f rotation = packet.getRotation();
GameProfile gameProfile = new GameProfile(packet.getUuid(), Utils.lengthCutter(packet.getUsername(), 16));
- player.getJavaSession().send(new ClientboundPlayerInfoPacket(PlayerListEntryAction.ADD_PLAYER, new PlayerListEntry[]{new PlayerListEntry(gameProfile, GameMode.SURVIVAL, 10, Component.text(Utils.lengthCutter(packet.getMetadata().getString(EntityData.NAMETAG), 16)), 0L, null, null)}));
+ player.getJavaSession().send(new ClientboundPlayerInfoPacket(PlayerListEntryAction.ADD_PLAYER, new PlayerListEntry[]{new PlayerListEntry(gameProfile, GameMode.SURVIVAL, 10, Component.text(Utils.lengthCutter(packet.getMetadata().get(EntityDataTypes.NAME), 16)), 0L, null, null)}));
player.getJavaSession().send(new ClientboundAddPlayerPacket((int) packet.getRuntimeEntityId(), packet.getUuid(), position.getX(), position.getY(), position.getZ(), rotation.getY(), rotation.getX()));
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/AnimatePacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/AnimatePacket.java
index d86b7f8..f0a55e3 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/AnimatePacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/AnimatePacket.java
@@ -2,7 +2,7 @@
import com.github.steveice10.mc.protocol.data.game.entity.player.Animation;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundAnimatePacket;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -10,7 +10,7 @@ public class AnimatePacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.AnimatePacket packet = (com.nukkitx.protocol.bedrock.packet.AnimatePacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.AnimatePacket packet = (org.cloudburstmc.protocol.bedrock.packet.AnimatePacket) pk;
switch (packet.getAction()) {
case SWING_ARM: {
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/BlockEventPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/BlockEventPacket.java
index 4ac348b..33f1ca5 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/BlockEventPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/BlockEventPacket.java
@@ -4,7 +4,7 @@
import com.github.steveice10.mc.protocol.data.game.level.block.value.ChestValueType;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockEventPacket;
import com.nukkitx.math.vector.Vector3i;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -12,10 +12,10 @@ public class BlockEventPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.BlockEventPacket packet = (com.nukkitx.protocol.bedrock.packet.BlockEventPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.BlockEventPacket packet = (org.cloudburstmc.protocol.bedrock.packet.BlockEventPacket) pk;
if (packet.getEventType() == 1) {
- Vector3i pos = packet.getBlockPosition();
+ Vector3i pos = Vector3i.from(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ());
if (packet.getEventData() == 2) {
player.getJavaSession().send(new ClientboundBlockEventPacket(pos, ChestValueType.VIEWING_PLAYER_COUNT, new ChestValue(1), 54));
} else {
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ChangeDimensionPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ChangeDimensionPacket.java
index 8cb41bf..0afaf11 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ChangeDimensionPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ChangeDimensionPacket.java
@@ -1,9 +1,9 @@
package org.barrelmc.barrel.network.translator.bedrock;
-import com.nukkitx.math.vector.Vector3i;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
-import com.nukkitx.protocol.bedrock.data.PlayerActionType;
-import com.nukkitx.protocol.bedrock.packet.PlayerActionPacket;
+import org.cloudburstmc.math.vector.Vector3i;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.data.PlayerActionType;
+import org.cloudburstmc.protocol.bedrock.packet.PlayerActionPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -17,6 +17,6 @@ public void translate(BedrockPacket pk, Player player) {
playerActionPacket.setResultPosition(Vector3i.ZERO);
playerActionPacket.setFace(0);
playerActionPacket.setRuntimeEntityId(player.getRuntimeEntityId());
- player.getBedrockClient().getSession().sendPacket(playerActionPacket);
+ player.getBedrockClientSession().sendPacket(playerActionPacket);
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/DisconnectPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/DisconnectPacket.java
index e2b97aa..d26a7c2 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/DisconnectPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/DisconnectPacket.java
@@ -1,6 +1,6 @@
package org.barrelmc.barrel.network.translator.bedrock;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -8,7 +8,7 @@ public class DisconnectPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.DisconnectPacket packet = (com.nukkitx.protocol.bedrock.packet.DisconnectPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.DisconnectPacket packet = (org.cloudburstmc.protocol.bedrock.packet.DisconnectPacket) pk;
player.disconnect(packet.getKickMessage());
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/LevelChunkPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/LevelChunkPacket.java
index 1bad1c7..381f5a7 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/LevelChunkPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/LevelChunkPacket.java
@@ -7,12 +7,6 @@
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundLevelChunkWithLightPacket;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.LongArrayTag;
-import com.nukkitx.nbt.NBTInputStream;
-import com.nukkitx.nbt.NbtMap;
-import com.nukkitx.nbt.NbtMapBuilder;
-import com.nukkitx.nbt.util.stream.NetworkDataInputStream;
-import com.nukkitx.network.VarInts;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.Unpooled;
@@ -22,6 +16,12 @@
import org.barrelmc.barrel.utils.Utils;
import org.barrelmc.barrel.utils.nukkit.BitArray;
import org.barrelmc.barrel.utils.nukkit.BitArrayVersion;
+import org.cloudburstmc.nbt.NBTInputStream;
+import org.cloudburstmc.nbt.NbtMap;
+import org.cloudburstmc.nbt.NbtMapBuilder;
+import org.cloudburstmc.nbt.util.stream.NetworkDataInputStream;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
+import org.cloudburstmc.protocol.common.util.VarInts;
import java.io.IOException;
import java.util.BitSet;
@@ -31,7 +31,7 @@ public class LevelChunkPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.LevelChunkPacket packet = (com.nukkitx.protocol.bedrock.packet.LevelChunkPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.LevelChunkPacket packet = (org.cloudburstmc.protocol.bedrock.packet.LevelChunkPacket) pk;
int subChunksLength = packet.getSubChunksLength();
ChunkSection[] chunkSections = new ChunkSection[subChunksLength];
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/LevelEventPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/LevelEventPacket.java
index 1a6dddb..a24e09d 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/LevelEventPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/LevelEventPacket.java
@@ -3,8 +3,8 @@
import com.github.steveice10.mc.protocol.data.game.entity.player.BlockBreakStage;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockDestructionPacket;
import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
-import com.nukkitx.protocol.bedrock.data.LevelEventType;
+import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -12,13 +12,13 @@ public class LevelEventPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.LevelEventPacket packet = (com.nukkitx.protocol.bedrock.packet.LevelEventPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket packet = (org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket) pk;
- if (packet.getType() == LevelEventType.BLOCK_START_BREAK) {
- Vector3f pos = packet.getPosition();
+ if (packet.getType() == LevelEvent.BLOCK_START_BREAK) {
+ Vector3f pos = Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ());
player.getJavaSession().send(new ClientboundBlockDestructionPacket(0, pos.toInt(), BlockBreakStage.STAGE_1));
- } else if (packet.getType() == LevelEventType.BLOCK_STOP_BREAK) {
- Vector3f pos = packet.getPosition();
+ } else if (packet.getType() == LevelEvent.BLOCK_STOP_BREAK) {
+ Vector3f pos = Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ());
player.getJavaSession().send(new ClientboundBlockDestructionPacket(0, pos.toInt(), BlockBreakStage.RESET));
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/MoveEntityAbsolutePacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/MoveEntityAbsolutePacket.java
index ce11ed6..79c90e4 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/MoveEntityAbsolutePacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/MoveEntityAbsolutePacket.java
@@ -2,8 +2,8 @@
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundRotateHeadPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundTeleportEntityPacket;
-import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.math.vector.Vector3f;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -11,7 +11,7 @@ public class MoveEntityAbsolutePacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket packet = (com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.MoveEntityAbsolutePacket packet = (org.cloudburstmc.protocol.bedrock.packet.MoveEntityAbsolutePacket) pk;
Vector3f position = packet.getPosition(), rotation = packet.getRotation();
player.getJavaSession().send(new ClientboundTeleportEntityPacket((int) packet.getRuntimeEntityId(), position.getX(), position.getY() - 1.62F, position.getZ(), rotation.getY(), rotation.getX(), packet.isOnGround()));
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/MovePlayerPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/MovePlayerPacket.java
index 7d9bdb3..cf13f81 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/MovePlayerPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/MovePlayerPacket.java
@@ -3,8 +3,8 @@
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundRotateHeadPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundTeleportEntityPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
-import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.math.vector.Vector3f;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -12,7 +12,7 @@ public class MovePlayerPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.MovePlayerPacket packet = (com.nukkitx.protocol.bedrock.packet.MovePlayerPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.MovePlayerPacket packet = (org.cloudburstmc.protocol.bedrock.packet.MovePlayerPacket) pk;
Vector3f position = packet.getPosition(), rotation = packet.getRotation();
if (packet.getRuntimeEntityId() == player.getRuntimeEntityId()) {
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/NetworkSettingsPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/NetworkSettingsPacket.java
index 1c03f56..1fa23c7 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/NetworkSettingsPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/NetworkSettingsPacket.java
@@ -1,6 +1,6 @@
package org.barrelmc.barrel.network.translator.bedrock;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
import org.barrelmc.barrel.server.ProxyServer;
@@ -8,17 +8,17 @@
public class NetworkSettingsPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.NetworkSettingsPacket packet = (com.nukkitx.protocol.bedrock.packet.NetworkSettingsPacket) pk;
- player.getBedrockClient().getSession().setCompression(packet.getCompressionAlgorithm());
+ org.cloudburstmc.protocol.bedrock.packet.NetworkSettingsPacket packet = (org.cloudburstmc.protocol.bedrock.packet.NetworkSettingsPacket) pk;
+ player.getBedrockClientSession().setCompression(packet.getCompressionAlgorithm());
- if (ProxyServer.getInstance().getConfig().getAuth().equals("offline")) {
- player.getBedrockClient().getSession().sendPacketImmediately(player.getLoginPacket());
- } else {
- try {
- player.getBedrockClient().getSession().sendPacketImmediately(player.getOnlineLoginPacket());
- } catch (Exception e) {
- e.printStackTrace();
+ try {
+ if (ProxyServer.getInstance().getConfig().getAuth().equals("offline")) {
+ player.getBedrockClientSession().sendPacketImmediately(player.getLoginPacket());
+ } else {
+ player.getBedrockClientSession().sendPacketImmediately(player.getOnlineLoginPacket());
}
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/PlayStatusPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/PlayStatusPacket.java
index e786b1b..2ec646c 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/PlayStatusPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/PlayStatusPacket.java
@@ -1,12 +1,12 @@
package org.barrelmc.barrel.network.translator.bedrock;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
-import com.nukkitx.math.vector.Vector2f;
-import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
-import com.nukkitx.protocol.bedrock.data.AuthoritativeMovementMode;
-import com.nukkitx.protocol.bedrock.packet.SetLocalPlayerAsInitializedPacket;
-import com.nukkitx.protocol.bedrock.packet.TickSyncPacket;
+import org.cloudburstmc.math.vector.Vector2f;
+import org.cloudburstmc.math.vector.Vector3f;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.data.AuthoritativeMovementMode;
+import org.cloudburstmc.protocol.bedrock.packet.SetLocalPlayerAsInitializedPacket;
+import org.cloudburstmc.protocol.bedrock.packet.TickSyncPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -19,21 +19,21 @@ public boolean immediate() {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.PlayStatusPacket packet = (com.nukkitx.protocol.bedrock.packet.PlayStatusPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.PlayStatusPacket packet = (org.cloudburstmc.protocol.bedrock.packet.PlayStatusPacket) pk;
- if (packet.getStatus() == com.nukkitx.protocol.bedrock.packet.PlayStatusPacket.Status.PLAYER_SPAWN) {
+ if (packet.getStatus() == org.cloudburstmc.protocol.bedrock.packet.PlayStatusPacket.Status.PLAYER_SPAWN) {
TickSyncPacket tickSyncPacket = new TickSyncPacket();
tickSyncPacket.setRequestTimestamp(0);
tickSyncPacket.setResponseTimestamp(0);
- player.getBedrockClient().getSession().sendPacketImmediately(tickSyncPacket);
+ player.getBedrockClientSession().sendPacketImmediately(tickSyncPacket);
- if (player.getStartGamePacketCache().getPlayerMovementSettings().getMovementMode() == AuthoritativeMovementMode.SERVER) {
+ if (player.getStartGamePacketCache().getAuthoritativeMovementMode() == AuthoritativeMovementMode.SERVER) {
player.startSendingPlayerInput();
}
SetLocalPlayerAsInitializedPacket setLocalPlayerAsInitializedPacket = new SetLocalPlayerAsInitializedPacket();
setLocalPlayerAsInitializedPacket.setRuntimeEntityId(player.getRuntimeEntityId());
- player.getBedrockClient().getSession().sendPacket(setLocalPlayerAsInitializedPacket);
+ player.getBedrockClientSession().sendPacket(setLocalPlayerAsInitializedPacket);
Vector3f pos = player.getLastServerPosition();
Vector2f rotation = player.getLastServerRotation();
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/PlayerListPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/PlayerListPacket.java
index 3f50eed..dfceec8 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/PlayerListPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/PlayerListPacket.java
@@ -5,7 +5,7 @@
import com.github.steveice10.mc.protocol.data.game.PlayerListEntryAction;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerInfoPacket;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import net.kyori.adventure.text.Component;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -17,10 +17,10 @@ public class PlayerListPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.PlayerListPacket packet = (com.nukkitx.protocol.bedrock.packet.PlayerListPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.PlayerListPacket packet = (org.cloudburstmc.protocol.bedrock.packet.PlayerListPacket) pk;
ArrayList playerListEntries = new ArrayList<>();
- for (com.nukkitx.protocol.bedrock.packet.PlayerListPacket.Entry entry : packet.getEntries()) {
+ for (org.cloudburstmc.protocol.bedrock.packet.PlayerListPacket.Entry entry : packet.getEntries()) {
GameProfile gameProfile = new GameProfile(entry.getUuid(), Utils.lengthCutter(entry.getName(), 16));
playerListEntries.add(new PlayerListEntry(gameProfile, GameMode.SURVIVAL, 0, Component.text(Utils.lengthCutter(entry.getName(), 16)), 0L, null, null));
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/RemoveEntityPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/RemoveEntityPacket.java
index 7d9fc2d..e1500c3 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/RemoveEntityPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/RemoveEntityPacket.java
@@ -1,7 +1,7 @@
package org.barrelmc.barrel.network.translator.bedrock;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundRemoveEntitiesPacket;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -9,7 +9,7 @@ public class RemoveEntityPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.RemoveEntityPacket packet = (com.nukkitx.protocol.bedrock.packet.RemoveEntityPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.RemoveEntityPacket packet = (org.cloudburstmc.protocol.bedrock.packet.RemoveEntityPacket) pk;
int[] entityIds = new int[1];
entityIds[0] = (int) packet.getUniqueEntityId();
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/RemoveObjectivePacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/RemoveObjectivePacket.java
index 9a04bc2..15fdefa 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/RemoveObjectivePacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/RemoveObjectivePacket.java
@@ -1,7 +1,7 @@
package org.barrelmc.barrel.network.translator.bedrock;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.scoreboard.ClientboundSetObjectivePacket;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -9,7 +9,7 @@ public class RemoveObjectivePacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.RemoveObjectivePacket packet = (com.nukkitx.protocol.bedrock.packet.RemoveObjectivePacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.RemoveObjectivePacket packet = (org.cloudburstmc.protocol.bedrock.packet.RemoveObjectivePacket) pk;
player.getJavaSession().send(new ClientboundSetObjectivePacket(packet.getObjectiveId()));
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ResourcePackStackPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ResourcePackStackPacket.java
index 6ec16c4..12969af 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ResourcePackStackPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ResourcePackStackPacket.java
@@ -1,7 +1,7 @@
package org.barrelmc.barrel.network.translator.bedrock;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
-import com.nukkitx.protocol.bedrock.packet.ResourcePackClientResponsePacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.ResourcePackClientResponsePacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -16,6 +16,6 @@ public boolean immediate() {
public void translate(BedrockPacket pk, Player player) {
ResourcePackClientResponsePacket response = new ResourcePackClientResponsePacket();
response.setStatus(ResourcePackClientResponsePacket.Status.COMPLETED);
- player.getBedrockClient().getSession().sendPacketImmediately(response);
+ player.getBedrockClientSession().sendPacketImmediately(response);
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ResourcePacksInfoPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ResourcePacksInfoPacket.java
index 383de7b..eb58ad9 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ResourcePacksInfoPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ResourcePacksInfoPacket.java
@@ -1,7 +1,7 @@
package org.barrelmc.barrel.network.translator.bedrock;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
-import com.nukkitx.protocol.bedrock.packet.ResourcePackClientResponsePacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.ResourcePackClientResponsePacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -16,6 +16,6 @@ public boolean immediate() {
public void translate(BedrockPacket pk, Player player) {
ResourcePackClientResponsePacket response = new ResourcePackClientResponsePacket();
response.setStatus(ResourcePackClientResponsePacket.Status.HAVE_ALL_PACKS);
- player.getBedrockClient().getSession().sendPacketImmediately(response);
+ player.getBedrockClientSession().sendPacketImmediately(response);
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ServerToClientHandshakePacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ServerToClientHandshakePacket.java
index b3cb087..d571da7 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ServerToClientHandshakePacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/ServerToClientHandshakePacket.java
@@ -1,9 +1,9 @@
package org.barrelmc.barrel.network.translator.bedrock;
import com.nimbusds.jwt.SignedJWT;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
-import com.nukkitx.protocol.bedrock.packet.ClientToServerHandshakePacket;
-import com.nukkitx.protocol.bedrock.util.EncryptionUtils;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.ClientToServerHandshakePacket;
+import org.cloudburstmc.protocol.bedrock.util.EncryptionUtils;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -22,7 +22,7 @@ public boolean immediate() {
@Override
public void translate(BedrockPacket pk, Player player) {
try {
- SignedJWT saltJwt = SignedJWT.parse(((com.nukkitx.protocol.bedrock.packet.ServerToClientHandshakePacket) pk).getJwt());
+ SignedJWT saltJwt = SignedJWT.parse(((org.cloudburstmc.protocol.bedrock.packet.ServerToClientHandshakePacket) pk).getJwt());
URI x5u = saltJwt.getHeader().getX509CertURL();
ECPublicKey serverKey = EncryptionUtils.generateKey(x5u.toASCIIString());
SecretKey key = EncryptionUtils.getSecretKey(
@@ -30,12 +30,12 @@ public void translate(BedrockPacket pk, Player player) {
serverKey,
Base64.getDecoder().decode(saltJwt.getJWTClaimsSet().getStringClaim("salt"))
);
- player.getBedrockClient().getSession().enableEncryption(key);
+ player.getBedrockClientSession().enableEncryption(key);
} catch (Exception e) {
throw new RuntimeException(e);
}
ClientToServerHandshakePacket clientToServerHandshake = new ClientToServerHandshakePacket();
- player.getBedrockClient().getSession().sendPacketImmediately(clientToServerHandshake);
+ player.getBedrockClientSession().sendPacketImmediately(clientToServerHandshake);
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetDisplayObjectivePacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetDisplayObjectivePacket.java
index 626d85c..1bdae37 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetDisplayObjectivePacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetDisplayObjectivePacket.java
@@ -5,7 +5,7 @@
import com.github.steveice10.mc.protocol.data.game.scoreboard.ScoreboardPosition;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.scoreboard.ClientboundSetDisplayObjectivePacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.scoreboard.ClientboundSetObjectivePacket;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import net.kyori.adventure.text.Component;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -15,7 +15,7 @@ public class SetDisplayObjectivePacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.SetDisplayObjectivePacket packet = (com.nukkitx.protocol.bedrock.packet.SetDisplayObjectivePacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.SetDisplayObjectivePacket packet = (org.cloudburstmc.protocol.bedrock.packet.SetDisplayObjectivePacket) pk;
String name = Utils.lengthCutter(packet.getDisplayName(), 32);
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetEntityDataPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetEntityDataPacket.java
index 72ea139..8e2c5e6 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetEntityDataPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetEntityDataPacket.java
@@ -1,16 +1,16 @@
package org.barrelmc.barrel.network.translator.bedrock;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
-import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
+import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
public class SetEntityDataPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket packet = (com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.SetEntityDataPacket packet = (org.cloudburstmc.protocol.bedrock.packet.SetEntityDataPacket) pk;
if (packet.getRuntimeEntityId() == player.getRuntimeEntityId() && packet.getMetadata().getFlags() != null) {
- player.setImmobile(packet.getMetadata().getFlags().getFlag(EntityFlag.NO_AI));
+ player.setImmobile(packet.getMetadata().getFlags().contains(EntityFlag.NO_AI));
}
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetPlayerGameTypePacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetPlayerGameTypePacket.java
index 21159b7..b6f24ac 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetPlayerGameTypePacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetPlayerGameTypePacket.java
@@ -2,8 +2,8 @@
import com.github.steveice10.mc.protocol.data.game.level.notify.GameEvent;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundGameEventPacket;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
-import com.nukkitx.protocol.bedrock.data.GameType;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.data.GameType;
import org.barrelmc.barrel.network.translator.TranslatorUtils;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -12,7 +12,7 @@ public class SetPlayerGameTypePacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket packet = (com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.SetPlayerGameTypePacket packet = (org.cloudburstmc.protocol.bedrock.packet.SetPlayerGameTypePacket) pk;
player.setGameMode(GameType.from(packet.getGamemode()));
player.getJavaSession().send(new ClientboundGameEventPacket(GameEvent.CHANGE_GAMEMODE, TranslatorUtils.translateGamemodeToJE(GameType.from(packet.getGamemode()))));
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetScorePacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetScorePacket.java
index 90d73e2..be758d2 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetScorePacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetScorePacket.java
@@ -1,8 +1,8 @@
package org.barrelmc.barrel.network.translator.bedrock;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.scoreboard.ClientboundSetScorePacket;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
-import com.nukkitx.protocol.bedrock.data.ScoreInfo;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.data.ScoreInfo;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
import org.barrelmc.barrel.utils.Utils;
@@ -13,7 +13,7 @@ public class SetScorePacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.SetScorePacket packet = (com.nukkitx.protocol.bedrock.packet.SetScorePacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.SetScorePacket packet = (org.cloudburstmc.protocol.bedrock.packet.SetScorePacket) pk;
List infos = packet.getInfos();
for (ScoreInfo scoreInfo : infos) {
int score = scoreInfo.getScore();
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetSpawnPositionPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetSpawnPositionPacket.java
index 1a830e0..6bc4cba 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetSpawnPositionPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetSpawnPositionPacket.java
@@ -2,15 +2,14 @@
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundSetDefaultSpawnPositionPacket;
import com.nukkitx.math.vector.Vector3i;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
public class SetSpawnPositionPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.SetSpawnPositionPacket packet = (com.nukkitx.protocol.bedrock.packet.SetSpawnPositionPacket) pk;
- Vector3i pos = packet.getSpawnPosition();
- player.getJavaSession().send(new ClientboundSetDefaultSpawnPositionPacket(pos, 0.0f));
+ org.cloudburstmc.protocol.bedrock.packet.SetSpawnPositionPacket packet = (org.cloudburstmc.protocol.bedrock.packet.SetSpawnPositionPacket) pk;
+ player.getJavaSession().send(new ClientboundSetDefaultSpawnPositionPacket(Vector3i.from(packet.getSpawnPosition().getX(), packet.getSpawnPosition().getY(), packet.getSpawnPosition().getZ()), 0.0f));
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetTimePacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetTimePacket.java
index dd15bfa..b4b3bba 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetTimePacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/SetTimePacket.java
@@ -1,7 +1,7 @@
package org.barrelmc.barrel.network.translator.bedrock;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundSetTimePacket;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -9,7 +9,7 @@ public class SetTimePacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.SetTimePacket packet = (com.nukkitx.protocol.bedrock.packet.SetTimePacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.SetTimePacket packet = (org.cloudburstmc.protocol.bedrock.packet.SetTimePacket) pk;
player.getJavaSession().send(new ClientboundSetTimePacket(0, packet.getTime()));
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/StartGamePacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/StartGamePacket.java
index 9deaa38..ec11bfa 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/StartGamePacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/StartGamePacket.java
@@ -4,19 +4,38 @@
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
-import com.nukkitx.math.vector.Vector2f;
-import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.math.vector.Vector2f;
+import org.cloudburstmc.math.vector.Vector3f;
+import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
+import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
+import org.cloudburstmc.protocol.bedrock.data.definitions.SimpleItemDefinition;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.TranslatorUtils;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
import org.barrelmc.barrel.server.ProxyServer;
+import org.cloudburstmc.protocol.common.DefinitionRegistry;
+import org.cloudburstmc.protocol.common.SimpleDefinitionRegistry;
public class StartGamePacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.StartGamePacket packet = (com.nukkitx.protocol.bedrock.packet.StartGamePacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.StartGamePacket packet = (org.cloudburstmc.protocol.bedrock.packet.StartGamePacket) pk;
+ player.getBedrockClientSession().getPeer().getCodecHelper().setItemDefinitions(SimpleDefinitionRegistry.builder()
+ .addAll(packet.getItemDefinitions())
+ .add(new SimpleItemDefinition("minecraft:empty", 0, false))
+ .build());
+ player.getBedrockClientSession().getPeer().getCodecHelper().setBlockDefinitions(new DefinitionRegistry() {
+ @Override
+ public BlockDefinition getDefinition(int i) {
+ return () -> i;
+ }
+ @Override
+ public boolean isRegistered(BlockDefinition blockDefinition) {
+ return true;
+ }
+ });
player.setRuntimeEntityId(packet.getRuntimeEntityId());
player.setOldPosition(packet.getPlayerPosition());
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/TakeItemEntityPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/TakeItemEntityPacket.java
index ca5932b..4e1a85a 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/TakeItemEntityPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/TakeItemEntityPacket.java
@@ -2,7 +2,7 @@
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundRemoveEntitiesPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundTakeItemEntityPacket;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -10,7 +10,7 @@ public class TakeItemEntityPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.TakeItemEntityPacket packet = (com.nukkitx.protocol.bedrock.packet.TakeItemEntityPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.TakeItemEntityPacket packet = (org.cloudburstmc.protocol.bedrock.packet.TakeItemEntityPacket) pk;
int[] entityIds = new int[1];
entityIds[0] = (int) packet.getItemRuntimeEntityId();
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/TextPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/TextPacket.java
index 5891c27..d9d334e 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/TextPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/TextPacket.java
@@ -1,7 +1,7 @@
package org.barrelmc.barrel.network.translator.bedrock;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import net.kyori.adventure.text.Component;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -10,7 +10,7 @@ public class TextPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.TextPacket packet = (com.nukkitx.protocol.bedrock.packet.TextPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.TextPacket packet = (org.cloudburstmc.protocol.bedrock.packet.TextPacket) pk;
switch (packet.getType()) {
case TIP:
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/UpdateAbilitiesPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/UpdateAbilitiesPacket.java
index bf98c1a..03401f7 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/UpdateAbilitiesPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/UpdateAbilitiesPacket.java
@@ -3,10 +3,10 @@
import com.github.steveice10.mc.protocol.data.game.level.notify.GameEvent;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerAbilitiesPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundGameEventPacket;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
-import com.nukkitx.protocol.bedrock.data.Ability;
-import com.nukkitx.protocol.bedrock.data.AbilityLayer;
-import com.nukkitx.protocol.bedrock.data.GameType;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.data.Ability;
+import org.cloudburstmc.protocol.bedrock.data.AbilityLayer;
+import org.cloudburstmc.protocol.bedrock.data.GameType;
import org.barrelmc.barrel.network.translator.TranslatorUtils;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -16,7 +16,7 @@
public class UpdateAbilitiesPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.UpdateAbilitiesPacket packet = (com.nukkitx.protocol.bedrock.packet.UpdateAbilitiesPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.UpdateAbilitiesPacket packet = (org.cloudburstmc.protocol.bedrock.packet.UpdateAbilitiesPacket) pk;
if (packet.getUniqueEntityId() == player.getRuntimeEntityId()) {
for (AbilityLayer abilityLayer : packet.getAbilityLayers().toArray(new AbilityLayer[0])) {
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/UpdateBlockPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/UpdateBlockPacket.java
index 488a74f..f5a245b 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/bedrock/UpdateBlockPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/bedrock/UpdateBlockPacket.java
@@ -3,7 +3,7 @@
import com.github.steveice10.mc.protocol.data.game.level.block.BlockChangeEntry;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockUpdatePacket;
import com.nukkitx.math.vector.Vector3i;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.barrelmc.barrel.network.converter.BlockConverter;
import org.barrelmc.barrel.network.translator.interfaces.BedrockPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -12,13 +12,12 @@ public class UpdateBlockPacket implements BedrockPacketTranslator {
@Override
public void translate(BedrockPacket pk, Player player) {
- com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket packet = (com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket) pk;
+ org.cloudburstmc.protocol.bedrock.packet.UpdateBlockPacket packet = (org.cloudburstmc.protocol.bedrock.packet.UpdateBlockPacket) pk;
if (packet.getDataLayer() == 0) {
- Vector3i pos = packet.getBlockPosition();
- int blockState = BlockConverter.bedrockRuntimeToJavaStateId(packet.getRuntimeId());
+ int blockState = BlockConverter.bedrockRuntimeToJavaStateId(packet.getDefinition().getRuntimeId());
- BlockChangeEntry blockChangeRecord = new BlockChangeEntry(pos, blockState);
+ BlockChangeEntry blockChangeRecord = new BlockChangeEntry(Vector3i.from(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()), blockState);
player.getJavaSession().send(new ClientboundBlockUpdatePacket(blockChangeRecord));
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/interfaces/BedrockPacketTranslator.java b/src/main/java/org/barrelmc/barrel/network/translator/interfaces/BedrockPacketTranslator.java
index ad0112a..4153e05 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/interfaces/BedrockPacketTranslator.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/interfaces/BedrockPacketTranslator.java
@@ -1,7 +1,7 @@
package org.barrelmc.barrel.network.translator.interfaces;
-import com.nukkitx.protocol.bedrock.BedrockPacket;
import org.barrelmc.barrel.player.Player;
+import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
public interface BedrockPacketTranslator {
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/java/ChatPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/java/ChatPacket.java
index 81b9829..50a752a 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/java/ChatPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/java/ChatPacket.java
@@ -2,7 +2,7 @@
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
-import com.nukkitx.protocol.bedrock.packet.TextPacket;
+import org.cloudburstmc.protocol.bedrock.packet.TextPacket;
import org.barrelmc.barrel.network.translator.interfaces.JavaPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -19,6 +19,6 @@ public void translate(MinecraftPacket pk, Player player) {
textPacket.setMessage(chatPacket.getMessage());
textPacket.setXuid("");
textPacket.setPlatformChatId("");
- player.getBedrockClient().getSession().sendPacket(textPacket);
+ player.getBedrockClientSession().sendPacket(textPacket);
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/java/ClientCommandPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/java/ClientCommandPacket.java
index 26d2c1e..cd55dc0 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/java/ClientCommandPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/java/ClientCommandPacket.java
@@ -3,8 +3,8 @@
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.github.steveice10.mc.protocol.data.game.ClientCommand;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
-import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.protocol.bedrock.packet.RespawnPacket;
+import org.cloudburstmc.math.vector.Vector3f;
+import org.cloudburstmc.protocol.bedrock.packet.RespawnPacket;
import org.barrelmc.barrel.network.translator.interfaces.JavaPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -20,7 +20,7 @@ public void translate(MinecraftPacket pk, Player player) {
respawnPacket.setPosition(Vector3f.from(0, 0, 0));
respawnPacket.setRuntimeEntityId(player.getRuntimeEntityId());
respawnPacket.setState(RespawnPacket.State.CLIENT_READY);
- player.getBedrockClient().getSession().sendPacket(respawnPacket);
+ player.getBedrockClientSession().sendPacket(respawnPacket);
}
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/java/ClientInformationPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/java/ClientInformationPacket.java
index 559e9d9..b959b9f 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/java/ClientInformationPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/java/ClientInformationPacket.java
@@ -2,7 +2,7 @@
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientInformationPacket;
-import com.nukkitx.protocol.bedrock.packet.RequestChunkRadiusPacket;
+import org.cloudburstmc.protocol.bedrock.packet.RequestChunkRadiusPacket;
import org.barrelmc.barrel.network.translator.interfaces.JavaPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -14,6 +14,6 @@ public void translate(MinecraftPacket pk, Player player) {
RequestChunkRadiusPacket chunkRadiusPacket = new RequestChunkRadiusPacket();
chunkRadiusPacket.setRadius(settingsPacket.getRenderDistance());
- player.getBedrockClient().getSession().sendPacketImmediately(chunkRadiusPacket);
+ player.getBedrockClientSession().sendPacketImmediately(chunkRadiusPacket);
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/java/MovePlayerPosPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/java/MovePlayerPosPacket.java
index 0d504e2..6305794 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/java/MovePlayerPosPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/java/MovePlayerPosPacket.java
@@ -3,9 +3,9 @@
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket;
-import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.protocol.bedrock.data.AuthoritativeMovementMode;
-import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
+import org.cloudburstmc.math.vector.Vector3f;
+import org.cloudburstmc.protocol.bedrock.data.AuthoritativeMovementMode;
+import org.cloudburstmc.protocol.bedrock.packet.MovePlayerPacket;
import org.barrelmc.barrel.network.translator.interfaces.JavaPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -22,7 +22,7 @@ public void translate(MinecraftPacket pk, Player player) {
player.setOldPosition(player.getVector3f());
player.setPosition(packet.getX(), packet.getY(), packet.getZ());
- if (player.getStartGamePacketCache().getPlayerMovementSettings().getMovementMode() == AuthoritativeMovementMode.CLIENT) {
+ if (player.getStartGamePacketCache().getAuthoritativeMovementMode() == AuthoritativeMovementMode.CLIENT) {
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
movePlayerPacket.setRuntimeEntityId(player.getRuntimeEntityId());
@@ -34,7 +34,7 @@ public void translate(MinecraftPacket pk, Player player) {
movePlayerPacket.setTeleportationCause(MovePlayerPacket.TeleportationCause.UNKNOWN);
movePlayerPacket.setEntityType(0);
- player.getBedrockClient().getSession().sendPacket(movePlayerPacket);
+ player.getBedrockClientSession().sendPacket(movePlayerPacket);
}
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/java/MovePlayerPosRotPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/java/MovePlayerPosRotPacket.java
index eb872fd..d7553a2 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/java/MovePlayerPosRotPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/java/MovePlayerPosRotPacket.java
@@ -3,9 +3,9 @@
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket;
-import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.protocol.bedrock.data.AuthoritativeMovementMode;
-import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
+import org.cloudburstmc.math.vector.Vector3f;
+import org.cloudburstmc.protocol.bedrock.data.AuthoritativeMovementMode;
+import org.cloudburstmc.protocol.bedrock.packet.MovePlayerPacket;
import org.barrelmc.barrel.network.translator.interfaces.JavaPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -22,7 +22,7 @@ public void translate(MinecraftPacket pk, Player player) {
player.setOldPosition(player.getVector3f());
player.setLocation(packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getPitch());
- if (player.getStartGamePacketCache().getPlayerMovementSettings().getMovementMode() == AuthoritativeMovementMode.CLIENT) {
+ if (player.getStartGamePacketCache().getAuthoritativeMovementMode() == AuthoritativeMovementMode.CLIENT) {
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
movePlayerPacket.setRuntimeEntityId(player.getRuntimeEntityId());
@@ -34,7 +34,7 @@ public void translate(MinecraftPacket pk, Player player) {
movePlayerPacket.setTeleportationCause(MovePlayerPacket.TeleportationCause.UNKNOWN);
movePlayerPacket.setEntityType(0);
- player.getBedrockClient().getSession().sendPacket(movePlayerPacket);
+ player.getBedrockClientSession().sendPacket(movePlayerPacket);
}
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/java/MovePlayerRotPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/java/MovePlayerRotPacket.java
index d8bd050..9b220b3 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/java/MovePlayerRotPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/java/MovePlayerRotPacket.java
@@ -2,9 +2,9 @@
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerRotPacket;
-import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.protocol.bedrock.data.AuthoritativeMovementMode;
-import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
+import org.cloudburstmc.math.vector.Vector3f;
+import org.cloudburstmc.protocol.bedrock.data.AuthoritativeMovementMode;
+import org.cloudburstmc.protocol.bedrock.packet.MovePlayerPacket;
import org.barrelmc.barrel.network.translator.interfaces.JavaPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -16,7 +16,7 @@ public void translate(MinecraftPacket pk, Player player) {
player.setRotation(packet.getYaw(), packet.getPitch());
- if (player.getStartGamePacketCache().getPlayerMovementSettings().getMovementMode() == AuthoritativeMovementMode.CLIENT) {
+ if (player.getStartGamePacketCache().getAuthoritativeMovementMode() == AuthoritativeMovementMode.CLIENT) {
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
movePlayerPacket.setMode(MovePlayerPacket.Mode.HEAD_ROTATION);
@@ -28,7 +28,7 @@ public void translate(MinecraftPacket pk, Player player) {
movePlayerPacket.setTeleportationCause(MovePlayerPacket.TeleportationCause.UNKNOWN);
movePlayerPacket.setEntityType(0);
- player.getBedrockClient().getSession().sendPacket(movePlayerPacket);
+ player.getBedrockClientSession().sendPacket(movePlayerPacket);
}
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/java/PlayerAbilitiesPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/java/PlayerAbilitiesPacket.java
index da1d12e..176b956 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/java/PlayerAbilitiesPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/java/PlayerAbilitiesPacket.java
@@ -2,9 +2,8 @@
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerAbilitiesPacket;
-import com.nukkitx.protocol.bedrock.data.Ability;
-import com.nukkitx.protocol.bedrock.data.AbilityType;
-import com.nukkitx.protocol.bedrock.packet.RequestAbilityPacket;
+import org.cloudburstmc.protocol.bedrock.data.Ability;
+import org.cloudburstmc.protocol.bedrock.packet.RequestAbilityPacket;
import org.barrelmc.barrel.network.translator.interfaces.JavaPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -15,9 +14,9 @@ public void translate(MinecraftPacket pk, Player player) {
RequestAbilityPacket requestAbilityPacket = new RequestAbilityPacket();
requestAbilityPacket.setAbility(Ability.FLYING);
- requestAbilityPacket.setType(AbilityType.BOOLEAN);
+ requestAbilityPacket.setType(Ability.Type.BOOLEAN);
requestAbilityPacket.setBoolValue(packet.isFlying());
requestAbilityPacket.setFloatValue(0.0f);
- player.getBedrockClient().getSession().sendPacket(requestAbilityPacket);
+ player.getBedrockClientSession().sendPacket(requestAbilityPacket);
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/java/PlayerActionPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/java/PlayerActionPacket.java
index d668182..289531a 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/java/PlayerActionPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/java/PlayerActionPacket.java
@@ -3,13 +3,13 @@
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerActionPacket;
-import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.math.vector.Vector3i;
-import com.nukkitx.protocol.bedrock.data.*;
-import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
-import com.nukkitx.protocol.bedrock.data.inventory.ItemUseTransaction;
+import org.cloudburstmc.math.vector.Vector3f;
+import org.cloudburstmc.math.vector.Vector3i;
+import org.cloudburstmc.protocol.bedrock.data.*;
+import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.barrelmc.barrel.network.translator.interfaces.JavaPacketTranslator;
import org.barrelmc.barrel.player.Player;
+import org.cloudburstmc.protocol.bedrock.data.inventory.transaction.ItemUseTransaction;
public class PlayerActionPacket implements JavaPacketTranslator {
@@ -31,7 +31,7 @@ public void translate(MinecraftPacket pk, Player player) {
}
switch (action) {
case START_DIGGING:
- if (player.getStartGamePacketCache().getPlayerMovementSettings().getMovementMode() == AuthoritativeMovementMode.CLIENT) {
+ if (player.getStartGamePacketCache().getAuthoritativeMovementMode() == AuthoritativeMovementMode.CLIENT) {
// TODO: implement for client authoritative
} else {
player.getPlayerAuthInputData().add(PlayerAuthInputData.PERFORM_BLOCK_ACTIONS);
@@ -48,7 +48,7 @@ public void translate(MinecraftPacket pk, Player player) {
}
break;
case CANCEL_DIGGING:
- if (player.getStartGamePacketCache().getPlayerMovementSettings().getMovementMode() == AuthoritativeMovementMode.CLIENT) {
+ if (player.getStartGamePacketCache().getAuthoritativeMovementMode() == AuthoritativeMovementMode.CLIENT) {
// TODO: implement for client authoritative
} else {
player.getPlayerAuthInputData().add(PlayerAuthInputData.PERFORM_BLOCK_ACTIONS);
@@ -63,7 +63,7 @@ public void translate(MinecraftPacket pk, Player player) {
}
break;
case FINISH_DIGGING:
- if (player.getStartGamePacketCache().getPlayerMovementSettings().getMovementMode() == AuthoritativeMovementMode.CLIENT) {
+ if (player.getStartGamePacketCache().getAuthoritativeMovementMode() == AuthoritativeMovementMode.CLIENT) {
// TODO: implement for client authoritative
} else {
// perform break block action
@@ -75,7 +75,7 @@ public void translate(MinecraftPacket pk, Player player) {
itemUseTransaction.setItemInHand(ItemData.AIR); // TODO: implement inventory
itemUseTransaction.setBlockFace(playerActionPacket.getFace().ordinal());
itemUseTransaction.setPlayerPosition(player.getVector3f());
- itemUseTransaction.setBlockRuntimeId(0);
+ itemUseTransaction.setBlockDefinition(() -> 0);
itemUseTransaction.setClickPosition(Vector3f.ZERO);
itemUseTransaction.setHotbarSlot(player.getHotbarSlot());
itemUseTransaction.setLegacyRequestId(0);
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/java/PlayerCommandPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/java/PlayerCommandPacket.java
index 1cbbfdf..3bb01d2 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/java/PlayerCommandPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/java/PlayerCommandPacket.java
@@ -2,11 +2,11 @@
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerCommandPacket;
-import com.nukkitx.math.vector.Vector3i;
-import com.nukkitx.protocol.bedrock.data.AuthoritativeMovementMode;
-import com.nukkitx.protocol.bedrock.data.PlayerActionType;
-import com.nukkitx.protocol.bedrock.data.PlayerAuthInputData;
-import com.nukkitx.protocol.bedrock.packet.PlayerActionPacket;
+import org.cloudburstmc.math.vector.Vector3i;
+import org.cloudburstmc.protocol.bedrock.data.AuthoritativeMovementMode;
+import org.cloudburstmc.protocol.bedrock.data.PlayerActionType;
+import org.cloudburstmc.protocol.bedrock.data.PlayerAuthInputData;
+import org.cloudburstmc.protocol.bedrock.packet.PlayerActionPacket;
import org.barrelmc.barrel.network.translator.interfaces.JavaPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -18,13 +18,13 @@ public void translate(MinecraftPacket pk, Player player) {
switch (packet.getState()) {
case START_SNEAKING: {
- if (player.getStartGamePacketCache().getPlayerMovementSettings().getMovementMode() == AuthoritativeMovementMode.CLIENT) {
+ if (player.getStartGamePacketCache().getAuthoritativeMovementMode() == AuthoritativeMovementMode.CLIENT) {
PlayerActionPacket playerActionPacket = new PlayerActionPacket();
playerActionPacket.setAction(PlayerActionType.START_SNEAK);
playerActionPacket.setBlockPosition(Vector3i.ZERO);
playerActionPacket.setFace(0);
playerActionPacket.setRuntimeEntityId(player.getRuntimeEntityId());
- player.getBedrockClient().getSession().sendPacket(playerActionPacket);
+ player.getBedrockClientSession().sendPacket(playerActionPacket);
} else {
player.getPlayerAuthInputData().add(PlayerAuthInputData.START_SNEAKING);
player.setSneaking(true);
@@ -32,13 +32,13 @@ public void translate(MinecraftPacket pk, Player player) {
break;
}
case STOP_SNEAKING: {
- if (player.getStartGamePacketCache().getPlayerMovementSettings().getMovementMode() == AuthoritativeMovementMode.CLIENT) {
+ if (player.getStartGamePacketCache().getAuthoritativeMovementMode() == AuthoritativeMovementMode.CLIENT) {
PlayerActionPacket playerActionPacket = new PlayerActionPacket();
playerActionPacket.setAction(PlayerActionType.STOP_SNEAK);
playerActionPacket.setBlockPosition(Vector3i.ZERO);
playerActionPacket.setFace(0);
playerActionPacket.setRuntimeEntityId(player.getRuntimeEntityId());
- player.getBedrockClient().getSession().sendPacket(playerActionPacket);
+ player.getBedrockClientSession().sendPacket(playerActionPacket);
} else {
player.setSneaking(false);
player.getPlayerAuthInputData().add(PlayerAuthInputData.STOP_SNEAKING);
@@ -46,13 +46,13 @@ public void translate(MinecraftPacket pk, Player player) {
break;
}
case START_SPRINTING: {
- if (player.getStartGamePacketCache().getPlayerMovementSettings().getMovementMode() == AuthoritativeMovementMode.CLIENT) {
+ if (player.getStartGamePacketCache().getAuthoritativeMovementMode() == AuthoritativeMovementMode.CLIENT) {
PlayerActionPacket playerActionPacket = new PlayerActionPacket();
playerActionPacket.setAction(PlayerActionType.START_SPRINT);
playerActionPacket.setBlockPosition(Vector3i.ZERO);
playerActionPacket.setFace(0);
playerActionPacket.setRuntimeEntityId(player.getRuntimeEntityId());
- player.getBedrockClient().getSession().sendPacket(playerActionPacket);
+ player.getBedrockClientSession().sendPacket(playerActionPacket);
} else {
player.getPlayerAuthInputData().add(PlayerAuthInputData.START_SPRINTING);
player.setSprinting(true);
@@ -60,13 +60,13 @@ public void translate(MinecraftPacket pk, Player player) {
break;
}
case STOP_SPRINTING: {
- if (player.getStartGamePacketCache().getPlayerMovementSettings().getMovementMode() == AuthoritativeMovementMode.CLIENT) {
+ if (player.getStartGamePacketCache().getAuthoritativeMovementMode() == AuthoritativeMovementMode.CLIENT) {
PlayerActionPacket playerActionPacket = new PlayerActionPacket();
playerActionPacket.setAction(PlayerActionType.STOP_SPRINT);
playerActionPacket.setBlockPosition(Vector3i.ZERO);
playerActionPacket.setFace(0);
playerActionPacket.setRuntimeEntityId(player.getRuntimeEntityId());
- player.getBedrockClient().getSession().sendPacket(playerActionPacket);
+ player.getBedrockClientSession().sendPacket(playerActionPacket);
} else {
player.setSprinting(false);
player.getPlayerAuthInputData().add(PlayerAuthInputData.STOP_SPRINTING);
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/java/SetCarriedItemPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/java/SetCarriedItemPacket.java
index d7b5277..c26c5e2 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/java/SetCarriedItemPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/java/SetCarriedItemPacket.java
@@ -2,7 +2,7 @@
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundSetCarriedItemPacket;
-import com.nukkitx.protocol.bedrock.packet.PlayerHotbarPacket;
+import org.cloudburstmc.protocol.bedrock.packet.PlayerHotbarPacket;
import org.barrelmc.barrel.network.translator.interfaces.JavaPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -18,6 +18,6 @@ public void translate(MinecraftPacket pk, Player player) {
playerHotbarPacket.setContainerId(0);
playerHotbarPacket.setSelectedHotbarSlot(packet.getSlot());
playerHotbarPacket.setSelectHotbarSlot(true);
- player.getBedrockClient().getSession().sendPacket(playerHotbarPacket);
+ player.getBedrockClientSession().sendPacket(playerHotbarPacket);
}
}
diff --git a/src/main/java/org/barrelmc/barrel/network/translator/java/SwingPacket.java b/src/main/java/org/barrelmc/barrel/network/translator/java/SwingPacket.java
index d7490a5..264ad90 100644
--- a/src/main/java/org/barrelmc/barrel/network/translator/java/SwingPacket.java
+++ b/src/main/java/org/barrelmc/barrel/network/translator/java/SwingPacket.java
@@ -1,7 +1,7 @@
package org.barrelmc.barrel.network.translator.java;
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
-import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
+import org.cloudburstmc.protocol.bedrock.packet.AnimatePacket;
import org.barrelmc.barrel.network.translator.interfaces.JavaPacketTranslator;
import org.barrelmc.barrel.player.Player;
@@ -13,6 +13,6 @@ public void translate(MinecraftPacket pk, Player player) {
animatePacket.setAction(AnimatePacket.Action.SWING_ARM);
animatePacket.setRuntimeEntityId(player.getRuntimeEntityId());
- player.getBedrockClient().getSession().sendPacket(animatePacket);
+ player.getBedrockClientSession().sendPacket(animatePacket);
}
}
diff --git a/src/main/java/org/barrelmc/barrel/player/Player.java b/src/main/java/org/barrelmc/barrel/player/Player.java
index 76a2d66..14cc5a8 100644
--- a/src/main/java/org/barrelmc/barrel/player/Player.java
+++ b/src/main/java/org/barrelmc/barrel/player/Player.java
@@ -12,18 +12,11 @@
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundSetChunkCacheCenterPacket;
import com.github.steveice10.mc.protocol.packet.login.serverbound.ServerboundHelloPacket;
import com.github.steveice10.packetlib.Session;
-import com.nukkitx.math.vector.Vector2f;
-import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.math.vector.Vector3i;
-import com.nukkitx.protocol.bedrock.BedrockClient;
-import com.nukkitx.protocol.bedrock.data.*;
-import com.nukkitx.protocol.bedrock.data.inventory.ItemUseTransaction;
-import com.nukkitx.protocol.bedrock.packet.LoginPacket;
-import com.nukkitx.protocol.bedrock.packet.PlayerAuthInputPacket;
-import com.nukkitx.protocol.bedrock.packet.RequestNetworkSettingsPacket;
-import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
-import com.nukkitx.protocol.bedrock.util.EncryptionUtils;
-import io.netty.util.AsciiString;
+import com.nimbusds.jwt.SignedJWT;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.Channel;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioDatagramChannel;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import lombok.Getter;
import lombok.Setter;
@@ -36,9 +29,22 @@
import org.barrelmc.barrel.network.translator.PacketTranslatorManager;
import org.barrelmc.barrel.server.ProxyServer;
import org.barrelmc.barrel.utils.Utils;
+import org.cloudburstmc.math.vector.Vector2f;
+import org.cloudburstmc.math.vector.Vector3f;
+import org.cloudburstmc.math.vector.Vector3i;
+import org.cloudburstmc.netty.channel.raknet.RakChannelFactory;
+import org.cloudburstmc.netty.channel.raknet.config.RakChannelOption;
+import org.cloudburstmc.protocol.bedrock.BedrockClientSession;
+import org.cloudburstmc.protocol.bedrock.data.*;
+import org.cloudburstmc.protocol.bedrock.data.inventory.transaction.ItemUseTransaction;
+import org.cloudburstmc.protocol.bedrock.netty.initializer.BedrockClientInitializer;
+import org.cloudburstmc.protocol.bedrock.packet.LoginPacket;
+import org.cloudburstmc.protocol.bedrock.packet.PlayerAuthInputPacket;
+import org.cloudburstmc.protocol.bedrock.packet.RequestNetworkSettingsPacket;
+import org.cloudburstmc.protocol.bedrock.packet.StartGamePacket;
+import org.cloudburstmc.protocol.bedrock.util.EncryptionUtils;
import java.net.InetSocketAddress;
-import java.nio.charset.StandardCharsets;
import java.security.*;
import java.security.interfaces.ECPrivateKey;
import java.security.interfaces.ECPublicKey;
@@ -47,7 +53,6 @@
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
public class Player extends Vector3 {
@@ -55,7 +60,9 @@ public class Player extends Vector3 {
@Getter
private final Session javaSession;
@Getter
- private BedrockClient bedrockClient;
+ private BedrockClientSession bedrockClientSession;
+ @Getter
+ private Channel channel;
@Getter
private final PacketTranslatorManager packetTranslatorManager;
@@ -159,30 +166,32 @@ public void startSendingPlayerInput() {
}
private void onlineLogin(ServerboundHelloPacket javaLoginPacket) {
- InetSocketAddress bindAddress = new InetSocketAddress("0.0.0.0", ThreadLocalRandom.current().nextInt(30000, 60000));
- BedrockClient client = new BedrockClient(bindAddress);
- client.setRakNetVersion(ProxyServer.getInstance().getBedrockPacketCodec().getRaknetProtocolVersion());
-
- this.bedrockClient = client;
- ProxyServer.getInstance().getOnlinePlayers().put(javaLoginPacket.getUsername(), this);
-
- client.bind().join();
-
Config config = ProxyServer.getInstance().getConfig();
InetSocketAddress bedrockAddress = new InetSocketAddress(config.getBedrockAddress(), config.getBedrockPort());
- client.connect(bedrockAddress).whenComplete((session, throwable) -> {
- if (throwable != null) {
- javaSession.disconnect("Server offline " + throwable);
- return;
- }
-
- session.setPacketCodec(ProxyServer.getInstance().getBedrockPacketCodec());
- session.addDisconnectHandler((reason) -> javaSession.disconnect("Client disconnected! " + reason.toString()));
- session.setBatchHandler(new BedrockBatchHandler(this));
- RequestNetworkSettingsPacket requestNetworkSettingsPacket = new RequestNetworkSettingsPacket();
- requestNetworkSettingsPacket.setProtocolVersion(ProxyServer.getInstance().getBedrockPacketCodec().getProtocolVersion());
- session.sendPacketImmediately(requestNetworkSettingsPacket);
- }).join();
+ try {
+ Player player = this;
+ channel = new Bootstrap()
+ .channelFactory(RakChannelFactory.client(NioDatagramChannel.class))
+ .group(new NioEventLoopGroup())
+ .option(RakChannelOption.RAK_PROTOCOL_VERSION, ProxyServer.getInstance().getBedrockPacketCodec().getRaknetProtocolVersion())
+ .handler(new BedrockClientInitializer() {
+ @Override
+ protected void initSession(BedrockClientSession session) {
+ bedrockClientSession = session;
+ session.setCodec(ProxyServer.getInstance().getBedrockPacketCodec());
+ session.setPacketHandler(new BedrockBatchHandler(player));
+
+ RequestNetworkSettingsPacket requestNetworkSettingsPacket = new RequestNetworkSettingsPacket();
+ requestNetworkSettingsPacket.setProtocolVersion(ProxyServer.getInstance().getBedrockPacketCodec().getProtocolVersion());
+ session.sendPacketImmediately(requestNetworkSettingsPacket);
+ }
+ })
+ .connect(bedrockAddress)
+ .syncUninterruptibly().channel();
+ } catch (Exception exception) {
+ javaSession.disconnect("Server offline " + exception);
+ }
+ ProxyServer.getInstance().getOnlinePlayers().put(javaLoginPacket.getUsername(), this);
}
public LoginPacket getOnlineLoginPacket() throws Exception {
@@ -230,7 +239,9 @@ public LoginPacket getOnlineLoginPacket() throws Exception {
JSONArray jsonArray = new JSONArray();
jsonArray.add(jwt);
jsonArray.addAll(minecraftNetChain);
- chainDataObject.put("chain", jsonArray);
+ for (int i = 0; i < jsonArray.size(); i++) {
+ loginPacket.getChain().add(SignedJWT.parse((String) jsonArray.get(i)));
+ }
}
{
String lastChain = minecraftNetChain.getString(minecraftNetChain.size() - 1);
@@ -245,43 +256,44 @@ public LoginPacket getOnlineLoginPacket() throws Exception {
this.UUID = extraData.getString("identity");
}
- loginPacket.setChainData(new AsciiString(chainDataObject.toJSONString().getBytes(StandardCharsets.UTF_8)));
- loginPacket.setSkinData(new AsciiString(this.getSkinData()));
+ loginPacket.setExtra(SignedJWT.parse(this.getSkinData()));
loginPacket.setProtocolVersion(ProxyServer.getInstance().getBedrockPacketCodec().getProtocolVersion());
return loginPacket;
}
private void offlineLogin(ServerboundHelloPacket javaLoginPacket) {
- InetSocketAddress bindAddress = new InetSocketAddress("0.0.0.0", ThreadLocalRandom.current().nextInt(30000, 60000));
- BedrockClient client = new BedrockClient(bindAddress);
- client.setRakNetVersion(ProxyServer.getInstance().getBedrockPacketCodec().getRaknetProtocolVersion());
-
this.xuid = "";
this.username = javaLoginPacket.getUsername();
this.UUID = java.util.UUID.randomUUID().toString();
- this.bedrockClient = client;
- ProxyServer.getInstance().getOnlinePlayers().put(javaLoginPacket.getUsername(), this);
-
- client.bind().join();
-
Config config = ProxyServer.getInstance().getConfig();
InetSocketAddress bedrockAddress = new InetSocketAddress(config.getBedrockAddress(), config.getBedrockPort());
- client.connect(bedrockAddress).whenComplete((session, throwable) -> {
- if (throwable != null) {
- javaSession.disconnect("Server offline " + throwable);
- return;
- }
-
- session.setPacketCodec(ProxyServer.getInstance().getBedrockPacketCodec());
- session.addDisconnectHandler((reason) -> javaSession.disconnect("Client disconnected! " + reason.toString()));
- session.setBatchHandler(new BedrockBatchHandler(this));
- RequestNetworkSettingsPacket requestNetworkSettingsPacket = new RequestNetworkSettingsPacket();
- requestNetworkSettingsPacket.setProtocolVersion(ProxyServer.getInstance().getBedrockPacketCodec().getProtocolVersion());
- session.sendPacketImmediately(requestNetworkSettingsPacket);
- }).join();
+ try {
+ Player player = this;
+ channel = new Bootstrap()
+ .channelFactory(RakChannelFactory.client(NioDatagramChannel.class))
+ .group(new NioEventLoopGroup())
+ .option(RakChannelOption.RAK_PROTOCOL_VERSION, ProxyServer.getInstance().getBedrockPacketCodec().getRaknetProtocolVersion())
+ .handler(new BedrockClientInitializer() {
+ @Override
+ protected void initSession(BedrockClientSession session) {
+ bedrockClientSession = session;
+ session.setCodec(ProxyServer.getInstance().getBedrockPacketCodec());
+ session.setPacketHandler(new BedrockBatchHandler(player));
+
+ RequestNetworkSettingsPacket requestNetworkSettingsPacket = new RequestNetworkSettingsPacket();
+ requestNetworkSettingsPacket.setProtocolVersion(ProxyServer.getInstance().getBedrockPacketCodec().getProtocolVersion());
+ session.sendPacketImmediately(requestNetworkSettingsPacket);
+ }
+ })
+ .connect(bedrockAddress)
+ .syncUninterruptibly().channel();
+ } catch (Exception exception) {
+ javaSession.disconnect("Server offline " + exception);
+ }
+ ProxyServer.getInstance().getOnlinePlayers().put(javaLoginPacket.getUsername(), this);
}
- public LoginPacket getLoginPacket() {
+ public LoginPacket getLoginPacket() throws Exception {
LoginPacket loginPacket = new LoginPacket();
KeyPair ecdsa384KeyPair = EncryptionUtils.createKeyPair();
@@ -308,12 +320,11 @@ public LoginPacket getLoginPacket() {
JSONArray chainDataJsonArray = new JSONArray();
chainDataJsonArray.add(jwt);
+ for (int i = 0; i < chainDataJsonArray.size(); i++) {
+ loginPacket.getChain().add(SignedJWT.parse((String) chainDataJsonArray.get(i)));
+ }
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("chain", chainDataJsonArray);
-
- loginPacket.setChainData(new AsciiString(jsonObject.toJSONString().getBytes(StandardCharsets.UTF_8)));
- loginPacket.setSkinData(new AsciiString(this.getSkinData()));
+ loginPacket.setExtra(SignedJWT.parse(this.getSkinData()));
loginPacket.setProtocolVersion(ProxyServer.getInstance().getBedrockPacketCodec().getProtocolVersion());
return loginPacket;
}
@@ -336,6 +347,7 @@ private String getSkinData() {
skinData.put("CapeImageWidth", 0);
skinData.put("CapeOnClassicSkin", false);
skinData.put("ClientRandomId", new Random().nextLong());
+ skinData.put("CompatibleWithClientSideChunkGen", false);
skinData.put("CurrentInputMode", 1);
skinData.put("DefaultInputMode", 1);
skinData.put("DeviceId", java.util.UUID.randomUUID().toString());
@@ -398,7 +410,11 @@ public void sendTip(String message) {
public void disconnect(String reason) {
playerInputExecutor.shutdown();
- this.getBedrockClient().getSession().disconnect();
+ this.bedrockClientSession.disconnect();
+ if (this.channel.isOpen()) {
+ this.channel.disconnect().syncUninterruptibly();
+ this.channel.parent().disconnect().syncUninterruptibly();
+ }
this.javaSession.disconnect(reason);
ProxyServer.getInstance().getOnlinePlayers().remove(username);
}
@@ -426,7 +442,7 @@ class PlayerAuthInputThread implements Runnable {
public void run() {
try {
- if (!player.getBedrockClient().getSession().isClosed()) {
+ if (player.getBedrockClientSession().isConnected()) {
++tick;
PlayerAuthInputPacket pk = new PlayerAuthInputPacket();
@@ -442,7 +458,7 @@ public void run() {
pk.setDelta(Vector3f.from(player.getVector3f().getX() - player.getOldPosition().getX(), player.getVector3f().getY() - player.getOldPosition().getY(), player.getVector3f().getZ() - player.getOldPosition().getZ()));
pk.setItemStackRequest(null);
pk.setItemUseTransaction(player.getPlayerAuthInputItemUseTransaction());
-
+ pk.setAnalogMoveVector(Vector2f.ZERO);
pk.getInputData().addAll(player.getPlayerAuthInputData());
pk.getPlayerActions().addAll(player.getPlayerAuthInputActions());
@@ -462,7 +478,7 @@ public void run() {
pk.getPlayerActions().add(blockActionData);
}
- player.getBedrockClient().getSession().sendPacketImmediately(pk);
+ player.getBedrockClientSession().sendPacketImmediately(pk);
player.getPlayerAuthInputData().removeAll(player.getPlayerAuthInputData());
player.getPlayerAuthInputActions().removeAll(player.getPlayerAuthInputActions());
diff --git a/src/main/java/org/barrelmc/barrel/server/ProxyServer.java b/src/main/java/org/barrelmc/barrel/server/ProxyServer.java
index 6410676..b37f41d 100644
--- a/src/main/java/org/barrelmc/barrel/server/ProxyServer.java
+++ b/src/main/java/org/barrelmc/barrel/server/ProxyServer.java
@@ -23,8 +23,6 @@
import com.github.steveice10.packetlib.event.server.SessionAddedEvent;
import com.github.steveice10.packetlib.event.server.SessionRemovedEvent;
import com.github.steveice10.packetlib.tcp.TcpServer;
-import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
-import com.nukkitx.protocol.bedrock.v560.Bedrock_v560;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.barrelmc.barrel.Barrel;
@@ -34,6 +32,8 @@
import org.barrelmc.barrel.network.JavaPacketHandler;
import org.barrelmc.barrel.player.Player;
import org.barrelmc.barrel.utils.FileManager;
+import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
+import org.cloudburstmc.protocol.bedrock.codec.v582.Bedrock_v582;
import org.yaml.snakeyaml.Yaml;
import java.io.FileInputStream;
@@ -54,7 +54,7 @@ public class ProxyServer {
@Getter
private final Map onlinePlayers = new ConcurrentHashMap<>();
@Getter
- private final BedrockPacketCodec bedrockPacketCodec = Bedrock_v560.V560_CODEC;
+ private final BedrockCodec bedrockPacketCodec = Bedrock_v582.CODEC;
@Getter
private final Path dataPath;