mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Show the nether fog when using the nether height workaround (#2663)
This commit is contained in:
parent
046c93ffb0
commit
8c7a3d1822
5 changed files with 59 additions and 23 deletions
|
@ -461,6 +461,8 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
|||
@Setter
|
||||
private boolean waitingForStatistics = false;
|
||||
|
||||
private final Set<String> fogNameSpaces = new HashSet<>();
|
||||
|
||||
private final Set<UUID> emotes;
|
||||
|
||||
/**
|
||||
|
@ -1006,11 +1008,11 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
|||
// Set the mood
|
||||
if (!isInWorldBorderWarningArea) {
|
||||
isInWorldBorderWarningArea = true;
|
||||
WorldBorder.sendFog(this, "minecraft:fog_crimson_forest");
|
||||
sendFog("minecraft:fog_crimson_forest");
|
||||
}
|
||||
} else if (isInWorldBorderWarningArea) {
|
||||
// Clear fog as we are outside the world border now
|
||||
WorldBorder.removeFog(this);
|
||||
removeFog("minecraft:fog_crimson_forest");
|
||||
isInWorldBorderWarningArea = false;
|
||||
}
|
||||
|
||||
|
@ -1490,4 +1492,36 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -296,21 +296,4 @@ public class WorldBorder {
|
|||
effectPacket.setType(WORLD_BORDER_PARTICLE);
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -116,6 +116,9 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||
|
||||
if (!newDimension.equals(session.getDimension())) {
|
||||
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());
|
||||
|
|
|
@ -58,6 +58,8 @@ public class DimensionUtils {
|
|||
|
||||
public static void switchDimension(GeyserSession session, String javaDimension) {
|
||||
int bedrockDimension = javaToBedrock(javaDimension);
|
||||
int previousDimension = javaToBedrock(session.getDimension());
|
||||
|
||||
Entity player = session.getPlayerEntity();
|
||||
|
||||
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.
|
||||
// The client wants sections sent to it before it can successfully respawn.
|
||||
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;
|
||||
}
|
||||
|
||||
public static boolean isCustomBedrockNetherId() {
|
||||
return BEDROCK_NETHER_ID == 2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,10 +148,9 @@ allow-custom-skulls: true
|
|||
# This option requires a restart of Geyser in order to change its setting.
|
||||
add-non-bedrock-items: true
|
||||
|
||||
# Bedrock prevents building and displaying blocks above Y127 in the Nether -
|
||||
# enabling this config option works around that by changing the Nether dimension ID
|
||||
# to the End ID. The main downside to this is that the sky will resemble that of
|
||||
# the end sky in the nether, but ultimately it's the only way for this feature to work.
|
||||
# Bedrock prevents building and displaying blocks above Y127 in the Nether.
|
||||
# This config option works around that by changing the Nether dimension ID to the End ID.
|
||||
# The main downside to this is that the entire Nether will have the same red fog rather than having different fog for each biome.
|
||||
above-bedrock-nether-building: false
|
||||
|
||||
# Force clients to load all resource packs if there are any.
|
||||
|
|
Loading…
Reference in a new issue