Signs work in 1.19.80

This commit is contained in:
Camotoy 2023-04-21 12:56:30 -04:00
parent 51566a963f
commit 66ae88a2f6
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
3 changed files with 60 additions and 1 deletions

View file

@ -100,6 +100,10 @@ public final class GameProtocol {
return session.getUpstream().getProtocolVersion() >= Bedrock_v567.CODEC.getProtocolVersion();
}
public static boolean supports1_19_80(GeyserSession session) {
return session.getUpstream().getProtocolVersion() >= Bedrock_v582.CODEC.getProtocolVersion();
}
/**
* Gets the {@link PacketCodec} for Minecraft: Java Edition.
*

View file

@ -30,6 +30,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.Serverb
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.protocol.bedrock.packet.BlockEntityDataPacket;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
@ -43,7 +44,14 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator<BlockEnti
NbtMap tag = packet.getData();
String id = tag.getString("id");
if (id.equals("Sign")) {
String text = tag.getString("Text");
String text;
if (GameProtocol.supports1_19_80(session)) {
// The other side is called... you guessed it... BackText
text = tag.getCompound("FrontText")
.getString("Text");
} else {
text = tag.getString("Text");
}
// Note: as of 1.18.30, only one packet is sent from Bedrock when the sign is finished.
// Previous versions did not have this behavior.
StringBuilder newMessage = new StringBuilder();

View file

@ -0,0 +1,47 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.translator.protocol.java.level;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundOpenSignEditorPacket;
import org.cloudburstmc.protocol.bedrock.packet.OpenSignPacket;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
@Translator(packet = ClientboundOpenSignEditorPacket.class)
public class JavaOpenSignEditorTranslator extends PacketTranslator<ClientboundOpenSignEditorPacket> {
@Override
public void translate(GeyserSession session, ClientboundOpenSignEditorPacket packet) {
if (GameProtocol.supports1_19_80(session)) {
OpenSignPacket openSignPacket = new OpenSignPacket();
openSignPacket.setPosition(packet.getPosition());
openSignPacket.setFrontSide(true); // Will be remedied in 1.20
session.sendUpstreamPacket(openSignPacket);
}
}
}