WieldingHand enum

Пакет: com.hypixel.hytale.server.npc.corecomponents.entity.filters

Файл: com/hypixel/hytale/server/npc/corecomponents/entity/filters/EntityFilterItemInHand.java

implements: Supplier<String>

Поля (1)

МодификаторыТипИмя
private final String description

Методы (2)

МодификаторыВозвратСигнатура
abstract Both Both("Both hands")
public String getpublic String get()

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.corecomponents.entity.filters;

class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.server.core.inventory.InventoryComponent;
class="kw">import com.hypixel.hytale.server.core.inventory.ItemStack;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
class="kw">import com.hypixel.hytale.server.npc.corecomponents.EntityFilterBase;
class="kw">import com.hypixel.hytale.server.npc.corecomponents.entity.filters.builders.BuilderEntityFilterItemInHand;
class="kw">import com.hypixel.hytale.server.npc.instructions.ExecutionSupport;
class="kw">import com.hypixel.hytale.server.npc.util.InventoryHelper;
class="kw">import java.util.List;
class="kw">import java.util.function.Supplier;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class EntityFilterItemInHand class="kw">extends EntityFilterBase {
   class="kw">public class="kw">static class="kw">final int COST = 300;
   @Nullable
   class="kw">protected class="kw">final List<String> items;
   class="kw">protected class="kw">final EntityFilterItemInHand.WieldingHand hand;

   class="kw">public EntityFilterItemInHand(@Nonnull BuilderEntityFilterItemInHand var1, @Nonnull BuilderSupport var2) {
      String[] var3 = var1.getItems(var2);
      this.items = var3 != null ? List.of(var3) : null;
      this.hand = var1.getHand(var2);
   }

   @Override
   class="kw">public boolean matchesEntity(
      @Nonnull Ref<EntityStore> var1, @Nonnull Ref<EntityStore> var2, @Nonnull ExecutionSupport var3, @Nonnull Store<EntityStore> var4
   ) {
      class="kw">return class="kw">switch (this.hand) {
         case Main -> {
            ItemStack var9 = InventoryComponent.getItemInHand(var4, var2);
            yield var9 != null && InventoryHelper.matchesItem(this.items, var9);
         }
         case OffHand -> {
            InventoryComponent.Utility var8 = var4.getComponent(var2, InventoryComponent.Utility.getComponentType());
            ItemStack var10 = var8 != null ? var8.getActiveItem() : null;
            yield var10 != null && InventoryHelper.matchesItem(this.items, var10);
         }
         class="kw">default -> {
            ItemStack var5 = InventoryComponent.getItemInHand(var4, var2);
            InventoryComponent.Utility var6 = var4.getComponent(var2, InventoryComponent.Utility.getComponentType());
            ItemStack var7 = var6 != null ? var6.getActiveItem() : null;
            yield var5 != null && InventoryHelper.matchesItem(this.items, var5) || var7 != null && InventoryHelper.matchesItem(this.items, var7);
         }
      };
   }

   @Override
   class="kw">public int cost() {
      class="kw">return 300;
   }

   class="kw">public enum WieldingHand class="kw">implements Supplier<String> {
      Main("The main hand"),
      OffHand("The off-hand"),
      Both("Both hands");

      class="kw">private class="kw">final String description;

      WieldingHand(String nullxx) {
         this.description = nullxx;
      }

      class="kw">public String get() {
         class="kw">return this.description;
      }
   }
}