Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 16:12:46 +01:00
Change lighting fix method
Dieser Commit ist enthalten in:
Ursprung
c4658ecdae
Commit
4153e98134
@ -67,7 +67,7 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
|
|||||||
session.getUpstream().sendPacket(chunkRadiusPacket);
|
session.getUpstream().sendPacket(chunkRadiusPacket);
|
||||||
|
|
||||||
if (DimensionUtils.javaToBedrock(packet.getDimension()) != entity.getDimension()) {
|
if (DimensionUtils.javaToBedrock(packet.getDimension()) != entity.getDimension()) {
|
||||||
DimensionUtils.switchDimension(session, packet.getDimension());
|
DimensionUtils.switchDimension(session, packet.getDimension(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,11 @@
|
|||||||
package org.geysermc.connector.network.translators.java;
|
package org.geysermc.connector.network.translators.java;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerRespawnPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerRespawnPacket;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
|
||||||
import com.nukkitx.protocol.bedrock.packet.*;
|
import com.nukkitx.protocol.bedrock.packet.*;
|
||||||
import org.geysermc.connector.entity.Entity;
|
import org.geysermc.connector.entity.Entity;
|
||||||
import org.geysermc.connector.entity.attribute.AttributeType;
|
import org.geysermc.connector.entity.attribute.AttributeType;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
import org.geysermc.connector.utils.ChunkUtils;
|
|
||||||
import org.geysermc.connector.utils.DimensionUtils;
|
import org.geysermc.connector.utils.DimensionUtils;
|
||||||
|
|
||||||
public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket> {
|
public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket> {
|
||||||
@ -44,7 +42,8 @@ public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket>
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
float maxHealth = entity.getAttributes().containsKey(AttributeType.MAX_HEALTH) ? entity.getAttributes().get(AttributeType.MAX_HEALTH).getValue() : 20f;
|
float maxHealth = entity.getAttributes().containsKey(AttributeType.MAX_HEALTH) ? entity.getAttributes().get(AttributeType.MAX_HEALTH).getValue() : 20f;
|
||||||
entity.getAttributes().put(AttributeType.HEALTH, AttributeType.HEALTH.getAttribute(maxHealth));
|
// Max health must be divisible by two in bedrock
|
||||||
|
entity.getAttributes().put(AttributeType.HEALTH, AttributeType.HEALTH.getAttribute(maxHealth, (maxHealth % 2 == 1 ? maxHealth + 1 : maxHealth)));
|
||||||
|
|
||||||
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
||||||
playerGameTypePacket.setGamemode(packet.getGamemode().ordinal());
|
playerGameTypePacket.setGamemode(packet.getGamemode().ordinal());
|
||||||
@ -52,23 +51,14 @@ public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket>
|
|||||||
session.setGameMode(packet.getGamemode());
|
session.setGameMode(packet.getGamemode());
|
||||||
|
|
||||||
if (entity.getDimension() != DimensionUtils.javaToBedrock(packet.getDimension())) {
|
if (entity.getDimension() != DimensionUtils.javaToBedrock(packet.getDimension())) {
|
||||||
DimensionUtils.switchDimension(session, packet.getDimension());
|
DimensionUtils.switchDimension(session, packet.getDimension(), false);
|
||||||
} else {
|
} else {
|
||||||
// Handled in JavaPlayerPositionRotationTranslator
|
// Handled in JavaPlayerPositionRotationTranslator
|
||||||
session.setSpawned(false);
|
session.setSpawned(false);
|
||||||
if (session.isManyDimPackets()) { //reloading world
|
if (session.isManyDimPackets()) { //reloading world
|
||||||
session.getEntityCache().removeAllEntities();
|
int fakeDim = entity.getDimension() == 0 ? -1 : 0;
|
||||||
//lighting fix
|
DimensionUtils.switchDimension(session, fakeDim, true);
|
||||||
ChunkUtils.sendEmptyChunks(session, entity.getPosition().toInt(), session.getRenderDistance(), false);
|
DimensionUtils.switchDimension(session, packet.getDimension(), 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.geysermc.connector.entity.Entity;
|
|||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
|
||||||
public class DimensionUtils {
|
public class DimensionUtils {
|
||||||
public static void switchDimension(GeyserSession session, int javaDimension) {
|
public static void switchDimension(GeyserSession session, int javaDimension, boolean fake) {
|
||||||
int bedrockDimension = javaToBedrock(javaDimension);
|
int bedrockDimension = javaToBedrock(javaDimension);
|
||||||
Entity player = session.getPlayerEntity();
|
Entity player = session.getPlayerEntity();
|
||||||
if (bedrockDimension == player.getDimension())
|
if (bedrockDimension == player.getDimension())
|
||||||
@ -28,6 +28,10 @@ public class DimensionUtils {
|
|||||||
stopSoundPacket.setSoundName("");
|
stopSoundPacket.setSoundName("");
|
||||||
session.getUpstream().sendPacket(stopSoundPacket);
|
session.getUpstream().sendPacket(stopSoundPacket);
|
||||||
|
|
||||||
|
if (fake) {
|
||||||
|
ChunkUtils.sendEmptyChunks(session, pos, 2, true);
|
||||||
|
}
|
||||||
|
|
||||||
session.setSpawned(false);
|
session.setSpawned(false);
|
||||||
session.setSwitchingDimension(true);
|
session.setSwitchingDimension(true);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren