3
0
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:
RK_01 2023-11-02 20:43:47 +01:00 committet von GitHub
Commit 2b5b91ad2c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
62 geänderte Dateien mit 11581 neuen und 204 gelöschten Zeilen

Datei anzeigen

@ -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! 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 ## Setting Up
Take a look [here](https://wiki.geysermc.org/geyser/setup/) for how to set up Geyser. Take a look [here](https://wiki.geysermc.org/geyser/setup/) for how to set up Geyser.

Datei anzeigen

@ -77,7 +77,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
// Copied from ViaVersion. // Copied from ViaVersion.
// https://github.com/ViaVersion/ViaVersion/blob/b8072aad86695cc8ec6f5e4103e43baf3abf6cc5/bungee/src/main/java/us/myles/ViaVersion/BungeePlugin.java#L43 // https://github.com/ViaVersion/ViaVersion/blob/b8072aad86695cc8ec6f5e4103e43baf3abf6cc5/bungee/src/main/java/us/myles/ViaVersion/BungeePlugin.java#L43
try { try {
ProtocolConstants.class.getField("MINECRAFT_1_19_3"); ProtocolConstants.class.getField("MINECRAFT_1_20_2");
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
getLogger().warning(" / \\"); getLogger().warning(" / \\");
getLogger().warning(" / \\"); getLogger().warning(" / \\");
@ -111,11 +111,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
@Override @Override
public void onEnable() { 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 // Force-disable query if enabled, or else Geyser won't enable
for (ListenerInfo info : getProxy().getConfig().getListeners()) { for (ListenerInfo info : getProxy().getConfig().getListeners()) {

Datei anzeigen

@ -5,9 +5,10 @@ plugins {
id("com.modrinth.minotaur") version "2.+" id("com.modrinth.minotaur") version "2.+"
} }
java { indra {
targetCompatibility = JavaVersion.VERSION_17 javaVersions {
sourceCompatibility = JavaVersion.VERSION_17 target(17)
}
} }
dependencies { dependencies {

Datei anzeigen

@ -114,16 +114,6 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger); GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
this.geyser = GeyserImpl.load(PlatformType.VELOCITY, this); 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() { private void postStartup() {

Datei anzeigen

@ -55,19 +55,20 @@ public final class AesKeyProducer implements KeyProducer {
} }
private SecureRandom secureRandom() throws NoSuchAlgorithmException { private SecureRandom secureRandom() throws NoSuchAlgorithmException {
// use Windows-PRNG for windows (default impl is SHA1PRNG) try {
if (System.getProperty("os.name").startsWith("Windows")) { // use Windows-PRNG for windows (default impl is SHA1PRNG)
return SecureRandom.getInstance("Windows-PRNG"); if (System.getProperty("os.name").startsWith("Windows")) {
} else { return SecureRandom.getInstance("Windows-PRNG");
try { } else {
// NativePRNG (which should be the default on unix-systems) can still block your // 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 // system. Even though it isn't as bad as NativePRNGBlocking, we still try to
// prevent that if possible // prevent that if possible
return SecureRandom.getInstance("NativePRNGNonBlocking"); 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();
} }
} }
} }

Datei anzeigen

@ -44,7 +44,7 @@ public class StatisticsCommand extends GeyserCommand {
session.setWaitingForStatistics(true); session.setWaitingForStatistics(true);
ServerboundClientCommandPacket ServerboundClientCommandPacket = new ServerboundClientCommandPacket(ClientCommand.STATS); ServerboundClientCommandPacket ServerboundClientCommandPacket = new ServerboundClientCommandPacket(ClientCommand.STATS);
session.sendDownstreamPacket(ServerboundClientCommandPacket); session.sendDownstreamGamePacket(ServerboundClientCommandPacket);
} }
@Override @Override

Datei anzeigen

@ -68,7 +68,7 @@ public class InteractionEntity extends Entity {
animatePacket.setAction(AnimatePacket.Action.SWING_ARM); animatePacket.setAction(AnimatePacket.Action.SWING_ARM);
session.sendUpstreamPacket(animatePacket); session.sendUpstreamPacket(animatePacket);
session.sendDownstreamPacket(new ServerboundSwingPacket(hand)); session.sendDownstreamGamePacket(new ServerboundSwingPacket(hand));
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }

Datei anzeigen

@ -43,9 +43,9 @@ import java.io.Reader;
import java.nio.file.*; import java.nio.file.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Stream;
@RequiredArgsConstructor @RequiredArgsConstructor
public class GeyserExtensionLoader extends ExtensionLoader { public class GeyserExtensionLoader extends ExtensionLoader {
@ -148,47 +148,46 @@ public class GeyserExtensionLoader extends ExtensionLoader {
Map<String, GeyserExtensionContainer> loadedExtensions = new LinkedHashMap<>(); Map<String, GeyserExtensionContainer> loadedExtensions = new LinkedHashMap<>();
Pattern[] extensionFilters = this.extensionFilters(); Pattern[] extensionFilters = this.extensionFilters();
try (Stream<Path> entries = Files.walk(extensionsDirectory)) { List<Path> extensionPaths = Files.walk(extensionsDirectory).toList();
entries.forEach(path -> { extensionPaths.forEach(path -> {
if (Files.isDirectory(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; return;
} }
for (Pattern filter : extensionFilters) { // Completely different API version
if (!filter.matcher(path.getFileName().toString()).matches()) { if (description.majorApiVersion() != Geyser.api().majorApiVersion()) {
return; GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, description.apiVersion()));
} return;
} }
try { // If the extension requires new API features, being backwards compatible
GeyserExtensionDescription description = this.extensionDescription(path); if (description.minorApiVersion() > Geyser.api().minorApiVersion()) {
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, description.apiVersion()));
String name = description.name(); return;
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);
} }
});
} 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()) { for (GeyserExtensionContainer container : loadedExtensions.values()) {
this.extensionContainers.put(container.extension(), container); this.extensionContainers.put(container.extension(), container);

Datei anzeigen

@ -82,14 +82,14 @@ public class AnvilContainer extends Container {
correctRename = plainNewName; correctRename = plainNewName;
// Java Edition sends a packet every time an item is renamed even slightly in GUI. Fortunately, this works out for us now // 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); ServerboundRenameItemPacket renameItemPacket = new ServerboundRenameItemPacket(plainNewName);
session.sendDownstreamPacket(renameItemPacket); session.sendDownstreamGamePacket(renameItemPacket);
} else { } else {
// Restore formatting for item since we're not renaming // Restore formatting for item since we're not renaming
correctRename = MessageTranslator.convertMessageLenient(originalName); correctRename = MessageTranslator.convertMessageLenient(originalName);
// Java Edition sends the original custom name when not renaming, // Java Edition sends the original custom name when not renaming,
// if there isn't a custom name an empty string is sent // if there isn't a custom name an empty string is sent
ServerboundRenameItemPacket renameItemPacket = new ServerboundRenameItemPacket(plainOriginalName); ServerboundRenameItemPacket renameItemPacket = new ServerboundRenameItemPacket(plainOriginalName);
session.sendDownstreamPacket(renameItemPacket); session.sendDownstreamGamePacket(renameItemPacket);
} }
useJavaLevelCost = false; useJavaLevelCost = false;

Datei anzeigen

@ -152,7 +152,7 @@ public final class ClickPlan {
changedItems changedItems
); );
session.sendDownstreamPacket(clickPacket); session.sendDownstreamGamePacket(clickPacket);
} }
session.getPlayerInventory().setCursor(simulatedCursor, session); session.getPlayerInventory().setCursor(simulatedCursor, session);

Datei anzeigen

@ -120,7 +120,7 @@ public class AnvilInventoryUpdater extends InventoryUpdater {
// does not result in a FilterTextPacket // does not result in a FilterTextPacket
String originalName = MessageTranslator.convertToPlainTextLenient(ItemUtils.getCustomName(input.getNbt()), session.locale()); String originalName = MessageTranslator.convertToPlainTextLenient(ItemUtils.getCustomName(input.getNbt()), session.locale());
ServerboundRenameItemPacket renameItemPacket = new ServerboundRenameItemPacket(originalName); ServerboundRenameItemPacket renameItemPacket = new ServerboundRenameItemPacket(originalName);
session.sendDownstreamPacket(renameItemPacket); session.sendDownstreamGamePacket(renameItemPacket);
anvilContainer.setNewName(null); anvilContainer.setNewName(null);
} }

Datei anzeigen

@ -173,8 +173,8 @@ public final class BlockStateValues {
} }
if (javaId.contains("wall_skull") || javaId.contains("wall_head")) { if (javaId.contains("wall_skull") || javaId.contains("wall_head")) {
String direction = javaId.substring(javaId.lastIndexOf("facing=") + 7); String direction = javaId.substring(javaId.lastIndexOf("facing=") + 7, javaId.lastIndexOf("powered=") - 1);
int rotation = switch (direction.substring(0, direction.length() - 1)) { int rotation = switch (direction) {
case "north" -> 180; case "north" -> 180;
case "west" -> 90; case "west" -> 90;
case "east" -> 270; case "east" -> 270;

Datei anzeigen

@ -30,19 +30,18 @@ import org.cloudburstmc.protocol.common.util.Preconditions;
public class GeyserChunkSection { public class GeyserChunkSection {
// As of at least 1.19.80 // Temporary reversion to v8 as it reduces the frequnecy of https://github.com/GeyserMC/Geyser/issues/4240
private static final int CHUNK_SECTION_VERSION = 9; // 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 BlockStorage[] storage;
private final int sectionY;
public GeyserChunkSection(int airBlockId, int sectionY) { public GeyserChunkSection(int airBlockId) {
this(new BlockStorage[]{new BlockStorage(airBlockId), new BlockStorage(airBlockId)}, sectionY); this(new BlockStorage[]{new BlockStorage(airBlockId), new BlockStorage(airBlockId)});
} }
public GeyserChunkSection(BlockStorage[] storage, int sectionY) { public GeyserChunkSection(BlockStorage[] storage) {
this.storage = storage; this.storage = storage;
this.sectionY = sectionY;
} }
public int getFullBlock(int x, int y, int z, int layer) { 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(CHUNK_SECTION_VERSION);
buffer.writeByte(this.storage.length); buffer.writeByte(this.storage.length);
// Required for chunk version 9+ // Required for chunk version 9+
buffer.writeByte(this.sectionY);
for (BlockStorage blockStorage : this.storage) { for (BlockStorage blockStorage : this.storage) {
blockStorage.writeToNetwork(buffer); blockStorage.writeToNetwork(buffer);
} }
@ -88,12 +86,12 @@ public class GeyserChunkSection {
return true; return true;
} }
public GeyserChunkSection copy(int sectionY) { public GeyserChunkSection copy() {
BlockStorage[] storage = new BlockStorage[this.storage.length]; BlockStorage[] storage = new BlockStorage[this.storage.length];
for (int i = 0; i < storage.length; i++) { for (int i = 0; i < storage.length; i++) {
storage[i] = this.storage[i].copy(); 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) { public static int blockPosition(int x, int y, int z) {

Datei anzeigen

@ -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.v589.Bedrock_v589;
import org.cloudburstmc.protocol.bedrock.codec.v594.Bedrock_v594; import org.cloudburstmc.protocol.bedrock.codec.v594.Bedrock_v594;
import org.cloudburstmc.protocol.bedrock.codec.v618.Bedrock_v618; 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.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec;
import org.geysermc.geyser.session.GeyserSession; 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 * Default Bedrock codec that should act as a fallback. Should represent the latest available
* release of the game that Geyser supports. * release of the game that Geyser supports.
*/ */
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = Bedrock_v618.CODEC.toBuilder() public static final BedrockCodec DEFAULT_BEDROCK_CODEC = Bedrock_v622.CODEC;
.minecraftVersion("1.20.31")
.build();
/** /**
* A list of all supported Bedrock versions that can join Geyser * 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() SUPPORTED_BEDROCK_CODECS.add(Bedrock_v594.CODEC.toBuilder()
.minecraftVersion("1.20.10/1.20.15") .minecraftVersion("1.20.10/1.20.15")
.build()); .build());
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC.toBuilder() SUPPORTED_BEDROCK_CODECS.add(Bedrock_v618.CODEC.toBuilder()
.minecraftVersion("1.20.30/1.20.31") .minecraftVersion("1.20.30/1.20.32")
.build()); .build());
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC);
} }
/** /**

Datei anzeigen

@ -110,6 +110,8 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
} else if (protocolVersion < GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) { } else if (protocolVersion < GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
session.disconnect(GeyserLocale.getLocaleStringLog("geyser.network.outdated.client", supportedVersions)); session.disconnect(GeyserLocale.getLocaleStringLog("geyser.network.outdated.client", supportedVersions));
return false; return false;
} else {
throw new IllegalStateException("Default codec of protocol version " + protocolVersion + " should have been found");
} }
} }

Datei anzeigen

@ -171,10 +171,12 @@ public final class GeyserServer {
GeyserServerInitializer serverInitializer = new GeyserServerInitializer(this.geyser); GeyserServerInitializer serverInitializer = new GeyserServerInitializer(this.geyser);
playerGroup = serverInitializer.getEventLoopGroup(); playerGroup = serverInitializer.getEventLoopGroup();
this.geyser.getLogger().debug("Setting MTU to " + this.geyser.getConfig().getMtu());
return new ServerBootstrap() return new ServerBootstrap()
.channelFactory(RakChannelFactory.server(TRANSPORT.datagramChannel())) .channelFactory(RakChannelFactory.server(TRANSPORT.datagramChannel()))
.group(group) .group(group)
.option(RakChannelOption.RAK_HANDLE_PING, true) .option(RakChannelOption.RAK_HANDLE_PING, true)
.option(RakChannelOption.RAK_MAX_MTU, this.geyser.getConfig().getMtu())
.childHandler(serverInitializer); .childHandler(serverInitializer);
} }

Datei anzeigen

@ -31,7 +31,6 @@ import org.cloudburstmc.protocol.bedrock.data.inventory.crafting.PotionMixData;
import org.geysermc.geyser.inventory.item.Potion; import org.geysermc.geyser.inventory.item.Potion;
import org.geysermc.geyser.item.Items; import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.item.type.Item; import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.registry.type.ItemMappings; 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) { 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) if (itemMapping == null)
throw new NullPointerException("No item entry exists for java identifier: " + javaItem.javaIdentifier()); throw new NullPointerException("No item entry exists for java identifier: " + javaItem.javaIdentifier());

Datei anzeigen

@ -36,11 +36,13 @@ import it.unimi.dsi.fastutil.objects.*;
import org.cloudburstmc.blockstateupdater.BlockStateUpdater; import org.cloudburstmc.blockstateupdater.BlockStateUpdater;
import org.cloudburstmc.blockstateupdater.BlockStateUpdater_1_20_10; import org.cloudburstmc.blockstateupdater.BlockStateUpdater_1_20_10;
import org.cloudburstmc.blockstateupdater.BlockStateUpdater_1_20_30; 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.blockstateupdater.util.tagupdater.CompoundTagUpdaterContext;
import org.cloudburstmc.nbt.*; import org.cloudburstmc.nbt.*;
import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589; import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589;
import org.cloudburstmc.protocol.bedrock.codec.v594.Bedrock_v594; import org.cloudburstmc.protocol.bedrock.codec.v594.Bedrock_v594;
import org.cloudburstmc.protocol.bedrock.codec.v618.Bedrock_v618; 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.BlockPropertyData;
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition; import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
@ -117,11 +119,13 @@ public final class BlockRegistryPopulator {
private static void registerBedrockBlocks() { private static void registerBedrockBlocks() {
Remapper mapper594 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE); Remapper mapper594 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE);
Remapper mapper618 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE, BlockStateUpdater_1_20_30.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() var blockMappers = ImmutableMap.<ObjectIntPair<String>, Remapper>builder()
.put(ObjectIntPair.of("1_20_0", Bedrock_v589.CODEC.getProtocolVersion()), tag -> tag) .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_10", Bedrock_v594.CODEC.getProtocolVersion()), mapper594)
.put(ObjectIntPair.of("1_20_30", Bedrock_v618.CODEC.getProtocolVersion()), mapper618) .put(ObjectIntPair.of("1_20_30", Bedrock_v618.CODEC.getProtocolVersion()), mapper618)
.put(ObjectIntPair.of("1_20_40", Bedrock_v622.CODEC.getProtocolVersion()), mapper622)
.build(); .build();
// We can keep this strong as nothing should be garbage collected // We can keep this strong as nothing should be garbage collected

Datei anzeigen

@ -41,6 +41,7 @@ import org.cloudburstmc.nbt.NbtType;
import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589; import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589;
import org.cloudburstmc.protocol.bedrock.codec.v594.Bedrock_v594; import org.cloudburstmc.protocol.bedrock.codec.v594.Bedrock_v594;
import org.cloudburstmc.protocol.bedrock.codec.v618.Bedrock_v618; 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.SoundEvent;
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition; import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition; 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_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_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_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(); GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap();

Datei anzeigen

@ -1135,7 +1135,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
if (position != null) { if (position != null) {
ServerboundMovePlayerPosPacket packet = new ServerboundMovePlayerPosPacket(playerEntity.isOnGround(), ServerboundMovePlayerPosPacket packet = new ServerboundMovePlayerPosPacket(playerEntity.isOnGround(),
position.getX(), position.getY(), position.getZ()); position.getX(), position.getY(), position.getZ());
sendDownstreamPacket(packet); sendDownstreamGamePacket(packet);
} }
lastMovementTimestamp = System.currentTimeMillis(); lastMovementTimestamp = System.currentTimeMillis();
} }
@ -1317,7 +1317,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
return false; return false;
} }
sendDownstreamPacket(useItemPacket); sendDownstreamGamePacket(useItemPacket);
playerEntity.setFlag(EntityFlag.BLOCKING, true); playerEntity.setFlag(EntityFlag.BLOCKING, true);
// Metadata should be updated later // Metadata should be updated later
return true; return true;
@ -1351,7 +1351,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
if (playerEntity.getFlag(EntityFlag.BLOCKING)) { if (playerEntity.getFlag(EntityFlag.BLOCKING)) {
ServerboundPlayerActionPacket releaseItemPacket = new ServerboundPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, ServerboundPlayerActionPacket releaseItemPacket = new ServerboundPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM,
Vector3i.ZERO, Direction.DOWN, 0); Vector3i.ZERO, Direction.DOWN, 0);
sendDownstreamPacket(releaseItemPacket); sendDownstreamGamePacket(releaseItemPacket);
playerEntity.setFlag(EntityFlag.BLOCKING, false); playerEntity.setFlag(EntityFlag.BLOCKING, false);
return true; return true;
} }
@ -1361,7 +1361,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
public void requestOffhandSwap() { public void requestOffhandSwap() {
ServerboundPlayerActionPacket swapHandsPacket = new ServerboundPlayerActionPacket(PlayerAction.SWAP_HANDS, Vector3i.ZERO, ServerboundPlayerActionPacket swapHandsPacket = new ServerboundPlayerActionPacket(PlayerAction.SWAP_HANDS, Vector3i.ZERO,
Direction.DOWN, 0); Direction.DOWN, 0);
sendDownstreamPacket(swapHandsPacket); sendDownstreamGamePacket(swapHandsPacket);
} }
@Override @Override
@ -1396,14 +1396,14 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
* Sends a chat message to the Java server. * Sends a chat message to the Java server.
*/ */
public void sendChat(String message) { 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. * Sends a command to the Java server.
*/ */
public void sendCommand(String command) { 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) { public void setServerRenderDistance(int renderDistance) {
@ -1575,6 +1575,39 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
upstream.sendPacketImmediately(packet); 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. * Send a packet to the remote server.
* *
@ -1718,7 +1751,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
// We're "flying locked" in this gamemode // We're "flying locked" in this gamemode
flying = true; flying = true;
ServerboundPlayerAbilitiesPacket abilitiesPacket = new ServerboundPlayerAbilitiesPacket(true); ServerboundPlayerAbilitiesPacket abilitiesPacket = new ServerboundPlayerAbilitiesPacket(true);
sendDownstreamPacket(abilitiesPacket); sendDownstreamGamePacket(abilitiesPacket);
} }
abilities.add(Ability.FLYING); abilities.add(Ability.FLYING);
} }

Datei anzeigen

@ -97,7 +97,7 @@ public class AdvancementsCache {
} else { } else {
// Send a packet indicating that we intend to open this particular advancement window // Send a packet indicating that we intend to open this particular advancement window
ServerboundSeenAdvancementsPacket packet = new ServerboundSeenAdvancementsPacket(id); ServerboundSeenAdvancementsPacket packet = new ServerboundSeenAdvancementsPacket(id);
session.sendDownstreamPacket(packet); session.sendDownstreamGamePacket(packet);
// Wait for a response there // Wait for a response there
} }
} }
@ -137,7 +137,7 @@ public class AdvancementsCache {
builder.closedResultHandler(() -> { builder.closedResultHandler(() -> {
// Indicate that we have closed the current advancement tab // Indicate that we have closed the current advancement tab
session.sendDownstreamPacket(new ServerboundSeenAdvancementsPacket()); session.sendDownstreamGamePacket(new ServerboundSeenAdvancementsPacket());
}).validResultHandler((response) -> { }).validResultHandler((response) -> {
if (response.getClickedButtonId() < visibleAdvancements.size()) { if (response.getClickedButtonId() < visibleAdvancements.size()) {
@ -146,7 +146,7 @@ public class AdvancementsCache {
} else { } else {
buildAndShowMenuForm(); buildAndShowMenuForm();
// Indicate that we have closed the current advancement tab // Indicate that we have closed the current advancement tab
session.sendDownstreamPacket(new ServerboundSeenAdvancementsPacket()); session.sendDownstreamGamePacket(new ServerboundSeenAdvancementsPacket());
} }
}); });

Datei anzeigen

@ -68,7 +68,7 @@ public class BookEditCache {
packet = null; packet = null;
return; return;
} }
session.sendDownstreamPacket(packet); session.sendDownstreamGamePacket(packet);
packet = null; packet = null;
lastBookUpdate = System.currentTimeMillis(); lastBookUpdate = System.currentTimeMillis();
} }

Datei anzeigen

@ -114,7 +114,7 @@ public class BeaconInventoryTranslator extends AbstractBlockInventoryTranslator
// Input a beacon payment // Input a beacon payment
BeaconPaymentAction beaconPayment = (BeaconPaymentAction) request.getActions()[0]; BeaconPaymentAction beaconPayment = (BeaconPaymentAction) request.getActions()[0];
ServerboundSetBeaconPacket packet = new ServerboundSetBeaconPacket(toJava(beaconPayment.getPrimaryEffect()), toJava(beaconPayment.getSecondaryEffect())); ServerboundSetBeaconPacket packet = new ServerboundSetBeaconPacket(toJava(beaconPayment.getPrimaryEffect()), toJava(beaconPayment.getSecondaryEffect()));
session.sendDownstreamPacket(packet); session.sendDownstreamGamePacket(packet);
return acceptRequest(request, makeContainerEntries(session, inventory, IntSets.emptySet())); return acceptRequest(request, makeContainerEntries(session, inventory, IntSets.emptySet()));
} }

Datei anzeigen

@ -129,7 +129,7 @@ public class EnchantingInventoryTranslator extends AbstractBlockInventoryTransla
return rejectRequest(request); return rejectRequest(request);
} }
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), javaSlot); ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), javaSlot);
session.sendDownstreamPacket(packet); session.sendDownstreamGamePacket(packet);
return acceptRequest(request, makeContainerEntries(session, inventory, IntSets.emptySet())); return acceptRequest(request, makeContainerEntries(session, inventory, IntSets.emptySet()));
} }

Datei anzeigen

@ -102,7 +102,7 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
if (session.isDroppingLecternBook()) { if (session.isDroppingLecternBook()) {
// We have to enter the inventory GUI to eject the book // We have to enter the inventory GUI to eject the book
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), 3); ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), 3);
session.sendDownstreamPacket(packet); session.sendDownstreamGamePacket(packet);
session.setDroppingLecternBook(false); session.setDroppingLecternBook(false);
InventoryUtils.closeInventory(session, inventory.getJavaId(), false); InventoryUtils.closeInventory(session, inventory.getJavaId(), false);
} else if (lecternContainer.getBlockEntityTag() == null) { } else if (lecternContainer.getBlockEntityTag() == null) {
@ -153,7 +153,7 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
session.getLecternCache().add(position); session.getLecternCache().add(position);
// Close the window - we will reopen it once the client has this data synced // Close the window - we will reopen it once the client has this data synced
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(lecternContainer.getJavaId()); ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(lecternContainer.getJavaId());
session.sendDownstreamPacket(closeWindowPacket); session.sendDownstreamGamePacket(closeWindowPacket);
InventoryUtils.closeInventory(session, inventory.getJavaId(), false); InventoryUtils.closeInventory(session, inventory.getJavaId(), false);
} }
} }

Datei anzeigen

@ -149,7 +149,7 @@ public class LoomInventoryTranslator extends AbstractBlockInventoryTranslator {
// And the Java loom window has a fixed row/width of four // 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. :) // 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); ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), index);
session.sendDownstreamPacket(packet); session.sendDownstreamGamePacket(packet);
GeyserItemStack inputCopy = inventory.getItem(0).copy(1); GeyserItemStack inputCopy = inventory.getItem(0).copy(1);
inputCopy.setNetId(session.getNextItemNetId()); inputCopy.setNetId(session.getNextItemNetId());

Datei anzeigen

@ -155,7 +155,7 @@ public class MerchantInventoryTranslator extends BaseInventoryTranslator {
private ItemStackResponse handleTrade(GeyserSession session, Inventory inventory, ItemStackRequest request, int tradeChoice) { private ItemStackResponse handleTrade(GeyserSession session, Inventory inventory, ItemStackRequest request, int tradeChoice) {
ServerboundSelectTradePacket packet = new ServerboundSelectTradePacket(tradeChoice); ServerboundSelectTradePacket packet = new ServerboundSelectTradePacket(tradeChoice);
session.sendDownstreamPacket(packet); session.sendDownstreamGamePacket(packet);
if (session.isEmulatePost1_13Logic()) { if (session.isEmulatePost1_13Logic()) {
// 1.18 Java cooperates nicer than older versions // 1.18 Java cooperates nicer than older versions

Datei anzeigen

@ -359,7 +359,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
} }
ServerboundSetCreativeModeSlotPacket creativeDropPacket = new ServerboundSetCreativeModeSlotPacket(-1, sourceItem.getItemStack(dropAction.getCount())); ServerboundSetCreativeModeSlotPacket creativeDropPacket = new ServerboundSetCreativeModeSlotPacket(-1, sourceItem.getItemStack(dropAction.getCount()));
session.sendDownstreamPacket(creativeDropPacket); session.sendDownstreamGamePacket(creativeDropPacket);
sourceItem.sub(dropAction.getCount()); sourceItem.sub(dropAction.getCount());
} }
@ -494,7 +494,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
dropStack = new ItemStack(javaCreativeItem.getId(), dropAction.getCount(), javaCreativeItem.getNbt()); dropStack = new ItemStack(javaCreativeItem.getId(), dropAction.getCount(), javaCreativeItem.getNbt());
} }
ServerboundSetCreativeModeSlotPacket creativeDropPacket = new ServerboundSetCreativeModeSlotPacket(-1, dropStack); ServerboundSetCreativeModeSlotPacket creativeDropPacket = new ServerboundSetCreativeModeSlotPacket(-1, dropStack);
session.sendDownstreamPacket(creativeDropPacket); session.sendDownstreamGamePacket(creativeDropPacket);
break; break;
} }
default: default:
@ -515,7 +515,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
ItemStack itemStack = item.isEmpty() ? new ItemStack(-1, 0, null) : item.getItemStack(); ItemStack itemStack = item.isEmpty() ? new ItemStack(-1, 0, null) : item.getItemStack();
ServerboundSetCreativeModeSlotPacket creativePacket = new ServerboundSetCreativeModeSlotPacket(slot, itemStack); ServerboundSetCreativeModeSlotPacket creativePacket = new ServerboundSetCreativeModeSlotPacket(slot, itemStack);
session.sendDownstreamPacket(creativePacket); session.sendDownstreamGamePacket(creativePacket);
} }
private static boolean isCraftingGrid(ItemStackRequestSlotData slotInfoData) { private static boolean isCraftingGrid(ItemStackRequestSlotData slotInfoData) {

Datei anzeigen

@ -69,7 +69,7 @@ public class StonecutterInventoryTranslator extends AbstractBlockInventoryTransl
if (container.getStonecutterButton() != button) { if (container.getStonecutterButton() != button) {
// Getting the index of the item in the Java stonecutter list // Getting the index of the item in the Java stonecutter list
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), button); ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), button);
session.sendDownstreamPacket(packet); session.sendDownstreamGamePacket(packet);
container.setStonecutterButton(button); container.setStonecutterButton(button);
} }

Datei anzeigen

@ -64,7 +64,7 @@ public class BedrockAnimateTranslator extends PacketTranslator<AnimatePacket> {
// and Bedrock 1.19.51. // and Bedrock 1.19.51.
// Note for the future: we should probably largely ignore this packet and instead replicate // Note for the future: we should probably largely ignore this packet and instead replicate
// all actions on our end, and send swings where needed. // 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(); 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 // 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); session.setSteeringLeft(packet.getRowingTime() > 0.0);
ServerboundPaddleBoatPacket steerLeftPacket = new ServerboundPaddleBoatPacket(session.isSteeringLeft(), session.isSteeringRight()); ServerboundPaddleBoatPacket steerLeftPacket = new ServerboundPaddleBoatPacket(session.isSteeringLeft(), session.isSteeringRight());
session.sendDownstreamPacket(steerLeftPacket); session.sendDownstreamGamePacket(steerLeftPacket);
} }
case ROW_RIGHT -> { case ROW_RIGHT -> {
session.setSteeringRight(packet.getRowingTime() > 0.0); session.setSteeringRight(packet.getRowingTime() > 0.0);
ServerboundPaddleBoatPacket steerRightPacket = new ServerboundPaddleBoatPacket(session.isSteeringLeft(), session.isSteeringRight()); ServerboundPaddleBoatPacket steerRightPacket = new ServerboundPaddleBoatPacket(session.isSteeringLeft(), session.isSteeringRight());
session.sendDownstreamPacket(steerRightPacket); session.sendDownstreamGamePacket(steerRightPacket);
} }
} }
} }

Datei anzeigen

@ -108,7 +108,7 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator<BlockEnti
if (iterator < lines.length) lines[iterator] = newMessage.toString(); if (iterator < lines.length) lines[iterator] = newMessage.toString();
Vector3i pos = Vector3i.from(tag.getInt("x"), tag.getInt("y"), tag.getInt("z")); Vector3i pos = Vector3i.from(tag.getInt("x"), tag.getInt("y"), tag.getInt("z"));
ServerboundSignUpdatePacket signUpdatePacket = new ServerboundSignUpdatePacket(pos, lines, session.getWorldCache().isEditingSignOnFront()); ServerboundSignUpdatePacket signUpdatePacket = new ServerboundSignUpdatePacket(pos, lines, session.getWorldCache().isEditingSignOnFront());
session.sendDownstreamPacket(signUpdatePacket); session.sendDownstreamGamePacket(signUpdatePacket);
} else if (id.equals("JigsawBlock")) { } else if (id.equals("JigsawBlock")) {
// Client has just sent a jigsaw block update // Client has just sent a jigsaw block update
@ -120,7 +120,7 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator<BlockEnti
String joint = tag.getString("joint"); String joint = tag.getString("joint");
ServerboundSetJigsawBlockPacket jigsawPacket = new ServerboundSetJigsawBlockPacket(pos, name, target, pool, ServerboundSetJigsawBlockPacket jigsawPacket = new ServerboundSetJigsawBlockPacket(pos, name, target, pool,
finalState, joint); finalState, joint);
session.sendDownstreamPacket(jigsawPacket); session.sendDownstreamGamePacket(jigsawPacket);
} }
} }

Datei anzeigen

@ -53,13 +53,13 @@ public class BedrockCommandBlockUpdateTranslator extends PacketTranslator<Comman
boolean automatic = !packet.isRedstoneMode(); // Automatic = Always Active option in Java boolean automatic = !packet.isRedstoneMode(); // Automatic = Always Active option in Java
ServerboundSetCommandBlockPacket commandBlockPacket = new ServerboundSetCommandBlockPacket( ServerboundSetCommandBlockPacket commandBlockPacket = new ServerboundSetCommandBlockPacket(
packet.getBlockPosition(), command, mode, outputTracked, isConditional, automatic); packet.getBlockPosition(), command, mode, outputTracked, isConditional, automatic);
session.sendDownstreamPacket(commandBlockPacket); session.sendDownstreamGamePacket(commandBlockPacket);
} else { } else {
ServerboundSetCommandMinecartPacket commandMinecartPacket = new ServerboundSetCommandMinecartPacket( ServerboundSetCommandMinecartPacket commandMinecartPacket = new ServerboundSetCommandMinecartPacket(
session.getEntityCache().getEntityByGeyserId(packet.getMinecartRuntimeEntityId()).getEntityId(), session.getEntityCache().getEntityByGeyserId(packet.getMinecartRuntimeEntityId()).getEntityId(),
command, outputTracked command, outputTracked
); );
session.sendDownstreamPacket(commandMinecartPacket); session.sendDownstreamGamePacket(commandMinecartPacket);
} }
} }
} }

Datei anzeigen

@ -55,7 +55,7 @@ public class BedrockContainerCloseTranslator extends PacketTranslator<ContainerC
if (openInventory != null) { if (openInventory != null) {
if (bedrockId == openInventory.getBedrockId()) { if (bedrockId == openInventory.getBedrockId()) {
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(openInventory.getJavaId()); ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(openInventory.getJavaId());
session.sendDownstreamPacket(closeWindowPacket); session.sendDownstreamGamePacket(closeWindowPacket);
InventoryUtils.closeInventory(session, openInventory.getJavaId(), false); InventoryUtils.closeInventory(session, openInventory.getJavaId(), false);
} else if (openInventory.isPending()) { } else if (openInventory.isPending()) {
InventoryUtils.displayInventory(session, openInventory); InventoryUtils.displayInventory(session, openInventory);

Datei anzeigen

@ -137,7 +137,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
ServerboundContainerClickPacket dropPacket = new ServerboundContainerClickPacket( ServerboundContainerClickPacket dropPacket = new ServerboundContainerClickPacket(
inventory.getJavaId(), inventory.getStateId(), hotbarSlot, clickType.actionType, clickType.action, inventory.getJavaId(), inventory.getStateId(), hotbarSlot, clickType.actionType, clickType.action,
inventory.getCursor().getItemStack(), changedItem); inventory.getCursor().getItemStack(), changedItem);
session.sendDownstreamPacket(dropPacket); session.sendDownstreamGamePacket(dropPacket);
return; return;
} }
if (session.getPlayerInventory().getItemInHand().isEmpty()) { if (session.getPlayerInventory().getItemInHand().isEmpty()) {
@ -150,7 +150,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
Direction.DOWN, Direction.DOWN,
0 0
); );
session.sendDownstreamPacket(dropPacket); session.sendDownstreamGamePacket(dropPacket);
if (dropAll) { if (dropAll) {
session.getPlayerInventory().setItemInHand(GeyserItemStack.EMPTY); session.getPlayerInventory().setItemInHand(GeyserItemStack.EMPTY);
@ -309,7 +309,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
packet.getClickPosition().getX(), packet.getClickPosition().getY(), packet.getClickPosition().getZ(), packet.getClickPosition().getX(), packet.getClickPosition().getY(), packet.getClickPosition().getZ(),
false, false,
session.getWorldCache().nextPredictionSequence()); session.getWorldCache().nextPredictionSequence());
session.sendDownstreamPacket(blockPacket); session.sendDownstreamGamePacket(blockPacket);
Item item = session.getPlayerInventory().getItemInHand().asItem(); Item item = session.getPlayerInventory().getItemInHand().asItem();
if (packet.getItemInHand() != null) { if (packet.getItemInHand() != null) {
@ -384,7 +384,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
} }
ServerboundUseItemPacket useItemPacket = new ServerboundUseItemPacket(Hand.MAIN_HAND, session.getWorldCache().nextPredictionSequence()); ServerboundUseItemPacket useItemPacket = new ServerboundUseItemPacket(Hand.MAIN_HAND, session.getWorldCache().nextPredictionSequence());
session.sendDownstreamPacket(useItemPacket); session.sendDownstreamGamePacket(useItemPacket);
List<LegacySetItemSlotData> legacySlots = packet.getLegacySlots(); List<LegacySetItemSlotData> legacySlots = packet.getLegacySlots();
if (packet.getActions().size() == 1 && legacySlots.size() > 0) { if (packet.getActions().size() == 1 && legacySlots.size() > 0) {
@ -453,13 +453,13 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
if (itemFrameEntity != null) { if (itemFrameEntity != null) {
ServerboundInteractPacket attackPacket = new ServerboundInteractPacket(itemFrameEntity.getEntityId(), ServerboundInteractPacket attackPacket = new ServerboundInteractPacket(itemFrameEntity.getEntityId(),
InteractAction.ATTACK, session.isSneaking()); InteractAction.ATTACK, session.isSneaking());
session.sendDownstreamPacket(attackPacket); session.sendDownstreamGamePacket(attackPacket);
break; break;
} }
PlayerAction action = session.getGameMode() == GameMode.CREATIVE ? PlayerAction.START_DIGGING : PlayerAction.FINISH_DIGGING; PlayerAction action = session.getGameMode() == GameMode.CREATIVE ? PlayerAction.START_DIGGING : PlayerAction.FINISH_DIGGING;
ServerboundPlayerActionPacket breakPacket = new ServerboundPlayerActionPacket(action, packet.getBlockPosition(), Direction.VALUES[packet.getBlockFace()], sequence); ServerboundPlayerActionPacket breakPacket = new ServerboundPlayerActionPacket(action, packet.getBlockPosition(), Direction.VALUES[packet.getBlockFace()], sequence);
session.sendDownstreamPacket(breakPacket); session.sendDownstreamGamePacket(breakPacket);
} }
} }
break; break;
@ -468,7 +468,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
// Followed to the Minecraft Protocol specification outlined at wiki.vg // Followed to the Minecraft Protocol specification outlined at wiki.vg
ServerboundPlayerActionPacket releaseItemPacket = new ServerboundPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, Vector3i.ZERO, ServerboundPlayerActionPacket releaseItemPacket = new ServerboundPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, Vector3i.ZERO,
Direction.DOWN, 0); Direction.DOWN, 0);
session.sendDownstreamPacket(releaseItemPacket); session.sendDownstreamGamePacket(releaseItemPacket);
} }
break; break;
case ITEM_USE_ON_ENTITY: case ITEM_USE_ON_ENTITY:
@ -490,7 +490,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
} }
ServerboundInteractPacket attackPacket = new ServerboundInteractPacket(entityId, ServerboundInteractPacket attackPacket = new ServerboundInteractPacket(entityId,
InteractAction.ATTACK, session.isSneaking()); 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 // Since 1.19.10, LevelSoundEventPackets are no longer sent by the client when attacking entities
CooldownUtils.sendCooldown(session); CooldownUtils.sendCooldown(session);
@ -510,7 +510,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
Vector3f clickPosition = packet.getClickPosition().sub(entityPosition); Vector3f clickPosition = packet.getClickPosition().sub(entityPosition);
boolean isSpectator = session.getGameMode() == GameMode.SPECTATOR; boolean isSpectator = session.getGameMode() == GameMode.SPECTATOR;
for (Hand hand : EntityUtils.HANDS) { 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(), InteractAction.INTERACT_AT, clickPosition.getX(), clickPosition.getY(), clickPosition.getZ(),
hand, session.isSneaking())); hand, session.isSneaking()));
@ -522,7 +522,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
} }
if (!result.consumesAction()) { if (!result.consumesAction()) {
session.sendDownstreamPacket(new ServerboundInteractPacket(entity.getEntityId(), session.sendDownstreamGamePacket(new ServerboundInteractPacket(entity.getEntityId(),
InteractAction.INTERACT, hand, session.isSneaking())); InteractAction.INTERACT, hand, session.isSneaking()));
if (!isSpectator) { if (!isSpectator) {
result = entity.interact(hand); result = entity.interact(hand);
@ -532,7 +532,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
if (result.consumesAction()) { if (result.consumesAction()) {
if (result.shouldSwing() && hand == Hand.OFF_HAND) { 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. // 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 // Note here to look into sending the animation packet back to Bedrock
} }
return; return;
@ -629,7 +629,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
lookAt(session, target); lookAt(session, target);
ServerboundUseItemPacket itemPacket = new ServerboundUseItemPacket(Hand.MAIN_HAND, session.getWorldCache().nextPredictionSequence()); ServerboundUseItemPacket itemPacket = new ServerboundUseItemPacket(Hand.MAIN_HAND, session.getWorldCache().nextPredictionSequence());
session.sendDownstreamPacket(itemPacket); session.sendDownstreamGamePacket(itemPacket);
return true; 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()); ServerboundMovePlayerPosRotPacket returnPacket = new ServerboundMovePlayerPosRotPacket(entity.isOnGround(), playerPosition.getX(), playerPosition.getY(), playerPosition.getZ(), entity.getYaw(), entity.getPitch());
// This matches Java edition behavior // This matches Java edition behavior
ServerboundMovePlayerPosRotPacket movementPacket = new ServerboundMovePlayerPosRotPacket(entity.isOnGround(), playerPosition.getX(), playerPosition.getY(), playerPosition.getZ(), yaw, pitch); ServerboundMovePlayerPosRotPacket movementPacket = new ServerboundMovePlayerPosRotPacket(entity.isOnGround(), playerPosition.getX(), playerPosition.getY(), playerPosition.getZ(), yaw, pitch);
session.sendDownstreamPacket(movementPacket); session.sendDownstreamGamePacket(movementPacket);
if (session.getLookBackScheduledFuture() != null) { if (session.getLookBackScheduledFuture() != null) {
session.getLookBackScheduledFuture().cancel(false); 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 // The player moved/rotated so there is no need to change their rotation back
return; return;
} }
session.sendDownstreamPacket(returnPacket); session.sendDownstreamGamePacket(returnPacket);
}, 150, TimeUnit.MILLISECONDS)); }, 150, TimeUnit.MILLISECONDS));
} }
} }

Datei anzeigen

@ -49,7 +49,7 @@ public class BedrockItemFrameDropItemTranslator extends PacketTranslator<ItemFra
if (entity != null) { if (entity != null) {
ServerboundInteractPacket interactPacket = new ServerboundInteractPacket(entity.getEntityId(), ServerboundInteractPacket interactPacket = new ServerboundInteractPacket(entity.getEntityId(),
InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking()); InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking());
session.sendDownstreamPacket(interactPacket); session.sendDownstreamGamePacket(interactPacket);
} }
} }
} }

Datei anzeigen

@ -58,7 +58,7 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
0, 0, 0, // Java doesn't care about these when dealing with a lectern 0, 0, 0, // Java doesn't care about these when dealing with a lectern
false, false,
session.getWorldCache().nextPredictionSequence()); session.getWorldCache().nextPredictionSequence());
session.sendDownstreamPacket(blockPacket); session.sendDownstreamGamePacket(blockPacket);
} else { } else {
// Bedrock wants to either move a page or exit // Bedrock wants to either move a page or exit
if (!(session.getOpenInventory() instanceof LecternContainer lecternContainer)) { if (!(session.getOpenInventory() instanceof LecternContainer lecternContainer)) {
@ -69,7 +69,7 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
if (lecternContainer.getCurrentBedrockPage() == packet.getPage()) { if (lecternContainer.getCurrentBedrockPage() == packet.getPage()) {
// The same page means Bedrock is closing the window // The same page means Bedrock is closing the window
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(lecternContainer.getJavaId()); ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(lecternContainer.getJavaId());
session.sendDownstreamPacket(closeWindowPacket); session.sendDownstreamGamePacket(closeWindowPacket);
InventoryUtils.closeInventory(session, lecternContainer.getJavaId(), false); InventoryUtils.closeInventory(session, lecternContainer.getJavaId(), false);
} else { } else {
// Each "page" Bedrock gives to us actually represents two pages (think opening a book and seeing two pages) // 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) { if (newJavaPage > currentJavaPage) {
for (int i = currentJavaPage; i < newJavaPage; i++) { for (int i = currentJavaPage; i < newJavaPage; i++) {
ServerboundContainerButtonClickPacket clickButtonPacket = new ServerboundContainerButtonClickPacket(session.getOpenInventory().getJavaId(), 2); ServerboundContainerButtonClickPacket clickButtonPacket = new ServerboundContainerButtonClickPacket(session.getOpenInventory().getJavaId(), 2);
session.sendDownstreamPacket(clickButtonPacket); session.sendDownstreamGamePacket(clickButtonPacket);
} }
} else { } else {
for (int i = currentJavaPage; i > newJavaPage; i--) { for (int i = currentJavaPage; i > newJavaPage; i--) {
ServerboundContainerButtonClickPacket clickButtonPacket = new ServerboundContainerButtonClickPacket(session.getOpenInventory().getJavaId(), 1); ServerboundContainerButtonClickPacket clickButtonPacket = new ServerboundContainerButtonClickPacket(session.getOpenInventory().getJavaId(), 1);
session.sendDownstreamPacket(clickButtonPacket); session.sendDownstreamGamePacket(clickButtonPacket);
} }
} }
} }

Datei anzeigen

@ -58,7 +58,7 @@ public class BedrockMobEquipmentTranslator extends PacketTranslator<MobEquipment
session.getPlayerInventory().setHeldItemSlot(newSlot); session.getPlayerInventory().setHeldItemSlot(newSlot);
ServerboundSetCarriedItemPacket setCarriedItemPacket = new ServerboundSetCarriedItemPacket(newSlot); ServerboundSetCarriedItemPacket setCarriedItemPacket = new ServerboundSetCarriedItemPacket(newSlot);
session.sendDownstreamPacket(setCarriedItemPacket); session.sendDownstreamGamePacket(setCarriedItemPacket);
GeyserItemStack newItem = session.getPlayerInventory().getItemInHand(); GeyserItemStack newItem = session.getPlayerInventory().getItemInHand();
@ -66,7 +66,7 @@ public class BedrockMobEquipmentTranslator extends PacketTranslator<MobEquipment
// Activate shield since we are already sneaking // Activate shield since we are already sneaking
// (No need to send a release item packet - Java doesn't do this when swapping items) // (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 // 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); 50, TimeUnit.MILLISECONDS);
} }

Datei anzeigen

@ -72,6 +72,6 @@ public class BedrockMoveEntityAbsoluteTranslator extends PacketTranslator<MoveEn
packet.getPosition().getX(), y, packet.getPosition().getZ(), packet.getPosition().getX(), y, packet.getPosition().getZ(),
packet.getRotation().getY() - 90, packet.getRotation().getX() packet.getRotation().getY() - 90, packet.getRotation().getX()
); );
session.sendDownstreamPacket(ServerboundMoveVehiclePacket); session.sendDownstreamGamePacket(ServerboundMoveVehiclePacket);
} }
} }

Datei anzeigen

@ -50,7 +50,7 @@ public class BedrockPlayerInputTranslator extends PacketTranslator<PlayerInputPa
packet.getInputMotion().getX(), packet.getInputMotion().getY(), packet.isJumping(), packet.isSneaking() packet.getInputMotion().getX(), packet.getInputMotion().getY(), packet.isJumping(), packet.isSneaking()
); );
session.sendDownstreamPacket(playerInputPacket); session.sendDownstreamGamePacket(playerInputPacket);
// Bedrock only sends movement vehicle packets while moving // Bedrock only sends movement vehicle packets while moving
// This allows horses to take damage while standing on magma // 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(), vehiclePosition.getX(), vehiclePosition.getY(), vehiclePosition.getZ(),
vehicle.getYaw() - 90, vehicle.getPitch() vehicle.getYaw() - 90, vehicle.getPitch()
); );
session.sendDownstreamPacket(moveVehiclePacket); session.sendDownstreamGamePacket(moveVehiclePacket);
} }
} }
} }

Datei anzeigen

@ -58,7 +58,7 @@ public class BedrockRequestAbilityTranslator extends PacketTranslator<RequestAbi
session.setFlying(isFlying); session.setFlying(isFlying);
ServerboundPlayerAbilitiesPacket abilitiesPacket = new ServerboundPlayerAbilitiesPacket(isFlying); ServerboundPlayerAbilitiesPacket abilitiesPacket = new ServerboundPlayerAbilitiesPacket(isFlying);
session.sendDownstreamPacket(abilitiesPacket); session.sendDownstreamGamePacket(abilitiesPacket);
} }
} }
} }

Datei anzeigen

@ -39,7 +39,7 @@ public class BedrockRespawnTranslator extends PacketTranslator<RespawnPacket> {
public void translate(GeyserSession session, RespawnPacket packet) { public void translate(GeyserSession session, RespawnPacket packet) {
if (packet.getState() == RespawnPacket.State.CLIENT_READY) { if (packet.getState() == RespawnPacket.State.CLIENT_READY) {
ServerboundClientCommandPacket javaRespawnPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN); ServerboundClientCommandPacket javaRespawnPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN);
session.sendDownstreamPacket(javaRespawnPacket); session.sendDownstreamGamePacket(javaRespawnPacket);
} }
} }
} }

Datei anzeigen

@ -39,7 +39,7 @@ public class BedrockShowCreditsTranslator extends PacketTranslator<ShowCreditsPa
public void translate(GeyserSession session, ShowCreditsPacket packet) { public void translate(GeyserSession session, ShowCreditsPacket packet) {
if (packet.getStatus() == ShowCreditsPacket.Status.END_CREDITS) { if (packet.getStatus() == ShowCreditsPacket.Status.END_CREDITS) {
ServerboundClientCommandPacket javaRespawnPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN); ServerboundClientCommandPacket javaRespawnPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN);
session.sendDownstreamPacket(javaRespawnPacket); session.sendDownstreamGamePacket(javaRespawnPacket);
} }
} }
} }

Datei anzeigen

@ -49,7 +49,7 @@ public class BedrockEntityEventTranslator extends PacketTranslator<EntityEventPa
case COMPLETE_TRADE -> { case COMPLETE_TRADE -> {
// Not sent as of 1.18.10 // Not sent as of 1.18.10
ServerboundSelectTradePacket selectTradePacket = new ServerboundSelectTradePacket(packet.getData()); ServerboundSelectTradePacket selectTradePacket = new ServerboundSelectTradePacket(packet.getData());
session.sendDownstreamPacket(selectTradePacket); session.sendDownstreamGamePacket(selectTradePacket);
session.scheduleInEventLoop(() -> { session.scheduleInEventLoop(() -> {
Inventory openInventory = session.getOpenInventory(); Inventory openInventory = session.getOpenInventory();

Datei anzeigen

@ -26,10 +26,6 @@
package org.geysermc.geyser.translator.protocol.bedrock.entity.player; 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.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.GameMode;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction; import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction;
@ -97,7 +93,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
case START_SWIMMING: case START_SWIMMING:
if (!entity.getFlag(EntityFlag.SWIMMING)) { if (!entity.getFlag(EntityFlag.SWIMMING)) {
ServerboundPlayerCommandPacket startSwimPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_SPRINTING); ServerboundPlayerCommandPacket startSwimPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_SPRINTING);
session.sendDownstreamPacket(startSwimPacket); session.sendDownstreamGamePacket(startSwimPacket);
session.setSwimming(true); 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 // Prevent packet spam when Bedrock players are crawling near the edge of a block
if (!session.getCollisionManager().mustPlayerCrawlHere()) { if (!session.getCollisionManager().mustPlayerCrawlHere()) {
ServerboundPlayerCommandPacket stopSwimPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.STOP_SPRINTING); ServerboundPlayerCommandPacket stopSwimPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.STOP_SPRINTING);
session.sendDownstreamPacket(stopSwimPacket); session.sendDownstreamGamePacket(stopSwimPacket);
session.setSwimming(false); session.setSwimming(false);
} }
@ -114,45 +110,45 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
case START_GLIDE: case START_GLIDE:
// Otherwise gliding will not work in creative // Otherwise gliding will not work in creative
ServerboundPlayerAbilitiesPacket playerAbilitiesPacket = new ServerboundPlayerAbilitiesPacket(false); ServerboundPlayerAbilitiesPacket playerAbilitiesPacket = new ServerboundPlayerAbilitiesPacket(false);
session.sendDownstreamPacket(playerAbilitiesPacket); session.sendDownstreamGamePacket(playerAbilitiesPacket);
case STOP_GLIDE: case STOP_GLIDE:
ServerboundPlayerCommandPacket glidePacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_ELYTRA_FLYING); ServerboundPlayerCommandPacket glidePacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_ELYTRA_FLYING);
session.sendDownstreamPacket(glidePacket); session.sendDownstreamGamePacket(glidePacket);
break; break;
case START_SNEAK: case START_SNEAK:
ServerboundPlayerCommandPacket startSneakPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_SNEAKING); ServerboundPlayerCommandPacket startSneakPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_SNEAKING);
session.sendDownstreamPacket(startSneakPacket); session.sendDownstreamGamePacket(startSneakPacket);
session.startSneaking(); session.startSneaking();
break; break;
case STOP_SNEAK: case STOP_SNEAK:
ServerboundPlayerCommandPacket stopSneakPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.STOP_SNEAKING); ServerboundPlayerCommandPacket stopSneakPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.STOP_SNEAKING);
session.sendDownstreamPacket(stopSneakPacket); session.sendDownstreamGamePacket(stopSneakPacket);
session.stopSneaking(); session.stopSneaking();
break; break;
case START_SPRINT: case START_SPRINT:
if (!entity.getFlag(EntityFlag.SWIMMING)) { if (!entity.getFlag(EntityFlag.SWIMMING)) {
ServerboundPlayerCommandPacket startSprintPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_SPRINTING); ServerboundPlayerCommandPacket startSprintPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_SPRINTING);
session.sendDownstreamPacket(startSprintPacket); session.sendDownstreamGamePacket(startSprintPacket);
session.setSprinting(true); session.setSprinting(true);
} }
break; break;
case STOP_SPRINT: case STOP_SPRINT:
if (!entity.getFlag(EntityFlag.SWIMMING)) { if (!entity.getFlag(EntityFlag.SWIMMING)) {
ServerboundPlayerCommandPacket stopSprintPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.STOP_SPRINTING); ServerboundPlayerCommandPacket stopSprintPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.STOP_SPRINTING);
session.sendDownstreamPacket(stopSprintPacket); session.sendDownstreamGamePacket(stopSprintPacket);
} }
session.setSprinting(false); session.setSprinting(false);
break; break;
case DROP_ITEM: case DROP_ITEM:
ServerboundPlayerActionPacket dropItemPacket = new ServerboundPlayerActionPacket(PlayerAction.DROP_ITEM, ServerboundPlayerActionPacket dropItemPacket = new ServerboundPlayerActionPacket(PlayerAction.DROP_ITEM,
vector, Direction.VALUES[packet.getFace()], 0); vector, Direction.VALUES[packet.getFace()], 0);
session.sendDownstreamPacket(dropItemPacket); session.sendDownstreamGamePacket(dropItemPacket);
break; break;
case STOP_SLEEP: case STOP_SLEEP:
ServerboundPlayerCommandPacket stopSleepingPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.LEAVE_BED); ServerboundPlayerCommandPacket stopSleepingPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.LEAVE_BED);
session.sendDownstreamPacket(stopSleepingPacket); session.sendDownstreamGamePacket(stopSleepingPacket);
break; break;
case START_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 // 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")) { if (identifier.startsWith("minecraft:fire") || identifier.startsWith("minecraft:soul_fire")) {
ServerboundPlayerActionPacket startBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, fireBlockPos, ServerboundPlayerActionPacket startBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, fireBlockPos,
Direction.VALUES[packet.getFace()], session.getWorldCache().nextPredictionSequence()); Direction.VALUES[packet.getFace()], session.getWorldCache().nextPredictionSequence());
session.sendDownstreamPacket(startBreakingPacket); session.sendDownstreamGamePacket(startBreakingPacket);
} }
ServerboundPlayerActionPacket startBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, ServerboundPlayerActionPacket startBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING,
vector, Direction.VALUES[packet.getFace()], session.getWorldCache().nextPredictionSequence()); vector, Direction.VALUES[packet.getFace()], session.getWorldCache().nextPredictionSequence());
session.sendDownstreamPacket(startBreakingPacket); session.sendDownstreamGamePacket(startBreakingPacket);
break; break;
} }
case CONTINUE_BREAK: case CONTINUE_BREAK:
@ -236,7 +232,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
// Break the block // Break the block
ServerboundPlayerActionPacket finishBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.FINISH_DIGGING, ServerboundPlayerActionPacket finishBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.FINISH_DIGGING,
vector, Direction.VALUES[packet.getFace()], session.getWorldCache().nextPredictionSequence()); vector, Direction.VALUES[packet.getFace()], session.getWorldCache().nextPredictionSequence());
session.sendDownstreamPacket(finishBreakingPacket); session.sendDownstreamGamePacket(finishBreakingPacket);
session.setBlockBreakStartTime(0); session.setBlockBreakStartTime(0);
break; break;
} }
@ -253,13 +249,13 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
if (itemFrameEntity != null) { if (itemFrameEntity != null) {
ServerboundInteractPacket interactPacket = new ServerboundInteractPacket(itemFrameEntity.getEntityId(), ServerboundInteractPacket interactPacket = new ServerboundInteractPacket(itemFrameEntity.getEntityId(),
InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking()); InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking());
session.sendDownstreamPacket(interactPacket); session.sendDownstreamGamePacket(interactPacket);
break; break;
} }
} }
ServerboundPlayerActionPacket abortBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.CANCEL_DIGGING, vector, Direction.DOWN, 0); ServerboundPlayerActionPacket abortBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.CANCEL_DIGGING, vector, Direction.DOWN, 0);
session.sendDownstreamPacket(abortBreakingPacket); session.sendDownstreamGamePacket(abortBreakingPacket);
LevelEventPacket stopBreak = new LevelEventPacket(); LevelEventPacket stopBreak = new LevelEventPacket();
stopBreak.setType(LevelEvent.BLOCK_STOP_BREAK); stopBreak.setType(LevelEvent.BLOCK_STOP_BREAK);
stopBreak.setPosition(vector.toFloat()); stopBreak.setPosition(vector.toFloat());
@ -287,7 +283,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
case MISSED_SWING: case MISSED_SWING:
// TODO Re-evaluate after pre-1.20.10 is no longer supported? // TODO Re-evaluate after pre-1.20.10 is no longer supported?
if (session.getArmAnimationTicks() == -1) { if (session.getArmAnimationTicks() == -1) {
session.sendDownstreamPacket(new ServerboundSwingPacket(Hand.MAIN_HAND)); session.sendDownstreamGamePacket(new ServerboundSwingPacket(Hand.MAIN_HAND));
session.activateArmAnimationTicking(); session.activateArmAnimationTicking();
// Send packet to Bedrock so it knows // Send packet to Bedrock so it knows
@ -313,7 +309,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
} }
session.setFlying(true); session.setFlying(true);
session.sendDownstreamPacket(new ServerboundPlayerAbilitiesPacket(true)); session.sendDownstreamGamePacket(new ServerboundPlayerAbilitiesPacket(true));
} else { } else {
// update whether we can fly // update whether we can fly
session.sendAdventureSettings(); session.sendAdventureSettings();
@ -329,7 +325,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
break; break;
case STOP_FLYING: case STOP_FLYING:
session.setFlying(false); session.setFlying(false);
session.sendDownstreamPacket(new ServerboundPlayerAbilitiesPacket(false)); session.sendDownstreamGamePacket(new ServerboundPlayerAbilitiesPacket(false));
break; break;
} }
} }

Datei anzeigen

@ -68,16 +68,16 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
} }
ServerboundInteractPacket interactPacket = new ServerboundInteractPacket(entity.getEntityId(), ServerboundInteractPacket interactPacket = new ServerboundInteractPacket(entity.getEntityId(),
InteractAction.INTERACT, Hand.MAIN_HAND, session.isSneaking()); InteractAction.INTERACT, Hand.MAIN_HAND, session.isSneaking());
session.sendDownstreamPacket(interactPacket); session.sendDownstreamGamePacket(interactPacket);
break; break;
case DAMAGE: case DAMAGE:
ServerboundInteractPacket attackPacket = new ServerboundInteractPacket(entity.getEntityId(), ServerboundInteractPacket attackPacket = new ServerboundInteractPacket(entity.getEntityId(),
InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking()); InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking());
session.sendDownstreamPacket(attackPacket); session.sendDownstreamGamePacket(attackPacket);
break; break;
case LEAVE_VEHICLE: case LEAVE_VEHICLE:
ServerboundPlayerCommandPacket sneakPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_SNEAKING); ServerboundPlayerCommandPacket sneakPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_SNEAKING);
session.sendDownstreamPacket(sneakPacket); session.sendDownstreamGamePacket(sneakPacket);
Entity currentVehicle = session.getPlayerEntity().getVehicle(); Entity currentVehicle = session.getPlayerEntity().getVehicle();
if (currentVehicle != null) { 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)) { 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. // This mob has an inventory of its own that we should open instead.
ServerboundPlayerCommandPacket openVehicleWindowPacket = new ServerboundPlayerCommandPacket(session.getPlayerEntity().getEntityId(), PlayerState.OPEN_VEHICLE_INVENTORY); ServerboundPlayerCommandPacket openVehicleWindowPacket = new ServerboundPlayerCommandPacket(session.getPlayerEntity().getEntityId(), PlayerState.OPEN_VEHICLE_INVENTORY);
session.sendDownstreamPacket(openVehicleWindowPacket); session.sendDownstreamGamePacket(openVehicleWindowPacket);
} else { } else {
session.setOpenInventory(session.getPlayerInventory()); session.setOpenInventory(session.getPlayerInventory());

Datei anzeigen

@ -83,7 +83,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
entity.setHeadYaw(headYaw); entity.setHeadYaw(headYaw);
entity.setOnGround(packet.isOnGround()); entity.setOnGround(packet.isOnGround());
session.sendDownstreamPacket(playerRotationPacket); session.sendDownstreamGamePacket(playerRotationPacket);
} else { } else {
if (session.getWorldBorder().isPassingIntoBorderBoundaries(packet.getPosition(), true)) { if (session.getWorldBorder().isPassingIntoBorderBoundaries(packet.getPosition(), true)) {
return; return;
@ -130,7 +130,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
entity.setOnGround(onGround); entity.setOnGround(onGround);
// Send final movement changes // Send final movement changes
session.sendDownstreamPacket(movePacket); session.sendDownstreamGamePacket(movePacket);
if (teleportThroughVoidFloor) { if (teleportThroughVoidFloor) {
// Work around there being a floor at the bottom of the world and teleport the player below it // Work around there being a floor at the bottom of the world and teleport the player below it

Datei anzeigen

@ -41,7 +41,7 @@ public class BedrockRiderJumpTranslator extends PacketTranslator<RiderJumpPacket
Entity vehicle = session.getPlayerEntity().getVehicle(); Entity vehicle = session.getPlayerEntity().getVehicle();
if (vehicle instanceof AbstractHorseEntity) { if (vehicle instanceof AbstractHorseEntity) {
ServerboundPlayerCommandPacket playerCommandPacket = new ServerboundPlayerCommandPacket(vehicle.getEntityId(), PlayerState.START_HORSE_JUMP, packet.getJumpStrength()); ServerboundPlayerCommandPacket playerCommandPacket = new ServerboundPlayerCommandPacket(vehicle.getEntityId(), PlayerState.START_HORSE_JUMP, packet.getJumpStrength());
session.sendDownstreamPacket(playerCommandPacket); session.sendDownstreamGamePacket(playerCommandPacket);
} }
} }
} }

Datei anzeigen

@ -57,7 +57,7 @@ public class BedrockLevelSoundEventTranslator extends PacketTranslator<LevelSoun
// ATTACK_NODAMAGE = player clicked air // ATTACK_NODAMAGE = player clicked air
// This should only be revisited if Bedrock packets get full Java parity, or Bedrock starts sending arm // 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 // 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(); session.activateArmAnimationTicking();
// Send packet to Bedrock so it knows // Send packet to Bedrock so it knows

Datei anzeigen

@ -40,7 +40,7 @@ public class JavaCustomQueryTranslator extends PacketTranslator<ClientboundCusto
public void translate(GeyserSession session, ClientboundCustomQueryPacket packet) { 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. // 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 // Note: Fabric Networking API v1 will not let the client log in without sending this
session.sendDownstreamPacket( session.sendDownstreamLoginPacket(
new ServerboundCustomQueryAnswerPacket(packet.getMessageId(), null) new ServerboundCustomQueryAnswerPacket(packet.getMessageId(), null)
); );
} }

Datei anzeigen

@ -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) { 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 // Confirm the teleport when we receive it to match Java edition
ServerboundAcceptTeleportationPacket teleportConfirmPacket = new ServerboundAcceptTeleportationPacket(id); ServerboundAcceptTeleportationPacket teleportConfirmPacket = new ServerboundAcceptTeleportationPacket(id);
session.sendDownstreamPacket(teleportConfirmPacket); session.sendDownstreamGamePacket(teleportConfirmPacket);
// Servers (especially ones like Hypixel) expect exact coordinates given back to them. // Servers (especially ones like Hypixel) expect exact coordinates given back to them.
ServerboundMovePlayerPosRotPacket positionPacket = new ServerboundMovePlayerPosRotPacket(false, x, y, z, yaw, pitch); ServerboundMovePlayerPosRotPacket positionPacket = new ServerboundMovePlayerPosRotPacket(false, x, y, z, yaw, pitch);
session.sendDownstreamPacket(positionPacket); session.sendDownstreamGamePacket(positionPacket);
} }
} }

Datei anzeigen

@ -63,7 +63,7 @@ public class JavaOpenScreenTranslator extends PacketTranslator<ClientboundOpenSc
InventoryUtils.closeInventory(session, openInventory.getJavaId(), true); InventoryUtils.closeInventory(session, openInventory.getJavaId(), true);
} }
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(packet.getContainerId()); ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(packet.getContainerId());
session.sendDownstreamPacket(closeWindowPacket); session.sendDownstreamGamePacket(closeWindowPacket);
return; return;
} }

Datei anzeigen

@ -39,6 +39,6 @@ public class JavaChunkBatchFinishedTranslator extends PacketTranslator<Clientbou
// server just sent a batch of LevelChunkWithLightPackets // server just sent a batch of LevelChunkWithLightPackets
// the vanilla client uses a ChunkBatchSizeCalculator to calculate the desiredChunksPerTick, // 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. // 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));
} }
} }

Datei anzeigen

@ -131,7 +131,7 @@ public class JavaGameEventTranslator extends PacketTranslator<ClientboundGameEve
switch ((EnterCreditsValue) packet.getValue()) { switch ((EnterCreditsValue) packet.getValue()) {
case SEEN_BEFORE -> { case SEEN_BEFORE -> {
ServerboundClientCommandPacket javaRespawnPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN); ServerboundClientCommandPacket javaRespawnPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN);
session.sendDownstreamPacket(javaRespawnPacket); session.sendDownstreamGamePacket(javaRespawnPacket);
} }
case FIRST_TIME -> { case FIRST_TIME -> {
ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket(); ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket();

Datei anzeigen

@ -154,7 +154,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
} }
BlockStorage[] layers = new BlockStorage[]{ layer0 }; BlockStorage[] layers = new BlockStorage[]{ layer0 };
sections[bedrockSectionY] = new GeyserChunkSection(layers, bedrockSectionY); sections[bedrockSectionY] = new GeyserChunkSection(layers);
} }
EXTENDED_COLLISIONS_STORAGE.get().clear(); EXTENDED_COLLISIONS_STORAGE.get().clear();
extendedCollisionNextSection = false; extendedCollisionNextSection = false;
@ -167,7 +167,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
if (javaPalette instanceof GlobalPalette) { if (javaPalette instanceof GlobalPalette) {
// As this is the global palette, simply iterate through the whole chunk section once // 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++) { for (int yzx = 0; yzx < BlockStorage.SIZE; yzx++) {
int javaId = javaData.get(yzx); int javaId = javaData.get(yzx);
int bedrockId = session.getBlockMappings().getBedrockBlockId(javaId); int bedrockId = session.getBlockMappings().getBedrockBlockId(javaId);
@ -217,9 +217,9 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
if (BlockRegistries.WATERLOGGED.get().get(javaId)) { if (BlockRegistries.WATERLOGGED.get().get(javaId)) {
BlockStorage waterlogged = new BlockStorage(SingletonBitArray.INSTANCE, IntLists.singleton(session.getBlockMappings().getBedrockWater().getRuntimeId())); 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 { } else {
sections[bedrockSectionY] = new GeyserChunkSection(new BlockStorage[] {blockStorage}, bedrockSectionY); sections[bedrockSectionY] = new GeyserChunkSection(new BlockStorage[] {blockStorage});
} }
if (useExtendedCollisions) { if (useExtendedCollisions) {
EXTENDED_COLLISIONS_STORAGE.get().clear(); 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) }; 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; extendedCollisionNextSection = thisExtendedCollisionNextSection;
} }
@ -432,7 +432,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
IntList palette = bedrockSection.getBlockStorageArray()[0].getPalette(); IntList palette = bedrockSection.getBlockStorageArray()[0].getPalette();
if (palette instanceof IntImmutableList || palette instanceof IntLists.Singleton) { if (palette instanceof IntImmutableList || palette instanceof IntLists.Singleton) {
// TODO there has to be a better way to expand the palette .-. // TODO there has to be a better way to expand the palette .-.
bedrockSection = bedrockSection.copy(bedrockSectionY); bedrockSection = bedrockSection.copy();
sections[bedrockSectionY] = bedrockSection; sections[bedrockSectionY] = bedrockSection;
} }
bedrockSection.setFullBlock(x, y & 0xF, z, 0, blockDefinition.getRuntimeId()); bedrockSection.setFullBlock(x, y & 0xF, z, 0, blockDefinition.getRuntimeId());

Datei anzeigen

@ -63,7 +63,7 @@ public class ChunkUtils {
static { static {
ByteBuf byteBuf = Unpooled.buffer(); ByteBuf byteBuf = Unpooled.buffer();
try { try {
new GeyserChunkSection(new BlockStorage[0], 0) new GeyserChunkSection(new BlockStorage[0])
.writeToNetwork(byteBuf); .writeToNetwork(byteBuf);
SERIALIZED_CHUNK_DATA = new byte[byteBuf.readableBytes()]; SERIALIZED_CHUNK_DATA = new byte[byteBuf.readableBytes()];
byteBuf.readBytes(SERIALIZED_CHUNK_DATA); byteBuf.readBytes(SERIALIZED_CHUNK_DATA);

Datei anzeigen

@ -260,7 +260,7 @@ public class InventoryUtils {
// If this is the item we're looking for // If this is the item we're looking for
if (geyserItem.getJavaId() == itemStack.getId() && Objects.equals(geyserItem.getNbt(), itemStack.getNbt())) { if (geyserItem.getJavaId() == itemStack.getId() && Objects.equals(geyserItem.getNbt(), itemStack.getNbt())) {
ServerboundPickItemPacket packetToSend = new ServerboundPickItemPacket(i); // https://wiki.vg/Protocol#Pick_Item ServerboundPickItemPacket packetToSend = new ServerboundPickItemPacket(i); // https://wiki.vg/Protocol#Pick_Item
session.sendDownstreamPacket(packetToSend); session.sendDownstreamGamePacket(packetToSend);
return; return;
} }
} }
@ -274,7 +274,7 @@ public class InventoryUtils {
if ((slot - 36) != inventory.getHeldItemSlot()) { if ((slot - 36) != inventory.getHeldItemSlot()) {
setHotbarItem(session, slot); 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 ServerboundPickItemPacket packetToSend = new ServerboundPickItemPacket(i); // https://wiki.vg/Protocol#Pick_Item
session.sendDownstreamPacket(packetToSend); session.sendDownstreamGamePacket(packetToSend);
return; return;
} }
@ -340,7 +340,7 @@ public class InventoryUtils {
if ((slot - 36) != inventory.getHeldItemSlot()) { if ((slot - 36) != inventory.getHeldItemSlot()) {
setHotbarItem(session, slot); setHotbarItem(session, slot);
} }
session.sendDownstreamPacket(actionPacket); session.sendDownstreamGamePacket(actionPacket);
} else { } else {
session.getGeyser().getLogger().debug("Cannot find item for block " + itemName); session.getGeyser().getLogger().debug("Cannot find item for block " + itemName);
} }

Binäre Datei nicht angezeigt.

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Datei anzeigen

@ -145,10 +145,9 @@
{ {
"origin": [ -0.1, 0.0, -2.0 ], "origin": [ -0.1, 0.0, -2.0 ],
"size": [ 4, 12, 4 ], "size": [ 4, 12, 4 ],
"uv": [ 0, 16 ] "uv": [ 16, 48 ]
} }
], ]
"mirror": true
}, },
{ {
@ -219,4 +218,4 @@
} }
} }
] ]
} }

Datei anzeigen

@ -145,10 +145,9 @@
{ {
"origin": [ -0.1, 0.0, -2.0 ], "origin": [ -0.1, 0.0, -2.0 ],
"size": [ 4, 12, 4 ], "size": [ 4, 12, 4 ],
"uv": [ 0, 16 ] "uv": [ 16, 48 ]
} }
], ]
"mirror": true
}, },
{ {
@ -219,4 +218,4 @@
} }
} }
] ]
} }

Datei anzeigen

@ -9,10 +9,10 @@ netty = "4.1.80.Final"
guava = "29.0-jre" guava = "29.0-jre"
gson = "2.3.1" # Provided by Spigot 1.8.8 gson = "2.3.1" # Provided by Spigot 1.8.8
websocket = "1.5.1" websocket = "1.5.1"
protocol = "3.0.0.Beta1-20230908.171156-106" protocol = "3.0.0.Beta1-20231016.115644-107"
protocol-connection = "3.0.0.Beta1-20230908.171156-105" protocol-connection = "3.0.0.Beta1-20231016.115644-106"
raknet = "1.0.0.CR1-20230703.195238-9" raknet = "1.0.0.CR1-20230703.195238-9"
blockstateupdater="1.20.30-20230918.203831-4" blockstateupdater="1.20.40-20231016.111746-1"
mcauthlib = "d9d773e" mcauthlib = "d9d773e"
mcprotocollib = "1.20.2-1-20231003.141424-6" mcprotocollib = "1.20.2-1-20231003.141424-6"
adventure = "4.14.0" adventure = "4.14.0"