3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-09-17 00:33:47 +02:00

Start of extended world height support

Dieser Commit ist enthalten in:
Camotoy 2021-07-13 20:48:45 -04:00
Ursprung b2619fa7c7
Commit c7d4130a44
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
13 geänderte Dateien mit 9570 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -45,6 +45,8 @@ public interface GeyserConfiguration {
Map<String, ? extends IUserAuthenticationInfo> getUserAuths(); Map<String, ? extends IUserAuthenticationInfo> getUserAuths();
boolean isExtendedWorldHeight();
boolean isCommandSuggestions(); boolean isCommandSuggestions();
@JsonIgnore @JsonIgnore

Datei anzeigen

@ -55,6 +55,9 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
private BedrockConfiguration bedrock = new BedrockConfiguration(); private BedrockConfiguration bedrock = new BedrockConfiguration();
private RemoteConfiguration remote = new RemoteConfiguration(); private RemoteConfiguration remote = new RemoteConfiguration();
@JsonProperty("extended-world-height")
private boolean extendedWorldHeight = false;
@JsonProperty("floodgate-key-file") @JsonProperty("floodgate-key-file")
private String floodgateKeyFile = "public-key.pem"; private String floodgateKeyFile = "public-key.pem";

Datei anzeigen

@ -28,6 +28,7 @@ package org.geysermc.connector.network;
import com.nukkitx.protocol.bedrock.BedrockPacketCodec; import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
import com.nukkitx.protocol.bedrock.v440.Bedrock_v440; import com.nukkitx.protocol.bedrock.v440.Bedrock_v440;
import com.nukkitx.protocol.bedrock.v448.Bedrock_v448; import com.nukkitx.protocol.bedrock.v448.Bedrock_v448;
import org.geysermc.connector.GeyserConnector;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -40,15 +41,17 @@ public class BedrockProtocol {
* Default Bedrock codec that should act as a fallback. Should represent the latest available * Default Bedrock codec that should act as a fallback. Should represent the latest available
* release of the game that Geyser supports. * release of the game that Geyser supports.
*/ */
public static final BedrockPacketCodec DEFAULT_BEDROCK_CODEC = Bedrock_v440.V440_CODEC; public static final BedrockPacketCodec DEFAULT_BEDROCK_CODEC = Bedrock_v448.V448_CODEC;
/** /**
* A list of all supported Bedrock versions that can join Geyser * A list of all supported Bedrock versions that can join Geyser
*/ */
public static final List<BedrockPacketCodec> SUPPORTED_BEDROCK_CODECS = new ArrayList<>(); public static final List<BedrockPacketCodec> SUPPORTED_BEDROCK_CODECS = new ArrayList<>();
static { static {
if (!GeyserConnector.getInstance().getConfig().isExtendedWorldHeight()) {
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v440.V440_CODEC);
}
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC); SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC);
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v448.V448_CODEC);
} }
/** /**

Datei anzeigen

@ -137,6 +137,11 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
stackPacket.getExperiments().add(new ExperimentData("data_driven_items", true)); stackPacket.getExperiments().add(new ExperimentData("data_driven_items", true));
} }
if (session.getConnector().getConfig().isExtendedWorldHeight()) {
// Allow extended world height in the overworld to work
stackPacket.getExperiments().add(new ExperimentData("caves_and_cliffs", true));
}
session.sendUpstreamPacket(stackPacket); session.sendUpstreamPacket(stackPacket);
break; break;

Datei anzeigen

@ -1070,6 +1070,10 @@ public class GeyserSession implements CommandSender {
settings.setServerAuthoritativeBlockBreaking(false); settings.setServerAuthoritativeBlockBreaking(false);
startGamePacket.setPlayerMovementSettings(settings); startGamePacket.setPlayerMovementSettings(settings);
if (connector.getConfig().isExtendedWorldHeight()) {
startGamePacket.getExperiments().add(new ExperimentData("caves_and_cliffs", true));
}
upstream.sendPacket(startGamePacket); upstream.sendPacket(startGamePacket);
} }
@ -1191,11 +1195,7 @@ public class GeyserSession implements CommandSender {
* @param packet the bedrock packet from the NukkitX protocol lib * @param packet the bedrock packet from the NukkitX protocol lib
*/ */
public void sendUpstreamPacket(BedrockPacket packet) { public void sendUpstreamPacket(BedrockPacket packet) {
if (upstream != null) { upstream.sendPacket(packet);
upstream.sendPacket(packet);
} else {
connector.getLogger().debug("Tried to send upstream packet " + packet.getClass().getSimpleName() + " but the session was null");
}
} }
/** /**
@ -1204,11 +1204,7 @@ public class GeyserSession implements CommandSender {
* @param packet the bedrock packet from the NukkitX protocol lib * @param packet the bedrock packet from the NukkitX protocol lib
*/ */
public void sendUpstreamPacketImmediately(BedrockPacket packet) { public void sendUpstreamPacketImmediately(BedrockPacket packet) {
if (upstream != null) { upstream.sendPacketImmediately(packet);
upstream.sendPacketImmediately(packet);
} else {
connector.getLogger().debug("Tried to send upstream packet " + packet.getClass().getSimpleName() + " immediately but the session was null");
}
} }
/** /**

Datei anzeigen

@ -41,6 +41,7 @@ public class UpstreamSession {
private boolean initialized = false; private boolean initialized = false;
public void sendPacket(@NonNull BedrockPacket packet) { public void sendPacket(@NonNull BedrockPacket packet) {
System.out.println(packet);
if (!isClosed()) { if (!isClosed()) {
session.sendPacket(packet); session.sendPacket(packet);
} }

Datei anzeigen

@ -33,6 +33,7 @@ import com.nukkitx.math.vector.Vector3d;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket; import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket; import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.common.ChatColor; import org.geysermc.connector.common.ChatColor;
import org.geysermc.connector.entity.player.PlayerEntity; import org.geysermc.connector.entity.player.PlayerEntity;
import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.entity.type.EntityType;
@ -42,6 +43,14 @@ import org.geysermc.connector.network.translators.Translator;
@Translator(packet = MovePlayerPacket.class) @Translator(packet = MovePlayerPacket.class)
public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPacket> { public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPacket> {
/* The upper and lower bounds to check for the void floor that only exists in Bedrock */
private static final int BEDROCK_VOID_FLOOR_UPPER_Y;
private static final int BEDROCK_VOID_FLOOR_LOWER_Y;
static {
BEDROCK_VOID_FLOOR_LOWER_Y = GeyserConnector.getInstance().getConfig().isExtendedWorldHeight() ? -104 : -40;
BEDROCK_VOID_FLOOR_UPPER_Y = BEDROCK_VOID_FLOOR_LOWER_Y + 2;
}
@Override @Override
public void translate(MovePlayerPacket packet, GeyserSession session) { public void translate(MovePlayerPacket packet, GeyserSession session) {
@ -108,7 +117,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
if (notMovingUp) { if (notMovingUp) {
int floorY = position.getFloorY(); int floorY = position.getFloorY();
if (floorY <= -38 && floorY >= -40) { if (floorY <= BEDROCK_VOID_FLOOR_LOWER_Y && floorY >= BEDROCK_VOID_FLOOR_UPPER_Y) {
// Work around there being a floor at Y -40 and teleport the player below it // Work around there being a floor at Y -40 and teleport the player below it
// Moving from below Y -40 to above the void floor works fine // Moving from below Y -40 to above the void floor works fine
//TODO: This will need to be changed for 1.17 //TODO: This will need to be changed for 1.17

Datei anzeigen

@ -52,8 +52,15 @@ import java.util.function.BiFunction;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
public class BlockRegistryPopulator { public class BlockRegistryPopulator {
private static final ImmutableMap<String, BiFunction<String, NbtMapBuilder, String>> STATE_MAPPER = ImmutableMap.<String, BiFunction<String, NbtMapBuilder, String>>builder() private static final ImmutableMap<String, BiFunction<String, NbtMapBuilder, String>> STATE_MAPPER;
.put("1_17_0", (bedrockIdentifier, statesBuilder) -> {
private static final Object2IntMap<String> PALETTE_VERSIONS;
static {
ImmutableMap.Builder<String, BiFunction<String, NbtMapBuilder, String>> stateMapperBuilder = ImmutableMap.<String, BiFunction<String, NbtMapBuilder, String>>builder()
.put("1_17_10", (bedrockIdentifier, statesBuilder) -> null);
if (!GeyserConnector.getInstance().getConfig().isExtendedWorldHeight()) {
stateMapperBuilder.put("1_17_0", (bedrockIdentifier, statesBuilder) -> {
if (bedrockIdentifier.contains("candle")) { if (bedrockIdentifier.contains("candle")) {
// Replace candles with sea pickles or cake // Replace candles with sea pickles or cake
if (bedrockIdentifier.contains("cake")) { if (bedrockIdentifier.contains("cake")) {
@ -67,16 +74,16 @@ public class BlockRegistryPopulator {
} }
} }
return null; return null;
}) });
.put("1_17_10", (bedrockIdentifier, statesBuilder) -> null)
.build();
private static final Object2IntMap<String> PALETTE_VERSIONS = new Object2IntOpenHashMap<String>() {
{
put("1_17_0", Bedrock_v440.V440_CODEC.getProtocolVersion());
put("1_17_10", Bedrock_v448.V448_CODEC.getProtocolVersion());
} }
}; STATE_MAPPER = stateMapperBuilder.build();
PALETTE_VERSIONS = new Object2IntOpenHashMap<>();
if (!GeyserConnector.getInstance().getConfig().isExtendedWorldHeight()) {
PALETTE_VERSIONS.put("1_17_0", Bedrock_v440.V440_CODEC.getProtocolVersion());
}
PALETTE_VERSIONS.put("1_17_10", Bedrock_v448.V448_CODEC.getProtocolVersion());
}
/** /**
* Stores the raw blocks JSON until it is no longer needed. * Stores the raw blocks JSON until it is no longer needed.

Datei anzeigen

@ -57,9 +57,15 @@ import java.io.InputStream;
import java.util.*; import java.util.*;
public class ItemRegistryPopulator { public class ItemRegistryPopulator {
private static final Map<String, PaletteVersion> PALETTE_VERSIONS = new Object2ObjectOpenHashMap<String, PaletteVersion>(){ private static final Map<String, PaletteVersion> PALETTE_VERSIONS;
{
put("1_17_0", new PaletteVersion(Bedrock_v440.V440_CODEC.getProtocolVersion(), new Object2ObjectOpenHashMap<String, String>() { static {
PALETTE_VERSIONS = new Object2ObjectOpenHashMap<>();
if (GeyserConnector.getInstance().getConfig().isExtendedWorldHeight()) {
// Required to send the full palette or else the client crashes
PALETTE_VERSIONS.put("1_17_10.caves_and_cliffs", new PaletteVersion(Bedrock_v448.V448_CODEC.getProtocolVersion(), Collections.emptyMap()));
} else {
PALETTE_VERSIONS.put("1_17_0", new PaletteVersion(Bedrock_v440.V440_CODEC.getProtocolVersion(), new Object2ObjectOpenHashMap<String, String>() {
{ {
put("minecraft:candle", "minecraft:sea_pickle"); put("minecraft:candle", "minecraft:sea_pickle");
put("minecraft:white_candle", "minecraft:sea_pickle"); put("minecraft:white_candle", "minecraft:sea_pickle");
@ -80,9 +86,9 @@ public class ItemRegistryPopulator {
put("minecraft:black_candle", "minecraft:sea_pickle"); put("minecraft:black_candle", "minecraft:sea_pickle");
} }
})); }));
put("1_17_10", new PaletteVersion(Bedrock_v448.V448_CODEC.getProtocolVersion(), Collections.emptyMap())); PALETTE_VERSIONS.put("1_17_10", new PaletteVersion(Bedrock_v448.V448_CODEC.getProtocolVersion(), Collections.emptyMap()));
} }
}; }
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor

Datei anzeigen

@ -71,11 +71,11 @@ public class ChunkUtils {
/** /**
* The minimum height Bedrock Edition will accept. * The minimum height Bedrock Edition will accept.
*/ */
private static final int MINIMUM_ACCEPTED_HEIGHT = 0; private static final int MINIMUM_ACCEPTED_HEIGHT = GeyserConnector.getInstance().getConfig().isExtendedWorldHeight() ? -64 : 0;
/** /**
* The maximum height Bedrock Edition will accept. * The maximum chunk height Bedrock Edition will accept, from the lowest point to the highest.
*/ */
private static final int MAXIMUM_ACCEPTED_HEIGHT = 256; private static final int MAXIMUM_ACCEPTED_HEIGHT = GeyserConnector.getInstance().getConfig().isExtendedWorldHeight() ? 380 : 256;
private static int indexYZXtoXZY(int yzx) { private static int indexYZXtoXZY(int yzx) {
return (yzx >> 8) | (yzx & 0x0F0) | ((yzx & 0x00F) << 8); return (yzx >> 8) | (yzx & 0x0F0) | ((yzx & 0x00F) << 8);
@ -92,7 +92,7 @@ public class ChunkUtils {
BitSet pistonOrFlowerPaletteIds = new BitSet(); BitSet pistonOrFlowerPaletteIds = new BitSet();
for (int sectionY = 0; sectionY < javaSections.length; sectionY++) { for (int sectionY = 0; sectionY < javaSections.length; sectionY++) {
if (yOffset < 0 && sectionY < -yOffset) { if (yOffset < MINIMUM_ACCEPTED_HEIGHT && sectionY < -yOffset) {
// Ignore this chunk since it goes below the accepted height limit // Ignore this chunk since it goes below the accepted height limit
continue; continue;
} }

Datei anzeigen

@ -57,6 +57,11 @@ remote:
# This is designed to be used for forced hosts on proxies # This is designed to be used for forced hosts on proxies
forward-hostname: false forward-hostname: false
# Allows the overworld world height to be extended from 0 - 255 to -64 - 320. This option cannot be changed during a reload.
# 1.17.0-1.17.2 Bedrock clients cannot connect with this option enabled.
# Performance issues may occur for Bedrock clients as this is an experimental toggle on their end.
extended-world-height: false
# Floodgate uses encryption to ensure use from authorised sources. # Floodgate uses encryption to ensure use from authorised sources.
# This should point to the public key generated by Floodgate (BungeeCord, Spigot or Velocity) # This should point to the public key generated by Floodgate (BungeeCord, Spigot or Velocity)
# You can ignore this when not using Floodgate. # You can ignore this when not using Floodgate.