InventoryPacketHandler class

Пакет: com.hypixel.hytale.server.core.io.handlers.game

Файл: com/hypixel/hytale/server/core/io/handlers/game/InventoryPacketHandler.java

implements: SubPacketHandler

Поля (131)

МодификаторыТипИмя
break
break
break
break
final IPacketHandler packetHandler
return
return
return
return
return
return
return
return
return
return
return
return
return
Item var1
ItemContainer var10
int var10
ItemStackTransaction var10
ComponentType var10
Window var10
ItemStack var11
int var11
ItemStack var11
InventoryComponent var11
Window var11
ItemStack var12
var12
InventoryComponent var12
Window var12
short var13
var13
CombinedItemContainer var14
InventoryComponent.Armor var15
ItemStack var16
Item var17
BlockSelectorToolData var18
int var19
int var2
PlayerRef var2
PlayerRef var2
PlayerRef var2
PlayerRef var2
PlayerRef var2
PlayerRef var2
PlayerRef var2
PlayerRef var2
PlayerRef var2
BlockSelectorToolData var20
ItemStack var21
ItemSoundSet var22
String var23
Ref var3
Player var3
Ref var3
Player var3
Ref var3
Player var3
Ref var3
Player var3
Ref var3
Ref var3
Ref var3
PlayerSettings var3
var3
Ref var3
Ref var3
Player var3
Store var4
PlayerRef var4
Store var4
PlayerRef var4
Store var4
InventoryComponent.Hotbar var4
Store var4
PlayerRef var4
Store var4
DropItemEvent.PlayerRequest var4
Store var4
byte var4
var4
Store var4
Store var4
PacketHandler var4
Store var4
PlayerSettings var4
var4
World var5
ItemStack var5
World var5
World var5
ItemContainer var5
World var5
ItemStack var5
World var5
ItemContainer var5
World var5
int var5
World var5
World var5
ItemContainer var5
World var5
InventoryComponent.Backpack var5
CombinedItemContainer var6
ItemStack var6
byte var6
Item var6
ItemStackSlotTransaction var6
byte var6
byte var6
var6
var6
ItemStackTransaction var7
ItemStack var7
ItemArmor var7
ItemStack var7
InventoryActiveSlotRequestEvent var7
InventoryActiveSlotRequestEvent var7
ItemStack var8
BlockGroup var8
int var8
String var8
byte var8
ItemContainer var9
Item var9
InventoryComponent.Utility var9
ComponentType var9
ItemContainer var9

Методы (57)

