3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-08 10:50:11 +02:00

ACTUALLY fix swapping armor in hotbar when armor is already present (#2206)

Tested with iOS, desktop and console
Dieser Commit ist enthalten in:
Camotoy 2021-05-10 21:14:30 -04:00 committet von GitHub
Ursprung 95bcd4000f
Commit dbf366b138
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -39,10 +39,7 @@ import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.math.vector.Vector3i; import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.protocol.bedrock.data.LevelEventType; import com.nukkitx.protocol.bedrock.data.LevelEventType;
import com.nukkitx.protocol.bedrock.data.entity.EntityFlags; import com.nukkitx.protocol.bedrock.data.entity.EntityFlags;
import com.nukkitx.protocol.bedrock.data.inventory.ContainerId; import com.nukkitx.protocol.bedrock.data.inventory.*;
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
import com.nukkitx.protocol.bedrock.data.inventory.InventoryActionData;
import com.nukkitx.protocol.bedrock.data.inventory.InventorySource;
import com.nukkitx.protocol.bedrock.packet.*; import com.nukkitx.protocol.bedrock.packet.*;
import org.geysermc.connector.entity.CommandBlockMinecartEntity; import org.geysermc.connector.entity.CommandBlockMinecartEntity;
import org.geysermc.connector.entity.Entity; import org.geysermc.connector.entity.Entity;
@ -241,9 +238,10 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
session.setInteracting(true); session.setInteracting(true);
break; break;
case 1: case 1:
if (packet.getActions().size() == 1) { if (packet.getActions().size() == 1 && packet.getLegacySlots().size() > 0) {
InventoryActionData actionData = packet.getActions().get(0); InventoryActionData actionData = packet.getActions().get(0);
if (actionData.getSlot() == 6 && actionData.getToItem().getId() != 0) { LegacySetItemSlotData slotData = packet.getLegacySlots().get(0);
if (slotData.getContainerId() == 6 && actionData.getToItem().getId() != 0) {
// The player is trying to swap out an armor piece that already has an item in it // The player is trying to swap out an armor piece that already has an item in it
// Java Edition does not allow this; let's revert it // Java Edition does not allow this; let's revert it
session.getInventoryTranslator().updateInventory(session, session.getPlayerInventory()); session.getInventoryTranslator().updateInventory(session, session.getPlayerInventory());