diff --git a/README.md b/README.md
index 52dfb6533..ed53e5fe5 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,6 @@ Please note, Geyser is **not** (currently) a plugin. Watch the video below or ta
- Block Particles
- Block Entities ([`block-entities`](https://github.com/GeyserMC/Geyser/tree/block-entities))
- Some Entity Flags
-- Proper Movement
- Support to be Ran as a Plugin ([`plugin`](https://github.com/GeyserMC/Geyser/tree/plugin))
## Compiling
diff --git a/connector/pom.xml b/connector/pom.xml
index 9de1e3e75..cff4c87a2 100644
--- a/connector/pom.xml
+++ b/connector/pom.xml
@@ -67,7 +67,7 @@
com.nukkitx.protocol
bedrock-v389
- 2.4.4
+ 2.5.1
compile
diff --git a/connector/src/main/java/org/geysermc/connector/entity/Entity.java b/connector/src/main/java/org/geysermc/connector/entity/Entity.java
index a4f5aae1f..6907f489b 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/Entity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/Entity.java
@@ -30,7 +30,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.MetadataType;
import com.github.steveice10.mc.protocol.data.message.TextMessage;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.EntityData;
-import com.nukkitx.protocol.bedrock.data.EntityDataDictionary;
+import com.nukkitx.protocol.bedrock.data.EntityDataMap;
import com.nukkitx.protocol.bedrock.data.EntityFlag;
import com.nukkitx.protocol.bedrock.data.EntityFlags;
import com.nukkitx.protocol.bedrock.packet.*;
@@ -65,7 +65,6 @@ public class Entity {
protected Vector3f rotation;
protected float scale = 1;
- protected boolean movePending;
protected EntityType entityType;
@@ -73,20 +72,20 @@ public class Entity {
protected LongSet passengers = new LongOpenHashSet();
protected Map attributes = new HashMap<>();
- protected EntityDataDictionary metadata = new EntityDataDictionary();
+ protected EntityDataMap metadata = new EntityDataMap();
public Entity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
this.entityId = entityId;
this.geyserId = geyserId;
this.entityType = entityType;
- this.position = position;
this.motion = motion;
this.rotation = rotation;
this.valid = false;
- this.movePending = false;
this.dimension = 0;
+ setPosition(position);
+
metadata.put(EntityData.SCALE, 1f);
metadata.put(EntityData.MAX_AIR, (short) 400);
metadata.put(EntityData.AIR, (short) 0);
@@ -132,25 +131,40 @@ public class Entity {
return true;
}
- public void moveRelative(double relX, double relY, double relZ, float yaw, float pitch) {
- moveRelative(relX, relY, relZ, Vector3f.from(yaw, pitch, yaw));
+ public void moveRelative(GeyserSession session, double relX, double relY, double relZ, float yaw, float pitch, boolean isOnGround) {
+ moveRelative(session, relX, relY, relZ, Vector3f.from(yaw, pitch, yaw), isOnGround);
}
- public void moveRelative(double relX, double relY, double relZ, Vector3f rotation) {
+ public void moveRelative(GeyserSession session, double relX, double relY, double relZ, Vector3f rotation, boolean isOnGround) {
setRotation(rotation);
this.position = Vector3f.from(position.getX() + relX, position.getY() + relY, position.getZ() + relZ);
- this.movePending = true;
+
+ MoveEntityAbsolutePacket moveEntityPacket = new MoveEntityAbsolutePacket();
+ moveEntityPacket.setRuntimeEntityId(geyserId);
+ moveEntityPacket.setPosition(position);
+ moveEntityPacket.setRotation(getBedrockRotation());
+ moveEntityPacket.setOnGround(isOnGround);
+ moveEntityPacket.setTeleported(false);
+
+ session.getUpstream().sendPacket(moveEntityPacket);
}
- public void moveAbsolute(Vector3f position, float yaw, float pitch) {
- moveAbsolute(position, Vector3f.from(yaw, pitch, yaw));
+ public void moveAbsolute(GeyserSession session, Vector3f position, float yaw, float pitch, boolean isOnGround) {
+ moveAbsolute(session, position, Vector3f.from(yaw, pitch, yaw), isOnGround);
}
- public void moveAbsolute(Vector3f position, Vector3f rotation) {
+ public void moveAbsolute(GeyserSession session, Vector3f position, Vector3f rotation, boolean isOnGround) {
setPosition(position);
setRotation(rotation);
- this.movePending = true;
+ MoveEntityAbsolutePacket moveEntityPacket = new MoveEntityAbsolutePacket();
+ moveEntityPacket.setRuntimeEntityId(geyserId);
+ moveEntityPacket.setPosition(position);
+ moveEntityPacket.setRotation(getBedrockRotation());
+ moveEntityPacket.setOnGround(isOnGround);
+ moveEntityPacket.setTeleported(false);
+
+ session.getUpstream().sendPacket(moveEntityPacket);
}
public void updateBedrockAttributes(GeyserSession session) {
@@ -216,14 +230,6 @@ public class Entity {
session.getUpstream().sendPacket(entityDataPacket);
}
- public void setPosition(Vector3f position) {
- if (is(PlayerEntity.class)) {
- this.position = position.add(0, entityType.getOffset(), 0);
- return;
- }
- this.position = position;
- }
-
/**
* x = Pitch, y = HeadYaw, z = Yaw
*/
diff --git a/connector/src/main/java/org/geysermc/connector/entity/PlayerEntity.java b/connector/src/main/java/org/geysermc/connector/entity/PlayerEntity.java
index 205830022..49af65546 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/PlayerEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/PlayerEntity.java
@@ -27,7 +27,10 @@ package org.geysermc.connector.entity;
import com.github.steveice10.mc.auth.data.GameProfile;
import com.nukkitx.math.vector.Vector3f;
+import com.nukkitx.protocol.bedrock.data.CommandPermission;
+import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.AddPlayerPacket;
+import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
import com.nukkitx.protocol.bedrock.packet.PlayerListPacket;
import lombok.Getter;
import lombok.Setter;
@@ -74,11 +77,8 @@ public class PlayerEntity extends LivingEntity {
addPlayerPacket.setRotation(getBedrockRotation());
addPlayerPacket.setMotion(motion);
addPlayerPacket.setHand(hand);
- addPlayerPacket.setPlayerFlags(0);
- addPlayerPacket.setCommandPermission(0);
- addPlayerPacket.setWorldFlags(0);
- addPlayerPacket.setPlayerPermission(0);
- addPlayerPacket.setCustomFlags(0);
+ addPlayerPacket.getAdventureSettings().setCommandPermission(CommandPermission.NORMAL);
+ addPlayerPacket.getAdventureSettings().setPlayerPermission(PlayerPermission.VISITOR);
addPlayerPacket.setDeviceId("");
addPlayerPacket.setPlatformChatId("");
addPlayerPacket.getMetadata().putAll(metadata);
@@ -94,7 +94,7 @@ public class PlayerEntity extends LivingEntity {
if (getLastSkinUpdate() == -1) {
if (playerList) {
PlayerListPacket playerList = new PlayerListPacket();
- playerList.setType(PlayerListPacket.Type.ADD);
+ playerList.setAction(PlayerListPacket.Action.ADD);
playerList.getEntries().add(SkinUtils.buildDefaultEntry(profile, geyserId));
session.getUpstream().sendPacket(playerList);
}
@@ -110,10 +110,44 @@ public class PlayerEntity extends LivingEntity {
// remove from playerlist if player isn't on playerlist
Geyser.getGeneralThreadPool().execute(() -> {
PlayerListPacket playerList = new PlayerListPacket();
- playerList.setType(PlayerListPacket.Type.REMOVE);
+ playerList.setAction(PlayerListPacket.Action.REMOVE);
playerList.getEntries().add(new PlayerListPacket.Entry(uuid));
session.getUpstream().sendPacket(playerList);
});
}
}
+
+ @Override
+ public void moveAbsolute(GeyserSession session, Vector3f position, Vector3f rotation, boolean isOnGround) {
+ setPosition(position);
+ setRotation(rotation);
+
+ MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
+ movePlayerPacket.setRuntimeEntityId(geyserId);
+ movePlayerPacket.setPosition(this.position);
+ movePlayerPacket.setRotation(getBedrockRotation());
+ movePlayerPacket.setOnGround(isOnGround);
+ movePlayerPacket.setMode(MovePlayerPacket.Mode.NORMAL);
+
+ session.getUpstream().sendPacket(movePlayerPacket);
+ }
+
+ @Override
+ public void moveRelative(GeyserSession session, double relX, double relY, double relZ, Vector3f rotation, boolean isOnGround) {
+ setRotation(rotation);
+ this.position = Vector3f.from(position.getX() + relX, position.getY() + relY, position.getZ() + relZ);
+
+ MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
+ movePlayerPacket.setRuntimeEntityId(geyserId);
+ movePlayerPacket.setPosition(position);
+ movePlayerPacket.setRotation(getBedrockRotation());
+ movePlayerPacket.setOnGround(isOnGround);
+ movePlayerPacket.setMode(MovePlayerPacket.Mode.NORMAL);
+ session.getUpstream().sendPacket(movePlayerPacket);
+ }
+
+ @Override
+ public void setPosition(Vector3f position) {
+ this.position = position.add(0, entityType.getOffset(), 0);
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/LoggingPacketHandler.java b/connector/src/main/java/org/geysermc/connector/network/LoggingPacketHandler.java
index 313e7adcf..91b3ebd40 100644
--- a/connector/src/main/java/org/geysermc/connector/network/LoggingPacketHandler.java
+++ b/connector/src/main/java/org/geysermc/connector/network/LoggingPacketHandler.java
@@ -192,11 +192,6 @@ public class LoggingPacketHandler implements BedrockPacketHandler {
return defaultHandler(packet);
}
- @Override
- public boolean handle(LevelSoundEvent3Packet packet) {
- return defaultHandler(packet);
- }
-
@Override
public boolean handle(MapInfoRequestPacket packet) {
return defaultHandler(packet);
diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
index 0165f854e..9984249c5 100644
--- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
+++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
@@ -45,7 +45,8 @@ import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.nbt.tag.CompoundTag;
import com.nukkitx.protocol.bedrock.BedrockServerSession;
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
-import com.nukkitx.protocol.bedrock.data.GameRule;
+import com.nukkitx.protocol.bedrock.data.GameRuleData;
+import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.*;
import lombok.Getter;
import lombok.Setter;
@@ -99,6 +100,14 @@ public class GeyserSession implements Player {
private GameMode gameMode = GameMode.SURVIVAL;
private final AtomicInteger pendingDimSwitches = new AtomicInteger(0);
+ @Setter
+ private boolean sprinting;
+
+ @Setter
+ private boolean jumping;
+
+ @Setter
+ private boolean switchingDimension = false;
private boolean manyDimPackets = false;
private ServerRespawnPacket lastDimPacket = null;
@@ -309,7 +318,7 @@ public class GeyserSession implements Player {
startGamePacket.setLightningLevel(0);
startGamePacket.setMultiplayerGame(true);
startGamePacket.setBroadcastingToLan(true);
- startGamePacket.getGamerules().add(new GameRule<>("showcoordinates", true));
+ startGamePacket.getGamerules().add(new GameRuleData<>("showcoordinates", true));
startGamePacket.setPlatformBroadcastMode(GamePublishSetting.PUBLIC);
startGamePacket.setXblBroadcastMode(GamePublishSetting.PUBLIC);
startGamePacket.setCommandsEnabled(true);
@@ -317,7 +326,7 @@ public class GeyserSession implements Player {
startGamePacket.setBonusChestEnabled(false);
startGamePacket.setStartingWithMap(false);
startGamePacket.setTrustingPlayers(true);
- startGamePacket.setDefaultPlayerPermission(1);
+ startGamePacket.setDefaultPlayerPermission(PlayerPermission.OPERATOR);
startGamePacket.setServerChunkTickRange(4);
startGamePacket.setBehaviorPackLocked(false);
startGamePacket.setResourcePackLocked(false);
diff --git a/connector/src/main/java/org/geysermc/connector/network/session/cache/EntityCache.java b/connector/src/main/java/org/geysermc/connector/network/session/cache/EntityCache.java
index 2834cb909..bbd714e2f 100644
--- a/connector/src/main/java/org/geysermc/connector/network/session/cache/EntityCache.java
+++ b/connector/src/main/java/org/geysermc/connector/network/session/cache/EntityCache.java
@@ -55,7 +55,6 @@ public class EntityCache {
}
public void spawnEntity(Entity entity) {
- entity.moveAbsolute(entity.getPosition(), entity.getRotation().getX(), entity.getRotation().getY());
cacheEntity(entity);
entity.spawnEntity(session);
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java
index c18859c11..1268e3273 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java
@@ -27,10 +27,7 @@ package org.geysermc.connector.network.translators;
import com.github.steveice10.mc.protocol.packet.ingame.server.*;
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.*;
-import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerActionAckPacket;
-import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket;
-import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
-import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerSetExperiencePacket;
+import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.*;
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.*;
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerDisplayScoreboardPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerScoreboardObjectivePacket;
@@ -129,8 +126,7 @@ public class TranslatorsInit {
Registry.registerJava(ServerPlayerHealthPacket.class, new JavaPlayerHealthTranslator());
Registry.registerJava(ServerPlayerActionAckPacket.class, new JavaPlayerActionAckTranslator());
- // FIXME: This translator messes with allowing flight in creative mode. Will need to be addressed later
- // Registry.registerJava(ServerPlayerAbilitiesPacket.class, new JavaPlayerAbilitiesTranslator());
+ Registry.registerJava(ServerPlayerAbilitiesPacket.class, new JavaPlayerAbilitiesTranslator());
Registry.registerJava(ServerNotifyClientPacket.class, new JavaNotifyClientTranslator());
Registry.registerJava(ServerChunkDataPacket.class, new JavaChunkDataTranslator());
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java
index af23acd0f..98a580ee3 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java
@@ -40,6 +40,8 @@ import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
+import java.util.concurrent.TimeUnit;
+
public class BedrockActionTranslator extends PacketTranslator {
@Override
@@ -80,10 +82,12 @@ public class BedrockActionTranslator extends PacketTranslator {
+ session.setJumping(false);
+ }, 1, TimeUnit.SECONDS);
+ break;
}
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInteractTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInteractTranslator.java
index 67d398f6f..ab73e9bb1 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInteractTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInteractTranslator.java
@@ -44,12 +44,12 @@ public class BedrockInteractTranslator extends PacketTranslator
return;
switch (packet.getAction()) {
- case 1:
+ case INTERACT:
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
InteractAction.INTERACT, Hand.MAIN_HAND);
session.getDownstream().getSession().send(interactPacket);
break;
- case 2:
+ case DAMAGE:
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
InteractAction.ATTACK, Hand.MAIN_HAND);
session.getDownstream().getSession().send(attackPacket);
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockMovePlayerTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockMovePlayerTranslator.java
index 5e99dd63c..06ac369d3 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockMovePlayerTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockMovePlayerTranslator.java
@@ -26,6 +26,7 @@
package org.geysermc.connector.network.translators.bedrock;
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
+import com.nukkitx.math.GenericMath;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
@@ -61,17 +62,15 @@ public class BedrockMovePlayerTranslator extends PacketTranslator {
@Override
public void translate(RespawnPacket packet, GeyserSession session) {
- if (packet.getSpawnState() == RespawnPacket.State.CLIENT_READY) {
+ if (packet.getState() == RespawnPacket.State.CLIENT_READY) {
RespawnPacket respawnPacket = new RespawnPacket();
respawnPacket.setRuntimeEntityId(0);
respawnPacket.setPosition(Vector3f.ZERO);
- respawnPacket.setSpawnState(RespawnPacket.State.SERVER_SEARCHING);
+ respawnPacket.setState(RespawnPacket.State.SERVER_SEARCHING);
session.getUpstream().sendPacket(respawnPacket);
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java
index f4753b8dd..61a55b424 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java
@@ -66,7 +66,7 @@ public class BlockTranslator {
Map blockStateMap = new HashMap<>();
for (CompoundTag tag : blocksTag.getValue()) {
- if (blockStateMap.putIfAbsent(tag.getAsCompound("block"), tag) != null) {
+ if (blockStateMap.putIfAbsent(tag.getCompound("block"), tag) != null) {
throw new AssertionError("Duplicate block states in Bedrock palette");
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/GenericInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/GenericInventoryTranslator.java
index 8f74c4ddd..754d05c67 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/GenericInventoryTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/GenericInventoryTranslator.java
@@ -67,8 +67,8 @@ public class GenericInventoryTranslator extends InventoryTranslator {
public void updateSlot(GeyserSession session, Inventory inventory, int slot) {
InventorySlotPacket slotPacket = new InventorySlotPacket();
slotPacket.setContainerId(inventory.getId());
- slotPacket.setSlot(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItems()[slot]));
- slotPacket.setInventorySlot(slot);
+ slotPacket.setItem(TranslatorsInit.getItemTranslator().translateToBedrock(inventory.getItems()[slot]));
+ slotPacket.setSlot(slot);
session.getUpstream().sendPacket(slotPacket);
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaBossBarTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaBossBarTranslator.java
index c918c0d5b..bfde6f74c 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaBossBarTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaBossBarTranslator.java
@@ -46,7 +46,7 @@ public class JavaBossBarTranslator extends PacketTranslator
long entityId = session.getEntityCache().addBossBar(packet.getUuid());
addBossEntity(session, entityId);
- bossEventPacket.setType(BossEventPacket.Type.SHOW);
+ bossEventPacket.setAction(BossEventPacket.Action.SHOW);
bossEventPacket.setBossUniqueEntityId(entityId);
bossEventPacket.setTitle(MessageUtils.getBedrockMessage(packet.getTitle()));
bossEventPacket.setHealthPercentage(packet.getHealth());
@@ -55,15 +55,15 @@ public class JavaBossBarTranslator extends PacketTranslator
bossEventPacket.setDarkenSky(0);
break;
case UPDATE_TITLE:
- bossEventPacket.setType(BossEventPacket.Type.TITLE);
+ bossEventPacket.setAction(BossEventPacket.Action.TITLE);
bossEventPacket.setTitle(MessageUtils.getBedrockMessage(packet.getTitle()));
break;
case UPDATE_HEALTH:
- bossEventPacket.setType(BossEventPacket.Type.HEALTH_PERCENTAGE);
+ bossEventPacket.setAction(BossEventPacket.Action.HEALTH_PERCENTAGE);
bossEventPacket.setHealthPercentage(packet.getHealth());
break;
case REMOVE:
- bossEventPacket.setType(BossEventPacket.Type.HIDE);
+ bossEventPacket.setAction(BossEventPacket.Action.HIDE);
removeBossEntity(session, session.getEntityCache().removeBossBar(packet.getUuid()));
break;
case UPDATE_STYLE:
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java
index 3f11dc8cf..51758011e 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java
@@ -27,6 +27,7 @@ package org.geysermc.connector.network.translators.java;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
+import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.*;
import org.geysermc.connector.entity.PlayerEntity;
import org.geysermc.connector.network.session.GeyserSession;
@@ -43,7 +44,7 @@ public class JavaJoinGameTranslator extends PacketTranslator {
@Override
@@ -42,7 +46,7 @@ public class JavaPlayerAbilitiesTranslator extends PacketTranslator playerFlags = new HashSet<>();
+ playerFlags.add(AdventureSettingsPacket.Flag.AUTO_JUMP);
+ if (packet.isCanFly())
+ playerFlags.add(AdventureSettingsPacket.Flag.MAY_FLY);
- playerFlags = setPlayerFlag(0x20, true, playerFlags); // auto jump
- playerFlags = setPlayerFlag(0x40, packet.isCanFly(), playerFlags); // can fly
- playerFlags = setPlayerFlag(0x200, packet.isFlying(), playerFlags); // is flying
+ if (packet.isFlying())
+ playerFlags.add(AdventureSettingsPacket.Flag.FLYING);
AdventureSettingsPacket adventureSettingsPacket = new AdventureSettingsPacket();
- adventureSettingsPacket.setPlayerPermission(1);
+ adventureSettingsPacket.setPlayerPermission(PlayerPermission.OPERATOR);
adventureSettingsPacket.setUniqueEntityId(entity.getGeyserId());
- adventureSettingsPacket.setPlayerFlags(playerFlags);
+ adventureSettingsPacket.getFlags().addAll(playerFlags);
session.getUpstream().sendPacket(adventureSettingsPacket);
}
-
- private int setPlayerFlag(int flag, boolean value, int playerFlags) {
- if (value) {
- return playerFlags | flag;
- } else {
- return playerFlags & ~flag;
- }
- }
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerListEntryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerListEntryTranslator.java
index c39a95dbf..48f20dbdd 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerListEntryTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerListEntryTranslator.java
@@ -41,7 +41,7 @@ public class JavaPlayerListEntryTranslator extends PacketTranslator 1.5 || (yDis < 1.45 || yDis > (session.isJumping() ? 4.3 : (session.isSprinting() ? 2.5 : 1.9))) || zDis > 1.5) {
+ entity.moveAbsolute(session, Vector3f.from(packet.getX(), packet.getY(), packet.getZ()), packet.getYaw(), packet.getPitch(), true);
+ }
+ }
ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(packet.getTeleportId());
session.getDownstream().getSession().send(teleportConfirmPacket);
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaNotifyClientTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaNotifyClientTranslator.java
index da2e8a153..490a66437 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaNotifyClientTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaNotifyClientTranslator.java
@@ -31,13 +31,17 @@ import com.github.steveice10.mc.protocol.data.game.world.notify.EnterCreditsValu
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientRequestPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerNotifyClientPacket;
import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.protocol.bedrock.data.EntityDataDictionary;
+import com.nukkitx.protocol.bedrock.data.EntityDataMap;
import com.nukkitx.protocol.bedrock.data.EntityFlag;
+import com.nukkitx.protocol.bedrock.data.LevelEventType;
+import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.*;
import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
+import java.util.HashSet;
+import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
public class JavaNotifyClientTranslator extends PacketTranslator {
@@ -51,27 +55,34 @@ public class JavaNotifyClientTranslator extends PacketTranslator playerFlags = new HashSet<>();
GameMode gameMode = (GameMode) packet.getValue();
- playerFlags = setPlayerFlag(0x01, gameMode == GameMode.ADVENTURE, playerFlags); // world immutable
- playerFlags = setPlayerFlag(0x20, true, playerFlags); // auto jump
- playerFlags = setPlayerFlag(0x40, gameMode == GameMode.CREATIVE || gameMode == GameMode.SPECTATOR, playerFlags); // can fly
- playerFlags = setPlayerFlag(0x80, gameMode == GameMode.SPECTATOR, playerFlags); // no clip
- playerFlags = setPlayerFlag(0x200, gameMode == GameMode.SPECTATOR, playerFlags); // is flying
+ if (gameMode == GameMode.ADVENTURE)
+ playerFlags.add(AdventureSettingsPacket.Flag.IMMUTABLE_WORLD);
+
+ if (gameMode == GameMode.CREATIVE)
+ playerFlags.add(AdventureSettingsPacket.Flag.MAY_FLY);
+
+ if (gameMode == GameMode.SPECTATOR) {
+ playerFlags.add(AdventureSettingsPacket.Flag.MAY_FLY);
+ playerFlags.add(AdventureSettingsPacket.Flag.NO_CLIP);
+ playerFlags.add(AdventureSettingsPacket.Flag.FLYING);
+ }
+
+ playerFlags.add(AdventureSettingsPacket.Flag.AUTO_JUMP);
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
playerGameTypePacket.setGamemode(gameMode.ordinal());
@@ -79,12 +90,12 @@ public class JavaNotifyClientTranslator extends PacketTranslator