Inventory class
Пакет: com.hypixel.hytale.server.core.inventory
Файл: com/hypixel/hytale/server/core/inventory/Inventory.java
Поля (18)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
int |
VERSION |
|
Ref |
var1 |
|
Ref |
var1 |
|
Ref |
var1 |
|
Ref |
var1 |
|
Ref |
var1 |
|
Ref |
var1 |
|
Ref |
var1 |
|
Ref |
var1 |
|
Ref |
var1 |
|
Ref |
var1 |
|
int |
var1 |
|
|
var1 |
|
|
var1 |
|
|
var1 |
|
|
var1 |
|
ItemContainer |
var2 |
|
Inventory |
var2 |
Методы (23)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
public |
void |
backwardsCompatHookvoid backwardsCompatHook(Holder<EntityStore> var1) |
|
|
if if(this.entity == null) |
|
|
if if(this.entity != null) |
|
|
if if(this.entity == null) |
|
|
if if(this.entity == null) |
|
|
if if(this.entity == null) |
|
|
if if(this.entity == null) |
|
|
if if(this.entity == null) |
|
|
if if(this.entity == null) |
|
|
if if(this.entity == null) |
|
|
if if(var1 >= 0) |
|
|
if if(this.entity != null) |
|
|
if if(this.deserializedStorage != null) |
|
|
if if(this.deserializedArmor != null) |
|
|
if if(this.deserializedHotbar != null) |
|
|
if if(this.deserializedUtility != null) |
|
|
if if(this.deserializedTools != null) |
|
|
if if(this.deserializedBackpack != null) |
|
|
if if(this == var1) |
|
|
if if(this.tools != null) |
public |
void |
migrateToComponentsvoid migrateToComponents(Holder<EntityStore> var1) |
|
return |
switchreturn switch(var1) |
|
return |
switchreturn switch(var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.inventory;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Holder;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.protocol.SmartMoveType;
class="kw">import com.hypixel.hytale.server.core.entity.LivingEntity;
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.inventory.container.CombinedItemContainer;
class="kw">import com.hypixel.hytale.server.core.inventory.container.ItemContainer;
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.universe.world.storage.EntityStore;
class="kw">import java.util.List;
class="kw">import java.util.Objects;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
@Deprecated(forRemoval = true)
class="kw">public class Inventory {
class="kw">public class="kw">static class="kw">final int VERSION = 4;
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<Inventory> CODEC = BuilderCodec.builder(Inventory.class, Inventory::new)
.versioned()
.codecVersion(4)
.append(new KeyedCodec<>("Storage", ItemContainer.CODEC), (var0, var1) -> var0.deserializedStorage = var1, var0 -> var0.deserializedStorage)
.add()
.append(new KeyedCodec<>("Armor", ItemContainer.CODEC), (var0, var1) -> var0.deserializedArmor = var1, var0 -> var0.deserializedArmor)
.add()
.append(new KeyedCodec<>("HotBar", ItemContainer.CODEC), (var0, var1) -> var0.deserializedHotbar = var1, var0 -> var0.deserializedHotbar)
.add()
.append(new KeyedCodec<>("Utility", ItemContainer.CODEC), (var0, var1) -> var0.deserializedUtility = var1, var0 -> var0.deserializedUtility)
.add()
.append(new KeyedCodec<>("Backpack", ItemContainer.CODEC), (var0, var1) -> var0.deserializedBackpack = var1, var0 -> var0.deserializedBackpack)
.add()
.append(
new KeyedCodec<>("ActiveHotbarSlot", Codec.BYTE), (var0, var1) -> var0.deserializedActiveHotbarSlot = var1, var0 -> var0.deserializedActiveHotbarSlot
)
.add()
.append(new KeyedCodec<>("Tool", ItemContainer.CODEC), (var0, var1) -> var0.deserializedTools = var1, var0 -> var0.deserializedTools)
.add()
.append(
new KeyedCodec<>("ActiveToolsSlot", Codec.BYTE), (var0, var1) -> var0.deserializedActiveToolsSlot = var1, var0 -> var0.deserializedActiveToolsSlot
)
.add()
.append(
new KeyedCodec<>("ActiveUtilitySlot", Codec.BYTE),
(var0, var1) -> var0.deserializedActiveUtilitySlot = var1,
var0 -> var0.deserializedActiveUtilitySlot
)
.add()
.build();
class="kw">private ItemContainer deserializedStorage;
class="kw">private ItemContainer deserializedArmor;
class="kw">private ItemContainer deserializedHotbar;
class="kw">private ItemContainer deserializedUtility;
class="kw">private ItemContainer deserializedTools;
class="kw">private ItemContainer deserializedBackpack;
class="kw">private byte deserializedActiveHotbarSlot;
class="kw">private byte deserializedActiveUtilitySlot = -1;
class="kw">private byte deserializedActiveToolsSlot = -1;
@Nullable
class="kw">private InventoryComponent.Storage storage;
@Nullable
class="kw">private InventoryComponent.Armor armor;
@Nullable
class="kw">private InventoryComponent.Hotbar hotbar;
@Nullable
class="kw">private InventoryComponent.Utility utility;
@Nullable
class="kw">private InventoryComponent.Tool tools;
@Nullable
class="kw">private InventoryComponent.Backpack backpack;
@Nullable
class="kw">private LivingEntity entity;
class="kw">public Inventory() {
}
@Deprecated(forRemoval = true)
class="kw">public void unregister() {
this.entity = null;
}
@Deprecated(forRemoval = 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) {
InventoryUtils.moveItem(var0, var1, var2, var3, var4, var5, var6);
}
@Deprecated(forRemoval = true)
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
) {
InventoryUtils.smartMoveItem(var0, var1, var2, var3, var4, var5, var6);
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ListTransaction<MoveTransaction<ItemStackTransaction>> takeAll(
@Nonnull Ref<EntityStore> var1, int var2, PlayerSettings var3, @Nonnull ComponentAccessor<EntityStore> var4
) {
class="kw">return InventoryUtils.takeAll(var1, var2, var3, var4);
}
@Deprecated(forRemoval = true)
class="kw">public class="kw">static ListTransaction<MoveTransaction<ItemStackTransaction>> takeAllWithPriority(
@Nonnull Ref<EntityStore> var0, ItemContainer var1, PlayerSettings var2, @Nonnull ComponentAccessor<EntityStore> var3
) {
class="kw">return InventoryUtils.takeAllWithPriority(var0, var1, var2, var3);
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ListTransaction<MoveTransaction<ItemStackTransaction>> putAll(int var1) {
ItemContainer var2 = this.getSectionById(var1);
class="kw">return var2 != null ? this.storage.getInventory().moveAllItemStacksTo(var2) : null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ListTransaction<MoveTransaction<ItemStackTransaction>> quickStack(
@Nonnull Ref<EntityStore> var1, int var2, @Nonnull ComponentAccessor<EntityStore> var3
) {
class="kw">return InventoryUtils.quickStack(var1, var2, var3);
}
@Deprecated(forRemoval = true)
@Nonnull
class="kw">public List<ItemStack> dropAllItemStacks() {
if (this.entity == null) {
class="kw">return List.of();
}
Ref var1 = this.entity.getReference();
class="kw">return var1 != null && var1.isValid() ? InventoryUtils.dropAllItemStacks(var1, var1.getStore()) : List.of();
}
@Deprecated(forRemoval = true)
class="kw">public void clear() {
if (this.entity != null) {
Ref var1 = this.entity.getReference();
if (var1 != null && var1.isValid()) {
InventoryUtils.clear(var1, var1.getStore());
}
}
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ItemContainer getStorage() {
class="kw">return this.storage != null ? this.storage.getInventory() : null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ItemContainer getArmor() {
class="kw">return this.armor != null ? this.armor.getInventory() : null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ItemContainer getHotbar() {
class="kw">return this.hotbar != null ? this.hotbar.getInventory() : null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ItemContainer getUtility() {
class="kw">return this.utility != null ? this.utility.getInventory() : null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ItemContainer getTools() {
class="kw">return this.tools != null ? this.tools.getInventory() : null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ItemContainer getBackpack() {
class="kw">return this.backpack != null ? this.backpack.getInventory() : null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public CombinedItemContainer getCombinedHotbarFirst() {
if (this.entity == null) {
class="kw">return null;
}
Ref var1 = this.entity.getReference();
class="kw">return var1 != null && var1.isValid() ? InventoryComponent.getCombined(var1.getStore(), var1, InventoryComponent.HOTBAR_FIRST) : null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public CombinedItemContainer getCombinedStorageFirst() {
if (this.entity == null) {
class="kw">return null;
}
Ref var1 = this.entity.getReference();
class="kw">return var1 != null && var1.isValid() ? InventoryComponent.getCombined(var1.getStore(), var1, InventoryComponent.STORAGE_FIRST) : null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public CombinedItemContainer getCombinedBackpackStorageHotbar() {
if (this.entity == null) {
class="kw">return null;
}
Ref var1 = this.entity.getReference();
class="kw">return var1 != null && var1.isValid() ? InventoryComponent.getCombined(var1.getStore(), var1, InventoryComponent.BACKPACK_STORAGE_HOTBAR) : null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public CombinedItemContainer getCombinedBackpackStorageHotbarFirst() {
if (this.entity == null) {
class="kw">return null;
}
Ref var1 = this.entity.getReference();
class="kw">return var1 != null && var1.isValid() ? InventoryComponent.getCombined(var1.getStore(), var1, InventoryComponent.HOTBAR_STORAGE_BACKPACK) : null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public CombinedItemContainer getCombinedArmorHotbarUtilityStorage() {
if (this.entity == null) {
class="kw">return null;
}
Ref var1 = this.entity.getReference();
class="kw">return var1 != null && var1.isValid() ? InventoryComponent.getCombined(var1.getStore(), var1, InventoryComponent.ARMOR_HOTBAR_UTILITY_STORAGE) : null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public CombinedItemContainer getCombinedHotbarUtilityConsumableStorage() {
if (this.entity == null) {
class="kw">return null;
}
Ref var1 = this.entity.getReference();
class="kw">return var1 != null && var1.isValid()
? InventoryComponent.getCombined(var1.getStore(), var1, InventoryComponent.HOTBAR_UTILITY_CONSUMABLE_STORAGE)
: null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public CombinedItemContainer getCombinedStorageHotbarBackpack() {
if (this.entity == null) {
class="kw">return null;
}
Ref var1 = this.entity.getReference();
class="kw">return var1 != null && var1.isValid() ? InventoryComponent.getCombined(var1.getStore(), var1, InventoryComponent.STORAGE_HOTBAR_BACKPACK) : null;
}
@Deprecated(forRemoval = true)
class="kw">public class="kw">static void setActiveSlot(@Nonnull Ref<EntityStore> var0, int var1, byte var2, @Nonnull ComponentAccessor<EntityStore> var3) {
InventoryUtils.setActiveSlot(var0, var1, var2, var3);
}
@Deprecated(forRemoval = true)
class="kw">public class="kw">static byte getActiveSlot(@Nonnull Ref<EntityStore> var0, int var1, @Nonnull ComponentAccessor<EntityStore> var2) {
class="kw">return InventoryUtils.getActiveSlot(var0, var1, var2);
}
@Deprecated(forRemoval = true)
class="kw">public byte getActiveSlot(int var1) {
class="kw">return class="kw">switch (var1) {
case -8 -> this.tools.getActiveSlot();
case -5 -> this.utility.getActiveSlot();
case -1 -> this.hotbar.getActiveSlot();
class="kw">default -> throw new IllegalArgumentException("Inventory section with id " + var1 + " cannot select an active slot");
};
}
@Deprecated(forRemoval = true)
class="kw">public byte getActiveHotbarSlot() {
class="kw">return this.hotbar.getActiveSlot();
}
@Deprecated(forRemoval = true)
class="kw">public void setActiveHotbarSlot(@Nonnull Ref<EntityStore> var1, byte var2, @Nonnull ComponentAccessor<EntityStore> var3) {
InventoryUtils.setActiveSlot(var1, -1, var2, var3);
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ItemStack getActiveHotbarItem() {
class="kw">return this.hotbar.getActiveItem();
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ItemStack getActiveToolItem() {
class="kw">return this.tools.getActiveItem();
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ItemStack getItemInHand() {
class="kw">return this.tools != null && this.tools.usingToolsItem ? this.getActiveToolItem() : this.getActiveHotbarItem();
}
@Deprecated(forRemoval = true)
class="kw">public byte getActiveUtilitySlot() {
class="kw">return this.utility.getActiveSlot();
}
@Deprecated(forRemoval = true)
class="kw">public void setActiveUtilitySlot(@Nonnull Ref<EntityStore> var1, byte var2, @Nonnull ComponentAccessor<EntityStore> var3) {
InventoryUtils.setActiveSlot(var1, -5, var2, var3);
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ItemStack getUtilityItem() {
class="kw">return this.utility.getActiveItem();
}
@Deprecated(forRemoval = true)
class="kw">public byte getActiveToolsSlot() {
class="kw">return this.tools.getActiveSlot();
}
@Deprecated(forRemoval = true)
class="kw">public void setActiveToolsSlot(@Nonnull Ref<EntityStore> var1, byte var2, @Nonnull ComponentAccessor<EntityStore> var3) {
InventoryUtils.setActiveSlot(var1, -8, var2, var3);
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ItemStack getToolsItem() {
class="kw">return this.tools != null ? this.tools.getActiveItem() : null;
}
@Deprecated(forRemoval = true)
@Nullable
class="kw">public ItemContainer getSectionById(int var1) {
if (var1 >= 0) {
class="kw">return this.entity class="kw">instanceof Player var2 && var2.getWindowManager().getWindow(var1) class="kw">instanceof ItemContainerWindow var4
? var4.getItemContainer()
: null;
}
class="kw">return class="kw">switch (var1) {
case -9 -> this.backpack.getInventory();
case -8 -> this.tools.getInventory();
class="kw">default -> null;
case -5 -> this.utility.getInventory();
case -3 -> this.armor.getInventory();
case -2 -> this.storage.getInventory();
case -1 -> this.hotbar.getInventory();
};
}
@Deprecated(forRemoval = true)
class="kw">public void setEntity(@Nonnull LivingEntity var1) {
this.entity = var1;
}
@Deprecated(forRemoval = true)
class="kw">public void sortStorage() {
if (this.entity != null) {
Ref var1 = this.entity.getReference();
if (var1 != null && var1.isValid()) {
InventoryUtils.sortStorage(var1, var1.getStore());
}
}
}
@Deprecated(forRemoval = true)
class="kw">public class="kw">static boolean containsBrokenItem(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1) {
class="kw">return InventoryUtils.containsBrokenItem(var0, var1);
}
class="kw">public void migrateToComponents(Holder<EntityStore> var1) {
if (this.deserializedStorage != null) {
var1.putComponent(InventoryComponent.Storage.getComponentType(), new InventoryComponent.Storage(this.deserializedStorage));
this.deserializedStorage = null;
}
if (this.deserializedArmor != null) {
var1.putComponent(InventoryComponent.Armor.getComponentType(), new InventoryComponent.Armor(this.deserializedArmor));
this.deserializedArmor = null;
}
if (this.deserializedHotbar != null) {
var1.putComponent(
InventoryComponent.Hotbar.getComponentType(), new InventoryComponent.Hotbar(this.deserializedHotbar, this.deserializedActiveHotbarSlot)
);
this.deserializedHotbar = null;
}
if (this.deserializedUtility != null) {
var1.putComponent(
InventoryComponent.Utility.getComponentType(), new InventoryComponent.Utility(this.deserializedUtility, this.deserializedActiveUtilitySlot)
);
this.deserializedUtility = null;
}
if (this.deserializedTools != null) {
var1.putComponent(InventoryComponent.Tool.getComponentType(), new InventoryComponent.Tool(this.deserializedTools, this.deserializedActiveToolsSlot));
this.deserializedTools = null;
}
if (this.deserializedBackpack != null) {
var1.putComponent(InventoryComponent.Backpack.getComponentType(), new InventoryComponent.Backpack(this.deserializedBackpack));
this.deserializedBackpack = null;
}
}
class="kw">public void backwardsCompatHook(Holder<EntityStore> var1) {
this.storage = var1.getComponent(InventoryComponent.Storage.getComponentType());
this.armor = var1.getComponent(InventoryComponent.Armor.getComponentType());
this.hotbar = var1.getComponent(InventoryComponent.Hotbar.getComponentType());
this.utility = var1.getComponent(InventoryComponent.Utility.getComponentType());
this.tools = var1.getComponent(InventoryComponent.Tool.getComponentType());
this.backpack = var1.getComponent(InventoryComponent.Backpack.getComponentType());
}
@Override
class="kw">public boolean equals(@Nullable Object var1) {
if (this == var1) {
class="kw">return true;
}
if (var1 != null && this.getClass() == var1.getClass()) {
Inventory var2 = (Inventory)var1;
if (!Objects.equals(this.storage, var2.storage)) {
class="kw">return false;
} else if (!Objects.equals(this.armor, var2.armor)) {
class="kw">return false;
} else if (!Objects.equals(this.utility, var2.utility)) {
class="kw">return false;
} else if (!Objects.equals(this.tools, var2.tools)) {
class="kw">return false;
} else {
class="kw">return !Objects.equals(this.backpack, var2.backpack) ? false : Objects.equals(this.hotbar, var2.hotbar);
}
} else {
class="kw">return false;
}
}
@Override
class="kw">public int hashCode() {
int var1 = this.storage != null ? this.storage.hashCode() : 0;
var1 = 31 * var1 + (this.armor != null ? this.armor.hashCode() : 0);
var1 = 31 * var1 + (this.hotbar != null ? this.hotbar.hashCode() : 0);
var1 = 31 * var1 + (this.utility != null ? this.utility.hashCode() : 0);
var1 = 31 * var1 + (this.tools != null ? this.tools.hashCode() : 0);
class="kw">return 31 * var1 + (this.backpack != null ? this.backpack.hashCode() : 0);
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "Inventory{storage=" + this.storage + ", armor=" + this.armor + ", hotbar=" + this.hotbar + ", utility=" + this.utility + "}";
}
@Deprecated(forRemoval = true)
class="kw">public void setUsingToolsItem(boolean var1) {
if (this.tools != null) {
this.tools.setUsingToolsItem(var1);
}
}
@Deprecated(forRemoval = true)
class="kw">public boolean usingToolsItem() {
class="kw">return this.tools != null && this.tools.isUsingToolsItem();
}
}