mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Start of extended world height support
This commit is contained in:
parent
b2619fa7c7
commit
c7d4130a44
13 changed files with 9570 additions and 33 deletions
|
@ -45,6 +45,8 @@ public interface GeyserConfiguration {
|
|||
|
||||
Map<String, ? extends IUserAuthenticationInfo> getUserAuths();
|
||||
|
||||
boolean isExtendedWorldHeight();
|
||||
|
||||
boolean isCommandSuggestions();
|
||||
|
||||
@JsonIgnore
|
||||
|
|
|
@ -55,6 +55,9 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
|
|||
private BedrockConfiguration bedrock = new BedrockConfiguration();
|
||||
private RemoteConfiguration remote = new RemoteConfiguration();
|
||||
|
||||
@JsonProperty("extended-world-height")
|
||||
private boolean extendedWorldHeight = false;
|
||||
|
||||
@JsonProperty("floodgate-key-file")
|
||||
private String floodgateKeyFile = "public-key.pem";
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ package org.geysermc.connector.network;
|
|||
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
||||
import com.nukkitx.protocol.bedrock.v440.Bedrock_v440;
|
||||
import com.nukkitx.protocol.bedrock.v448.Bedrock_v448;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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
|
||||
* 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
|
||||
*/
|
||||
public static final List<BedrockPacketCodec> SUPPORTED_BEDROCK_CODECS = new ArrayList<>();
|
||||
|
||||
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(Bedrock_v448.V448_CODEC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -137,6 +137,11 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
|||
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);
|
||||
break;
|
||||
|
||||
|
|
|
@ -1070,6 +1070,10 @@ public class GeyserSession implements CommandSender {
|
|||
settings.setServerAuthoritativeBlockBreaking(false);
|
||||
startGamePacket.setPlayerMovementSettings(settings);
|
||||
|
||||
if (connector.getConfig().isExtendedWorldHeight()) {
|
||||
startGamePacket.getExperiments().add(new ExperimentData("caves_and_cliffs", true));
|
||||
}
|
||||
|
||||
upstream.sendPacket(startGamePacket);
|
||||
}
|
||||
|
||||
|
@ -1191,11 +1195,7 @@ public class GeyserSession implements CommandSender {
|
|||
* @param packet the bedrock packet from the NukkitX protocol lib
|
||||
*/
|
||||
public void sendUpstreamPacket(BedrockPacket packet) {
|
||||
if (upstream != null) {
|
||||
upstream.sendPacket(packet);
|
||||
} else {
|
||||
connector.getLogger().debug("Tried to send upstream packet " + packet.getClass().getSimpleName() + " but the session was null");
|
||||
}
|
||||
upstream.sendPacket(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1204,11 +1204,7 @@ public class GeyserSession implements CommandSender {
|
|||
* @param packet the bedrock packet from the NukkitX protocol lib
|
||||
*/
|
||||
public void sendUpstreamPacketImmediately(BedrockPacket packet) {
|
||||
if (upstream != null) {
|
||||
upstream.sendPacketImmediately(packet);
|
||||
} else {
|
||||
connector.getLogger().debug("Tried to send upstream packet " + packet.getClass().getSimpleName() + " immediately but the session was null");
|
||||
}
|
||||
upstream.sendPacketImmediately(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,6 +41,7 @@ public class UpstreamSession {
|
|||
private boolean initialized = false;
|
||||
|
||||
public void sendPacket(@NonNull BedrockPacket packet) {
|
||||
System.out.println(packet);
|
||||
if (!isClosed()) {
|
||||
session.sendPacket(packet);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.nukkitx.math.vector.Vector3d;
|
|||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.common.ChatColor;
|
||||
import org.geysermc.connector.entity.player.PlayerEntity;
|
||||
import org.geysermc.connector.entity.type.EntityType;
|
||||
|
@ -42,6 +43,14 @@ import org.geysermc.connector.network.translators.Translator;
|
|||
|
||||
@Translator(packet = MovePlayerPacket.class)
|
||||
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
|
||||
public void translate(MovePlayerPacket packet, GeyserSession session) {
|
||||
|
@ -108,7 +117,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
|||
|
||||
if (notMovingUp) {
|
||||
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
|
||||
// Moving from below Y -40 to above the void floor works fine
|
||||
//TODO: This will need to be changed for 1.17
|
||||
|
|
|
@ -52,8 +52,15 @@ import java.util.function.BiFunction;
|
|||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class BlockRegistryPopulator {
|
||||
private static final ImmutableMap<String, BiFunction<String, NbtMapBuilder, String>> STATE_MAPPER = ImmutableMap.<String, BiFunction<String, NbtMapBuilder, String>>builder()
|
||||
.put("1_17_0", (bedrockIdentifier, statesBuilder) -> {
|
||||
private static final ImmutableMap<String, BiFunction<String, NbtMapBuilder, String>> STATE_MAPPER;
|
||||
|
||||
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")) {
|
||||
// Replace candles with sea pickles or cake
|
||||
if (bedrockIdentifier.contains("cake")) {
|
||||
|
@ -67,16 +74,16 @@ public class BlockRegistryPopulator {
|
|||
}
|
||||
}
|
||||
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.
|
||||
|
|
|
@ -57,9 +57,15 @@ import java.io.InputStream;
|
|||
import java.util.*;
|
||||
|
||||
public class ItemRegistryPopulator {
|
||||
private static final Map<String, PaletteVersion> PALETTE_VERSIONS = new Object2ObjectOpenHashMap<String, PaletteVersion>(){
|
||||
{
|
||||
put("1_17_0", new PaletteVersion(Bedrock_v440.V440_CODEC.getProtocolVersion(), new Object2ObjectOpenHashMap<String, String>() {
|
||||
private static final Map<String, PaletteVersion> PALETTE_VERSIONS;
|
||||
|
||||
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:white_candle", "minecraft:sea_pickle");
|
||||
|
@ -80,9 +86,9 @@ public class ItemRegistryPopulator {
|
|||
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
|
||||
@AllArgsConstructor
|
||||
|
|
|
@ -71,11 +71,11 @@ public class ChunkUtils {
|
|||
/**
|
||||
* 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) {
|
||||
return (yzx >> 8) | (yzx & 0x0F0) | ((yzx & 0x00F) << 8);
|
||||
|
@ -92,7 +92,7 @@ public class ChunkUtils {
|
|||
BitSet pistonOrFlowerPaletteIds = new BitSet();
|
||||
|
||||
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
|
||||
continue;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -57,6 +57,11 @@ remote:
|
|||
# This is designed to be used for forced hosts on proxies
|
||||
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.
|
||||
# This should point to the public key generated by Floodgate (BungeeCord, Spigot or Velocity)
|
||||
# You can ignore this when not using Floodgate.
|
||||
|
|
Loading…
Reference in a new issue