МодификаторыВозвратСигнатура
static boolean blocksInventoryAccessboolean blocksInventoryAccess(@Nonnull Ref<EntityStore> var0, @Nonnull Store<EntityStore> var1)
abstract for for(short var15 = 0; var15 < var14.getCapacity()
public void handlevoid handle(@Nonnull SetCreativeItem var1)
public void handlevoid handle(@Nonnull DropCreativeItem var1)
public void handlevoid handle(SwitchHotbarBlockSet var1)
public void handlevoid handle(@Nonnull SmartGiveCreativeItem var1)
public void handlevoid handle(@Nonnull DropItemStack var1)
public void handlevoid handle(@Nonnull MoveItemStack var1)
public void handlevoid handle(@Nonnull SmartMoveItemStack var1)
public void handlevoid handle(@Nonnull SetActiveSlot var1)
public void handlevoid handle(@Nonnull InventoryAction var1)
if if(var0.quantity <= 0)
if if(var1 != null && var1 != Item.UNKNOWN)
if if(var1.item.quantity > 0)
if if(var5 == null)
if if(var1.slotId < 0)
if if(var10 != null)
if if(var1.override)
if if(var9 != null)
if if(var6 != null)
if if(var6 != -1)
if if(var8 != null)
if if(var9 != null)
if if(var10 != -1)
if if(var11 != -1 && var11 != var10)
if if(var12 != null)
if if(var22 != null)
if if(var23 != null)
if if(var19 != 0)
if if(var5 != null)
if if(var7 != null)
if if(var15 != null)
if if(var9 != null)
if if(var9 != null)
if if(var11 != null)
if if(var5 == null)
if if(var10 == null)
if if(var12 == null)
if if(var1.toSectionId != var1.fromSectionId && var1.toSectionId == -5)
if if(var6 == var4)
if if(var3 == null)
if if(var1.inventorySectionId == -1)
if if(var5 == null)
if if(var6 != var1.activeSlot)
if if(var6 != var8)
if if(var1.inventorySectionId >= 0 || var1.inventorySectionId == -9)
if if(var4 == null)
if if(var1.inventorySectionId == -9)
if if(var12 instanceof ItemContainerWindow var13)
if if(var1.inventorySectionId == -9)
if if(var11 instanceof ItemContainerWindow)
if if(var1.inventorySectionId == -9)
if if(var10 instanceof ItemContainerWindow)
if if(var1.inventorySectionId == 0)
if if(var1.inventorySectionId == -9 && var5 != null)
switch switch(var1.moveType)
switch switch(var1.inventoryActionType)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.io.handlers.game;

class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.protocol.GameMode;
class="kw">import com.hypixel.hytale.protocol.ItemQuantity;
class="kw">import com.hypixel.hytale.protocol.ItemSoundEvent;
class="kw">import com.hypixel.hytale.protocol.SoundCategory;
class="kw">import com.hypixel.hytale.protocol.packets.inventory.DropCreativeItem;
class="kw">import com.hypixel.hytale.protocol.packets.inventory.DropItemStack;
class="kw">import com.hypixel.hytale.protocol.packets.inventory.InventoryAction;
class="kw">import com.hypixel.hytale.protocol.packets.inventory.MoveItemStack;
class="kw">import com.hypixel.hytale.protocol.packets.inventory.SetActiveSlot;
class="kw">import com.hypixel.hytale.protocol.packets.inventory.SetCreativeItem;
class="kw">import com.hypixel.hytale.protocol.packets.inventory.SmartGiveCreativeItem;
class="kw">import com.hypixel.hytale.protocol.packets.inventory.SmartMoveItemStack;
class="kw">import com.hypixel.hytale.protocol.packets.inventory.SwitchHotbarBlockSet;
class="kw">import com.hypixel.hytale.protocol.packets.window.WindowType;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.asset.type.item.config.BlockGroup;
class="kw">import com.hypixel.hytale.server.core.asset.type.item.config.BlockSelectorToolData;
class="kw">import com.hypixel.hytale.server.core.asset.type.item.config.Item;
class="kw">import com.hypixel.hytale.server.core.asset.type.item.config.ItemArmor;
class="kw">import com.hypixel.hytale.server.core.asset.type.itemsound.config.ItemSoundSet;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent;
class="kw">import com.hypixel.hytale.server.core.entity.ItemUtils;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
class="kw">import com.hypixel.hytale.server.core.entity.entities.player.windows.ItemContainerWindow;
class="kw">import com.hypixel.hytale.server.core.entity.entities.player.windows.Window;
class="kw">import com.hypixel.hytale.server.core.event.events.ecs.DropItemEvent;
class="kw">import com.hypixel.hytale.server.core.event.events.ecs.InventoryActiveSlotRequestEvent;
class="kw">import com.hypixel.hytale.server.core.inventory.InventoryComponent;
class="kw">import com.hypixel.hytale.server.core.inventory.InventoryUtils;
class="kw">import com.hypixel.hytale.server.core.inventory.ItemStack;
class="kw">import com.hypixel.hytale.server.core.inventory.container.CombinedItemContainer;
class="kw">import com.hypixel.hytale.server.core.inventory.container.ItemContainer;
class="kw">import com.hypixel.hytale.server.core.inventory.container.SortType;
class="kw">import com.hypixel.hytale.server.core.inventory.transaction.ItemStackSlotTransaction;
class="kw">import com.hypixel.hytale.server.core.inventory.transaction.ItemStackTransaction;
class="kw">import com.hypixel.hytale.server.core.io.PacketHandler;
class="kw">import com.hypixel.hytale.server.core.io.handlers.IPacketHandler;
class="kw">import com.hypixel.hytale.server.core.io.handlers.SubPacketHandler;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.PreventInventoryAccess;
class="kw">import com.hypixel.hytale.server.core.modules.entity.gamemode.GameModeTypes;
class="kw">import com.hypixel.hytale.server.core.modules.entity.player.PlayerSettings;
class="kw">import com.hypixel.hytale.server.core.modules.item.ItemModule;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.SoundUtil;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.core.util.NotificationUtil;
class="kw">import com.hypixel.hytale.server.core.util.TempAssetIdUtil;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class InventoryPacketHandler class="kw">implements SubPacketHandler {
   class="kw">private class="kw">final IPacketHandler packetHandler;

   class="kw">public InventoryPacketHandler(IPacketHandler var1) {
      this.packetHandler = var1;
   }

   @Override
   class="kw">public void registerHandlers() {
      this.packetHandler.registerHandler(171, var1 -> this.handle((SetCreativeItem)var1));
      this.packetHandler.registerHandler(172, var1 -> this.handle((DropCreativeItem)var1));
      this.packetHandler.registerHandler(173, var1 -> this.handle((SmartGiveCreativeItem)var1));
      this.packetHandler.registerHandler(174, var1 -> this.handle((DropItemStack)var1));
      this.packetHandler.registerHandler(175, var1 -> this.handle((MoveItemStack)var1));
      this.packetHandler.registerHandler(176, var1 -> this.handle((SmartMoveItemStack)var1));
      this.packetHandler.registerHandler(177, var1 -> this.handle((SetActiveSlot)var1));
      this.packetHandler.registerHandler(178, var1 -> this.handle((SwitchHotbarBlockSet)var1));
      this.packetHandler.registerHandler(179, var1 -> this.handle((InventoryAction)var1));
   }

   @Nullable
   class="kw">private class="kw">static ItemStack getItemStackFromQuantity(@Nonnull ItemQuantity var0) {
      if (var0.quantity <= 0) {
         class="kw">return null;
      } else {
         Item var1 = Item.getAssetMap().getAsset(var0.itemId);
         if (var1 != null && var1 != Item.UNKNOWN) {
            int var2 = Math.min(var0.quantity, var1.getMaxStack());
            class="kw">return new ItemStack(var1.getId(), var2);
         } else {
            class="kw">return null;
         }
      }
   }

   class="kw">static boolean blocksInventoryAccess(@Nonnull Ref<EntityStore> var0, @Nonnull Store<EntityStore> var1) {
      class="kw">return var1.getArchetype(var0).contains(PreventInventoryAccess.getComponentType());
   }

   class="kw">public void handle(@Nonnull SetCreativeItem var1) {
      PlayerRef var2 = this.packetHandler.getPlayerRef();
      Ref var3 = var2.getReference();
      if (var3 != null && var3.isValid()) {
         Store var4 = var3.getStore();
         World var5 = var4.getExternalData().getWorld();
         var5.execute(() -> {
            if (!blocksInventoryAccess(var3, var4)) {
               Player var3 = var4.getComponent(var3, Player.getComponentType());
               assert var3 != null;
               PlayerRef var4 = var4.getComponent(var3, PlayerRef.getComponentType());
               assert var4 != null;
               if (var3.getGameMode() != GameMode.Creative) {
                  NotificationUtil.sendNotification(var4.getPacketHandler(), Message.translation("server.general.setCreativeItem.notInCreativeMode"));
               } else {
                  if (var1.item.quantity > 0) {
                     ItemStack var5 = getItemStackFromQuantity(var1.item);
                     if (var5 == null) {
                        class="kw">return;
                     }

                     if (var1.slotId < 0) {
                        CombinedItemContainer var6 = InventoryComponent.getCombined(var4, var3, InventoryComponent.HOTBAR_FIRST);
                        ItemStackTransaction var7 = var6.addItemStack(var5);
                        ItemStack var8 = var7.getRemainder();
                        if (var8 != null && !var8.isEmpty() && !GameModeTypes.preventsItemDrops(var3, var4)) {
                           ItemUtils.dropItem(var3, var8, var4);
                        }
                     } else {
                        ItemContainer var10 = InventoryUtils.getSectionById(var3, var1.inventorySectionId, var4);
                        if (var10 != null) {
                           if (var1.override) {
                              var10.setItemStackForSlot((short)var1.slotId, var5);
                           } else {
                              ItemStack var11 = var10.getItemStack((short)var1.slotId);
                              if (var11 != null && !var11.isEmpty() && var11.isStackableWith(var5)) {
                                 var10.addItemStackToSlot((short)var1.slotId, var5);
                              } else {
                                 var10.setItemStackForSlot((short)var1.slotId, var5);
                              }
                           }
                        }
                     }
                  } else if (var1.override) {
                     ItemContainer var9 = InventoryUtils.getSectionById(var3, var1.inventorySectionId, var4);
                     if (var9 != null) {
                        var9.setItemStackForSlot((short)var1.slotId, null);
                     }
                  }
               }
            }
         });
      }
   }

   class="kw">public void handle(@Nonnull DropCreativeItem var1) {
      PlayerRef var2 = this.packetHandler.getPlayerRef();
      Ref var3 = var2.getReference();
      if (var3 != null && var3.isValid()) {
         Store var4 = var3.getStore();
         World var5 = var4.getExternalData().getWorld();
         ItemStack var6 = getItemStackFromQuantity(var1.item);
         if (var6 != null) {
            var5.execute(() -> {
               if (!blocksInventoryAccess(var3, var4)) {
                  Player var3 = var4.getComponent(var3, Player.getComponentType());
                  assert var3 != null;
                  PlayerRef var4 = var4.getComponent(var3, PlayerRef.getComponentType());
                  assert var4 != null;
                  if (var3.getGameMode() != GameMode.Creative) {
                     NotificationUtil.sendNotification(var4.getPacketHandler(), Message.translation("server.general.setCreativeItem.notInCreativeMode"));
                  } else if (!GameModeTypes.preventsItemDrops(var3, var4)) {
                     ItemUtils.dropItem(var3, var6, var4);
                  }
               }
            });
         }
      }
   }

   class="kw">public void handle(SwitchHotbarBlockSet var1) {
      PlayerRef var2 = this.packetHandler.getPlayerRef();
      Ref var3 = var2.getReference();
      if (var3 != null && var3.isValid()) {
         Store var4 = var3.getStore();
         World var5 = var4.getExternalData().getWorld();
         var5.execute(() -> {
            if (!blocksInventoryAccess(var3, var4)) {
               Player var3 = var4.getComponent(var3, Player.getComponentType());
               assert var3 != null;
               InventoryComponent.Hotbar var4 = var4.getComponent(var3, InventoryComponent.Hotbar.getComponentType());
               assert var4 != null;
               ItemContainer var5 = var4.getInventory();
               byte var6 = var4.getActiveSlot();
               if (var6 != -1) {
                  ItemStack var7 = var5.getItemStack(var6);
                  if (var7 != null && !var7.isEmpty()) {
                     BlockGroup var8 = BlockGroup.findItemGroup(var7.getItem());
                     if (var8 != null) {
                        Item var9 = Item.getAssetMap().getAsset(var1.itemId);
                        if (var9 != null) {
                           int var10 = var8.getIndex(var7.getItem());
                           if (var10 != -1) {
                              int var11 = var8.getIndex(var9);
                              if (var11 != -1 && var11 != var10) {
                                 ItemStack var12 = null;
                                 short var13 = -1;
                                 CombinedItemContainer var14 = InventoryComponent.getCombined(var4, var3, InventoryComponent.ARMOR_HOTBAR_UTILITY_STORAGE);

                                 for (short var15 = 0; var15 < var14.getCapacity(); var15++) {
                                    ItemStack var16 = var14.getItemStack(var15);
                                    if (!ItemStack.isEmpty(var16)) {
                                       Item var17 = var16.getItem();
                                       BlockSelectorToolData var18 = var17.getBlockSelectorToolData();
                                       if (var18 != null && (var12 == null || var12.getDurability() < var16.getDurability())) {
                                          var12 = var16;
                                          var13 = var15;
                                       }
                                    }
                                 }

                                 if (var12 != null) {
                                    BlockSelectorToolData var20 = var12.getItem().getBlockSelectorToolData();
                                    if (ItemUtils.canDecreaseItemStackDurability(var3, var4) && !var12.isUnbreakable()) {
                                       ItemUtils.updateItemStackDurability(var3, var12, var14, var13, -var20.getDurabilityLossOnUse(), var4);
                                    }

                                    ItemStack var21 = new ItemStack(var8.get(var11), var7.getQuantity());
                                    var5.setItemStackForSlot(var6, var21);
                                    ItemSoundSet var22 = ItemSoundSet.getAssetMap().getAsset(var9.getItemSoundSetIndex());
                                    if (var22 != null) {
                                       String var23 = var22.getSoundEventIds().get(ItemSoundEvent.Drop);
                                       if (var23 != null) {
                                          int var19 = SoundEvent.getAssetMap().getIndex(var23);
                                          if (var19 != 0) {
                                             SoundUtil.playSoundEvent2d(var3, var19, SoundCategory.UI, var4);
                                          }
                                       }
                                    }
                                 }
                              }
                           }
                        }
                     }
                  }
               }
            }
         });
      }
   }

   class="kw">public void handle(@Nonnull SmartGiveCreativeItem var1) {
      PlayerRef var2 = this.packetHandler.getPlayerRef();
      Ref var3 = var2.getReference();
      if (var3 != null && var3.isValid()) {
         Store var4 = var3.getStore();
         World var5 = var4.getExternalData().getWorld();
         var5.execute(() -> {
            if (!blocksInventoryAccess(var3, var4)) {
               Player var3 = var4.getComponent(var3, Player.getComponentType());
               assert var3 != null;
               PlayerRef var4 = var4.getComponent(var3, PlayerRef.getComponentType());
               assert var4 != null;
               if (var3.getGameMode() != GameMode.Creative) {
                  NotificationUtil.sendNotification(var4.getPacketHandler(), Message.translation("server.general.setCreativeItem.notInCreativeMode"));
               } else {
                  ItemStack var5 = getItemStackFromQuantity(var1.item);
                  if (var5 != null) {
                     class="kw">switch (var1.moveType) {
                        case EquipOrMergeStack:
                           Item var6 = var5.getItem();
                           ItemArmor var7 = var6.getArmor();
                           if (var7 != null) {
                              InventoryComponent.Armor var15 = var4.getComponent(var3, InventoryComponent.Armor.getComponentType());
                              if (var15 != null) {
                                 var15.getInventory().setItemStackForSlot((short)var7.getArmorSlot().ordinal(), var5);
                              }

                              class="kw">return;
                           }

                           int var8 = var5.getQuantity();
                           if (var6.getUtility().isUsable()) {
                              InventoryComponent.Utility var9 = var4.getComponent(var3, InventoryComponent.Utility.getComponentType());
                              if (var9 != null) {
                                 ItemStackTransaction var10 = var9.getInventory().addItemStack(var5);
                                 ItemStack var11 = var10.getRemainder();
                                 if (ItemStack.isEmpty(var11) || var11.getQuantity() != var8) {
                                    for (ItemStackSlotTransaction var14 : var10.getSlotTransactions()) {
                                       if (var14.succeeded()) {
                                          var9.setActiveSlot((byte)var14.getSlot(), var3, var4);
                                       }
                                    }
                                 }
                              }
                           }
                           break;
                        case PutInHotbarOrWindow:
                           Player.giveItem(var5, var3, var4);
                        case PutInHotbarOrBackpack:
                     }
                  }
               }
            }
         });
      }
   }

   class="kw">public void handle(@Nonnull DropItemStack var1) {
      PlayerRef var2 = this.packetHandler.getPlayerRef();
      Ref var3 = var2.getReference();
      if (var3 != null && var3.isValid()) {
         Store var4 = var3.getStore();
         World var5 = var4.getExternalData().getWorld();
         var5.execute(
            () -> {
               if (blocksInventoryAccess(var3, var4)) {
                  ComponentType var9 = InventoryComponent.getComponentTypeById(var1.inventorySectionId);
                  if (var9 != null) {
                     InventoryComponent var11 = var4.getComponent(var3, var9);
                     if (var11 != null) {
                        var11.markDirty();
                     }
                  }
               } else {
                  DropItemEvent.PlayerRequest var4 = new DropItemEvent.PlayerRequest(var1.inventorySectionId, (short)var1.slotId);
                  var4.setCancelled(GameModeTypes.preventsItemDrops(var3, var4));
                  var4.invoke(var3, var4);
                  if (!var4.isCancelled()) {
                     ItemContainer var5 = InventoryUtils.getSectionById(var3, var4.getInventorySectionId(), var4);
                     if (var5 == null) {
                        HytaleLogger.getLogger()
                           .at(Level.WARNING)
                           .log("%s attempted to drop an ItemStack from an invalid inventory section! %s", var2.getUsername(), var4.getInventorySectionId());
                        class="kw">return;
                     }

                     ItemStackSlotTransaction var6 = var5.removeItemStackFromSlot(var4.getSlotId(), var1.quantity);
                     ItemStack var7 = var6.getOutput();
                     if (var7 == null || var7.isEmpty()) {
                        HytaleLogger.getLogger().at(Level.WARNING).log("%s attempted to drop an empty ItemStack!", var2.getUsername());
                        class="kw">return;
                     }

                     String var8 = var7.getItemId();
                     if (!ItemModule.exists(var8)) {
                        HytaleLogger.getLogger().at(Level.WARNING).log("%s attempted to drop an unregistered ItemStack! %s", var2.getUsername(), var8);
                        class="kw">return;
                     }

                     ItemUtils.throwItem(var3, var7, 6.0F, var4);
                     SoundUtil.playSoundEvent2d(var3, TempAssetIdUtil.getSoundEventIndex("SFX_Player_Drop_Item"), SoundCategory.UI, var4);
                  } else {
                     ComponentType var10 = InventoryComponent.getComponentTypeById(var1.inventorySectionId);
                     if (var10 == null) {
                        class="kw">return;
                     }

                     InventoryComponent var12 = var4.getComponent(var3, var10);
                     if (var12 == null) {
                        class="kw">return;
                     }

                     var12.markDirty();
                  }
               }
            }
         );
      }
   }

   class="kw">public void handle(@Nonnull MoveItemStack var1) {
      PlayerRef var2 = this.packetHandler.getPlayerRef();
      Ref var3 = var2.getReference();
      if (var3 != null && var3.isValid()) {
         Store var4 = var3.getStore();
         World var5 = var4.getExternalData().getWorld();
         var5.execute(() -> {
            if (!blocksInventoryAccess(var3, var4)) {
               InventoryUtils.moveItem(var3, var1.fromSectionId, var1.fromSlotId, var1.quantity, var1.toSectionId, var1.toSlotId, var4);
               if (var1.toSectionId != var1.fromSectionId && var1.toSectionId == -5) {
                  byte var4 = (byte)var1.toSlotId;
                  int var5 = var1.toSectionId;
                  byte var6 = InventoryUtils.getActiveSlot(var3, var5, var4);
                  if (var6 == var4) {
                     class="kw">return;
                  }

                  InventoryActiveSlotRequestEvent var7 = new InventoryActiveSlotRequestEvent(var5, var6, var4, true);
                  var4.invoke(var3, var7);
                  if (var7.isCancelled() || var7.getNewSlot() == var6) {
                     class="kw">return;
                  }

                  var4 = var7.getNewSlot();
                  InventoryUtils.setActiveSlot(var3, var5, var4, var4);
                  var2.getPacketHandler().writeNoCache(new SetActiveSlot(var5, var4));
               }
            }
         });
      }
   }

   class="kw">public void handle(@Nonnull SmartMoveItemStack var1) {
      PlayerRef var2 = this.packetHandler.getPlayerRef();
      Ref var3 = var2.getReference();
      if (var3 != null && var3.isValid()) {
         Store var4 = var3.getStore();
         World var5 = var4.getExternalData().getWorld();
         var5.execute(() -> {
            if (!blocksInventoryAccess(var3, var4)) {
               PlayerSettings var3 = var4.getComponent(var3, PlayerSettings.getComponentType());
               if (var3 == null) {
                  var3 = PlayerSettings.defaults();
               }

               InventoryUtils.smartMoveItem(var3, var1.fromSectionId, var1.fromSlotId, var1.quantity, var1.moveType, var3, var4);
            }
         });
      }
   }

   class="kw">public void handle(@Nonnull SetActiveSlot var1) {
      PlayerRef var2 = this.packetHandler.getPlayerRef();
      Ref var3 = var2.getReference();
      if (var3 != null && var3.isValid()) {
         Store var4 = var3.getStore();
         World var5 = var4.getExternalData().getWorld();
         var5.execute(
            () -> {
               if (!blocksInventoryAccess(var3, var4)) {
                  PacketHandler var4 = var2.getPacketHandler();
                  if (var1.inventorySectionId == -1) {
                     var4.disconnect(Message.translation("server.general.disconnect.hotbarChangeWithoutInteraction"));
                  } else {
                     ItemContainer var5 = InventoryUtils.getSectionById(var3, var1.inventorySectionId, var4);
                     if (var5 == null) {
                        var4.disconnect(
                           Message.translation("server.general.disconnect.invalidInventorySection").param("inventorySectionId", var1.inventorySectionId)
                        );
                     } else if (var1.activeSlot < -1 || var1.activeSlot >= var5.getCapacity()) {
                        var4.disconnect(
                           Message.translation("server.general.disconnect.hotbarSlotOutOfRange").param("inventorySectionId", var1.inventorySectionId)
                        );
                     } else if (var1.activeSlot == InventoryUtils.getActiveSlot(var3, var1.inventorySectionId, var4)) {
                        var4.disconnect(Message.translation("server.general.disconnect.hotbarSlotAlreadySelected"));
                     } else {
                        byte var8 = InventoryUtils.getActiveSlot(var3, var1.inventorySectionId, var4);
                        byte var6 = (byte)var1.activeSlot;
                        InventoryActiveSlotRequestEvent var7 = new InventoryActiveSlotRequestEvent(var1.inventorySectionId, var8, var6, false);
                        var4.invoke(var3, var7);
                        if (var7.isCancelled()) {
                           var6 = var8;
                        } else if (var6 != var7.getNewSlot()) {
                           var6 = var7.getNewSlot();
                        }

                        if (var6 != var1.activeSlot) {
                           var4.writeNoCache(new SetActiveSlot(var1.inventorySectionId, var6));
                        }

                        if (var6 != var8) {
                           InventoryUtils.setActiveSlot(var3, var1.inventorySectionId, var6, var4);
                        }
                     }
                  }
               }
            }
         );
      }
   }

   class="kw">public void handle(@Nonnull InventoryAction var1) {
      PlayerRef var2 = this.packetHandler.getPlayerRef();
      Ref var3 = var2.getReference();
      if (var3 != null && var3.isValid()) {
         if (var1.inventorySectionId >= 0 || var1.inventorySectionId == -9) {
            Store var4 = var3.getStore();
            World var5 = var4.getExternalData().getWorld();
            var5.execute(() -> {
               if (!blocksInventoryAccess(var3, var4)) {
                  Player var3 = var4.getComponent(var3, Player.getComponentType());
                  assert var3 != null;
                  PlayerSettings var4 = var4.getComponent(var3, PlayerSettings.getComponentType());
                  if (var4 == null) {
                     var4 = PlayerSettings.defaults();
                  }

                  class="kw">switch (var1.inventoryActionType) {
                     case TakeAll:
                        if (var1.inventorySectionId == -9) {
                           InventoryUtils.takeAll(var3, var1.inventorySectionId, var4, var4);
                           class="kw">return;
                        }

                        Window var12 = var3.getWindowManager().getWindow(var1.inventorySectionId);
                        if (var12 class="kw">instanceof ItemContainerWindow var13) {
                           if (var12.getType() == WindowType.Processing) {
                              if (var13.getItemContainer() class="kw">instanceof CombinedItemContainer var8 && var8.getContainersSize() >= 3) {
                                 ItemContainer var9 = var8.getContainer(2);
                                 InventoryUtils.takeAllWithPriority(var3, var9, var4, var4);
                              }
                           } else {
                              InventoryUtils.takeAll(var3, var1.inventorySectionId, var4, var4);
                           }
                        }
                        break;
                     case PutAll:
                        if (var1.inventorySectionId == -9) {
                           InventoryUtils.putAll(var3, var1.inventorySectionId, var4);
                           class="kw">return;
                        }

                        Window var11 = var3.getWindowManager().getWindow(var1.inventorySectionId);
                        if (var11 class="kw">instanceof ItemContainerWindow) {
                           InventoryUtils.putAll(var3, var1.inventorySectionId, var4);
                        }
                        break;
                     case QuickStack:
                        if (var1.inventorySectionId == -9) {
                           InventoryUtils.quickStack(var3, var1.inventorySectionId, var4);
                           class="kw">return;
                        }

                        Window var10 = var3.getWindowManager().getWindow(var1.inventorySectionId);
                        if (var10 class="kw">instanceof ItemContainerWindow) {
                           InventoryUtils.quickStack(var3, var1.inventorySectionId, var4);
                        }
                        break;
                     case Sort:
                        if (var1.inventorySectionId == 0) {
                           InventoryUtils.sortStorage(var3, var4);
                        } else {
                           InventoryComponent.Backpack var5 = var4.getComponent(var3, InventoryComponent.Backpack.getComponentType());
                           if (var1.inventorySectionId == -9 && var5 != null) {
                              var5.getInventory().sortItems(SortType.TYPE);
                              class="kw">return;
                           }

                           if (var3.getWindowManager().getWindow(var1.inventorySectionId) class="kw">instanceof ItemContainerWindow var7) {
                              var7.getItemContainer().sortItems(SortType.TYPE);
                           }
                        }
                  }
               }
            });
         }
      }
   }
}