Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void onPacketReceived(CloudburstPacketEvent event) {

session.lastRealPosInt = realIntPos;

if (Vector3f.from(packet.getPosition().getX(), 0, packet.getPosition().getZ()).length() < GFPExtension.config.maxPosition()) {
if (Math.abs(packet.getPosition().getX()) <= GFPExtension.config.maxPosition() && Math.abs(packet.getPosition().getZ()) <= GFPExtension.config.maxPosition()) {
Comment thread
oryxel1 marked this conversation as resolved.
return;
}

Expand Down Expand Up @@ -203,6 +203,7 @@ public void packetReceived(MCPLPacketEvent event) {
session.getChunkCache().sendChunksWithOffset();
session.getEntityCache().resendWithOffset();
session.sendWorldSpawn();
session.resendVehicle();
});
}
}
Expand Down
37 changes: 36 additions & 1 deletion src/main/java/org/oryxel/gfp/session/CachedSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.protocol.bedrock.BedrockServerSession;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityLinkData;
import org.cloudburstmc.protocol.bedrock.packet.SetEntityLinkPacket;
import org.cloudburstmc.protocol.bedrock.packet.SetSpawnPositionPacket;
import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.DimensionUtils;
Expand All @@ -29,7 +32,7 @@ public class CachedSession {

@Getter
@Setter
private Vector3i offset = Vector3i.from(0, 0 ,0);
private Vector3i offset = Vector3i.from(0, 0, 0);

public Vector3i lastRealPosInt = Vector3i.ZERO;
public Vector3f rotation = Vector3f.ZERO;
Expand Down Expand Up @@ -64,6 +67,7 @@ public void reOffsetPlayer(double x, double z, Vector3i newOffset) {
this.chunkCache.sendChunksWithOffset();
this.entityCache.resendWithOffset();
this.sendWorldSpawn();
this.resendVehicle();
}

public void sendWorldSpawn() {
Expand All @@ -77,4 +81,35 @@ public void sendWorldSpawn() {
spawnPositionPacket.setSpawnType(SetSpawnPositionPacket.Type.WORLD_SPAWN);
this.session.sendUpstreamPacket(spawnPositionPacket);
}

public void resendVehicle() {
SessionPlayerEntity player = this.session.getPlayerEntity();

Entity vehicle = player.getVehicle();
if (vehicle == null) {
return;
}

SetEntityLinkPacket unmount = new SetEntityLinkPacket();
unmount.setEntityLink(new EntityLinkData(
vehicle.geyserId(),
player.geyserId(),
EntityLinkData.Type.REMOVE,
false,
false,
0f)
);
SetEntityLinkPacket mount = new SetEntityLinkPacket();
mount.setEntityLink(new EntityLinkData(
vehicle.geyserId(),
player.geyserId(),
EntityLinkData.Type.RIDER,
false,
false,
0f)
);

this.session.sendUpstreamPacket(unmount);
this.session.sendUpstreamPacket(mount);
}
}