Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 22:40:18 +01:00
Merge branch 'master' into feature/viaproxy-platform
Dieser Commit ist enthalten in:
Commit
2b5b91ad2c
@ -14,7 +14,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t
|
||||
|
||||
Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have joined us here!
|
||||
|
||||
### Currently supporting Minecraft Bedrock 1.20.0 - 1.20.32 and Minecraft Java 1.20.2
|
||||
### Currently supporting Minecraft Bedrock 1.20.0 - 1.20.40 and Minecraft Java 1.20.2
|
||||
|
||||
## Setting Up
|
||||
Take a look [here](https://wiki.geysermc.org/geyser/setup/) for how to set up Geyser.
|
||||
|
@ -77,7 +77,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
||||
// Copied from ViaVersion.
|
||||
// https://github.com/ViaVersion/ViaVersion/blob/b8072aad86695cc8ec6f5e4103e43baf3abf6cc5/bungee/src/main/java/us/myles/ViaVersion/BungeePlugin.java#L43
|
||||
try {
|
||||
ProtocolConstants.class.getField("MINECRAFT_1_19_3");
|
||||
ProtocolConstants.class.getField("MINECRAFT_1_20_2");
|
||||
} catch (NoSuchFieldException e) {
|
||||
getLogger().warning(" / \\");
|
||||
getLogger().warning(" / \\");
|
||||
@ -111,11 +111,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Remove this in like a year
|
||||
if (getProxy().getPluginManager().getPlugin("floodgate-bungee") != null) {
|
||||
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.outdated", "https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Force-disable query if enabled, or else Geyser won't enable
|
||||
for (ListenerInfo info : getProxy().getConfig().getListeners()) {
|
||||
|
@ -5,9 +5,10 @@ plugins {
|
||||
id("com.modrinth.minotaur") version "2.+"
|
||||
}
|
||||
|
||||
java {
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
indra {
|
||||
javaVersions {
|
||||
target(17)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -114,16 +114,6 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
||||
|
||||
this.geyser = GeyserImpl.load(PlatformType.VELOCITY, this);
|
||||
|
||||
// Remove this in like a year
|
||||
try {
|
||||
// Should only exist on 1.0
|
||||
Class.forName("org.geysermc.floodgate.FloodgateAPI");
|
||||
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.outdated",
|
||||
"https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/"));
|
||||
return;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private void postStartup() {
|
||||
|
@ -55,19 +55,20 @@ public final class AesKeyProducer implements KeyProducer {
|
||||
}
|
||||
|
||||
private SecureRandom secureRandom() throws NoSuchAlgorithmException {
|
||||
// use Windows-PRNG for windows (default impl is SHA1PRNG)
|
||||
if (System.getProperty("os.name").startsWith("Windows")) {
|
||||
return SecureRandom.getInstance("Windows-PRNG");
|
||||
} else {
|
||||
try {
|
||||
try {
|
||||
// use Windows-PRNG for windows (default impl is SHA1PRNG)
|
||||
if (System.getProperty("os.name").startsWith("Windows")) {
|
||||
return SecureRandom.getInstance("Windows-PRNG");
|
||||
} else {
|
||||
// NativePRNG (which should be the default on unix-systems) can still block your
|
||||
// system. Even though it isn't as bad as NativePRNGBlocking, we still try to
|
||||
// prevent that if possible
|
||||
return SecureRandom.getInstance("NativePRNGNonBlocking");
|
||||
} catch (NoSuchAlgorithmException ignored) {
|
||||
// at this point we just have to go with the default impl even if it blocks
|
||||
return new SecureRandom();
|
||||
|
||||
}
|
||||
} catch (NoSuchAlgorithmException ignored) {
|
||||
// Fall back to the default impl as we couldn't load any others
|
||||
return new SecureRandom();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class StatisticsCommand extends GeyserCommand {
|
||||
|
||||
session.setWaitingForStatistics(true);
|
||||
ServerboundClientCommandPacket ServerboundClientCommandPacket = new ServerboundClientCommandPacket(ClientCommand.STATS);
|
||||
session.sendDownstreamPacket(ServerboundClientCommandPacket);
|
||||
session.sendDownstreamGamePacket(ServerboundClientCommandPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,7 +68,7 @@ public class InteractionEntity extends Entity {
|
||||
animatePacket.setAction(AnimatePacket.Action.SWING_ARM);
|
||||
session.sendUpstreamPacket(animatePacket);
|
||||
|
||||
session.sendDownstreamPacket(new ServerboundSwingPacket(hand));
|
||||
session.sendDownstreamGamePacket(new ServerboundSwingPacket(hand));
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -43,9 +43,9 @@ import java.io.Reader;
|
||||
import java.nio.file.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class GeyserExtensionLoader extends ExtensionLoader {
|
||||
@ -148,47 +148,46 @@ public class GeyserExtensionLoader extends ExtensionLoader {
|
||||
Map<String, GeyserExtensionContainer> loadedExtensions = new LinkedHashMap<>();
|
||||
|
||||
Pattern[] extensionFilters = this.extensionFilters();
|
||||
try (Stream<Path> entries = Files.walk(extensionsDirectory)) {
|
||||
entries.forEach(path -> {
|
||||
if (Files.isDirectory(path)) {
|
||||
List<Path> extensionPaths = Files.walk(extensionsDirectory).toList();
|
||||
extensionPaths.forEach(path -> {
|
||||
if (Files.isDirectory(path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Pattern filter : extensionFilters) {
|
||||
if (!filter.matcher(path.getFileName().toString()).matches()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
GeyserExtensionDescription description = this.extensionDescription(path);
|
||||
|
||||
String name = description.name();
|
||||
String id = description.id();
|
||||
if (extensions.containsKey(id) || extensionManager.extension(id) != null) {
|
||||
GeyserImpl.getInstance().getLogger().warning(GeyserLocale.getLocaleStringLog("geyser.extensions.load.duplicate", name, path.toString()));
|
||||
return;
|
||||
}
|
||||
|
||||
for (Pattern filter : extensionFilters) {
|
||||
if (!filter.matcher(path.getFileName().toString()).matches()) {
|
||||
return;
|
||||
}
|
||||
// Completely different API version
|
||||
if (description.majorApiVersion() != Geyser.api().majorApiVersion()) {
|
||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, description.apiVersion()));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
GeyserExtensionDescription description = this.extensionDescription(path);
|
||||
|
||||
String name = description.name();
|
||||
String id = description.id();
|
||||
if (extensions.containsKey(id) || extensionManager.extension(id) != null) {
|
||||
GeyserImpl.getInstance().getLogger().warning(GeyserLocale.getLocaleStringLog("geyser.extensions.load.duplicate", name, path.toString()));
|
||||
return;
|
||||
}
|
||||
|
||||
// Completely different API version
|
||||
if (description.majorApiVersion() != Geyser.api().majorApiVersion()) {
|
||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, description.apiVersion()));
|
||||
return;
|
||||
}
|
||||
|
||||
// If the extension requires new API features, being backwards compatible
|
||||
if (description.minorApiVersion() > Geyser.api().minorApiVersion()) {
|
||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, description.apiVersion()));
|
||||
return;
|
||||
}
|
||||
|
||||
extensions.put(id, path);
|
||||
loadedExtensions.put(id, this.loadExtension(path, description));
|
||||
} catch (Exception e) {
|
||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_with_name", path.getFileName(), path.toAbsolutePath()), e);
|
||||
// If the extension requires new API features, being backwards compatible
|
||||
if (description.minorApiVersion() > Geyser.api().minorApiVersion()) {
|
||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, description.apiVersion()));
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
extensions.put(id, path);
|
||||
loadedExtensions.put(id, this.loadExtension(path, description));
|
||||
} catch (Exception e) {
|
||||
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_with_name", path.getFileName(), path.toAbsolutePath()), e);
|
||||
}
|
||||
});
|
||||
|
||||
for (GeyserExtensionContainer container : loadedExtensions.values()) {
|
||||
this.extensionContainers.put(container.extension(), container);
|
||||
|
@ -82,14 +82,14 @@ public class AnvilContainer extends Container {
|
||||
correctRename = plainNewName;
|
||||
// Java Edition sends a packet every time an item is renamed even slightly in GUI. Fortunately, this works out for us now
|
||||
ServerboundRenameItemPacket renameItemPacket = new ServerboundRenameItemPacket(plainNewName);
|
||||
session.sendDownstreamPacket(renameItemPacket);
|
||||
session.sendDownstreamGamePacket(renameItemPacket);
|
||||
} else {
|
||||
// Restore formatting for item since we're not renaming
|
||||
correctRename = MessageTranslator.convertMessageLenient(originalName);
|
||||
// Java Edition sends the original custom name when not renaming,
|
||||
// if there isn't a custom name an empty string is sent
|
||||
ServerboundRenameItemPacket renameItemPacket = new ServerboundRenameItemPacket(plainOriginalName);
|
||||
session.sendDownstreamPacket(renameItemPacket);
|
||||
session.sendDownstreamGamePacket(renameItemPacket);
|
||||
}
|
||||
|
||||
useJavaLevelCost = false;
|
||||
|
@ -152,7 +152,7 @@ public final class ClickPlan {
|
||||
changedItems
|
||||
);
|
||||
|
||||
session.sendDownstreamPacket(clickPacket);
|
||||
session.sendDownstreamGamePacket(clickPacket);
|
||||
}
|
||||
|
||||
session.getPlayerInventory().setCursor(simulatedCursor, session);
|
||||
|
@ -120,7 +120,7 @@ public class AnvilInventoryUpdater extends InventoryUpdater {
|
||||
// does not result in a FilterTextPacket
|
||||
String originalName = MessageTranslator.convertToPlainTextLenient(ItemUtils.getCustomName(input.getNbt()), session.locale());
|
||||
ServerboundRenameItemPacket renameItemPacket = new ServerboundRenameItemPacket(originalName);
|
||||
session.sendDownstreamPacket(renameItemPacket);
|
||||
session.sendDownstreamGamePacket(renameItemPacket);
|
||||
|
||||
anvilContainer.setNewName(null);
|
||||
}
|
||||
|
@ -173,8 +173,8 @@ public final class BlockStateValues {
|
||||
}
|
||||
|
||||
if (javaId.contains("wall_skull") || javaId.contains("wall_head")) {
|
||||
String direction = javaId.substring(javaId.lastIndexOf("facing=") + 7);
|
||||
int rotation = switch (direction.substring(0, direction.length() - 1)) {
|
||||
String direction = javaId.substring(javaId.lastIndexOf("facing=") + 7, javaId.lastIndexOf("powered=") - 1);
|
||||
int rotation = switch (direction) {
|
||||
case "north" -> 180;
|
||||
case "west" -> 90;
|
||||
case "east" -> 270;
|
||||
|
@ -30,19 +30,18 @@ import org.cloudburstmc.protocol.common.util.Preconditions;
|
||||
|
||||
public class GeyserChunkSection {
|
||||
|
||||
// As of at least 1.19.80
|
||||
private static final int CHUNK_SECTION_VERSION = 9;
|
||||
// Temporary reversion to v8 as it reduces the frequnecy of https://github.com/GeyserMC/Geyser/issues/4240
|
||||
// This does not fully resolve the issue so a better solution is still needed
|
||||
private static final int CHUNK_SECTION_VERSION = 8;
|
||||
|
||||
private final BlockStorage[] storage;
|
||||
private final int sectionY;
|
||||
|
||||
public GeyserChunkSection(int airBlockId, int sectionY) {
|
||||
this(new BlockStorage[]{new BlockStorage(airBlockId), new BlockStorage(airBlockId)}, sectionY);
|
||||
public GeyserChunkSection(int airBlockId) {
|
||||
this(new BlockStorage[]{new BlockStorage(airBlockId), new BlockStorage(airBlockId)});
|
||||
}
|
||||
|
||||
public GeyserChunkSection(BlockStorage[] storage, int sectionY) {
|
||||
public GeyserChunkSection(BlockStorage[] storage) {
|
||||
this.storage = storage;
|
||||
this.sectionY = sectionY;
|
||||
}
|
||||
|
||||
public int getFullBlock(int x, int y, int z, int layer) {
|
||||
@ -61,7 +60,6 @@ public class GeyserChunkSection {
|
||||
buffer.writeByte(CHUNK_SECTION_VERSION);
|
||||
buffer.writeByte(this.storage.length);
|
||||
// Required for chunk version 9+
|
||||
buffer.writeByte(this.sectionY);
|
||||
for (BlockStorage blockStorage : this.storage) {
|
||||
blockStorage.writeToNetwork(buffer);
|
||||
}
|
||||
@ -88,12 +86,12 @@ public class GeyserChunkSection {
|
||||
return true;
|
||||
}
|
||||
|
||||
public GeyserChunkSection copy(int sectionY) {
|
||||
public GeyserChunkSection copy() {
|
||||
BlockStorage[] storage = new BlockStorage[this.storage.length];
|
||||
for (int i = 0; i < storage.length; i++) {
|
||||
storage[i] = this.storage[i].copy();
|
||||
}
|
||||
return new GeyserChunkSection(storage, sectionY);
|
||||
return new GeyserChunkSection(storage);
|
||||
}
|
||||
|
||||
public static int blockPosition(int x, int y, int z) {
|
||||
|
@ -31,6 +31,7 @@ import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v594.Bedrock_v594;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v618.Bedrock_v618;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v622.Bedrock_v622;
|
||||
import org.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
@ -46,9 +47,7 @@ public final class GameProtocol {
|
||||
* Default Bedrock codec that should act as a fallback. Should represent the latest available
|
||||
* release of the game that Geyser supports.
|
||||
*/
|
||||
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = Bedrock_v618.CODEC.toBuilder()
|
||||
.minecraftVersion("1.20.31")
|
||||
.build();
|
||||
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = Bedrock_v622.CODEC;
|
||||
|
||||
/**
|
||||
* A list of all supported Bedrock versions that can join Geyser
|
||||
@ -68,9 +67,10 @@ public final class GameProtocol {
|
||||
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v594.CODEC.toBuilder()
|
||||
.minecraftVersion("1.20.10/1.20.15")
|
||||
.build());
|
||||
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC.toBuilder()
|
||||
.minecraftVersion("1.20.30/1.20.31")
|
||||
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v618.CODEC.toBuilder()
|
||||
.minecraftVersion("1.20.30/1.20.32")
|
||||
.build());
|
||||
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,6 +110,8 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
||||
} else if (protocolVersion < GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
|
||||
session.disconnect(GeyserLocale.getLocaleStringLog("geyser.network.outdated.client", supportedVersions));
|
||||
return false;
|
||||
} else {
|
||||
throw new IllegalStateException("Default codec of protocol version " + protocolVersion + " should have been found");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,10 +171,12 @@ public final class GeyserServer {
|
||||
|
||||
GeyserServerInitializer serverInitializer = new GeyserServerInitializer(this.geyser);
|
||||
playerGroup = serverInitializer.getEventLoopGroup();
|
||||
this.geyser.getLogger().debug("Setting MTU to " + this.geyser.getConfig().getMtu());
|
||||
return new ServerBootstrap()
|
||||
.channelFactory(RakChannelFactory.server(TRANSPORT.datagramChannel()))
|
||||
.group(group)
|
||||
.option(RakChannelOption.RAK_HANDLE_PING, true)
|
||||
.option(RakChannelOption.RAK_MAX_MTU, this.geyser.getConfig().getMtu())
|
||||
.childHandler(serverInitializer);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ import org.cloudburstmc.protocol.bedrock.data.inventory.crafting.PotionMixData;
|
||||
import org.geysermc.geyser.inventory.item.Potion;
|
||||
import org.geysermc.geyser.item.Items;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.network.GameProtocol;
|
||||
import org.geysermc.geyser.registry.Registries;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.registry.type.ItemMappings;
|
||||
@ -115,7 +114,7 @@ public class PotionMixRegistryLoader implements RegistryLoader<Object, Int2Objec
|
||||
}
|
||||
|
||||
private static ItemMapping getNonNull(ItemMappings mappings, Item javaItem) {
|
||||
ItemMapping itemMapping = Registries.ITEMS.forVersion(GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()).getMapping(javaItem);
|
||||
ItemMapping itemMapping = mappings.getMapping(javaItem);
|
||||
if (itemMapping == null)
|
||||
throw new NullPointerException("No item entry exists for java identifier: " + javaItem.javaIdentifier());
|
||||
|
||||
|
@ -36,11 +36,13 @@ import it.unimi.dsi.fastutil.objects.*;
|
||||
import org.cloudburstmc.blockstateupdater.BlockStateUpdater;
|
||||
import org.cloudburstmc.blockstateupdater.BlockStateUpdater_1_20_10;
|
||||
import org.cloudburstmc.blockstateupdater.BlockStateUpdater_1_20_30;
|
||||
import org.cloudburstmc.blockstateupdater.BlockStateUpdater_1_20_40;
|
||||
import org.cloudburstmc.blockstateupdater.util.tagupdater.CompoundTagUpdaterContext;
|
||||
import org.cloudburstmc.nbt.*;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v594.Bedrock_v594;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v618.Bedrock_v618;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v622.Bedrock_v622;
|
||||
import org.cloudburstmc.protocol.bedrock.data.BlockPropertyData;
|
||||
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
@ -117,11 +119,13 @@ public final class BlockRegistryPopulator {
|
||||
private static void registerBedrockBlocks() {
|
||||
Remapper mapper594 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE);
|
||||
Remapper mapper618 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE, BlockStateUpdater_1_20_30.INSTANCE);
|
||||
Remapper mapper622 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE, BlockStateUpdater_1_20_30.INSTANCE, BlockStateUpdater_1_20_40.INSTANCE);
|
||||
|
||||
var blockMappers = ImmutableMap.<ObjectIntPair<String>, Remapper>builder()
|
||||
.put(ObjectIntPair.of("1_20_0", Bedrock_v589.CODEC.getProtocolVersion()), tag -> tag)
|
||||
.put(ObjectIntPair.of("1_20_10", Bedrock_v594.CODEC.getProtocolVersion()), mapper594)
|
||||
.put(ObjectIntPair.of("1_20_30", Bedrock_v618.CODEC.getProtocolVersion()), mapper618)
|
||||
.put(ObjectIntPair.of("1_20_40", Bedrock_v622.CODEC.getProtocolVersion()), mapper622)
|
||||
.build();
|
||||
|
||||
// We can keep this strong as nothing should be garbage collected
|
||||
|
@ -41,6 +41,7 @@ import org.cloudburstmc.nbt.NbtType;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v594.Bedrock_v594;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v618.Bedrock_v618;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.v622.Bedrock_v622;
|
||||
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
|
||||
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
|
||||
@ -116,6 +117,7 @@ public class ItemRegistryPopulator {
|
||||
paletteVersions.add(new PaletteVersion("1_20_0", Bedrock_v589.CODEC.getProtocolVersion()));
|
||||
paletteVersions.add(new PaletteVersion("1_20_10", Bedrock_v594.CODEC.getProtocolVersion(), Collections.emptyMap(), remapper594));
|
||||
paletteVersions.add(new PaletteVersion("1_20_30", Bedrock_v618.CODEC.getProtocolVersion(), Collections.emptyMap(), remapper618));
|
||||
paletteVersions.add(new PaletteVersion("1_20_40", Bedrock_v622.CODEC.getProtocolVersion(), Collections.emptyMap(), remapper618)); // NO item changes between 1.20.30 and 1.20.40
|
||||
|
||||
GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap();
|
||||
|
||||
|
@ -1135,7 +1135,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||
if (position != null) {
|
||||
ServerboundMovePlayerPosPacket packet = new ServerboundMovePlayerPosPacket(playerEntity.isOnGround(),
|
||||
position.getX(), position.getY(), position.getZ());
|
||||
sendDownstreamPacket(packet);
|
||||
sendDownstreamGamePacket(packet);
|
||||
}
|
||||
lastMovementTimestamp = System.currentTimeMillis();
|
||||
}
|
||||
@ -1317,7 +1317,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||
return false;
|
||||
}
|
||||
|
||||
sendDownstreamPacket(useItemPacket);
|
||||
sendDownstreamGamePacket(useItemPacket);
|
||||
playerEntity.setFlag(EntityFlag.BLOCKING, true);
|
||||
// Metadata should be updated later
|
||||
return true;
|
||||
@ -1351,7 +1351,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||
if (playerEntity.getFlag(EntityFlag.BLOCKING)) {
|
||||
ServerboundPlayerActionPacket releaseItemPacket = new ServerboundPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM,
|
||||
Vector3i.ZERO, Direction.DOWN, 0);
|
||||
sendDownstreamPacket(releaseItemPacket);
|
||||
sendDownstreamGamePacket(releaseItemPacket);
|
||||
playerEntity.setFlag(EntityFlag.BLOCKING, false);
|
||||
return true;
|
||||
}
|
||||
@ -1361,7 +1361,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||
public void requestOffhandSwap() {
|
||||
ServerboundPlayerActionPacket swapHandsPacket = new ServerboundPlayerActionPacket(PlayerAction.SWAP_HANDS, Vector3i.ZERO,
|
||||
Direction.DOWN, 0);
|
||||
sendDownstreamPacket(swapHandsPacket);
|
||||
sendDownstreamGamePacket(swapHandsPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1396,14 +1396,14 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||
* Sends a chat message to the Java server.
|
||||
*/
|
||||
public void sendChat(String message) {
|
||||
sendDownstreamPacket(new ServerboundChatPacket(message, Instant.now().toEpochMilli(), 0L, null, 0, new BitSet()));
|
||||
sendDownstreamGamePacket(new ServerboundChatPacket(message, Instant.now().toEpochMilli(), 0L, null, 0, new BitSet()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a command to the Java server.
|
||||
*/
|
||||
public void sendCommand(String command) {
|
||||
sendDownstreamPacket(new ServerboundChatCommandPacket(command, Instant.now().toEpochMilli(), 0L, Collections.emptyList(), 0, new BitSet()));
|
||||
sendDownstreamGamePacket(new ServerboundChatCommandPacket(command, Instant.now().toEpochMilli(), 0L, Collections.emptyList(), 0, new BitSet()));
|
||||
}
|
||||
|
||||
public void setServerRenderDistance(int renderDistance) {
|
||||
@ -1575,6 +1575,39 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||
upstream.sendPacketImmediately(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a packet to the remote server if in the game state.
|
||||
*
|
||||
* @param packet the java edition packet from MCProtocolLib
|
||||
*/
|
||||
public void sendDownstreamGamePacket(Packet packet) {
|
||||
sendDownstreamPacket(packet, ProtocolState.GAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a packet to the remote server if in the login state.
|
||||
*
|
||||
* @param packet the java edition packet from MCProtocolLib
|
||||
*/
|
||||
public void sendDownstreamLoginPacket(Packet packet) {
|
||||
sendDownstreamPacket(packet, ProtocolState.LOGIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a packet to the remote server if in the specified state.
|
||||
*
|
||||
* @param packet the java edition packet from MCProtocolLib
|
||||
* @param intendedState the state the client should be in
|
||||
*/
|
||||
public void sendDownstreamPacket(Packet packet, ProtocolState intendedState) {
|
||||
if (protocol.getState() != intendedState) {
|
||||
geyser.getLogger().debug("Tried to send " + packet.getClass().getSimpleName() + " packet while not in " + intendedState.name() + " state");
|
||||
return;
|
||||
}
|
||||
|
||||
sendDownstreamPacket(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a packet to the remote server.
|
||||
*
|
||||
@ -1718,7 +1751,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||
// We're "flying locked" in this gamemode
|
||||
flying = true;
|
||||
ServerboundPlayerAbilitiesPacket abilitiesPacket = new ServerboundPlayerAbilitiesPacket(true);
|
||||
sendDownstreamPacket(abilitiesPacket);
|
||||
sendDownstreamGamePacket(abilitiesPacket);
|
||||
}
|
||||
abilities.add(Ability.FLYING);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class AdvancementsCache {
|
||||
} else {
|
||||
// Send a packet indicating that we intend to open this particular advancement window
|
||||
ServerboundSeenAdvancementsPacket packet = new ServerboundSeenAdvancementsPacket(id);
|
||||
session.sendDownstreamPacket(packet);
|
||||
session.sendDownstreamGamePacket(packet);
|
||||
// Wait for a response there
|
||||
}
|
||||
}
|
||||
@ -137,7 +137,7 @@ public class AdvancementsCache {
|
||||
|
||||
builder.closedResultHandler(() -> {
|
||||
// Indicate that we have closed the current advancement tab
|
||||
session.sendDownstreamPacket(new ServerboundSeenAdvancementsPacket());
|
||||
session.sendDownstreamGamePacket(new ServerboundSeenAdvancementsPacket());
|
||||
|
||||
}).validResultHandler((response) -> {
|
||||
if (response.getClickedButtonId() < visibleAdvancements.size()) {
|
||||
@ -146,7 +146,7 @@ public class AdvancementsCache {
|
||||
} else {
|
||||
buildAndShowMenuForm();
|
||||
// Indicate that we have closed the current advancement tab
|
||||
session.sendDownstreamPacket(new ServerboundSeenAdvancementsPacket());
|
||||
session.sendDownstreamGamePacket(new ServerboundSeenAdvancementsPacket());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class BookEditCache {
|
||||
packet = null;
|
||||
return;
|
||||
}
|
||||
session.sendDownstreamPacket(packet);
|
||||
session.sendDownstreamGamePacket(packet);
|
||||
packet = null;
|
||||
lastBookUpdate = System.currentTimeMillis();
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class BeaconInventoryTranslator extends AbstractBlockInventoryTranslator
|
||||
// Input a beacon payment
|
||||
BeaconPaymentAction beaconPayment = (BeaconPaymentAction) request.getActions()[0];
|
||||
ServerboundSetBeaconPacket packet = new ServerboundSetBeaconPacket(toJava(beaconPayment.getPrimaryEffect()), toJava(beaconPayment.getSecondaryEffect()));
|
||||
session.sendDownstreamPacket(packet);
|
||||
session.sendDownstreamGamePacket(packet);
|
||||
return acceptRequest(request, makeContainerEntries(session, inventory, IntSets.emptySet()));
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ public class EnchantingInventoryTranslator extends AbstractBlockInventoryTransla
|
||||
return rejectRequest(request);
|
||||
}
|
||||
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), javaSlot);
|
||||
session.sendDownstreamPacket(packet);
|
||||
session.sendDownstreamGamePacket(packet);
|
||||
return acceptRequest(request, makeContainerEntries(session, inventory, IntSets.emptySet()));
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
|
||||
if (session.isDroppingLecternBook()) {
|
||||
// We have to enter the inventory GUI to eject the book
|
||||
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), 3);
|
||||
session.sendDownstreamPacket(packet);
|
||||
session.sendDownstreamGamePacket(packet);
|
||||
session.setDroppingLecternBook(false);
|
||||
InventoryUtils.closeInventory(session, inventory.getJavaId(), false);
|
||||
} else if (lecternContainer.getBlockEntityTag() == null) {
|
||||
@ -153,7 +153,7 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
|
||||
session.getLecternCache().add(position);
|
||||
// Close the window - we will reopen it once the client has this data synced
|
||||
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(lecternContainer.getJavaId());
|
||||
session.sendDownstreamPacket(closeWindowPacket);
|
||||
session.sendDownstreamGamePacket(closeWindowPacket);
|
||||
InventoryUtils.closeInventory(session, inventory.getJavaId(), false);
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class LoomInventoryTranslator extends AbstractBlockInventoryTranslator {
|
||||
// And the Java loom window has a fixed row/width of four
|
||||
// So... Number / 4 = row (so we don't have to bother there), and number % 4 is our column, which leads us back to our index. :)
|
||||
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), index);
|
||||
session.sendDownstreamPacket(packet);
|
||||
session.sendDownstreamGamePacket(packet);
|
||||
|
||||
GeyserItemStack inputCopy = inventory.getItem(0).copy(1);
|
||||
inputCopy.setNetId(session.getNextItemNetId());
|
||||
|
@ -155,7 +155,7 @@ public class MerchantInventoryTranslator extends BaseInventoryTranslator {
|
||||
|
||||
private ItemStackResponse handleTrade(GeyserSession session, Inventory inventory, ItemStackRequest request, int tradeChoice) {
|
||||
ServerboundSelectTradePacket packet = new ServerboundSelectTradePacket(tradeChoice);
|
||||
session.sendDownstreamPacket(packet);
|
||||
session.sendDownstreamGamePacket(packet);
|
||||
|
||||
if (session.isEmulatePost1_13Logic()) {
|
||||
// 1.18 Java cooperates nicer than older versions
|
||||
|
@ -359,7 +359,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
||||
}
|
||||
|
||||
ServerboundSetCreativeModeSlotPacket creativeDropPacket = new ServerboundSetCreativeModeSlotPacket(-1, sourceItem.getItemStack(dropAction.getCount()));
|
||||
session.sendDownstreamPacket(creativeDropPacket);
|
||||
session.sendDownstreamGamePacket(creativeDropPacket);
|
||||
|
||||
sourceItem.sub(dropAction.getCount());
|
||||
}
|
||||
@ -494,7 +494,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
||||
dropStack = new ItemStack(javaCreativeItem.getId(), dropAction.getCount(), javaCreativeItem.getNbt());
|
||||
}
|
||||
ServerboundSetCreativeModeSlotPacket creativeDropPacket = new ServerboundSetCreativeModeSlotPacket(-1, dropStack);
|
||||
session.sendDownstreamPacket(creativeDropPacket);
|
||||
session.sendDownstreamGamePacket(creativeDropPacket);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -515,7 +515,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
||||
ItemStack itemStack = item.isEmpty() ? new ItemStack(-1, 0, null) : item.getItemStack();
|
||||
|
||||
ServerboundSetCreativeModeSlotPacket creativePacket = new ServerboundSetCreativeModeSlotPacket(slot, itemStack);
|
||||
session.sendDownstreamPacket(creativePacket);
|
||||
session.sendDownstreamGamePacket(creativePacket);
|
||||
}
|
||||
|
||||
private static boolean isCraftingGrid(ItemStackRequestSlotData slotInfoData) {
|
||||
|
@ -69,7 +69,7 @@ public class StonecutterInventoryTranslator extends AbstractBlockInventoryTransl
|
||||
if (container.getStonecutterButton() != button) {
|
||||
// Getting the index of the item in the Java stonecutter list
|
||||
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), button);
|
||||
session.sendDownstreamPacket(packet);
|
||||
session.sendDownstreamGamePacket(packet);
|
||||
container.setStonecutterButton(button);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class BedrockAnimateTranslator extends PacketTranslator<AnimatePacket> {
|
||||
// and Bedrock 1.19.51.
|
||||
// Note for the future: we should probably largely ignore this packet and instead replicate
|
||||
// all actions on our end, and send swings where needed.
|
||||
session.sendDownstreamPacket(new ServerboundSwingPacket(Hand.MAIN_HAND));
|
||||
session.sendDownstreamGamePacket(new ServerboundSwingPacket(Hand.MAIN_HAND));
|
||||
session.activateArmAnimationTicking();
|
||||
}
|
||||
},
|
||||
@ -77,12 +77,12 @@ public class BedrockAnimateTranslator extends PacketTranslator<AnimatePacket> {
|
||||
// Packet value is a float of how long one has been rowing, so we convert that into a boolean
|
||||
session.setSteeringLeft(packet.getRowingTime() > 0.0);
|
||||
ServerboundPaddleBoatPacket steerLeftPacket = new ServerboundPaddleBoatPacket(session.isSteeringLeft(), session.isSteeringRight());
|
||||
session.sendDownstreamPacket(steerLeftPacket);
|
||||
session.sendDownstreamGamePacket(steerLeftPacket);
|
||||
}
|
||||
case ROW_RIGHT -> {
|
||||
session.setSteeringRight(packet.getRowingTime() > 0.0);
|
||||
ServerboundPaddleBoatPacket steerRightPacket = new ServerboundPaddleBoatPacket(session.isSteeringLeft(), session.isSteeringRight());
|
||||
session.sendDownstreamPacket(steerRightPacket);
|
||||
session.sendDownstreamGamePacket(steerRightPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator<BlockEnti
|
||||
if (iterator < lines.length) lines[iterator] = newMessage.toString();
|
||||
Vector3i pos = Vector3i.from(tag.getInt("x"), tag.getInt("y"), tag.getInt("z"));
|
||||
ServerboundSignUpdatePacket signUpdatePacket = new ServerboundSignUpdatePacket(pos, lines, session.getWorldCache().isEditingSignOnFront());
|
||||
session.sendDownstreamPacket(signUpdatePacket);
|
||||
session.sendDownstreamGamePacket(signUpdatePacket);
|
||||
|
||||
} else if (id.equals("JigsawBlock")) {
|
||||
// Client has just sent a jigsaw block update
|
||||
@ -120,7 +120,7 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator<BlockEnti
|
||||
String joint = tag.getString("joint");
|
||||
ServerboundSetJigsawBlockPacket jigsawPacket = new ServerboundSetJigsawBlockPacket(pos, name, target, pool,
|
||||
finalState, joint);
|
||||
session.sendDownstreamPacket(jigsawPacket);
|
||||
session.sendDownstreamGamePacket(jigsawPacket);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,13 +53,13 @@ public class BedrockCommandBlockUpdateTranslator extends PacketTranslator<Comman
|
||||
boolean automatic = !packet.isRedstoneMode(); // Automatic = Always Active option in Java
|
||||
ServerboundSetCommandBlockPacket commandBlockPacket = new ServerboundSetCommandBlockPacket(
|
||||
packet.getBlockPosition(), command, mode, outputTracked, isConditional, automatic);
|
||||
session.sendDownstreamPacket(commandBlockPacket);
|
||||
session.sendDownstreamGamePacket(commandBlockPacket);
|
||||
} else {
|
||||
ServerboundSetCommandMinecartPacket commandMinecartPacket = new ServerboundSetCommandMinecartPacket(
|
||||
session.getEntityCache().getEntityByGeyserId(packet.getMinecartRuntimeEntityId()).getEntityId(),
|
||||
command, outputTracked
|
||||
);
|
||||
session.sendDownstreamPacket(commandMinecartPacket);
|
||||
session.sendDownstreamGamePacket(commandMinecartPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class BedrockContainerCloseTranslator extends PacketTranslator<ContainerC
|
||||
if (openInventory != null) {
|
||||
if (bedrockId == openInventory.getBedrockId()) {
|
||||
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(openInventory.getJavaId());
|
||||
session.sendDownstreamPacket(closeWindowPacket);
|
||||
session.sendDownstreamGamePacket(closeWindowPacket);
|
||||
InventoryUtils.closeInventory(session, openInventory.getJavaId(), false);
|
||||
} else if (openInventory.isPending()) {
|
||||
InventoryUtils.displayInventory(session, openInventory);
|
||||
|
@ -137,7 +137,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
ServerboundContainerClickPacket dropPacket = new ServerboundContainerClickPacket(
|
||||
inventory.getJavaId(), inventory.getStateId(), hotbarSlot, clickType.actionType, clickType.action,
|
||||
inventory.getCursor().getItemStack(), changedItem);
|
||||
session.sendDownstreamPacket(dropPacket);
|
||||
session.sendDownstreamGamePacket(dropPacket);
|
||||
return;
|
||||
}
|
||||
if (session.getPlayerInventory().getItemInHand().isEmpty()) {
|
||||
@ -150,7 +150,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
Direction.DOWN,
|
||||
0
|
||||
);
|
||||
session.sendDownstreamPacket(dropPacket);
|
||||
session.sendDownstreamGamePacket(dropPacket);
|
||||
|
||||
if (dropAll) {
|
||||
session.getPlayerInventory().setItemInHand(GeyserItemStack.EMPTY);
|
||||
@ -309,7 +309,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
packet.getClickPosition().getX(), packet.getClickPosition().getY(), packet.getClickPosition().getZ(),
|
||||
false,
|
||||
session.getWorldCache().nextPredictionSequence());
|
||||
session.sendDownstreamPacket(blockPacket);
|
||||
session.sendDownstreamGamePacket(blockPacket);
|
||||
|
||||
Item item = session.getPlayerInventory().getItemInHand().asItem();
|
||||
if (packet.getItemInHand() != null) {
|
||||
@ -384,7 +384,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
}
|
||||
|
||||
ServerboundUseItemPacket useItemPacket = new ServerboundUseItemPacket(Hand.MAIN_HAND, session.getWorldCache().nextPredictionSequence());
|
||||
session.sendDownstreamPacket(useItemPacket);
|
||||
session.sendDownstreamGamePacket(useItemPacket);
|
||||
|
||||
List<LegacySetItemSlotData> legacySlots = packet.getLegacySlots();
|
||||
if (packet.getActions().size() == 1 && legacySlots.size() > 0) {
|
||||
@ -453,13 +453,13 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
if (itemFrameEntity != null) {
|
||||
ServerboundInteractPacket attackPacket = new ServerboundInteractPacket(itemFrameEntity.getEntityId(),
|
||||
InteractAction.ATTACK, session.isSneaking());
|
||||
session.sendDownstreamPacket(attackPacket);
|
||||
session.sendDownstreamGamePacket(attackPacket);
|
||||
break;
|
||||
}
|
||||
|
||||
PlayerAction action = session.getGameMode() == GameMode.CREATIVE ? PlayerAction.START_DIGGING : PlayerAction.FINISH_DIGGING;
|
||||
ServerboundPlayerActionPacket breakPacket = new ServerboundPlayerActionPacket(action, packet.getBlockPosition(), Direction.VALUES[packet.getBlockFace()], sequence);
|
||||
session.sendDownstreamPacket(breakPacket);
|
||||
session.sendDownstreamGamePacket(breakPacket);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -468,7 +468,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
// Followed to the Minecraft Protocol specification outlined at wiki.vg
|
||||
ServerboundPlayerActionPacket releaseItemPacket = new ServerboundPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, Vector3i.ZERO,
|
||||
Direction.DOWN, 0);
|
||||
session.sendDownstreamPacket(releaseItemPacket);
|
||||
session.sendDownstreamGamePacket(releaseItemPacket);
|
||||
}
|
||||
break;
|
||||
case ITEM_USE_ON_ENTITY:
|
||||
@ -490,7 +490,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
}
|
||||
ServerboundInteractPacket attackPacket = new ServerboundInteractPacket(entityId,
|
||||
InteractAction.ATTACK, session.isSneaking());
|
||||
session.sendDownstreamPacket(attackPacket);
|
||||
session.sendDownstreamGamePacket(attackPacket);
|
||||
|
||||
// Since 1.19.10, LevelSoundEventPackets are no longer sent by the client when attacking entities
|
||||
CooldownUtils.sendCooldown(session);
|
||||
@ -510,7 +510,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
Vector3f clickPosition = packet.getClickPosition().sub(entityPosition);
|
||||
boolean isSpectator = session.getGameMode() == GameMode.SPECTATOR;
|
||||
for (Hand hand : EntityUtils.HANDS) {
|
||||
session.sendDownstreamPacket(new ServerboundInteractPacket(entity.getEntityId(),
|
||||
session.sendDownstreamGamePacket(new ServerboundInteractPacket(entity.getEntityId(),
|
||||
InteractAction.INTERACT_AT, clickPosition.getX(), clickPosition.getY(), clickPosition.getZ(),
|
||||
hand, session.isSneaking()));
|
||||
|
||||
@ -522,7 +522,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
}
|
||||
|
||||
if (!result.consumesAction()) {
|
||||
session.sendDownstreamPacket(new ServerboundInteractPacket(entity.getEntityId(),
|
||||
session.sendDownstreamGamePacket(new ServerboundInteractPacket(entity.getEntityId(),
|
||||
InteractAction.INTERACT, hand, session.isSneaking()));
|
||||
if (!isSpectator) {
|
||||
result = entity.interact(hand);
|
||||
@ -532,7 +532,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
if (result.consumesAction()) {
|
||||
if (result.shouldSwing() && hand == Hand.OFF_HAND) {
|
||||
// Currently, Bedrock will send us the arm swing packet in most cases. But it won't for offhand.
|
||||
session.sendDownstreamPacket(new ServerboundSwingPacket(hand));
|
||||
session.sendDownstreamGamePacket(new ServerboundSwingPacket(hand));
|
||||
// Note here to look into sending the animation packet back to Bedrock
|
||||
}
|
||||
return;
|
||||
@ -629,7 +629,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
lookAt(session, target);
|
||||
|
||||
ServerboundUseItemPacket itemPacket = new ServerboundUseItemPacket(Hand.MAIN_HAND, session.getWorldCache().nextPredictionSequence());
|
||||
session.sendDownstreamPacket(itemPacket);
|
||||
session.sendDownstreamGamePacket(itemPacket);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -671,7 +671,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
ServerboundMovePlayerPosRotPacket returnPacket = new ServerboundMovePlayerPosRotPacket(entity.isOnGround(), playerPosition.getX(), playerPosition.getY(), playerPosition.getZ(), entity.getYaw(), entity.getPitch());
|
||||
// This matches Java edition behavior
|
||||
ServerboundMovePlayerPosRotPacket movementPacket = new ServerboundMovePlayerPosRotPacket(entity.isOnGround(), playerPosition.getX(), playerPosition.getY(), playerPosition.getZ(), yaw, pitch);
|
||||
session.sendDownstreamPacket(movementPacket);
|
||||
session.sendDownstreamGamePacket(movementPacket);
|
||||
|
||||
if (session.getLookBackScheduledFuture() != null) {
|
||||
session.getLookBackScheduledFuture().cancel(false);
|
||||
@ -683,7 +683,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
// The player moved/rotated so there is no need to change their rotation back
|
||||
return;
|
||||
}
|
||||
session.sendDownstreamPacket(returnPacket);
|
||||
session.sendDownstreamGamePacket(returnPacket);
|
||||
}, 150, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class BedrockItemFrameDropItemTranslator extends PacketTranslator<ItemFra
|
||||
if (entity != null) {
|
||||
ServerboundInteractPacket interactPacket = new ServerboundInteractPacket(entity.getEntityId(),
|
||||
InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking());
|
||||
session.sendDownstreamPacket(interactPacket);
|
||||
session.sendDownstreamGamePacket(interactPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
|
||||
0, 0, 0, // Java doesn't care about these when dealing with a lectern
|
||||
false,
|
||||
session.getWorldCache().nextPredictionSequence());
|
||||
session.sendDownstreamPacket(blockPacket);
|
||||
session.sendDownstreamGamePacket(blockPacket);
|
||||
} else {
|
||||
// Bedrock wants to either move a page or exit
|
||||
if (!(session.getOpenInventory() instanceof LecternContainer lecternContainer)) {
|
||||
@ -69,7 +69,7 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
|
||||
if (lecternContainer.getCurrentBedrockPage() == packet.getPage()) {
|
||||
// The same page means Bedrock is closing the window
|
||||
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(lecternContainer.getJavaId());
|
||||
session.sendDownstreamPacket(closeWindowPacket);
|
||||
session.sendDownstreamGamePacket(closeWindowPacket);
|
||||
InventoryUtils.closeInventory(session, lecternContainer.getJavaId(), false);
|
||||
} else {
|
||||
// Each "page" Bedrock gives to us actually represents two pages (think opening a book and seeing two pages)
|
||||
@ -83,12 +83,12 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
|
||||
if (newJavaPage > currentJavaPage) {
|
||||
for (int i = currentJavaPage; i < newJavaPage; i++) {
|
||||
ServerboundContainerButtonClickPacket clickButtonPacket = new ServerboundContainerButtonClickPacket(session.getOpenInventory().getJavaId(), 2);
|
||||
session.sendDownstreamPacket(clickButtonPacket);
|
||||
session.sendDownstreamGamePacket(clickButtonPacket);
|
||||
}
|
||||
} else {
|
||||
for (int i = currentJavaPage; i > newJavaPage; i--) {
|
||||
ServerboundContainerButtonClickPacket clickButtonPacket = new ServerboundContainerButtonClickPacket(session.getOpenInventory().getJavaId(), 1);
|
||||
session.sendDownstreamPacket(clickButtonPacket);
|
||||
session.sendDownstreamGamePacket(clickButtonPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class BedrockMobEquipmentTranslator extends PacketTranslator<MobEquipment
|
||||
session.getPlayerInventory().setHeldItemSlot(newSlot);
|
||||
|
||||
ServerboundSetCarriedItemPacket setCarriedItemPacket = new ServerboundSetCarriedItemPacket(newSlot);
|
||||
session.sendDownstreamPacket(setCarriedItemPacket);
|
||||
session.sendDownstreamGamePacket(setCarriedItemPacket);
|
||||
|
||||
GeyserItemStack newItem = session.getPlayerInventory().getItemInHand();
|
||||
|
||||
@ -66,7 +66,7 @@ public class BedrockMobEquipmentTranslator extends PacketTranslator<MobEquipment
|
||||
// Activate shield since we are already sneaking
|
||||
// (No need to send a release item packet - Java doesn't do this when swapping items)
|
||||
// Required to do it a tick later or else it doesn't register
|
||||
session.scheduleInEventLoop(() -> session.sendDownstreamPacket(new ServerboundUseItemPacket(Hand.MAIN_HAND, session.getWorldCache().nextPredictionSequence())),
|
||||
session.scheduleInEventLoop(() -> session.sendDownstreamGamePacket(new ServerboundUseItemPacket(Hand.MAIN_HAND, session.getWorldCache().nextPredictionSequence())),
|
||||
50, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,6 @@ public class BedrockMoveEntityAbsoluteTranslator extends PacketTranslator<MoveEn
|
||||
packet.getPosition().getX(), y, packet.getPosition().getZ(),
|
||||
packet.getRotation().getY() - 90, packet.getRotation().getX()
|
||||
);
|
||||
session.sendDownstreamPacket(ServerboundMoveVehiclePacket);
|
||||
session.sendDownstreamGamePacket(ServerboundMoveVehiclePacket);
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class BedrockPlayerInputTranslator extends PacketTranslator<PlayerInputPa
|
||||
packet.getInputMotion().getX(), packet.getInputMotion().getY(), packet.isJumping(), packet.isSneaking()
|
||||
);
|
||||
|
||||
session.sendDownstreamPacket(playerInputPacket);
|
||||
session.sendDownstreamGamePacket(playerInputPacket);
|
||||
|
||||
// Bedrock only sends movement vehicle packets while moving
|
||||
// This allows horses to take damage while standing on magma
|
||||
@ -83,7 +83,7 @@ public class BedrockPlayerInputTranslator extends PacketTranslator<PlayerInputPa
|
||||
vehiclePosition.getX(), vehiclePosition.getY(), vehiclePosition.getZ(),
|
||||
vehicle.getYaw() - 90, vehicle.getPitch()
|
||||
);
|
||||
session.sendDownstreamPacket(moveVehiclePacket);
|
||||
session.sendDownstreamGamePacket(moveVehiclePacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class BedrockRequestAbilityTranslator extends PacketTranslator<RequestAbi
|
||||
|
||||
session.setFlying(isFlying);
|
||||
ServerboundPlayerAbilitiesPacket abilitiesPacket = new ServerboundPlayerAbilitiesPacket(isFlying);
|
||||
session.sendDownstreamPacket(abilitiesPacket);
|
||||
session.sendDownstreamGamePacket(abilitiesPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class BedrockRespawnTranslator extends PacketTranslator<RespawnPacket> {
|
||||
public void translate(GeyserSession session, RespawnPacket packet) {
|
||||
if (packet.getState() == RespawnPacket.State.CLIENT_READY) {
|
||||
ServerboundClientCommandPacket javaRespawnPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN);
|
||||
session.sendDownstreamPacket(javaRespawnPacket);
|
||||
session.sendDownstreamGamePacket(javaRespawnPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class BedrockShowCreditsTranslator extends PacketTranslator<ShowCreditsPa
|
||||
public void translate(GeyserSession session, ShowCreditsPacket packet) {
|
||||
if (packet.getStatus() == ShowCreditsPacket.Status.END_CREDITS) {
|
||||
ServerboundClientCommandPacket javaRespawnPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN);
|
||||
session.sendDownstreamPacket(javaRespawnPacket);
|
||||
session.sendDownstreamGamePacket(javaRespawnPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class BedrockEntityEventTranslator extends PacketTranslator<EntityEventPa
|
||||
case COMPLETE_TRADE -> {
|
||||
// Not sent as of 1.18.10
|
||||
ServerboundSelectTradePacket selectTradePacket = new ServerboundSelectTradePacket(packet.getData());
|
||||
session.sendDownstreamPacket(selectTradePacket);
|
||||
session.sendDownstreamGamePacket(selectTradePacket);
|
||||
|
||||
session.scheduleInEventLoop(() -> {
|
||||
Inventory openInventory = session.getOpenInventory();
|
||||
|
@ -26,10 +26,6 @@
|
||||
package org.geysermc.geyser.translator.protocol.bedrock.entity.player;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundInteractPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerAbilitiesPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerActionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerCommandPacket;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction;
|
||||
@ -97,7 +93,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||
case START_SWIMMING:
|
||||
if (!entity.getFlag(EntityFlag.SWIMMING)) {
|
||||
ServerboundPlayerCommandPacket startSwimPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_SPRINTING);
|
||||
session.sendDownstreamPacket(startSwimPacket);
|
||||
session.sendDownstreamGamePacket(startSwimPacket);
|
||||
|
||||
session.setSwimming(true);
|
||||
}
|
||||
@ -106,7 +102,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||
// Prevent packet spam when Bedrock players are crawling near the edge of a block
|
||||
if (!session.getCollisionManager().mustPlayerCrawlHere()) {
|
||||
ServerboundPlayerCommandPacket stopSwimPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.STOP_SPRINTING);
|
||||
session.sendDownstreamPacket(stopSwimPacket);
|
||||
session.sendDownstreamGamePacket(stopSwimPacket);
|
||||
|
||||
session.setSwimming(false);
|
||||
}
|
||||
@ -114,45 +110,45 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||
case START_GLIDE:
|
||||
// Otherwise gliding will not work in creative
|
||||
ServerboundPlayerAbilitiesPacket playerAbilitiesPacket = new ServerboundPlayerAbilitiesPacket(false);
|
||||
session.sendDownstreamPacket(playerAbilitiesPacket);
|
||||
session.sendDownstreamGamePacket(playerAbilitiesPacket);
|
||||
case STOP_GLIDE:
|
||||
ServerboundPlayerCommandPacket glidePacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_ELYTRA_FLYING);
|
||||
session.sendDownstreamPacket(glidePacket);
|
||||
session.sendDownstreamGamePacket(glidePacket);
|
||||
break;
|
||||
case START_SNEAK:
|
||||
ServerboundPlayerCommandPacket startSneakPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_SNEAKING);
|
||||
session.sendDownstreamPacket(startSneakPacket);
|
||||
session.sendDownstreamGamePacket(startSneakPacket);
|
||||
|
||||
session.startSneaking();
|
||||
break;
|
||||
case STOP_SNEAK:
|
||||
ServerboundPlayerCommandPacket stopSneakPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.STOP_SNEAKING);
|
||||
session.sendDownstreamPacket(stopSneakPacket);
|
||||
session.sendDownstreamGamePacket(stopSneakPacket);
|
||||
|
||||
session.stopSneaking();
|
||||
break;
|
||||
case START_SPRINT:
|
||||
if (!entity.getFlag(EntityFlag.SWIMMING)) {
|
||||
ServerboundPlayerCommandPacket startSprintPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_SPRINTING);
|
||||
session.sendDownstreamPacket(startSprintPacket);
|
||||
session.sendDownstreamGamePacket(startSprintPacket);
|
||||
session.setSprinting(true);
|
||||
}
|
||||
break;
|
||||
case STOP_SPRINT:
|
||||
if (!entity.getFlag(EntityFlag.SWIMMING)) {
|
||||
ServerboundPlayerCommandPacket stopSprintPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.STOP_SPRINTING);
|
||||
session.sendDownstreamPacket(stopSprintPacket);
|
||||
session.sendDownstreamGamePacket(stopSprintPacket);
|
||||
}
|
||||
session.setSprinting(false);
|
||||
break;
|
||||
case DROP_ITEM:
|
||||
ServerboundPlayerActionPacket dropItemPacket = new ServerboundPlayerActionPacket(PlayerAction.DROP_ITEM,
|
||||
vector, Direction.VALUES[packet.getFace()], 0);
|
||||
session.sendDownstreamPacket(dropItemPacket);
|
||||
session.sendDownstreamGamePacket(dropItemPacket);
|
||||
break;
|
||||
case STOP_SLEEP:
|
||||
ServerboundPlayerCommandPacket stopSleepingPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.LEAVE_BED);
|
||||
session.sendDownstreamPacket(stopSleepingPacket);
|
||||
session.sendDownstreamGamePacket(stopSleepingPacket);
|
||||
break;
|
||||
case START_BREAK: {
|
||||
// Ignore START_BREAK when the player is CREATIVE to avoid Spigot receiving 2 packets it interpets as block breaking. https://github.com/GeyserMC/Geyser/issues/4021
|
||||
@ -189,12 +185,12 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||
if (identifier.startsWith("minecraft:fire") || identifier.startsWith("minecraft:soul_fire")) {
|
||||
ServerboundPlayerActionPacket startBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, fireBlockPos,
|
||||
Direction.VALUES[packet.getFace()], session.getWorldCache().nextPredictionSequence());
|
||||
session.sendDownstreamPacket(startBreakingPacket);
|
||||
session.sendDownstreamGamePacket(startBreakingPacket);
|
||||
}
|
||||
|
||||
ServerboundPlayerActionPacket startBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING,
|
||||
vector, Direction.VALUES[packet.getFace()], session.getWorldCache().nextPredictionSequence());
|
||||
session.sendDownstreamPacket(startBreakingPacket);
|
||||
session.sendDownstreamGamePacket(startBreakingPacket);
|
||||
break;
|
||||
}
|
||||
case CONTINUE_BREAK:
|
||||
@ -236,7 +232,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||
// Break the block
|
||||
ServerboundPlayerActionPacket finishBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.FINISH_DIGGING,
|
||||
vector, Direction.VALUES[packet.getFace()], session.getWorldCache().nextPredictionSequence());
|
||||
session.sendDownstreamPacket(finishBreakingPacket);
|
||||
session.sendDownstreamGamePacket(finishBreakingPacket);
|
||||
session.setBlockBreakStartTime(0);
|
||||
break;
|
||||
}
|
||||
@ -253,13 +249,13 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||
if (itemFrameEntity != null) {
|
||||
ServerboundInteractPacket interactPacket = new ServerboundInteractPacket(itemFrameEntity.getEntityId(),
|
||||
InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking());
|
||||
session.sendDownstreamPacket(interactPacket);
|
||||
session.sendDownstreamGamePacket(interactPacket);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ServerboundPlayerActionPacket abortBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.CANCEL_DIGGING, vector, Direction.DOWN, 0);
|
||||
session.sendDownstreamPacket(abortBreakingPacket);
|
||||
session.sendDownstreamGamePacket(abortBreakingPacket);
|
||||
LevelEventPacket stopBreak = new LevelEventPacket();
|
||||
stopBreak.setType(LevelEvent.BLOCK_STOP_BREAK);
|
||||
stopBreak.setPosition(vector.toFloat());
|
||||
@ -287,7 +283,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||
case MISSED_SWING:
|
||||
// TODO Re-evaluate after pre-1.20.10 is no longer supported?
|
||||
if (session.getArmAnimationTicks() == -1) {
|
||||
session.sendDownstreamPacket(new ServerboundSwingPacket(Hand.MAIN_HAND));
|
||||
session.sendDownstreamGamePacket(new ServerboundSwingPacket(Hand.MAIN_HAND));
|
||||
session.activateArmAnimationTicking();
|
||||
|
||||
// Send packet to Bedrock so it knows
|
||||
@ -313,7 +309,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||
}
|
||||
|
||||
session.setFlying(true);
|
||||
session.sendDownstreamPacket(new ServerboundPlayerAbilitiesPacket(true));
|
||||
session.sendDownstreamGamePacket(new ServerboundPlayerAbilitiesPacket(true));
|
||||
} else {
|
||||
// update whether we can fly
|
||||
session.sendAdventureSettings();
|
||||
@ -329,7 +325,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||
break;
|
||||
case STOP_FLYING:
|
||||
session.setFlying(false);
|
||||
session.sendDownstreamPacket(new ServerboundPlayerAbilitiesPacket(false));
|
||||
session.sendDownstreamGamePacket(new ServerboundPlayerAbilitiesPacket(false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -68,16 +68,16 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
|
||||
}
|
||||
ServerboundInteractPacket interactPacket = new ServerboundInteractPacket(entity.getEntityId(),
|
||||
InteractAction.INTERACT, Hand.MAIN_HAND, session.isSneaking());
|
||||
session.sendDownstreamPacket(interactPacket);
|
||||
session.sendDownstreamGamePacket(interactPacket);
|
||||
break;
|
||||
case DAMAGE:
|
||||
ServerboundInteractPacket attackPacket = new ServerboundInteractPacket(entity.getEntityId(),
|
||||
InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking());
|
||||
session.sendDownstreamPacket(attackPacket);
|
||||
session.sendDownstreamGamePacket(attackPacket);
|
||||
break;
|
||||
case LEAVE_VEHICLE:
|
||||
ServerboundPlayerCommandPacket sneakPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_SNEAKING);
|
||||
session.sendDownstreamPacket(sneakPacket);
|
||||
session.sendDownstreamGamePacket(sneakPacket);
|
||||
|
||||
Entity currentVehicle = session.getPlayerEntity().getVehicle();
|
||||
if (currentVehicle != null) {
|
||||
@ -123,7 +123,7 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
|
||||
if (ridingEntity instanceof AbstractHorseEntity || (ridingEntity != null && ridingEntity.getDefinition().entityType() == EntityType.CHEST_BOAT)) {
|
||||
// This mob has an inventory of its own that we should open instead.
|
||||
ServerboundPlayerCommandPacket openVehicleWindowPacket = new ServerboundPlayerCommandPacket(session.getPlayerEntity().getEntityId(), PlayerState.OPEN_VEHICLE_INVENTORY);
|
||||
session.sendDownstreamPacket(openVehicleWindowPacket);
|
||||
session.sendDownstreamGamePacket(openVehicleWindowPacket);
|
||||
} else {
|
||||
session.setOpenInventory(session.getPlayerInventory());
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
||||
entity.setHeadYaw(headYaw);
|
||||
entity.setOnGround(packet.isOnGround());
|
||||
|
||||
session.sendDownstreamPacket(playerRotationPacket);
|
||||
session.sendDownstreamGamePacket(playerRotationPacket);
|
||||
} else {
|
||||
if (session.getWorldBorder().isPassingIntoBorderBoundaries(packet.getPosition(), true)) {
|
||||
return;
|
||||
@ -130,7 +130,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
||||
entity.setOnGround(onGround);
|
||||
|
||||
// Send final movement changes
|
||||
session.sendDownstreamPacket(movePacket);
|
||||
session.sendDownstreamGamePacket(movePacket);
|
||||
|
||||
if (teleportThroughVoidFloor) {
|
||||
// Work around there being a floor at the bottom of the world and teleport the player below it
|
||||
|
@ -41,7 +41,7 @@ public class BedrockRiderJumpTranslator extends PacketTranslator<RiderJumpPacket
|
||||
Entity vehicle = session.getPlayerEntity().getVehicle();
|
||||
if (vehicle instanceof AbstractHorseEntity) {
|
||||
ServerboundPlayerCommandPacket playerCommandPacket = new ServerboundPlayerCommandPacket(vehicle.getEntityId(), PlayerState.START_HORSE_JUMP, packet.getJumpStrength());
|
||||
session.sendDownstreamPacket(playerCommandPacket);
|
||||
session.sendDownstreamGamePacket(playerCommandPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class BedrockLevelSoundEventTranslator extends PacketTranslator<LevelSoun
|
||||
// ATTACK_NODAMAGE = player clicked air
|
||||
// This should only be revisited if Bedrock packets get full Java parity, or Bedrock starts sending arm
|
||||
// animation packets after ATTACK_NODAMAGE, OR ATTACK_NODAMAGE gets removed/isn't sent in the same spot
|
||||
session.sendDownstreamPacket(new ServerboundSwingPacket(Hand.MAIN_HAND));
|
||||
session.sendDownstreamGamePacket(new ServerboundSwingPacket(Hand.MAIN_HAND));
|
||||
session.activateArmAnimationTicking();
|
||||
|
||||
// Send packet to Bedrock so it knows
|
||||
|
@ -40,7 +40,7 @@ public class JavaCustomQueryTranslator extends PacketTranslator<ClientboundCusto
|
||||
public void translate(GeyserSession session, ClientboundCustomQueryPacket packet) {
|
||||
// A vanilla client doesn't know any PluginMessage in the Login state, so we don't know any either.
|
||||
// Note: Fabric Networking API v1 will not let the client log in without sending this
|
||||
session.sendDownstreamPacket(
|
||||
session.sendDownstreamLoginPacket(
|
||||
new ServerboundCustomQueryAnswerPacket(packet.getMessageId(), null)
|
||||
);
|
||||
}
|
||||
|
@ -133,9 +133,9 @@ public class JavaPlayerPositionTranslator extends PacketTranslator<ClientboundPl
|
||||
private void acceptTeleport(GeyserSession session, double x, double y, double z, float yaw, float pitch, int id) {
|
||||
// Confirm the teleport when we receive it to match Java edition
|
||||
ServerboundAcceptTeleportationPacket teleportConfirmPacket = new ServerboundAcceptTeleportationPacket(id);
|
||||
session.sendDownstreamPacket(teleportConfirmPacket);
|
||||
session.sendDownstreamGamePacket(teleportConfirmPacket);
|
||||
// Servers (especially ones like Hypixel) expect exact coordinates given back to them.
|
||||
ServerboundMovePlayerPosRotPacket positionPacket = new ServerboundMovePlayerPosRotPacket(false, x, y, z, yaw, pitch);
|
||||
session.sendDownstreamPacket(positionPacket);
|
||||
session.sendDownstreamGamePacket(positionPacket);
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class JavaOpenScreenTranslator extends PacketTranslator<ClientboundOpenSc
|
||||
InventoryUtils.closeInventory(session, openInventory.getJavaId(), true);
|
||||
}
|
||||
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(packet.getContainerId());
|
||||
session.sendDownstreamPacket(closeWindowPacket);
|
||||
session.sendDownstreamGamePacket(closeWindowPacket);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,6 @@ public class JavaChunkBatchFinishedTranslator extends PacketTranslator<Clientbou
|
||||
// server just sent a batch of LevelChunkWithLightPackets
|
||||
// the vanilla client uses a ChunkBatchSizeCalculator to calculate the desiredChunksPerTick,
|
||||
// but currently we just send an arbitrary value. server clamps the value between 0.01 and 64.
|
||||
session.sendDownstreamPacket(new ServerboundChunkBatchReceivedPacket(20));
|
||||
session.sendDownstreamGamePacket(new ServerboundChunkBatchReceivedPacket(20));
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class JavaGameEventTranslator extends PacketTranslator<ClientboundGameEve
|
||||
switch ((EnterCreditsValue) packet.getValue()) {
|
||||
case SEEN_BEFORE -> {
|
||||
ServerboundClientCommandPacket javaRespawnPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN);
|
||||
session.sendDownstreamPacket(javaRespawnPacket);
|
||||
session.sendDownstreamGamePacket(javaRespawnPacket);
|
||||
}
|
||||
case FIRST_TIME -> {
|
||||
ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket();
|
||||
|
@ -154,7 +154,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
|
||||
}
|
||||
|
||||
BlockStorage[] layers = new BlockStorage[]{ layer0 };
|
||||
sections[bedrockSectionY] = new GeyserChunkSection(layers, bedrockSectionY);
|
||||
sections[bedrockSectionY] = new GeyserChunkSection(layers);
|
||||
}
|
||||
EXTENDED_COLLISIONS_STORAGE.get().clear();
|
||||
extendedCollisionNextSection = false;
|
||||
@ -167,7 +167,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
|
||||
|
||||
if (javaPalette instanceof GlobalPalette) {
|
||||
// As this is the global palette, simply iterate through the whole chunk section once
|
||||
GeyserChunkSection section = new GeyserChunkSection(session.getBlockMappings().getBedrockAir().getRuntimeId(), bedrockSectionY);
|
||||
GeyserChunkSection section = new GeyserChunkSection(session.getBlockMappings().getBedrockAir().getRuntimeId());
|
||||
for (int yzx = 0; yzx < BlockStorage.SIZE; yzx++) {
|
||||
int javaId = javaData.get(yzx);
|
||||
int bedrockId = session.getBlockMappings().getBedrockBlockId(javaId);
|
||||
@ -217,9 +217,9 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
|
||||
|
||||
if (BlockRegistries.WATERLOGGED.get().get(javaId)) {
|
||||
BlockStorage waterlogged = new BlockStorage(SingletonBitArray.INSTANCE, IntLists.singleton(session.getBlockMappings().getBedrockWater().getRuntimeId()));
|
||||
sections[bedrockSectionY] = new GeyserChunkSection(new BlockStorage[] {blockStorage, waterlogged}, bedrockSectionY);
|
||||
sections[bedrockSectionY] = new GeyserChunkSection(new BlockStorage[] {blockStorage, waterlogged});
|
||||
} else {
|
||||
sections[bedrockSectionY] = new GeyserChunkSection(new BlockStorage[] {blockStorage}, bedrockSectionY);
|
||||
sections[bedrockSectionY] = new GeyserChunkSection(new BlockStorage[] {blockStorage});
|
||||
}
|
||||
if (useExtendedCollisions) {
|
||||
EXTENDED_COLLISIONS_STORAGE.get().clear();
|
||||
@ -378,7 +378,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
|
||||
layers = new BlockStorage[]{ layer0, new BlockStorage(BitArrayVersion.V1.createArray(BlockStorage.SIZE, layer1Data), layer1Palette) };
|
||||
}
|
||||
|
||||
sections[bedrockSectionY] = new GeyserChunkSection(layers, bedrockSectionY);
|
||||
sections[bedrockSectionY] = new GeyserChunkSection(layers);
|
||||
extendedCollisionNextSection = thisExtendedCollisionNextSection;
|
||||
}
|
||||
|
||||
@ -432,7 +432,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
|
||||
IntList palette = bedrockSection.getBlockStorageArray()[0].getPalette();
|
||||
if (palette instanceof IntImmutableList || palette instanceof IntLists.Singleton) {
|
||||
// TODO there has to be a better way to expand the palette .-.
|
||||
bedrockSection = bedrockSection.copy(bedrockSectionY);
|
||||
bedrockSection = bedrockSection.copy();
|
||||
sections[bedrockSectionY] = bedrockSection;
|
||||
}
|
||||
bedrockSection.setFullBlock(x, y & 0xF, z, 0, blockDefinition.getRuntimeId());
|
||||
|
@ -63,7 +63,7 @@ public class ChunkUtils {
|
||||
static {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
try {
|
||||
new GeyserChunkSection(new BlockStorage[0], 0)
|
||||
new GeyserChunkSection(new BlockStorage[0])
|
||||
.writeToNetwork(byteBuf);
|
||||
SERIALIZED_CHUNK_DATA = new byte[byteBuf.readableBytes()];
|
||||
byteBuf.readBytes(SERIALIZED_CHUNK_DATA);
|
||||
|
@ -260,7 +260,7 @@ public class InventoryUtils {
|
||||
// If this is the item we're looking for
|
||||
if (geyserItem.getJavaId() == itemStack.getId() && Objects.equals(geyserItem.getNbt(), itemStack.getNbt())) {
|
||||
ServerboundPickItemPacket packetToSend = new ServerboundPickItemPacket(i); // https://wiki.vg/Protocol#Pick_Item
|
||||
session.sendDownstreamPacket(packetToSend);
|
||||
session.sendDownstreamGamePacket(packetToSend);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -274,7 +274,7 @@ public class InventoryUtils {
|
||||
if ((slot - 36) != inventory.getHeldItemSlot()) {
|
||||
setHotbarItem(session, slot);
|
||||
}
|
||||
session.sendDownstreamPacket(actionPacket);
|
||||
session.sendDownstreamGamePacket(actionPacket);
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ public class InventoryUtils {
|
||||
}
|
||||
|
||||
ServerboundPickItemPacket packetToSend = new ServerboundPickItemPacket(i); // https://wiki.vg/Protocol#Pick_Item
|
||||
session.sendDownstreamPacket(packetToSend);
|
||||
session.sendDownstreamGamePacket(packetToSend);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ public class InventoryUtils {
|
||||
if ((slot - 36) != inventory.getHeldItemSlot()) {
|
||||
setHotbarItem(session, slot);
|
||||
}
|
||||
session.sendDownstreamPacket(actionPacket);
|
||||
session.sendDownstreamGamePacket(actionPacket);
|
||||
} else {
|
||||
session.getGeyser().getLogger().debug("Cannot find item for block " + itemName);
|
||||
}
|
||||
|
BIN
core/src/main/resources/bedrock/block_palette.1_20_40.nbt
Normale Datei
BIN
core/src/main/resources/bedrock/block_palette.1_20_40.nbt
Normale Datei
Binäre Datei nicht angezeigt.
5787
core/src/main/resources/bedrock/creative_items.1_20_40.json
Normale Datei
5787
core/src/main/resources/bedrock/creative_items.1_20_40.json
Normale Datei
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
5570
core/src/main/resources/bedrock/runtime_item_states.1_20_40.json
Normale Datei
5570
core/src/main/resources/bedrock/runtime_item_states.1_20_40.json
Normale Datei
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -145,10 +145,9 @@
|
||||
{
|
||||
"origin": [ -0.1, 0.0, -2.0 ],
|
||||
"size": [ 4, 12, 4 ],
|
||||
"uv": [ 0, 16 ]
|
||||
"uv": [ 16, 48 ]
|
||||
}
|
||||
],
|
||||
"mirror": true
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
@ -219,4 +218,4 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -145,10 +145,9 @@
|
||||
{
|
||||
"origin": [ -0.1, 0.0, -2.0 ],
|
||||
"size": [ 4, 12, 4 ],
|
||||
"uv": [ 0, 16 ]
|
||||
"uv": [ 16, 48 ]
|
||||
}
|
||||
],
|
||||
"mirror": true
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
@ -219,4 +218,4 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ netty = "4.1.80.Final"
|
||||
guava = "29.0-jre"
|
||||
gson = "2.3.1" # Provided by Spigot 1.8.8
|
||||
websocket = "1.5.1"
|
||||
protocol = "3.0.0.Beta1-20230908.171156-106"
|
||||
protocol-connection = "3.0.0.Beta1-20230908.171156-105"
|
||||
protocol = "3.0.0.Beta1-20231016.115644-107"
|
||||
protocol-connection = "3.0.0.Beta1-20231016.115644-106"
|
||||
raknet = "1.0.0.CR1-20230703.195238-9"
|
||||
blockstateupdater="1.20.30-20230918.203831-4"
|
||||
blockstateupdater="1.20.40-20231016.111746-1"
|
||||
mcauthlib = "d9d773e"
|
||||
mcprotocollib = "1.20.2-1-20231003.141424-6"
|
||||
adventure = "4.14.0"
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren