3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-05 07:40:11 +01:00

Feature: Add method to close forms in the API (#4957)

* Add closeForm api method

* Move version check to GameProtocol
Dieser Commit ist enthalten in:
chris 2024-08-12 23:29:00 +02:00 committet von GitHub
Ursprung bd73cbd243
Commit ce62824899
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
3 geänderte Dateien mit 23 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -60,6 +60,16 @@ public interface GeyserConnection extends Connection, CommandSource {
*/
@NonNull EntityData entities();
/**
* Returns the current ping of the connection.
*/
int ping();
/**
* Closes the currently open form on the client.
*/
void closeForm();
/**
* @param javaId the Java entity ID to look up.
* @return a {@link GeyserEntity} if present in this connection's entity tracker.
@ -132,9 +142,4 @@ public interface GeyserConnection extends Connection, CommandSource {
@Deprecated
@NonNull
Set<String> fogEffects();
/**
* Returns the current ping of the connection.
*/
int ping();
}

Datei anzeigen

@ -97,6 +97,10 @@ public final class GameProtocol {
return session.getUpstream().getProtocolVersion() < Bedrock_v685.CODEC.getProtocolVersion();
}
public static boolean isPre1_21_2(GeyserSession session) {
return session.getUpstream().getProtocolVersion() < Bedrock_v686.CODEC.getProtocolVersion();
}
/**
* Gets the {@link PacketCodec} for Minecraft: Java Edition.
*

Datei anzeigen

@ -79,6 +79,7 @@ import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.cloudburstmc.protocol.bedrock.packet.BiomeDefinitionListPacket;
import org.cloudburstmc.protocol.bedrock.packet.CameraPresetsPacket;
import org.cloudburstmc.protocol.bedrock.packet.ChunkRadiusUpdatedPacket;
import org.cloudburstmc.protocol.bedrock.packet.ClientboundCloseFormPacket;
import org.cloudburstmc.protocol.bedrock.packet.CraftingDataPacket;
import org.cloudburstmc.protocol.bedrock.packet.CreativeContentPacket;
import org.cloudburstmc.protocol.bedrock.packet.EmoteListPacket;
@ -140,6 +141,7 @@ import org.geysermc.geyser.item.type.BlockItem;
import org.geysermc.geyser.level.BedrockDimension;
import org.geysermc.geyser.level.JavaDimension;
import org.geysermc.geyser.level.physics.CollisionManager;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.network.netty.LocalSession;
import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.BlockMappings;
@ -2114,6 +2116,13 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
return (int) Math.floor(rakSessionCodec.getPing());
}
@Override
public void closeForm() {
if (!GameProtocol.isPre1_21_2(this)) {
sendUpstreamPacket(new ClientboundCloseFormPacket());
}
}
public void addCommandEnum(String name, String enums) {
softEnumPacket(name, SoftEnumUpdateType.ADD, enums);
}