Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 20:43:04 +02:00
Fix lighting when reloading world
Dieser Commit ist enthalten in:
Ursprung
b2f86ec20b
Commit
782feed641
@ -128,7 +128,7 @@ public class GeyserSession implements Player {
|
||||
startGame();
|
||||
this.remoteServer = remoteServer;
|
||||
|
||||
ChunkUtils.sendEmptyChunks(this, playerEntity.getPosition().toInt(), 5);
|
||||
ChunkUtils.sendEmptyChunks(this, playerEntity.getPosition().toInt(), 0, false);
|
||||
|
||||
BiomeDefinitionListPacket biomePacket = new BiomeDefinitionListPacket();
|
||||
biomePacket.setTag(CompoundTag.EMPTY);
|
||||
|
@ -26,10 +26,12 @@
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerRespawnPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
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 org.geysermc.connector.utils.ChunkUtils;
|
||||
import org.geysermc.connector.utils.DimensionUtils;
|
||||
|
||||
public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket> {
|
||||
@ -48,12 +50,22 @@ public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket>
|
||||
if (entity.getDimension() != DimensionUtils.javaToBedrock(packet.getDimension())) {
|
||||
DimensionUtils.switchDimension(session, packet.getDimension());
|
||||
} else {
|
||||
if (session.isManyDimPackets()) { //reloading world
|
||||
session.getEntityCache().removeAllEntities();
|
||||
//TODO: fix lighting bug
|
||||
}
|
||||
// Handled in JavaPlayerPositionRotationTranslator
|
||||
session.setSpawned(false);
|
||||
if (session.isManyDimPackets()) { //reloading world
|
||||
session.getEntityCache().removeAllEntities();
|
||||
//lighting fix
|
||||
ChunkUtils.sendEmptyChunks(session, entity.getPosition().toInt(), session.getRenderDistance(), false);
|
||||
Vector3f tempPos = Vector3f.from(entity.getPosition().getX() > 0 ? -5000 : 5000, 0, 0);
|
||||
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
|
||||
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
movePlayerPacket.setPosition(tempPos);
|
||||
movePlayerPacket.setRotation(Vector3f.ZERO);
|
||||
movePlayerPacket.setMode(MovePlayerPacket.Mode.NORMAL);
|
||||
movePlayerPacket.setOnGround(true);
|
||||
session.getUpstream().sendPacket(movePlayerPacket);
|
||||
ChunkUtils.sendEmptyChunks(session, tempPos.toInt(), 5, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,16 +73,16 @@ public class ChunkUtils {
|
||||
session.getUpstream().sendPacket(waterPacket);
|
||||
}
|
||||
|
||||
public static void sendEmptyChunks(GeyserSession session, Vector3i position, int radius) {
|
||||
public static void sendEmptyChunks(GeyserSession session, Vector3i position, int radius, boolean forceUpdate) {
|
||||
int chunkX = position.getX() >> 4;
|
||||
int chunkZ = position.getZ() >> 4;
|
||||
NetworkChunkPublisherUpdatePacket chunkPublisherUpdatePacket = new NetworkChunkPublisherUpdatePacket();
|
||||
chunkPublisherUpdatePacket.setPosition(position);
|
||||
chunkPublisherUpdatePacket.setRadius(radius << 4);
|
||||
chunkPublisherUpdatePacket.setRadius(radius + 1 << 4);
|
||||
session.getUpstream().sendPacket(chunkPublisherUpdatePacket);
|
||||
session.setLastChunkPosition(null);
|
||||
for (int x = -radius; x < radius; x++) {
|
||||
for (int z = -radius; z < radius; z++) {
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
for (int z = -radius; z <= radius; z++) {
|
||||
LevelChunkPacket data = new LevelChunkPacket();
|
||||
data.setChunkX(chunkX + x);
|
||||
data.setChunkZ(chunkZ + z);
|
||||
@ -90,6 +90,15 @@ public class ChunkUtils {
|
||||
data.setData(TranslatorsInit.EMPTY_LEVEL_CHUNK_DATA);
|
||||
data.setCachingEnabled(false);
|
||||
session.getUpstream().sendPacket(data);
|
||||
|
||||
if (forceUpdate) {
|
||||
Vector3i pos = Vector3i.from(chunkX + x << 4, 80, chunkZ + z << 4);
|
||||
UpdateBlockPacket blockPacket = new UpdateBlockPacket();
|
||||
blockPacket.setBlockPosition(pos);
|
||||
blockPacket.setDataLayer(1);
|
||||
blockPacket.setRuntimeId(1);
|
||||
session.getUpstream().sendPacket(blockPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren