Merge branch 'master' into feature/extensions

This commit is contained in:
RednedEpic 2022-09-04 16:42:14 -05:00
commit 8fb22ee225
36 changed files with 97 additions and 65 deletions

View file

@ -17,7 +17,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t
Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have joined us here!
### Currently supporting Minecraft Bedrock 1.19.0/1.19.1x/1.19.20 and Minecraft Java 1.19.1/1.19.2.
### Currently supporting Minecraft Bedrock 1.19.0/1.19.1x/1.19.20/1.19.21/1.19.22 and Minecraft Java 1.19.1/1.19.2.
## Setting Up
Take a look [here](https://wiki.geysermc.org/geyser/setup/) for how to set up Geyser.

View file

@ -73,7 +73,8 @@ public class SpigotCommandSource implements GeyserCommandSource {
return;
}
handle.sendMessage(BungeeComponentSerializer.get().serialize(message));
// CommandSender#sendMessage(BaseComponent[]) is Paper-only
handle.spigot().sendMessage(BungeeComponentSerializer.get().serialize(message));
}
@Override

View file

@ -26,7 +26,7 @@
object Versions {
const val jacksonVersion = "2.13.2"
const val fastutilVersion = "8.5.2"
const val nettyVersion = "4.1.66.Final"
const val nettyVersion = "4.1.80.Final"
const val guavaVersion = "29.0-jre"
const val gsonVersion = "2.3.1" // Provided by Spigot 1.8.8
const val nbtVersion = "2.1.0"

View file

@ -107,6 +107,8 @@ public interface GeyserConfiguration {
int getCustomSkullRenderDistance();
boolean isLogPlayerIpAddresses();
boolean isNotifyOnNewBedrockUpdate();
IMetricsInfo getMetrics();

View file

@ -148,6 +148,9 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
@JsonProperty("xbox-achievements-enabled")
private boolean xboxAchievementsEnabled = false;
@JsonProperty("log-player-ip-addresses")
private boolean logPlayerIpAddresses = true;
@JsonProperty("notify-on-new-bedrock-update")
private boolean notifyOnNewBedrockUpdate = true;

View file

@ -44,7 +44,7 @@ import java.util.Arrays;
@ToString
public abstract class Inventory {
@Getter
protected final int id;
protected final int javaId;
/**
* The Java inventory state ID from the server. As of Java Edition 1.18.1 this value has one instance per player.
@ -93,15 +93,23 @@ public abstract class Inventory {
this("Inventory", id, size, containerType);
}
protected Inventory(String title, int id, int size, ContainerType containerType) {
protected Inventory(String title, int javaId, int size, ContainerType containerType) {
this.title = title;
this.id = id;
this.javaId = javaId;
this.size = size;
this.containerType = containerType;
this.items = new GeyserItemStack[size];
Arrays.fill(items, GeyserItemStack.EMPTY);
}
// This is to prevent conflicts with special bedrock inventory IDs.
// The vanilla java server only sends an ID between 1 and 100 when opening an inventory,
// so this is rarely needed. (certain plugins)
// Example: https://github.com/GeyserMC/Geyser/issues/3254
public int getBedrockId() {
return javaId <= 100 ? javaId : (javaId % 100) + 1;
}
public GeyserItemStack getItem(int slot) {
if (slot > this.size) {
GeyserImpl.getInstance().getLogger().debug("Tried to get an item out of bounds! " + this);

View file

@ -144,7 +144,7 @@ public final class ClickPlan {
}
ServerboundContainerClickPacket clickPacket = new ServerboundContainerClickPacket(
inventory.getId(),
inventory.getJavaId(),
stateId,
action.slot,
action.click.actionType,

View file

@ -133,7 +133,7 @@ public class BlockInventoryHolder extends InventoryHolder {
@Override
public void openInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) {
ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket();
containerOpenPacket.setId((byte) inventory.getId());
containerOpenPacket.setId((byte) inventory.getBedrockId());
containerOpenPacket.setType(containerType);
containerOpenPacket.setBlockPosition(inventory.getHolderPosition());
containerOpenPacket.setUniqueEntityId(inventory.getHolderId());
@ -146,7 +146,7 @@ public class BlockInventoryHolder extends InventoryHolder {
// No need to reset a block since we didn't change any blocks
// But send a container close packet because we aren't destroying the original.
ContainerClosePacket packet = new ContainerClosePacket();
packet.setId((byte) inventory.getId());
packet.setId((byte) inventory.getBedrockId());
packet.setUnknownBool0(true); //TODO needs to be changed in Protocol to "server-side" or something
session.sendUpstreamPacket(packet);
return;

View file

@ -59,7 +59,7 @@ public class ChestInventoryUpdater extends InventoryUpdater {
}
InventoryContentPacket contentPacket = new InventoryContentPacket();
contentPacket.setContainerId(inventory.getId());
contentPacket.setContainerId(inventory.getBedrockId());
contentPacket.setContents(bedrockItems);
session.sendUpstreamPacket(contentPacket);
}
@ -70,7 +70,7 @@ public class ChestInventoryUpdater extends InventoryUpdater {
return true;
InventorySlotPacket slotPacket = new InventorySlotPacket();
slotPacket.setContainerId(inventory.getId());
slotPacket.setContainerId(inventory.getBedrockId());
slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot));
slotPacket.setItem(inventory.getItem(javaSlot).getItemData(session));
session.sendUpstreamPacket(slotPacket);

View file

@ -47,7 +47,7 @@ public class ContainerInventoryUpdater extends InventoryUpdater {
}
InventoryContentPacket contentPacket = new InventoryContentPacket();
contentPacket.setContainerId(inventory.getId());
contentPacket.setContainerId(inventory.getBedrockId());
contentPacket.setContents(Arrays.asList(bedrockItems));
session.sendUpstreamPacket(contentPacket);
}
@ -58,7 +58,7 @@ public class ContainerInventoryUpdater extends InventoryUpdater {
return true;
InventorySlotPacket slotPacket = new InventorySlotPacket();
slotPacket.setContainerId(inventory.getId());
slotPacket.setContainerId(inventory.getBedrockId());
slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot));
slotPacket.setItem(inventory.getItem(javaSlot).getItemData(session));
session.sendUpstreamPacket(slotPacket);

View file

@ -47,7 +47,7 @@ public class HorseInventoryUpdater extends InventoryUpdater {
}
InventoryContentPacket contentPacket = new InventoryContentPacket();
contentPacket.setContainerId(inventory.getId());
contentPacket.setContainerId(inventory.getBedrockId());
contentPacket.setContents(Arrays.asList(bedrockItems));
session.sendUpstreamPacket(contentPacket);
}

View file

@ -84,14 +84,16 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
}
}
geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.attempt_connect", inetSocketAddress));
String ip = geyser.getConfig().isLogPlayerIpAddresses() ? inetSocketAddress.toString() : "<IP address withheld>";
geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.attempt_connect", ip));
return true;
}
@Override
public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
if (geyser.getConfig().isDebugMode() && PRINT_DEBUG_PINGS) {
geyser.getLogger().debug(GeyserLocale.getLocaleStringLog("geyser.network.pinged", inetSocketAddress));
String ip = geyser.getConfig().isLogPlayerIpAddresses() ? inetSocketAddress.toString() : "<IP address withheld>";
geyser.getLogger().debug(GeyserLocale.getLocaleStringLog("geyser.network.pinged", ip));
}
GeyserConfiguration config = geyser.getConfig();

View file

@ -46,7 +46,7 @@ public final class GameProtocol {
* release of the game that Geyser supports.
*/
public static final BedrockPacketCodec DEFAULT_BEDROCK_CODEC = Bedrock_v544.V544_CODEC.toBuilder()
.minecraftVersion("1.19.21")
.minecraftVersion("1.19.22")
.protocolVersion(545)
.build();
/**
@ -68,7 +68,9 @@ public final class GameProtocol {
.minecraftVersion("1.19.10/1.19.11")
.build());
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v544.V544_CODEC);
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC);
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC.toBuilder()
.minecraftVersion("1.19.21/1.19.22")
.build());
}
/**

View file

@ -106,7 +106,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
ResourcePackManifest.Header header = resourcePack.getManifest().getHeader();
resourcePacksInfo.getResourcePackInfos().add(new ResourcePacksInfoPacket.Entry(
header.getUuid().toString(), header.getVersionString(), resourcePack.getFile().length(),
"", "", "", false, false));
resourcePack.getContentKey(), "", header.getUuid().toString(), false, false));
}
resourcePacksInfo.setForcedToAccept(GeyserImpl.getInstance().getConfig().isForceResourcePacks());
session.sendUpstreamPacket(resourcePacksInfo);

View file

@ -25,16 +25,20 @@
package org.geysermc.geyser.pack;
import lombok.Getter;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.event.lifecycle.GeyserLoadResourcePacksEvent;
import org.geysermc.geyser.util.FileUtils;
import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.FileUtils;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
@ -59,6 +63,9 @@ public class ResourcePack {
private ResourcePackManifest manifest;
private ResourcePackManifest.Version version;
@Getter
private String contentKey;
/**
* Loop through the packs directory and locate valid resource pack files
*/
@ -118,6 +125,11 @@ public class ResourcePack {
}
}
});
// Check if a file exists with the same name as the resource pack suffixed by .key,
// and set this as content key. (e.g. test.zip, key file would be test.zip.key)
File keyFile = new File(file.getParentFile(), file.getName() + ".key");
pack.contentKey = keyFile.exists() ? Files.readString(keyFile.toPath(), StandardCharsets.UTF_8) : "";
} catch (Exception e) {
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.resource_pack.broken", file.getName()));
e.printStackTrace();

View file

@ -140,7 +140,6 @@ import org.geysermc.geyser.util.LoginEncryptionUtils;
import org.geysermc.geyser.util.MathUtils;
import java.net.ConnectException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
@ -1043,7 +1042,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
} else {
// Downstream's disconnect will fire an event that prints a log message
// Otherwise, we print a message here
InetAddress address = upstream.getAddress().getAddress();
String address = geyser.getConfig().isLogPlayerIpAddresses() ? upstream.getAddress().getAddress().toString() : "<IP address withheld>";
geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.disconnect", address, reason));
}
if (!upstream.isClosed()) {

View file

@ -62,7 +62,7 @@ public class BeaconInventoryTranslator extends AbstractBlockInventoryTranslator
@Override
public void openInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) {
if (!((BeaconContainer) inventory).isUsingRealBlock()) {
InventoryUtils.closeInventory(session, inventory.getId(), false);
InventoryUtils.closeInventory(session, inventory.getJavaId(), false);
return;
}
super.openInventory(translator, session, inventory);

View file

@ -43,7 +43,7 @@ public class BrewingInventoryTranslator extends AbstractBlockInventoryTranslator
public void openInventory(GeyserSession session, Inventory inventory) {
super.openInventory(session, inventory);
ContainerSetDataPacket dataPacket = new ContainerSetDataPacket();
dataPacket.setWindowId((byte) inventory.getId());
dataPacket.setWindowId((byte) inventory.getBedrockId());
dataPacket.setProperty(ContainerSetDataPacket.BREWING_STAND_FUEL_TOTAL);
dataPacket.setValue(20);
session.sendUpstreamPacket(dataPacket);
@ -52,7 +52,7 @@ public class BrewingInventoryTranslator extends AbstractBlockInventoryTranslator
@Override
public void updateProperty(GeyserSession session, Inventory inventory, int key, int value) {
ContainerSetDataPacket dataPacket = new ContainerSetDataPacket();
dataPacket.setWindowId((byte) inventory.getId());
dataPacket.setWindowId((byte) inventory.getBedrockId());
switch (key) {
case 0:
dataPacket.setProperty(ContainerSetDataPacket.BREWING_STAND_BREW_TIME);

View file

@ -127,7 +127,7 @@ public class EnchantingInventoryTranslator extends AbstractBlockInventoryTransla
// Slot should be determined as 0, 1, or 2
return rejectRequest(request);
}
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getId(), javaSlot);
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), javaSlot);
session.sendDownstreamPacket(packet);
return acceptRequest(request, makeContainerEntries(session, inventory, IntSets.emptySet()));
}

View file

@ -52,7 +52,7 @@ public class Generic3X3InventoryTranslator extends AbstractBlockInventoryTransla
@Override
public void openInventory(GeyserSession session, Inventory inventory) {
ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket();
containerOpenPacket.setId((byte) inventory.getId());
containerOpenPacket.setId((byte) inventory.getBedrockId());
// Required for opening the real block - otherwise, if the container type is incorrect, it refuses to open
containerOpenPacket.setType(((Generic3X3Container) inventory).isDropper() ? com.nukkitx.protocol.bedrock.data.inventory.ContainerType.DROPPER : com.nukkitx.protocol.bedrock.data.inventory.ContainerType.DISPENSER);
containerOpenPacket.setBlockPosition(inventory.getHolderPosition());

View file

@ -804,7 +804,7 @@ public abstract class InventoryTranslator {
*/
//TODO: compatibility for simulated inventory (ClickPlan)
private static int findTempSlot(Inventory inventory, GeyserItemStack item, boolean emptyOnly, int... slotBlacklist) {
int offset = inventory.getId() == 0 ? 1 : 0; //offhand is not a viable temp slot
int offset = inventory.getJavaId() == 0 ? 1 : 0; //offhand is not a viable temp slot
HashSet<GeyserItemStack> itemBlacklist = new HashSet<>(slotBlacklist.length + 1);
itemBlacklist.add(item);

View file

@ -99,10 +99,10 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
LecternContainer lecternContainer = (LecternContainer) inventory;
if (session.isDroppingLecternBook()) {
// We have to enter the inventory GUI to eject the book
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getId(), 3);
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), 3);
session.sendDownstreamPacket(packet);
session.setDroppingLecternBook(false);
InventoryUtils.closeInventory(session, inventory.getId(), false);
InventoryUtils.closeInventory(session, inventory.getJavaId(), false);
} else if (lecternContainer.getBlockEntityTag() == null) {
CompoundTag tag = book.getNbt();
// Position has to be the last interacted position... right?
@ -150,9 +150,9 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
BlockEntityUtils.updateBlockEntity(session, blockEntityTag, position);
session.getLecternCache().add(position);
// Close the window - we will reopen it once the client has this data synced
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(lecternContainer.getId());
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(lecternContainer.getJavaId());
session.sendDownstreamPacket(closeWindowPacket);
InventoryUtils.closeInventory(session, inventory.getId(), false);
InventoryUtils.closeInventory(session, inventory.getJavaId(), false);
}
}
}

View file

@ -147,7 +147,7 @@ public class LoomInventoryTranslator extends AbstractBlockInventoryTranslator {
// Java's formula: 4 * row + col
// And the Java loom window has a fixed row/width of four
// So... Number / 4 = row (so we don't have to bother there), and number % 4 is our column, which leads us back to our index. :)
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getId(), index);
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), index);
session.sendDownstreamPacket(packet);
GeyserItemStack inputCopy = inventory.getItem(0).copy(1);

View file

@ -68,7 +68,7 @@ public class StonecutterInventoryTranslator extends AbstractBlockInventoryTransl
ItemStack javaOutput = craftingData.output();
// Getting the index of the item in the Java stonecutter list
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getId(), button);
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getJavaId(), button);
session.sendDownstreamPacket(packet);
container.setStonecutterButton(button);
if (inventory.getItem(1).getJavaId() != javaOutput.getId()) {

View file

@ -130,7 +130,7 @@ public class DoubleChestInventoryTranslator extends ChestInventoryTranslator {
@Override
public void openInventory(GeyserSession session, Inventory inventory) {
ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket();
containerOpenPacket.setId((byte) inventory.getId());
containerOpenPacket.setId((byte) inventory.getBedrockId());
containerOpenPacket.setType(ContainerType.CONTAINER);
containerOpenPacket.setBlockPosition(inventory.getHolderPosition());
containerOpenPacket.setUniqueEntityId(inventory.getHolderId());
@ -143,7 +143,7 @@ public class DoubleChestInventoryTranslator extends ChestInventoryTranslator {
// No need to reset a block since we didn't change any blocks
// But send a container close packet because we aren't destroying the original.
ContainerClosePacket packet = new ContainerClosePacket();
packet.setId((byte) inventory.getId());
packet.setId((byte) inventory.getBedrockId());
packet.setUnknownBool0(true); //TODO needs to be changed in Protocol to "server-side" or something
session.sendUpstreamPacket(packet);
return;

View file

@ -43,7 +43,7 @@ public abstract class AbstractFurnaceInventoryTranslator extends AbstractBlockIn
@Override
public void updateProperty(GeyserSession session, Inventory inventory, int key, int value) {
ContainerSetDataPacket dataPacket = new ContainerSetDataPacket();
dataPacket.setWindowId((byte) inventory.getId());
dataPacket.setWindowId((byte) inventory.getBedrockId());
switch (key) {
case 0:
dataPacket.setProperty(ContainerSetDataPacket.FURNACE_LIT_TIME);

View file

@ -105,7 +105,7 @@ public abstract class ChestedHorseInventoryTranslator extends AbstractHorseInven
}
InventoryContentPacket horseContentsPacket = new InventoryContentPacket();
horseContentsPacket.setContainerId(inventory.getId());
horseContentsPacket.setContainerId(inventory.getBedrockId());
horseContentsPacket.setContents(Arrays.asList(horseItems));
session.sendUpstreamPacket(horseContentsPacket);
}

View file

@ -40,23 +40,23 @@ public class BedrockContainerCloseTranslator extends PacketTranslator<ContainerC
@Override
public void translate(GeyserSession session, ContainerClosePacket packet) {
byte windowId = packet.getId();
byte bedrockId = packet.getId();
//Client wants close confirmation
session.sendUpstreamPacket(packet);
session.setClosingInventory(false);
if (windowId == -1 && session.getOpenInventory() instanceof MerchantContainer) {
if (bedrockId == -1 && session.getOpenInventory() instanceof MerchantContainer) {
// 1.16.200 - window ID is always -1 sent from Bedrock
windowId = (byte) session.getOpenInventory().getId();
bedrockId = (byte) session.getOpenInventory().getBedrockId();
}
Inventory openInventory = session.getOpenInventory();
if (openInventory != null) {
if (windowId == openInventory.getId()) {
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(windowId);
if (bedrockId == openInventory.getBedrockId()) {
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(openInventory.getJavaId());
session.sendDownstreamPacket(closeWindowPacket);
InventoryUtils.closeInventory(session, windowId, false);
InventoryUtils.closeInventory(session, openInventory.getJavaId(), false);
} else if (openInventory.isPending()) {
InventoryUtils.displayInventory(session, openInventory);
openInventory.setPending(false);

View file

@ -114,7 +114,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
changedItem = Int2ObjectMaps.singleton(hotbarSlot, itemStack.getItemStack());
}
ServerboundContainerClickPacket dropPacket = new ServerboundContainerClickPacket(
inventory.getId(), inventory.getStateId(), hotbarSlot, clickType.actionType, clickType.action,
inventory.getJavaId(), inventory.getStateId(), hotbarSlot, clickType.actionType, clickType.action,
inventory.getCursor().getItemStack(), changedItem);
session.sendDownstreamPacket(dropPacket);
return;
@ -371,7 +371,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
changedSlots.put(bedrockHotbarSlot, armorSlotItem.getItemStack());
ServerboundContainerClickPacket clickPacket = new ServerboundContainerClickPacket(
playerInventory.getId(), playerInventory.getStateId(), armorSlot,
playerInventory.getJavaId(), playerInventory.getStateId(), armorSlot,
click.actionType, click.action, null, changedSlots);
session.sendDownstreamPacket(clickPacket);
}

View file

@ -68,9 +68,9 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
if (lecternContainer.getCurrentBedrockPage() == packet.getPage()) {
// The same page means Bedrock is closing the window
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(lecternContainer.getId());
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(lecternContainer.getJavaId());
session.sendDownstreamPacket(closeWindowPacket);
InventoryUtils.closeInventory(session, lecternContainer.getId(), false);
InventoryUtils.closeInventory(session, lecternContainer.getJavaId(), false);
} else {
// Each "page" Bedrock gives to us actually represents two pages (think opening a book and seeing two pages)
// Each "page" on Java is just one page (think a spiral notebook folded back to only show one page)
@ -82,12 +82,12 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
// is a byte when transmitted over the network and therefore this stops us at 128
if (newJavaPage > currentJavaPage) {
for (int i = currentJavaPage; i < newJavaPage; i++) {
ServerboundContainerButtonClickPacket clickButtonPacket = new ServerboundContainerButtonClickPacket(session.getOpenInventory().getId(), 2);
ServerboundContainerButtonClickPacket clickButtonPacket = new ServerboundContainerButtonClickPacket(session.getOpenInventory().getJavaId(), 2);
session.sendDownstreamPacket(clickButtonPacket);
}
} else {
for (int i = currentJavaPage; i > newJavaPage; i--) {
ServerboundContainerButtonClickPacket clickButtonPacket = new ServerboundContainerButtonClickPacket(session.getOpenInventory().getId(), 1);
ServerboundContainerButtonClickPacket clickButtonPacket = new ServerboundContainerButtonClickPacket(session.getOpenInventory().getJavaId(), 1);
session.sendDownstreamPacket(clickButtonPacket);
}
}

View file

@ -38,6 +38,6 @@ public class JavaContainerCloseTranslator extends PacketTranslator<ClientboundCo
public void translate(GeyserSession session, ClientboundContainerClosePacket packet) {
// Sometimes the server can request a window close of ID 0... when the window isn't even open
// Don't confirm in this instance
InventoryUtils.closeInventory(session, packet.getContainerId(), (session.getOpenInventory() != null && session.getOpenInventory().getId() == packet.getContainerId()));
InventoryUtils.closeInventory(session, packet.getContainerId(), (session.getOpenInventory() != null && session.getOpenInventory().getJavaId() == packet.getContainerId()));
}
}

View file

@ -54,7 +54,7 @@ public class JavaMerchantOffersTranslator extends PacketTranslator<ClientboundMe
@Override
public void translate(GeyserSession session, ClientboundMerchantOffersPacket packet) {
Inventory openInventory = session.getOpenInventory();
if (!(openInventory instanceof MerchantContainer merchantInventory && openInventory.getId() == packet.getContainerId())) {
if (!(openInventory instanceof MerchantContainer merchantInventory && openInventory.getJavaId() == packet.getContainerId())) {
return;
}

View file

@ -49,7 +49,7 @@ public class JavaOpenScreenTranslator extends PacketTranslator<ClientboundOpenSc
// No translator exists for this window type. Close all windows and return.
if (newTranslator == null) {
if (openInventory != null) {
InventoryUtils.closeInventory(session, openInventory.getId(), true);
InventoryUtils.closeInventory(session, openInventory.getJavaId(), true);
}
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(packet.getContainerId());
session.sendDownstreamPacket(closeWindowPacket);
@ -64,7 +64,7 @@ public class JavaOpenScreenTranslator extends PacketTranslator<ClientboundOpenSc
// In rare cases, inventories can do funny things where it keeps the same window type up but change the contents.
if (openInventory.getContainerType() != packet.getType()) {
// Sometimes the server can double-open an inventory with the same ID - don't confirm in that instance.
InventoryUtils.closeInventory(session, openInventory.getId(), openInventory.getId() != packet.getContainerId());
InventoryUtils.closeInventory(session, openInventory.getJavaId(), openInventory.getJavaId() != packet.getContainerId());
}
}

View file

@ -90,7 +90,7 @@ public class InventoryUtils {
if (translator instanceof DoubleChestInventoryTranslator && !((Container) inventory).isUsingRealBlock()) {
session.scheduleInEventLoop(() -> {
Inventory openInv = session.getOpenInventory();
if (openInv != null && openInv.getId() == inventory.getId()) {
if (openInv != null && openInv.getJavaId() == inventory.getJavaId()) {
translator.openInventory(session, inventory);
translator.updateInventory(session, inventory);
} else if (openInv != null && openInv.isPending()) {
@ -108,11 +108,11 @@ public class InventoryUtils {
}
}
public static void closeInventory(GeyserSession session, int windowId, boolean confirm) {
public static void closeInventory(GeyserSession session, int javaId, boolean confirm) {
session.getPlayerInventory().setCursor(GeyserItemStack.EMPTY, session);
updateCursor(session);
Inventory inventory = getInventory(session, windowId);
Inventory inventory = getInventory(session, javaId);
if (inventory != null) {
InventoryTranslator translator = session.getInventoryTranslator();
translator.closeInventory(session, inventory);
@ -124,12 +124,12 @@ public class InventoryUtils {
session.setOpenInventory(null);
}
public static Inventory getInventory(GeyserSession session, int windowId) {
if (windowId == 0) {
public static Inventory getInventory(GeyserSession session, int javaId) {
if (javaId == 0) {
return session.getPlayerInventory();
} else {
Inventory openInventory = session.getOpenInventory();
if (openInventory != null && windowId == openInventory.getId()) {
if (openInventory != null && javaId == openInventory.getJavaId()) {
return openInventory;
}
return null;

View file

@ -35,7 +35,7 @@ import java.nio.file.Paths;
public final class LoopbackUtil {
private static final String checkExemption = "CheckNetIsolation LoopbackExempt -s";
private static final String loopbackCommand = "CheckNetIsolation LoopbackExempt -a -n='Microsoft.MinecraftUWP_8wekyb3d8bbwe'";
private static final String loopbackCommand = "CheckNetIsolation LoopbackExempt -a -n=Microsoft.MinecraftUWP_8wekyb3d8bbwe";
/**
* This string needs to be checked in the event Minecraft is not installed - no Minecraft string will be present in the checkExemption command.
*/
@ -50,12 +50,12 @@ public final class LoopbackUtil {
if (os.equalsIgnoreCase("Windows 10") || os.equalsIgnoreCase("Windows 11")) {
try {
Process process = Runtime.getRuntime().exec(checkExemption);
process.waitFor();
InputStream is = process.getInputStream();
int data;
StringBuilder sb = new StringBuilder();
while (is.available() != 0) {
sb.append((char) is.read());
while ((data = is.read()) != -1) {
sb.append((char) data);
}
return !sb.toString().contains(minecraftApplication);

View file

@ -175,6 +175,9 @@ force-resource-packs: true
# THIS DISABLES ALL COMMANDS FROM SUCCESSFULLY RUNNING FOR BEDROCK IN-GAME, as otherwise Bedrock thinks you are cheating.
xbox-achievements-enabled: false
# Whether player IP addresses will be logged by the server.
log-player-ip-addresses: true
# Whether to alert the console and operators that a new Geyser version is available that supports a Bedrock version
# that this Geyser version does not support. It's recommended to keep this option enabled, as many Bedrock platforms
# auto-update.