SoundPlay3DCommand class

Пакет: com.hypixel.hytale.server.core.command.commands.utility.sound

Файл: com/hypixel/hytale/server/core/command/commands/utility/sound/SoundPlay3DCommand.java

extends: AbstractTargetPlayerCommand

Поля (7)

МодификаторыТипИмя
int var10
TransformComponent var11
Vector3d var12
Vector3i var13
SoundEvent var7
SoundCategory var8
RelativeVector3i var9

Методы (1)

МодификаторыВозвратСигнатура
abstract super super("3d", "server.commands.sound.3d.desc")

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.command.commands.utility.sound;

class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
class="kw">import com.hypixel.hytale.protocol.SoundCategory;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent;
class="kw">import com.hypixel.hytale.server.core.command.system.CommandContext;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.system.DefaultArg;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.system.FlagArg;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
class="kw">import com.hypixel.hytale.server.core.command.system.arguments.types.RelativeVector3i;
class="kw">import com.hypixel.hytale.server.core.command.system.basecommands.AbstractTargetPlayerCommand;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.SoundUtil;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3i;

class="kw">public class SoundPlay3DCommand class="kw">extends AbstractTargetPlayerCommand {
   @Nonnull
   class="kw">private class="kw">final RequiredArg<SoundEvent> soundEventArg = this.withRequiredArg("sound", "server.commands.sound.play3d.sound.desc", ArgTypes.SOUND_EVENT_ASSET);
   @Nonnull
   class="kw">private class="kw">final DefaultArg<SoundCategory> categoryArg = this.withDefaultArg(
      "category", "server.commands.sound.category.desc", ArgTypes.SOUND_CATEGORY, SoundCategory.SFX, "server.commands.sound.category.class="kw">default"
   );
   @Nonnull
   class="kw">private class="kw">final RequiredArg<RelativeVector3i> positionArg = this.withRequiredArg(
      "position", "server.commands.sound.play3d.position.desc", ArgTypes.RELATIVE_VECTOR3I
   );
   @Nonnull
   class="kw">private class="kw">final FlagArg allFlag = this.withFlagArg("all", "server.commands.sound.all.desc");

   class="kw">public SoundPlay3DCommand() {
      super("3d", "server.commands.sound.3d.desc");
      this.addAliases("play3d");
   }

   @Override
   class="kw">protected void execute(
      @Nonnull CommandContext var1,
      @Nullable Ref<EntityStore> var2,
      @Nonnull Ref<EntityStore> var3,
      @Nonnull PlayerRef var4,
      @Nonnull World var5,
      @Nonnull Store<EntityStore> var6
   ) {
      SoundEvent var7 = this.soundEventArg.get(var1);
      SoundCategory var8 = this.categoryArg.get(var1);
      RelativeVector3i var9 = this.positionArg.get(var1);
      int var10 = SoundEvent.getAssetMap().getIndex(var7.getId());
      TransformComponent var11 = var6.getComponent(var3, TransformComponent.getComponentType());
      assert var11 != null;
      Vector3d var12 = var11.getPosition();
      Vector3i var13 = var9.resolve(MathUtil.floor(var12.x), MathUtil.floor(var12.y), MathUtil.floor(var12.z));
      if (this.allFlag.provided(var1)) {
         SoundUtil.playSoundEvent3d(var10, var8, var13.x, var13.y, var13.z, var5.getEntityStore().getStore());
      } else {
         SoundUtil.playSoundEvent3dToPlayer(var3, var10, var8, var13.x, var13.y, var13.z, var6);
      }
   }
}