3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 14:30:17 +01:00

Show the nether fog when using the nether height workaround (#2663)

Dieser Commit ist enthalten in:
Luke 2021-12-08 18:23:05 +00:00 committet von GitHub
Ursprung 046c93ffb0
Commit 8c7a3d1822
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
5 geänderte Dateien mit 59 neuen und 23 gelöschten Zeilen

Datei anzeigen

@ -461,6 +461,8 @@ public class GeyserSession implements GeyserConnection, CommandSender {
@Setter @Setter
private boolean waitingForStatistics = false; private boolean waitingForStatistics = false;
private final Set<String> fogNameSpaces = new HashSet<>();
private final Set<UUID> emotes; private final Set<UUID> emotes;
/** /**
@ -1006,11 +1008,11 @@ public class GeyserSession implements GeyserConnection, CommandSender {
// Set the mood // Set the mood
if (!isInWorldBorderWarningArea) { if (!isInWorldBorderWarningArea) {
isInWorldBorderWarningArea = true; isInWorldBorderWarningArea = true;
WorldBorder.sendFog(this, "minecraft:fog_crimson_forest"); sendFog("minecraft:fog_crimson_forest");
} }
} else if (isInWorldBorderWarningArea) { } else if (isInWorldBorderWarningArea) {
// Clear fog as we are outside the world border now // Clear fog as we are outside the world border now
WorldBorder.removeFog(this); removeFog("minecraft:fog_crimson_forest");
isInWorldBorderWarningArea = false; isInWorldBorderWarningArea = false;
} }
@ -1490,4 +1492,36 @@ public class GeyserSession implements GeyserConnection, CommandSender {
player.sendUpstreamPacket(emoteList); player.sendUpstreamPacket(emoteList);
} }
} }
/**
* Send the following fog IDs, as well as the cached ones, to the client.
*
* Fog IDs can be found here:
* https://wiki.bedrock.dev/documentation/fog-ids.html
*
* @param fogNameSpaces the fog ids to add
*/
public void sendFog(String... fogNameSpaces) {
this.fogNameSpaces.addAll(Arrays.asList(fogNameSpaces));
PlayerFogPacket packet = new PlayerFogPacket();
packet.getFogStack().addAll(this.fogNameSpaces);
sendUpstreamPacket(packet);
}
/**
* Removes the following fog IDs from the client and the cache.
*
* @param fogNameSpaces the fog ids to remove
*/
public void removeFog(String... fogNameSpaces) {
if (fogNameSpaces.length == 0) {
this.fogNameSpaces.clear();
} else {
this.fogNameSpaces.removeAll(Arrays.asList(fogNameSpaces));
}
PlayerFogPacket packet = new PlayerFogPacket();
packet.getFogStack().addAll(this.fogNameSpaces);
sendUpstreamPacket(packet);
}
} }

Datei anzeigen

@ -296,21 +296,4 @@ public class WorldBorder {
effectPacket.setType(WORLD_BORDER_PARTICLE); effectPacket.setType(WORLD_BORDER_PARTICLE);
session.getUpstream().sendPacket(effectPacket); session.getUpstream().sendPacket(effectPacket);
} }
/**
* Send the following fog IDs to the client
*/
public static void sendFog(GeyserSession session, String... fogNameSpaces) {
PlayerFogPacket packet = new PlayerFogPacket();
Collections.addAll(packet.getFogStack(), fogNameSpaces);
session.sendUpstreamPacket(packet);
}
/**
* Clear any additional fog sent to the client
*/
public static void removeFog(GeyserSession session) {
session.sendUpstreamPacket(new PlayerFogPacket());
}
} }

Datei anzeigen

@ -116,6 +116,9 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
if (!newDimension.equals(session.getDimension())) { if (!newDimension.equals(session.getDimension())) {
DimensionUtils.switchDimension(session, newDimension); DimensionUtils.switchDimension(session, newDimension);
} else if (DimensionUtils.isCustomBedrockNetherId() && newDimension.equalsIgnoreCase(DimensionUtils.NETHER)) {
// If the player is spawning into the "fake" nether, send them some fog
session.sendFog("minecraft:fog_hell");
} }
ChunkUtils.loadDimensionTag(session, packet.getDimension()); ChunkUtils.loadDimensionTag(session, packet.getDimension());

Datei anzeigen

@ -58,6 +58,8 @@ public class DimensionUtils {
public static void switchDimension(GeyserSession session, String javaDimension) { public static void switchDimension(GeyserSession session, String javaDimension) {
int bedrockDimension = javaToBedrock(javaDimension); int bedrockDimension = javaToBedrock(javaDimension);
int previousDimension = javaToBedrock(session.getDimension());
Entity player = session.getPlayerEntity(); Entity player = session.getPlayerEntity();
session.getChunkCache().clear(); session.getChunkCache().clear();
@ -102,6 +104,17 @@ public class DimensionUtils {
// TODO - fix this hack of a fix by sending the final dimension switching logic after sections have been sent. // TODO - fix this hack of a fix by sending the final dimension switching logic after sections have been sent.
// The client wants sections sent to it before it can successfully respawn. // The client wants sections sent to it before it can successfully respawn.
ChunkUtils.sendEmptyChunks(session, player.getPosition().toInt(), 3, true); ChunkUtils.sendEmptyChunks(session, player.getPosition().toInt(), 3, true);
// If the bedrock nether height workaround is enabled, meaning the client is told it's in the end dimension,
// we check if the player is entering the nether and apply the nether fog to fake the fact that the client
// thinks they are in the end dimension.
if (BEDROCK_NETHER_ID == 2) {
if (bedrockDimension == BEDROCK_NETHER_ID) {
session.sendFog("minecraft:fog_hell");
} else if (previousDimension == BEDROCK_NETHER_ID) {
session.removeFog("minecraft:fog_hell");
}
}
} }
/** /**
@ -163,4 +176,8 @@ public class DimensionUtils {
} }
return currentDimension.equals(OVERWORLD) ? NETHER : OVERWORLD; return currentDimension.equals(OVERWORLD) ? NETHER : OVERWORLD;
} }
public static boolean isCustomBedrockNetherId() {
return BEDROCK_NETHER_ID == 2;
}
} }

Datei anzeigen

@ -148,10 +148,9 @@ allow-custom-skulls: true
# This option requires a restart of Geyser in order to change its setting. # This option requires a restart of Geyser in order to change its setting.
add-non-bedrock-items: true add-non-bedrock-items: true
# Bedrock prevents building and displaying blocks above Y127 in the Nether - # Bedrock prevents building and displaying blocks above Y127 in the Nether.
# enabling this config option works around that by changing the Nether dimension ID # This config option works around that by changing the Nether dimension ID to the End ID.
# to the End ID. The main downside to this is that the sky will resemble that of # The main downside to this is that the entire Nether will have the same red fog rather than having different fog for each biome.
# the end sky in the nether, but ultimately it's the only way for this feature to work.
above-bedrock-nether-building: false above-bedrock-nether-building: false
# Force clients to load all resource packs if there are any. # Force clients to load all resource packs if there are any.