InventoryUtils class
Пакет: com.hypixel.hytale.server.core.inventory
Файл: com/hypixel/hytale/server/core/inventory/InventoryUtils.java
Поля (70)
| Модификаторы | Тип | Имя |
|---|---|---|
|
|
break |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
|
return |
|
ItemArmor |
var10 |
|
Player |
var10 |
|
InventoryComponent.Hotbar |
var10 |
|
ItemStack |
var10 |
|
ItemContainer |
var11 |
|
ItemStack |
var11 |
|
InventoryComponent.Utility |
var11 |
|
ItemStack |
var11 |
|
ItemStack |
var12 |
|
InventoryComponent.Tool |
var12 |
|
ItemContainer |
var13 |
|
int |
var13 |
|
InventoryComponent.Backpack |
var13 |
|
MoveTransaction |
var14 |
|
InteractionManager |
var14 |
|
ItemStack |
var15 |
|
PlayerRef |
var15 |
|
Player |
var16 |
|
InteractionContext |
var16 |
|
InventoryComponent.Storage |
var17 |
|
String |
var17 |
|
InventoryComponent.Hotbar |
var18 |
|
InteractionChainData |
var18 |
|
InteractionChain |
var19 |
|
CombinedItemContainer |
var2 |
|
InventoryComponent.Storage |
var2 |
|
CombinedItemContainer |
var20 |
|
ItemContainer |
var3 |
|
ItemContainer |
var3 |
|
ComponentType |
var3 |
|
InventoryComponent.Hotbar |
var3 |
|
ItemContainer |
var4 |
|
List |
var4 |
|
InventoryComponent.Storage |
var4 |
|
InventoryComponent |
var4 |
|
ItemStack |
var4 |
|
InventoryComponent.Utility |
var4 |
|
ComponentType |
var4 |
|
BlockType |
var5 |
|
|
var5 |
|
InventoryComponent.Tool |
var5 |
|
ActiveSlotInventoryComponent |
var5 |
|
EquipmentUpdate |
var5 |
|
ItemStack |
var6 |
|
ItemContainer |
var6 |
|
ItemContainer |
var7 |
|
ItemContainer |
var7 |
|
Player |
var7 |
|
World |
var7 |
|
ItemStack |
var8 |
|
InventoryComponent.Armor |
var8 |
|
ItemContainer |
var8 |
|
InventoryComponent.Storage |
var8 |
|
Window |
var8 |
|
PlayerConfig |
var8 |
|
Player |
var9 |
|
Item |
var9 |
|
InventoryComponent.Hotbar |
var9 |
|
InventoryComponent.Armor |
var9 |
|
PlayerConfig.ArmorVisibilityOption |
var9 |
Методы (40)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
static |
void |
clearvoid clear(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1) |
static |
boolean |
containsBrokenItemboolean containsBrokenItem(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1) |
abstract |
|
for for(int var5 = 0; var5 < var1.getCapacity() |
abstract |
|
for for(short var3 = 0; var3 < var2.getCapacity() |
static |
byte |
getActiveSlotbyte getActiveSlot(@Nonnull Ref<EntityStore> var0, int var1, @Nonnull ComponentAccessor<EntityStore> var2) |
abstract |
return |
getContainerForItemPickupreturn getContainerForItemPickup(var0, var1, var2, null, var3) |
abstract |
return |
getItemContainerForPickupLocationreturn getItemContainerForPickupLocation(var3, var0, var4) |
|
|
if if(var3 != null) |
|
|
if if(var5 == null) |
|
|
if if(var7 != null) |
|
|
if if(var16 != null) |
|
|
if if(var21 instanceof ItemContainerWindow var22) |
|
|
if if(var1 >= 0) |
|
|
if if(var9 != null) |
|
|
if if(var11 instanceof ItemContainerWindow var12) |
|
|
if if(var18 != null) |
|
|
if if(var17 != null) |
|
|
if if(var1 == -9) |
|
|
if if(var8 == null) |
|
|
if if(var7 != null) |
|
|
if if(var8 != null) |
|
|
if if(var14 != null) |
|
|
if if(var3 != null) |
|
|
if if(var4 != null) |
|
|
if if(var1 >= 0) |
|
|
if if(var7 != null) |
|
|
if if(var8 instanceof ItemContainerWindow var5) |
|
|
if if(var3 == null) |
|
|
if if(var2 != null) |
|
|
if if(var5 != null) |
|
|
if if(var3 != null) |
|
|
if if(var2 != null) |
static |
void |
moveItemvoid moveItem(@Nonnull Ref<EntityStore> var0, int var1, int var2, int var3, int var4, int var5, @Nonnull ComponentAccessor<EntityStore> var6) |
static |
void |
smartMoveItemvoid smartMoveItem(@Nonnull Ref<EntityStore> var0,
int var1,
int var2,
int var3,
@Nonnull SmartMoveType var4,
PlayerSettings var5,
@Nonnull ComponentAccessor<EntityStore> var6) |
static |
void |
sortStoragevoid sortStorage(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1) |
|
return |
switchreturn switch(var0) |
|
|
switch switch(var4) |
|
|
switch switch(var1) |
|
return |
switchreturn switch(var1) |
static |
boolean |
tryEquipArmorPartboolean tryEquipArmorPart(@Nonnull Ref<EntityStore> var0,
@Nonnull ItemStack var1,
int var2,
short var3,
int var4,
@Nonnull ItemContainer var5,
boolean var6,
@Nonnull ComponentAccessor<EntityStore> var7) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.inventory;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.protocol.BlockMaterial;
class="kw">import com.hypixel.hytale.protocol.EquipmentUpdate;
class="kw">import com.hypixel.hytale.protocol.InteractionChainData;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.protocol.ItemArmorSlot;
class="kw">import com.hypixel.hytale.protocol.PickupLocation;
class="kw">import com.hypixel.hytale.protocol.SmartMoveType;
class="kw">import com.hypixel.hytale.protocol.packets.inventory.UpdatePlayerInventory;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.asset.type.gameplay.PlayerConfig;
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.entity.InteractionChain;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionContext;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionManager;
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.ValidatedWindow;
class="kw">import com.hypixel.hytale.server.core.entity.entities.player.windows.Window;
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.ItemStackTransaction;
class="kw">import com.hypixel.hytale.server.core.inventory.transaction.ListTransaction;
class="kw">import com.hypixel.hytale.server.core.inventory.transaction.MoveTransaction;
class="kw">import com.hypixel.hytale.server.core.modules.entity.player.PlayerSettings;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.InteractionModule;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.Interaction;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.RootInteraction;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.none.ChangeActiveSlotInteraction;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
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.UUIDUtil;
class="kw">import it.unimi.dsi.fastutil.objects.ObjectArrayList;
class="kw">import java.util.Arrays;
class="kw">import java.util.List;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class InventoryUtils {
class="kw">public InventoryUtils() {
}
@Nonnull
class="kw">private class="kw">static ItemContainer getItemContainerForPickupLocation(
@Nonnull PickupLocation var0, @Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2
) {
class="kw">return class="kw">switch (var0) {
case Hotbar -> InventoryComponent.getCombined(var2, var1, InventoryComponent.HOTBAR_STORAGE_BACKPACK);
case Storage -> InventoryComponent.getCombined(var2, var1, InventoryComponent.STORAGE_HOTBAR_BACKPACK);
case Backpack -> InventoryComponent.getCombined(var2, var1, InventoryComponent.BACKPACK_STORAGE_HOTBAR);
};
}
@Nonnull
class="kw">public class="kw">static ItemContainer getContainerForItemPickup(
@Nonnull Ref<EntityStore> var0, @Nonnull Item var1, PlayerSettings var2, @Nonnull ComponentAccessor<EntityStore> var3
) {
class="kw">return getContainerForItemPickup(var0, var1, var2, null, var3);
}
@Nonnull
class="kw">public class="kw">static ItemContainer getContainerForItemPickup(
@Nonnull Ref<EntityStore> var0, @Nonnull Item var1, PlayerSettings var2, @Nullable PickupLocation var3, @Nonnull ComponentAccessor<EntityStore> var4
) {
if (var3 != null) {
class="kw">return getItemContainerForPickupLocation(var3, var0, var4);
}
if (var1.getArmor() != null) {
class="kw">return getItemContainerForPickupLocation(var2.armorItemsPreferredPickupLocation(), var0, var4);
}
if (var1.getWeapon() != null || var1.getTool() != null) {
class="kw">return getItemContainerForPickupLocation(var2.weaponAndToolItemsPreferredPickupLocation(), var0, var4);
}
if (var1.getUtility().isUsable()) {
class="kw">return getItemContainerForPickupLocation(var2.usableItemsItemsPreferredPickupLocation(), var0, var4);
}
BlockType var5 = var1.hasBlockType() ? BlockType.getAssetMap().getAsset(var1.getBlockId()) : BlockType.EMPTY;
if (var5 == null) {
var5 = BlockType.EMPTY;
}
class="kw">return var5.getMaterial() == BlockMaterial.Solid
? getItemContainerForPickupLocation(var2.solidBlockItemsPreferredPickupLocation(), var0, var4)
: getItemContainerForPickupLocation(var2.miscItemsPreferredPickupLocation(), var0, var4);
}
class="kw">public class="kw">static void smartMoveItem(
@Nonnull Ref<EntityStore> var0,
int var1,
int var2,
int var3,
@Nonnull SmartMoveType var4,
PlayerSettings var5,
@Nonnull ComponentAccessor<EntityStore> var6
) {
ItemContainer var7 = getSectionById(var0, var1, var6);
if (var7 != null) {
ItemStack var8 = var7.getItemStack((short)var2);
if (!ItemStack.isEmpty(var8)) {
class="kw">switch (var4) {
case EquipOrMergeStack:
if (tryEquipArmorPart(var0, var8, var1, (short)var2, var3, var7, true, var6)) {
class="kw">return;
}
Player var16 = var6.getComponent(var0, Player.getComponentType());
if (var16 != null) {
for (Window var21 : var16.getWindowManager().getWindows()) {
if (var21 class="kw">instanceof ItemContainerWindow var22) {
var22.getItemContainer().combineItemStacksIntoSlot(var7, (short)var2);
}
}
}
CombinedItemContainer var20 = InventoryComponent.getCombined(var6, var0, InventoryComponent.EVERYTHING);
var20.combineItemStacksIntoSlot(var7, (short)var2);
break;
case PutInHotbarOrWindow:
if (var1 >= 0) {
moveItemFromCheckToInventory(var0, var8, var7, (short)var2, var3, var5, var6);
class="kw">return;
}
Player var9 = var6.getComponent(var0, Player.getComponentType());
if (var9 != null) {
for (Window var11 : var9.getWindowManager().getWindows()) {
if (var11 class="kw">instanceof ItemContainerWindow var12) {
ItemContainer var13 = var12.getItemContainer();
MoveTransaction var14 = var7.moveItemStackFromSlot((short)var2, var3, var13);
ItemStack var15 = var14.getAddTransaction().getRemainder();
if (ItemStack.isEmpty(var15) || var15.getQuantity() != var3) {
class="kw">return;
}
}
}
}
if (tryEquipArmorPart(var0, var8, var1, (short)var2, var3, var7, false, var6)) {
class="kw">return;
}
class="kw">switch (var1) {
case -2:
InventoryComponent.Hotbar var18 = var6.getComponent(var0, InventoryComponent.Hotbar.getComponentType());
if (var18 != null) {
var7.moveItemStackFromSlot((short)var2, var3, var18.getInventory());
}
class="kw">return;
case -1:
InventoryComponent.Storage var17 = var6.getComponent(var0, InventoryComponent.Storage.getComponentType());
if (var17 != null) {
var7.moveItemStackFromSlot((short)var2, var3, var17.getInventory());
}
class="kw">return;
class="kw">default:
moveItemFromCheckToInventory(var0, var8, var7, (short)var2, var3, var5, var6);
class="kw">return;
}
case PutInHotbarOrBackpack:
if (var1 == -9) {
moveItemFromCheckToInventory(var0, var8, var7, (short)var2, var3, var5, var6);
} else {
var7.moveItemStackFromSlot((short)var2, var3, getContainerForItemPickup(var0, var8.getItem(), var5, PickupLocation.Backpack, var6));
}
}
}
}
}
class="kw">private class="kw">static boolean tryEquipArmorPart(
@Nonnull Ref<EntityStore> var0,
@Nonnull ItemStack var1,
int var2,
short var3,
int var4,
@Nonnull ItemContainer var5,
boolean var6,
@Nonnull ComponentAccessor<EntityStore> var7
) {
InventoryComponent.Armor var8 = var7.getComponent(var0, InventoryComponent.Armor.getComponentType());
if (var8 == null) {
class="kw">return false;
}
Item var9 = var1.getItem();
ItemArmor var10 = var9.getArmor();
ItemContainer var11 = var8.getInventory();
if (var10 == null || var2 == -3 || !var6 && var11.getItemStack((short)var10.getArmorSlot().ordinal()) != null) {
class="kw">return false;
}
var5.moveItemStackFromSlotToSlot(var3, var4, var11, (short)var10.getArmorSlot().ordinal());
class="kw">return true;
}
class="kw">public class="kw">static void moveItem(@Nonnull Ref<EntityStore> var0, int var1, int var2, int var3, int var4, int var5, @Nonnull ComponentAccessor<EntityStore> var6) {
ItemContainer var7 = getSectionById(var0, var1, var6);
if (var7 != null) {
ItemContainer var8 = getSectionById(var0, var4, var6);
if (var8 != null) {
InventoryComponent.Hotbar var9 = var6.getComponent(var0, InventoryComponent.Hotbar.getComponentType());
Player var10 = var6.getComponent(var0, Player.getComponentType());
if (var10 != null && var9 != null && (var4 == -1 && var9.getActiveSlot() == var5 || var1 == -1 && var9.getActiveSlot() == var2)) {
ItemStack var11 = var7.getItemStack((short)var2);
ItemStack var12 = var8.getItemStack((short)var5);
if (var12 == null || ItemStack.isStackableWith(var11, var12) || ItemStack.isSameItemType(var11, var12)) {
var7.moveItemStackFromSlotToSlot((short)var2, var3, var8, (short)var5);
class="kw">return;
}
int var13 = var4 == -1 && var9.getActiveSlot() == var5 ? var5 : var9.getActiveSlot();
InteractionManager var14 = var6.getComponent(var0, InteractionModule.get().getInteractionManagerComponent());
if (var14 != null) {
PlayerRef var15 = var6.getComponent(var0, PlayerRef.getComponentType());
assert var15 != null;
InteractionContext var16 = InteractionContext.forInteraction(var14, var0, InteractionType.SwapFrom, var6);
var16.getMetaStore().putMetaObject(Interaction.TARGET_SLOT, var13);
var16.getMetaStore()
.putMetaObject(
ChangeActiveSlotInteraction.PLACE_MOVED_ITEM,
() -> {
var7.moveItemStackFromSlotToSlot((short)var2, var3, var8, (short)var5);
if (var0.isValid()) {
InventoryComponent.Storage var8 = var6.getComponent(var0, InventoryComponent.Storage.getComponentType());
InventoryComponent.Armor var9 = var6.getComponent(var0, InventoryComponent.Armor.getComponentType());
InventoryComponent.Hotbar var10 = var6.getComponent(var0, InventoryComponent.Hotbar.getComponentType());
InventoryComponent.Utility var11 = var6.getComponent(var0, InventoryComponent.Utility.getComponentType());
InventoryComponent.Tool var12 = var6.getComponent(var0, InventoryComponent.Tool.getComponentType());
InventoryComponent.Backpack var13 = var6.getComponent(var0, InventoryComponent.Backpack.getComponentType());
var15.getPacketHandler()
.writeNoCache(
new UpdatePlayerInventory(
var8 != null ? var8.getInventory().toPacket() : null,
var9 != null ? var9.getInventory().toPacket() : null,
var10 != null ? var10.getInventory().toPacket() : null,
var11 != null ? var11.getInventory().toPacket() : null,
var12 != null ? var12.getInventory().toPacket() : null,
var13 != null ? var13.getInventory().toPacket() : null
)
);
}
}
);
String var17 = var16.getRootInteractionId(InteractionType.SwapFrom);
InteractionChainData var18 = new InteractionChainData(-1, UUIDUtil.EMPTY_UUID, null, null, null, -var13 - 1, null);
InteractionChain var19 = var14.initChain(
var18, InteractionType.SwapFrom, var16, RootInteraction.getRootInteractionOrUnknown(var17), null, false
);
var14.queueExecuteChain(var19);
class="kw">return;
}
}
var7.moveItemStackFromSlotToSlot((short)var2, var3, var8, (short)var5);
}
}
}
@Nonnull
class="kw">public class="kw">static MoveTransaction<ItemStackTransaction> moveItemFromCheckToInventory(
@Nonnull Ref<EntityStore> var0,
@Nonnull ItemStack var1,
@Nonnull ItemContainer var2,
short var3,
int var4,
PlayerSettings var5,
@Nonnull ComponentAccessor<EntityStore> var6
) {
class="kw">return var2.moveItemStackFromSlot(var3, var4, getContainerForItemPickup(var0, var1.getItem(), var5, var6));
}
@Nullable
class="kw">public class="kw">static ListTransaction<MoveTransaction<ItemStackTransaction>> takeAll(
@Nonnull Ref<EntityStore> var0, int var1, PlayerSettings var2, @Nonnull ComponentAccessor<EntityStore> var3
) {
ItemContainer var4 = getSectionById(var0, var1, var3);
class="kw">return var4 == null ? null : takeAllWithPriority(var0, var4, var2, var3);
}
@Nonnull
class="kw">public class="kw">static ListTransaction<MoveTransaction<ItemStackTransaction>> takeAllWithPriority(
@Nonnull Ref<EntityStore> var0, ItemContainer var1, PlayerSettings var2, @Nonnull ComponentAccessor<EntityStore> var3
) {
List var4 = new ObjectArrayList();
for (int var5 = 0; var5 < var1.getCapacity(); var5++) {
ItemStack var6 = var1.getItemStack((short)var5);
if (!ItemStack.isEmpty(var6)) {
var4.add(moveItemFromCheckToInventory(var0, var6, var1, (short)var5, var6.getQuantity(), var2, var3));
}
}
class="kw">return new ListTransaction<>(true, var4);
}
@Nullable
class="kw">public class="kw">static ListTransaction<MoveTransaction<ItemStackTransaction>> putAll(
@Nonnull Ref<EntityStore> var0, int var1, @Nonnull ComponentAccessor<EntityStore> var2
) {
ItemContainer var3 = getSectionById(var0, var1, var2);
if (var3 != null) {
InventoryComponent.Storage var4 = var2.getComponent(var0, InventoryComponent.Storage.getComponentType());
if (var4 != null) {
class="kw">return var4.getInventory().moveAllItemStacksTo(var3);
}
}
class="kw">return null;
}
@Nullable
class="kw">public class="kw">static ListTransaction<MoveTransaction<ItemStackTransaction>> quickStack(
@Nonnull Ref<EntityStore> var0, int var1, @Nonnull ComponentAccessor<EntityStore> var2
) {
ItemContainer var3 = getSectionById(var0, var1, var2);
class="kw">return var3 != null ? InventoryComponent.getCombined(var2, var0, InventoryComponent.HOTBAR_FIRST).quickStackTo(var3) : null;
}
@Nullable
class="kw">public class="kw">static ItemContainer getSectionById(@Nonnull Ref<EntityStore> var0, int var1, @Nonnull ComponentAccessor<EntityStore> var2) {
if (var1 >= 0) {
Player var7 = var2.getComponent(var0, Player.getComponentType());
if (var7 != null) {
Window var8 = var7.getWindowManager().getWindow(var1);
if (var8 class="kw">instanceof ItemContainerWindow var5) {
if (var8 class="kw">instanceof ValidatedWindow var6 && !var6.validate(var0, var2)) {
var8.close(var0, var2);
class="kw">return null;
}
class="kw">return var5.getItemContainer();
}
}
class="kw">return null;
} else {
ComponentType var3 = InventoryComponent.getComponentTypeById(var1);
if (var3 == null) {
class="kw">return null;
}
InventoryComponent var4 = var2.getComponent(var0, var3);
class="kw">return var4 != null ? var4.inventory : null;
}
}
class="kw">public class="kw">static boolean containsBrokenItem(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1) {
CombinedItemContainer var2 = InventoryComponent.getCombined(var1, var0, InventoryComponent.EVERYTHING);
for (short var3 = 0; var3 < var2.getCapacity(); var3++) {
ItemStack var4 = var2.getItemStack(var3);
if (!ItemStack.isEmpty(var4) && var4.isBroken()) {
class="kw">return true;
}
}
class="kw">return false;
}
@Nonnull
class="kw">public class="kw">static List<ItemStack> dropAllItemStacks(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1) {
class="kw">return InventoryComponent.getCombined(var1, var0, InventoryComponent.EVERYTHING).dropAllItemStacks();
}
class="kw">public class="kw">static void clear(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1) {
InventoryComponent.getCombined(var1, var0, InventoryComponent.EVERYTHING).clear();
}
class="kw">public class="kw">static void sortStorage(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1) {
InventoryComponent.Storage var2 = var1.getComponent(var0, InventoryComponent.Storage.getComponentType());
if (var2 != null) {
var2.getInventory().sortItems(SortType.TYPE);
var2.markChanged();
}
}
class="kw">public class="kw">static byte getActiveSlot(@Nonnull Ref<EntityStore> var0, int var1, @Nonnull ComponentAccessor<EntityStore> var2) {
class="kw">return class="kw">switch (var1) {
case -10 -> 0;
class="kw">default -> throw new IllegalArgumentException("Inventory section with id " + var1 + " cannot select an active slot");
case -8 -> {
InventoryComponent.Tool var5 = var2.getComponent(var0, InventoryComponent.Tool.getComponentType());
yield var5 != null ? var5.getActiveSlot() : -1;
}
case -5 -> {
InventoryComponent.Utility var4 = var2.getComponent(var0, InventoryComponent.Utility.getComponentType());
yield var4 != null ? var4.getActiveSlot() : -1;
}
case -1 -> {
InventoryComponent.Hotbar var3 = var2.getComponent(var0, InventoryComponent.Hotbar.getComponentType());
yield var3 != null ? var3.getActiveSlot() : -1;
}
};
}
@Deprecated
class="kw">public class="kw">static void setActiveSlot(@Nonnull Ref<EntityStore> var0, int var1, byte var2, @Nonnull ComponentAccessor<EntityStore> var3) {
ComponentType var4 = class="kw">switch (var1) {
case -8 -> InventoryComponent.Tool.getComponentType();
case -5 -> InventoryComponent.Utility.getComponentType();
case -1 -> InventoryComponent.Hotbar.getComponentType();
class="kw">default -> throw new IllegalArgumentException("Inventory section with id " + var1 + " cannot select an active slot");
};
ActiveSlotInventoryComponent var5 = var3.getComponent(var0, var4);
if (var5 != null) {
var5.setActiveSlot(var2, var0, var3);
}
}
@Nonnull
class="kw">public class="kw">static EquipmentUpdate createEquipmentUpdate(
@Nonnull Ref<EntityStore> var0,
@Nonnull ComponentAccessor<EntityStore> var1,
@Nullable PlayerSettings var2,
@Nullable InventoryComponent.Armor var3,
@Nullable InventoryComponent.Utility var4
) {
EquipmentUpdate var5 = new EquipmentUpdate();
if (var3 != null) {
ItemContainer var6 = var3.getInventory();
var5.armorIds = new String[var6.getCapacity()];
Arrays.fill(var5.armorIds, "");
var6.forEachWithMeta((var0x, var1x, var2x) -> var2x[var0x] = var1x.getItemId(), var5.armorIds);
if (var2 != null) {
World var7 = var1.getExternalData().getWorld();
PlayerConfig var8 = var7.getGameplayConfig().getPlayerConfig();
PlayerConfig.ArmorVisibilityOption var9 = var8.getArmorVisibilityOption();
if (var9.canHideHelmet() && var2.hideHelmet()) {
var5.armorIds[ItemArmorSlot.Head.ordinal()] = "";
}
if (var9.canHideCuirass() && var2.hideCuirass()) {
var5.armorIds[ItemArmorSlot.Chest.ordinal()] = "";
}
if (var9.canHideGauntlets() && var2.hideGauntlets()) {
var5.armorIds[ItemArmorSlot.Hands.ordinal()] = "";
}
if (var9.canHidePants() && var2.hidePants()) {
var5.armorIds[ItemArmorSlot.Legs.ordinal()] = "";
}
}
}
ItemStack var10 = InventoryComponent.getItemInHand(var1, var0);
var5.rightHandItemId = var10 != null ? var10.getItemId() : "Empty";
ItemStack var11 = var4 != null ? var4.getActiveItem() : null;
var5.leftHandItemId = var11 != null ? var11.getItemId() : "Empty";
class="kw">return var5;
}
}