mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Signs work in 1.19.80
This commit is contained in:
parent
51566a963f
commit
66ae88a2f6
3 changed files with 60 additions and 1 deletions
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue