ItemToolSpec class

Пакет: com.hypixel.hytale.server.core.asset.type.item.config

Файл: com/hypixel/hytale/server/core/asset/type/item/config/ItemToolSpec.java

implements: JsonAssetWithMap<String, DefaultAssetMap<String, ItemToolSpec>>, NetworkSerializable<com.hypixel.hytale.protocol.ItemToolSpec>

Поля (4)

МодификаторыТипИмя
ASSET_STORE
final AssetCodec<String, ItemToolSpec> CODEC
com.hypixel.hytale.protocol.ItemToolSpec var1
com.hypixel.hytale.protocol.ItemToolSpec var2

Методы (12)

МодификаторыВозвратСигнатура
static DefaultAssetMap<String, ItemToolSpec> getAssetMapDefaultAssetMap<String, ItemToolSpec> getAssetMap()
static AssetStore<String, ItemToolSpec, DefaultAssetMap<String, ItemToolSpec>> getAssetStoreAssetStore<String, ItemToolSpec, DefaultAssetMap<String, ItemToolSpec>> getAssetStore()
public String getGatherTypeString getGatherType()
public int getHitSoundLayerIndexint getHitSoundLayerIndex()
public String getIdString getId()
public float getPowerfloat getPower()
public int getQualityint getQuality()
if if(ASSET_STORE == null)
if if(this.hitSoundLayerId != null)
if if(var1 != null)
public boolean isIncorrectboolean isIncorrect()
protected void processConfigvoid processConfig()

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.asset.type.item.config;

class="kw">import com.hypixel.hytale.assetstore.AssetExtraInfo;
class="kw">import com.hypixel.hytale.assetstore.AssetKeyValidator;
class="kw">import com.hypixel.hytale.assetstore.AssetRegistry;
class="kw">import com.hypixel.hytale.assetstore.AssetStore;
class="kw">import com.hypixel.hytale.assetstore.codec.AssetBuilderCodec;
class="kw">import com.hypixel.hytale.assetstore.codec.AssetCodec;
class="kw">import com.hypixel.hytale.assetstore.map.DefaultAssetMap;
class="kw">import com.hypixel.hytale.assetstore.map.JsonAssetWithMap;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.validation.ValidatorCache;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.validator.SoundEventValidators;
class="kw">import com.hypixel.hytale.server.core.io.NetworkSerializable;
class="kw">import java.lang.ref.SoftReference;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class ItemToolSpec
   class="kw">implements JsonAssetWithMap<String, DefaultAssetMap<String, ItemToolSpec>>,
   NetworkSerializable<com.hypixel.hytale.protocol.ItemToolSpec> {
   class="kw">public class="kw">static class="kw">final AssetCodec<String, ItemToolSpec> CODEC = AssetBuilderCodec.builder(
         ItemToolSpec.class,
         ItemToolSpec::new,
         Codec.STRING,
         (var0, var1) -> var0.gatherType = var1,
         var0 -> var0.gatherType,
         (var0, var1) -> var0.data = var1,
         var0 -> var0.data
      )
      .append(new KeyedCodec<>("GatherType", Codec.STRING), (var0, var1) -> var0.gatherType = var1, var0 -> var0.gatherType)
      .add()
      .append(new KeyedCodec<>("Power", Codec.DOUBLE), (var0, var1) -> var0.power = var1.floatValue(), var0 -> (double)var0.power)
      .add()
      .append(new KeyedCodec<>("Quality", Codec.INTEGER), (var0, var1) -> var0.quality = var1, var0 -> var0.quality)
      .add()
      .append(new KeyedCodec<>("IsIncorrect", Codec.BOOLEAN), (var0, var1) -> var0.incorrect = var1, var0 -> var0.incorrect)
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("HitSoundLayer", Codec.STRING),
         (var0, var1) -> var0.hitSoundLayerId = var1,
         var0 -> var0.hitSoundLayerId,
         (var0, var1) -> var0.hitSoundLayerId = var1.hitSoundLayerId
      )
      .addValidator(SoundEvent.VALIDATOR_CACHE.getValidator())
      .addValidator(SoundEventValidators.MONO)
      .documentation("Sound to play in addition to the block breaking sound when hitting this block type.")
      .add()
      .afterDecode(ItemToolSpec::processConfig)
      .build();
   class="kw">public class="kw">static class="kw">final ValidatorCache<String> VALIDATOR_CACHE = new ValidatorCache<>(new AssetKeyValidator<>(ItemToolSpec::getAssetStore));
   class="kw">private class="kw">static AssetStore<String, ItemToolSpec, DefaultAssetMap<String, ItemToolSpec>> ASSET_STORE;
   class="kw">protected AssetExtraInfo.Data data;
   class="kw">protected String gatherType;
   class="kw">protected float power;
   class="kw">protected int quality;
   class="kw">protected boolean incorrect;
   @Nullable
   class="kw">protected String hitSoundLayerId = null;
   class="kw">protected class="kw">transient int hitSoundLayerIndex = 0;
   class="kw">private SoftReference<com.hypixel.hytale.protocol.ItemToolSpec> cachedPacket;

   class="kw">public class="kw">static AssetStore<String, ItemToolSpec, DefaultAssetMap<String, ItemToolSpec>> getAssetStore() {
      if (ASSET_STORE == null) {
         ASSET_STORE = AssetRegistry.getAssetStore(ItemToolSpec.class);
      }

      class="kw">return ASSET_STORE;
   }

   class="kw">public class="kw">static DefaultAssetMap<String, ItemToolSpec> getAssetMap() {
      class="kw">return (DefaultAssetMap<String, ItemToolSpec>)getAssetStore().getAssetMap();
   }

   class="kw">public ItemToolSpec(String var1, float var2, int var3) {
      this.gatherType = var1;
      this.power = var2;
      this.quality = var3;
   }

   class="kw">protected ItemToolSpec() {
   }

   class="kw">protected void processConfig() {
      if (this.hitSoundLayerId != null) {
         this.hitSoundLayerIndex = SoundEvent.getAssetMap().getIndex(this.hitSoundLayerId);
      }
   }

   @Nonnull
   class="kw">public com.hypixel.hytale.protocol.ItemToolSpec toPacket() {
      com.hypixel.hytale.protocol.ItemToolSpec var1 = this.cachedPacket == null ? null : this.cachedPacket.get();
      if (var1 != null) {
         class="kw">return var1;
      }

      com.hypixel.hytale.protocol.ItemToolSpec var2 = new com.hypixel.hytale.protocol.ItemToolSpec();
      var2.gatherType = this.gatherType;
      var2.power = this.power;
      var2.quality = this.quality;
      this.cachedPacket = new SoftReference<>(var2);
      class="kw">return var2;
   }

   class="kw">public String getId() {
      class="kw">return this.gatherType;
   }

   class="kw">public String getGatherType() {
      class="kw">return this.gatherType;
   }

   class="kw">public float getPower() {
      class="kw">return this.power;
   }

   class="kw">public int getQuality() {
      class="kw">return this.quality;
   }

   class="kw">public boolean isIncorrect() {
      class="kw">return this.incorrect;
   }

   class="kw">public int getHitSoundLayerIndex() {
      class="kw">return this.hitSoundLayerIndex;
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "ItemToolSpec{gatherType='"
         + this.gatherType
         + "', power="
         + this.power
         + ", quality="
         + this.quality
         + ", incorrect="
         + this.incorrect
         + ", hitSoundLayerId='"
         + this.hitSoundLayerId
         + "', hitSoundLayerIndex="
         + this.hitSoundLayerIndex
         + "}";
   }
}