Repulsion class

Пакет: com.hypixel.hytale.server.core.modules.entity.repulsion

Файл: com/hypixel/hytale/server/core/modules/entity/repulsion/Repulsion.java

implements: Component<EntityStore>

Поля (7)

МодификаторыТипИмя
final int VERSION
yield null
boolean var1
Repulsion var1
String var2
int var2
int var3

Методы (10)

МодификаторыВозвратСигнатура
public boolean consumeNetworkOutdatedboolean consumeNetworkOutdated()
static ComponentType<EntityStore, Repulsion> getComponentTypeComponentType<EntityStore, Repulsion> getComponentType()
public int getRepulsionConfigIndexint getRepulsionConfigIndex()
if if(var2 == null)
if if(var3 == -1)
if if(this.repulsionConfigIndex != -1)
if if(var2 != this.repulsionConfigIndex)
public boolean isMigratedboolean isMigrated()
public void setRepulsionConfigvoid setRepulsionConfig(@Nonnull RepulsionConfig var1)
return switchreturn switch(var0)

Исходный код

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

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.Component;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.server.core.modules.entity.EntityModule;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class Repulsion class="kw">implements Component<EntityStore> {
   class="kw">public class="kw">static class="kw">final int VERSION = 1;
   @Nonnull
   class="kw">private class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
   class="kw">public class="kw">static class="kw">final BuilderCodec<Repulsion> CODEC = BuilderCodec.<Repulsion>builder(Repulsion.class, Repulsion::new)
      .codecVersion(1)
      .versioned()
      .<Integer>append(new KeyedCodec<>("RepulsionConfigIndex", Codec.INTEGER), (var0, var1) -> var0.indexToMigrate = var1, var0 -> var0.indexToMigrate)
      .setVersionRange(0, 0)
      .add()
      .<String>append(new KeyedCodec<>("RepulsionConfigId", Codec.STRING), (var0, var1) -> var0.repulsionConfigId = var1, var0 -> var0.repulsionConfigId)
      .setVersionRange(1, 1)
      .add()
      .afterDecode((var0, var1) -> {
         if (var1.getVersion() == 0) {
            var0.repulsionConfigId = legacyIndexToId(var0.indexToMigrate);
            var0.migrated = true;
            var0.indexToMigrate = -1;
         }

         String var2 = var0.repulsionConfigId;
         if (var2 == null) {
            var0.repulsionConfigIndex = -1;
         } else {
            int var3 = RepulsionConfig.getAssetMap().getIndexOrDefault(var2, -1);
            if (var3 == -1) {
               LOGGER.at(Level.WARNING).log("RepulsionConfig '%s' does not exist; clearing the reference", var2);
               var0.repulsionConfigId = null;
            }

            var0.repulsionConfigIndex = var3;
         }
      })
      .build();
   class="kw">private int indexToMigrate = -1;
   @Nullable
   class="kw">private String repulsionConfigId;
   class="kw">private int repulsionConfigIndex = -1;
   class="kw">private boolean migrated;
   class="kw">private boolean isNetworkOutdated = true;

   class="kw">public class="kw">static ComponentType<EntityStore, Repulsion> getComponentType() {
      class="kw">return EntityModule.get().getRepulsionComponentType();
   }

   @Nullable
   class="kw">private class="kw">static String legacyIndexToId(int var0) {
      class="kw">return class="kw">switch (var0) {
         case -1 -> null;
         case 0 -> "DefaultRepulsion";
         case 1 -> "Minigames";
         class="kw">default -> {
            LOGGER.at(Level.WARNING).log("Unknown legacy RepulsionConfigIndex %d; dropping the reference", var0);
            yield null;
         }
      };
   }

   class="kw">public Repulsion(@Nonnull RepulsionConfig var1) {
      this.repulsionConfigIndex = RepulsionConfig.getAssetMap().getIndexOrDefault(var1.getId(), -1);
      if (this.repulsionConfigIndex != -1) {
         this.repulsionConfigId = var1.getId();
      }
   }

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

   class="kw">public int getRepulsionConfigIndex() {
      class="kw">return this.repulsionConfigIndex;
   }

   @Nullable
   class="kw">public String getRepulsionConfigId() {
      class="kw">return this.repulsionConfigId;
   }

   class="kw">public boolean isMigrated() {
      class="kw">return this.migrated;
   }

   class="kw">public void setRepulsionConfig(@Nonnull RepulsionConfig var1) {
      int var2 = RepulsionConfig.getAssetMap().getIndexOrDefault(var1.getId(), -1);
      if (var2 != this.repulsionConfigIndex) {
         this.repulsionConfigIndex = var2;
         this.repulsionConfigId = var2 != -1 ? var1.getId() : null;
         this.isNetworkOutdated = true;
      }
   }

   class="kw">public boolean consumeNetworkOutdated() {
      boolean var1 = this.isNetworkOutdated;
      this.isNetworkOutdated = false;
      class="kw">return var1;
   }

   @Nonnull
   @Override
   class="kw">public Component<EntityStore> clone() {
      Repulsion var1 = new Repulsion();
      var1.repulsionConfigId = this.repulsionConfigId;
      var1.repulsionConfigIndex = this.repulsionConfigIndex;
      var1.migrated = this.migrated;
      class="kw">return var1;
   }
}