SendBeaconInteraction class

Пакет: com.hypixel.hytale.server.npc.interactions

Файл: com/hypixel/hytale/server/npc/interactions/SendBeaconInteraction.java

extends: SimpleInstantInteraction

Поля (3)

МодификаторыТипИмя
Ref var4
CommandBuffer var5
TransformComponent var6

Методы (2)

МодификаторыВозвратСигнатура
if if(var4 == null)
if if(var6 == null)

Исходный код

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

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.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.protocol.InteractionState;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionContext;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.SimpleInstantInteraction;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.npc.components.messaging.BeaconBroadcast;
class="kw">import com.hypixel.hytale.server.npc.role.support.WorldSupport;
class="kw">import javax.annotation.Nonnull;

class="kw">public class SendBeaconInteraction class="kw">extends SimpleInstantInteraction {
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<SendBeaconInteraction> CODEC = BuilderCodec.builder(
         SendBeaconInteraction.class, SendBeaconInteraction::new, SimpleInstantInteraction.CODEC
      )
      .documentation("Broadcasts a beacon message to nearby NPCs and encounter managers listening for it.")
      .<String>appendInherited(
         new KeyedCodec<>("Message", Codec.STRING), (var0, var1) -> var0.message = var1, var0 -> var0.message, (var0, var1) -> var0.message = var1.message
      )
      .documentation("The beacon message key to broadcast. Only receivers listening for this key react.")
      .addValidator(Validators.nonNull())
      .add()
      .<Double>appendInherited(
         new KeyedCodec<>("Range", Codec.DOUBLE), (var0, var1) -> var0.range = var1, var0 -> var0.range, (var0, var1) -> var0.range = var1.range
      )
      .documentation("Broadcast radius.")
      .add()
      .<Double>appendInherited(
         new KeyedCodec<>("ExpirationTime", Codec.DOUBLE),
         (var0, var1) -> var0.expirationTime = var1,
         var0 -> var0.expirationTime,
         (var0, var1) -> var0.expirationTime = var1.expirationTime
      )
      .documentation("Seconds the message stays active on receivers. -1 is infinite.")
      .add()
      .<String[]>appendInherited(
         new KeyedCodec<>("TargetGroups", Codec.STRING_ARRAY),
         (var0, var1) -> var0.targetGroups = var1,
         var0 -> var0.targetGroups,
         (var0, var1) -> var0.targetGroups = var1.targetGroups
      )
      .documentation("Optional NPC groups to restrict delivery to. Omit to broadcast to every listener in range.")
      .add()
      .afterDecode(var0 -> var0.resolvedGroups = WorldSupport.createTagSetIndexArray(var0.targetGroups))
      .build();
   class="kw">private String message;
   class="kw">private double range = 64.0;
   class="kw">private double expirationTime = 1.0;
   class="kw">private String[] targetGroups;
   class="kw">private int[] resolvedGroups;

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

   @Override
   class="kw">protected void firstRun(@Nonnull InteractionType var1, @Nonnull InteractionContext var2, @Nonnull CooldownHandler var3) {
      Ref var4 = var2.getOwningEntity();
      if (var4 == null) {
         var2.getState().state = InteractionState.Failed;
      } else {
         CommandBuffer var5 = var2.getCommandBuffer();
         assert var5 != null;
         TransformComponent var6 = var5.getComponent(var4, TransformComponent.getComponentType());
         if (var6 == null) {
            var2.getState().state = InteractionState.Failed;
         } else {
            BeaconBroadcast.broadcast(var6.getPosition(), this.range, this.message, var4, -1, this.resolvedGroups, true, this.expirationTime, var5.getStore());
         }
      }
   }

   @Override
   class="kw">protected void simulateFirstRun(@Nonnull InteractionType var1, @Nonnull InteractionContext var2, @Nonnull CooldownHandler var3) {
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "SendBeaconInteraction{message=" + this.message + ", range=" + this.range + "} " + super.toString();
   }
}