Skip to content

Commit

Permalink
ACTUALLY fix swapping armor in hotbar when armor is already present (#…
Browse files Browse the repository at this point in the history
…2206)

Tested with iOS, desktop and console
  • Loading branch information
Camotoy authored May 11, 2021
1 parent 95bcd40 commit dbf366b
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@
import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.protocol.bedrock.data.LevelEventType;
import com.nukkitx.protocol.bedrock.data.entity.EntityFlags;
import com.nukkitx.protocol.bedrock.data.inventory.ContainerId;
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.data.inventory.*;
import com.nukkitx.protocol.bedrock.packet.*;
import org.geysermc.connector.entity.CommandBlockMinecartEntity;
import org.geysermc.connector.entity.Entity;
Expand Down Expand Up @@ -241,9 +238,10 @@ else if (packet.getItemInHand() != null && ItemRegistry.BUCKETS.contains(packet.
session.setInteracting(true);
break;
case 1:
if (packet.getActions().size() == 1) {
if (packet.getActions().size() == 1 && packet.getLegacySlots().size() > 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
// Java Edition does not allow this; let's revert it
session.getInventoryTranslator().updateInventory(session, session.getPlayerInventory());
Expand Down

0 comments on commit dbf366b

Please sign in to comment.