InteractionRules class

Пакет: com.hypixel.hytale.server.core.modules.interaction.interaction.config

Файл: com/hypixel/hytale/server/core/modules/interaction/interaction/config/InteractionRules.java

implements: NetworkSerializable<com.hypixel.hytale.protocol.InteractionRules>

Поля (2)

МодификаторыТипИмя
com.hypixel.hytale.protocol.InteractionRules var1
Set var6

Методы (6)

МодификаторыВозвратСигнатура
if if(var0.blockedByBypass != null)
if if(var0.blockingBypass != null)
if if(var0.interruptedByBypass != null)
if if(var0.interruptingBypass != null)
public boolean validateBlockedboolean validateBlocked(@Nonnull InteractionType var1, @Nonnull Int2ObjectMap<IntSet> var2, @Nonnull InteractionType var3, @Nonnull Int2ObjectMap<IntSet> var4, @Nonnull InteractionRules var5)
public boolean validateInterruptsboolean validateInterrupts(@Nonnull InteractionType var1, @Nonnull Int2ObjectMap<IntSet> var2, @Nonnull InteractionType var3, @Nonnull Int2ObjectMap<IntSet> var4, @Nonnull InteractionRules var5)

Исходный код

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

class="kw">import com.hypixel.hytale.assetstore.AssetRegistry;
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.codec.validation.Validators;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.server.core.io.NetworkSerializable;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.InteractionModule;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
class="kw">import it.unimi.dsi.fastutil.ints.IntSet;
class="kw">import java.util.Collections;
class="kw">import java.util.Set;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class InteractionRules class="kw">implements NetworkSerializable<com.hypixel.hytale.protocol.InteractionRules> {
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<InteractionRules> CODEC = BuilderCodec.builder(InteractionRules.class, InteractionRules::new)
      .appendInherited(
         new KeyedCodec<>("BlockedBy", InteractionModule.INTERACTION_TYPE_SET_CODEC),
         (var0, var1) -> var0.blockedBy = var1,
         var0 -> var0.blockedBy,
         (var0, var1) -> var0.blockedBy = var1.blockedBy
      )
      .documentation(
         "A collection of interaction types that should block this interaction from starting. If not set then a set of class="kw">default rules will be applied based on the interaction type that theinteraction is fired with.\nThis is only effective when used on the root interaction of a chain."
      )
      .add()
      .<Set<InteractionType>>appendInherited(
         new KeyedCodec<>("Blocking", InteractionModule.INTERACTION_TYPE_SET_CODEC),
         (var0, var1) -> var0.blocking = var1,
         var0 -> var0.blocking,
         (var0, var1) -> var0.blocking = var1.blocking
      )
      .documentation(
         "A collection of interaction types that this interaction blocks from starting whilst running.\nDefaults to an empty set (blocking nothing)."
      )
      .addValidator(Validators.nonNull())
      .add()
      .<Set<InteractionType>>appendInherited(
         new KeyedCodec<>("InterruptedBy", InteractionModule.INTERACTION_TYPE_SET_CODEC),
         (var0, var1) -> var0.interruptedBy = var1,
         var0 -> var0.interruptedBy,
         (var0, var1) -> var0.interruptedBy = var1.interruptedBy
      )
      .documentation(
         "A collection of interaction types that should stop this interaction while it's running.\nThis is only effective when used on the root interaction of a chain."
      )
      .add()
      .<Set<InteractionType>>appendInherited(
         new KeyedCodec<>("Interrupting", InteractionModule.INTERACTION_TYPE_SET_CODEC),
         (var0, var1) -> var0.interrupting = var1,
         var0 -> var0.interrupting,
         (var0, var1) -> var0.interrupting = var1.interrupting
      )
      .documentation("A collection of interaction types that this interaction should stop when it starts.")
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("BlockedByBypass", Codec.STRING),
         (var0, var1) -> var0.blockedByBypass = var1,
         var0 -> var0.blockedByBypass,
         (var0, var1) -> var0.blockedByBypass = var1.blockedByBypass
      )
      .documentation("A tag that if matched will bypass the `BlockedBy` rules.")
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("BlockingBypass", Codec.STRING),
         (var0, var1) -> var0.blockingBypass = var1,
         var0 -> var0.blockingBypass,
         (var0, var1) -> var0.blockingBypass = var1.blockingBypass
      )
      .documentation("A tag that if matched will bypass the `Blocking` rules.")
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("InterruptedByBypass", Codec.STRING),
         (var0, var1) -> var0.interruptedByBypass = var1,
         var0 -> var0.interruptedByBypass,
         (var0, var1) -> var0.interruptedByBypass = var1.interruptedByBypass
      )
      .documentation("A tag that if matched will bypass the `InterruptedBy` rules.")
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("InterruptingBypass", Codec.STRING),
         (var0, var1) -> var0.interruptingBypass = var1,
         var0 -> var0.interruptingBypass,
         (var0, var1) -> var0.interruptingBypass = var1.interruptingBypass
      )
      .documentation("A tag that if matched will bypass the `Interrupting` rules.")
      .add()
      .afterDecode(var0 -> {
         if (var0.blockedByBypass != null) {
            var0.blockedByBypassIndex = AssetRegistry.getOrCreateTagIndex(var0.blockedByBypass);
         }

         if (var0.blockingBypass != null) {
            var0.blockingBypassIndex = AssetRegistry.getOrCreateTagIndex(var0.blockingBypass);
         }

         if (var0.interruptedByBypass != null) {
            var0.interruptedByBypassIndex = AssetRegistry.getOrCreateTagIndex(var0.interruptedByBypass);
         }

         if (var0.interruptingBypass != null) {
            var0.interruptingBypassIndex = AssetRegistry.getOrCreateTagIndex(var0.interruptingBypass);
         }
      })
      .build();
   @Nonnull
   class="kw">public class="kw">static class="kw">final InteractionRules DEFAULT_RULES = new InteractionRules();
   @Nullable
   class="kw">protected Set<InteractionType> blockedBy;
   @Nonnull
   class="kw">protected Set<InteractionType> blocking = Collections.emptySet();
   @Nullable
   class="kw">protected Set<InteractionType> interruptedBy;
   @Nullable
   class="kw">protected Set<InteractionType> interrupting;
   @Nullable
   class="kw">protected String blockedByBypass;
   class="kw">protected int blockedByBypassIndex = Integer.MIN_VALUE;
   @Nullable
   class="kw">protected String blockingBypass;
   class="kw">protected int blockingBypassIndex = Integer.MIN_VALUE;
   @Nullable
   class="kw">protected String interruptedByBypass;
   class="kw">protected int interruptedByBypassIndex = Integer.MIN_VALUE;
   @Nullable
   class="kw">protected String interruptingBypass;
   class="kw">protected int interruptingBypassIndex = Integer.MIN_VALUE;

   class="kw">public InteractionRules() {
   }

   class="kw">public boolean validateInterrupts(
      @Nonnull InteractionType var1,
      @Nonnull Int2ObjectMap<IntSet> var2,
      @Nonnull InteractionType var3,
      @Nonnull Int2ObjectMap<IntSet> var4,
      @Nonnull InteractionRules var5
   ) {
      class="kw">return var5.interruptedBy == null
            || !var5.interruptedBy.contains(var1)
            || var5.interruptedByBypassIndex != Integer.MIN_VALUE && var2.containsKey(var5.interruptedByBypassIndex)
         ? this.interrupting != null
            && this.interrupting.contains(var3)
            && (this.interruptingBypassIndex == Integer.MIN_VALUE || !var4.containsKey(this.interruptingBypassIndex))
         : true;
   }

   class="kw">public boolean validateBlocked(
      @Nonnull InteractionType var1,
      @Nonnull Int2ObjectMap<IntSet> var2,
      @Nonnull InteractionType var3,
      @Nonnull Int2ObjectMap<IntSet> var4,
      @Nonnull InteractionRules var5
   ) {
      Set var6 = this.blockedBy != null ? this.blockedBy : InteractionTypeUtils.DEFAULT_INTERACTION_BLOCKED_BY.get(var1);
      class="kw">return !var6.contains(var3) || this.blockedByBypassIndex != Integer.MIN_VALUE && var4.containsKey(this.blockedByBypassIndex)
         ? var5.blocking.contains(var1) && (var5.blockingBypassIndex == Integer.MIN_VALUE || !var2.containsKey(var5.blockingBypassIndex))
         : true;
   }

   @Nonnull
   class="kw">public com.hypixel.hytale.protocol.InteractionRules toPacket() {
      com.hypixel.hytale.protocol.InteractionRules var1 = new com.hypixel.hytale.protocol.InteractionRules();
      var1.blockedBy = this.blockedBy == null ? null : this.blockedBy.toArray(InteractionType[]::new);
      var1.blocking = this.blocking.isEmpty() ? null : this.blocking.toArray(InteractionType[]::new);
      var1.interruptedBy = this.interruptedBy == null ? null : this.interruptedBy.toArray(InteractionType[]::new);
      var1.interrupting = this.interrupting == null ? null : this.interrupting.toArray(InteractionType[]::new);
      var1.blockedByBypassIndex = this.blockedByBypassIndex;
      var1.blockingBypassIndex = this.blockingBypassIndex;
      var1.interruptedByBypassIndex = this.interruptedByBypassIndex;
      var1.interruptingBypassIndex = this.interruptingBypassIndex;
      class="kw">return var1;
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "InteractionRules{blockedBy="
         + this.blockedBy
         + ", blocking="
         + this.blocking
         + ", interruptedBy="
         + this.interruptedBy
         + ", interrupting="
         + this.interrupting
         + ", blockedByBypass='"
         + this.blockedByBypass
         + "', blockedByBypassIndex="
         + this.blockedByBypassIndex
         + ", blockingBypass='"
         + this.blockingBypass
         + "', blockingBypassIndex="
         + this.blockingBypassIndex
         + ", interruptedByBypass='"
         + this.interruptedByBypass
         + "', interruptedByBypassIndex="
         + this.interruptedByBypassIndex
         + ", interruptingBypass='"
         + this.interruptingBypass
         + "', interruptingBypassIndex="
         + this.interruptingBypassIndex
         + "}";
   }
}