Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Remove legacy 1.19.2x Bedrock code
Dieser Commit ist enthalten in:
Ursprung
d7c6865912
Commit
acb25b0c99
@ -96,10 +96,6 @@ public final class GameProtocol {
|
||||
|
||||
/* Bedrock convenience methods to gatekeep features and easily remove the check on version removal */
|
||||
|
||||
public static boolean supports1_19_30(GeyserSession session) {
|
||||
return session.getUpstream().getProtocolVersion() >= Bedrock_v554.V554_CODEC.getProtocolVersion();
|
||||
}
|
||||
|
||||
public static boolean supports1_19_50(GeyserSession session) {
|
||||
return session.getUpstream().getProtocolVersion() >= Bedrock_v560.V560_CODEC.getProtocolVersion();
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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.bedrock;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.data.AdventureSetting;
|
||||
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
|
||||
@Translator(packet = AdventureSettingsPacket.class)
|
||||
public class BedrockAdventureSettingsTranslator extends PacketTranslator<AdventureSettingsPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, AdventureSettingsPacket packet) {
|
||||
boolean isFlying = packet.getSettings().contains(AdventureSetting.FLYING);
|
||||
BedrockRequestAbilityTranslator.handle(session, isFlying);
|
||||
}
|
||||
}
|
@ -30,7 +30,6 @@ import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.Server
|
||||
import com.nukkitx.protocol.bedrock.data.Ability;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.packet.RequestAbilityPacket;
|
||||
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,31 +42,22 @@ public class BedrockRequestAbilityTranslator extends PacketTranslator<RequestAbi
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, RequestAbilityPacket packet) {
|
||||
// Gatekeep to 1.19.30 so older versions don't fire twice
|
||||
if (!GameProtocol.supports1_19_30(session)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet.getAbility() == Ability.FLYING) {
|
||||
handle(session, packet.isBoolValue());
|
||||
}
|
||||
}
|
||||
boolean isFlying = packet.isBoolValue();
|
||||
if (!isFlying && session.getGameMode() == GameMode.SPECTATOR) {
|
||||
// We should always be flying in spectator mode
|
||||
session.sendAdventureSettings();
|
||||
return;
|
||||
} else if (isFlying && session.getPlayerEntity().getFlag(EntityFlag.SWIMMING) && session.getCollisionManager().isPlayerInWater()) {
|
||||
// As of 1.18.1, Java Edition cannot fly while in water, but it can fly while crawling
|
||||
// If this isn't present, swimming on a 1.13.2 server and then attempting to fly will put you into a flying/swimming state that is invalid on JE
|
||||
session.sendAdventureSettings();
|
||||
return;
|
||||
}
|
||||
|
||||
//FIXME remove after pre-1.19.30 support is dropped and merge into main method
|
||||
static void handle(GeyserSession session, boolean isFlying) {
|
||||
if (!isFlying && session.getGameMode() == GameMode.SPECTATOR) {
|
||||
// We should always be flying in spectator mode
|
||||
session.sendAdventureSettings();
|
||||
return;
|
||||
} else if (isFlying && session.getPlayerEntity().getFlag(EntityFlag.SWIMMING) && session.getCollisionManager().isPlayerInWater()) {
|
||||
// As of 1.18.1, Java Edition cannot fly while in water, but it can fly while crawling
|
||||
// If this isn't present, swimming on a 1.13.2 server and then attempting to fly will put you into a flying/swimming state that is invalid on JE
|
||||
session.sendAdventureSettings();
|
||||
return;
|
||||
session.setFlying(isFlying);
|
||||
ServerboundPlayerAbilitiesPacket abilitiesPacket = new ServerboundPlayerAbilitiesPacket(isFlying);
|
||||
session.sendDownstreamPacket(abilitiesPacket);
|
||||
}
|
||||
|
||||
session.setFlying(isFlying);
|
||||
ServerboundPlayerAbilitiesPacket abilitiesPacket = new ServerboundPlayerAbilitiesPacket(isFlying);
|
||||
session.sendDownstreamPacket(abilitiesPacket);
|
||||
}
|
||||
}
|
||||
|
@ -47,4 +47,9 @@ public class JavaKeepAliveTranslator extends PacketTranslator<ClientboundKeepAli
|
||||
latencyPacket.setTimestamp(packet.getPingId() * 1000);
|
||||
session.sendUpstreamPacket(latencyPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecuteInEventLoop() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,6 @@ import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCu
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||
import com.nukkitx.protocol.bedrock.data.GameRuleData;
|
||||
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
|
||||
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
@ -107,11 +105,6 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
||||
session.getUpstream().sendPostStartGamePackets();
|
||||
}
|
||||
|
||||
AdventureSettingsPacket bedrockPacket = new AdventureSettingsPacket();
|
||||
bedrockPacket.setUniqueEntityId(session.getPlayerEntity().getGeyserId());
|
||||
bedrockPacket.setPlayerPermission(PlayerPermission.MEMBER);
|
||||
session.sendUpstreamPacket(bedrockPacket);
|
||||
|
||||
if (!needsSpawnPacket) {
|
||||
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
||||
playerGameTypePacket.setGamemode(packet.getGameMode().ordinal());
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren