LaunchProjectileInteraction class

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

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

extends: SimpleInstantInteraction

implements: BallisticDataProvider

Поля (16)

МодификаторыТипИмя
return
UUIDComponent var10
UUID var11
TimeResource var12
Holder var13
ProjectileComponent var14
ItemStack var15
Item var16
ItemContainer var17
BrokenPenalties var18
CommandBuffer var4
World var5
Ref var6
Transform var7
Vector3d var8
Rotation3f var9

Методы (6)

МодификаторыВозвратСигнатура
public String getProjectileIdString getProjectileId()
if if(this.ignorePitch)
if if(this.ignoreYaw)
if if(this.ignoreRoll)
if if(var10 != null)
if if(var17 != null)

Исходный код

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

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.AddReason;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.Holder;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.math.vector.Transform;
class="kw">import com.hypixel.hytale.protocol.Direction;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.server.core.asset.type.gameplay.BrokenPenalties;
class="kw">import com.hypixel.hytale.server.core.asset.type.item.config.Item;
class="kw">import com.hypixel.hytale.server.core.asset.type.projectile.config.Projectile;
class="kw">import com.hypixel.hytale.server.core.codec.ProtocolCodecs;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionContext;
class="kw">import com.hypixel.hytale.server.core.entity.ItemUtils;
class="kw">import com.hypixel.hytale.server.core.entity.UUIDComponent;
class="kw">import com.hypixel.hytale.server.core.entity.entities.ProjectileComponent;
class="kw">import com.hypixel.hytale.server.core.inventory.InventoryUtils;
class="kw">import com.hypixel.hytale.server.core.inventory.ItemStack;
class="kw">import com.hypixel.hytale.server.core.inventory.container.ItemContainer;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.Intangible;
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.modules.projectile.config.BallisticData;
class="kw">import com.hypixel.hytale.server.core.modules.projectile.config.BallisticDataProvider;
class="kw">import com.hypixel.hytale.server.core.modules.time.TimeResource;
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 com.hypixel.hytale.server.core.util.TargetUtil;
class="kw">import java.util.UUID;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;

@Deprecated(forRemoval = true)
class="kw">public class LaunchProjectileInteraction class="kw">extends SimpleInstantInteraction class="kw">implements BallisticDataProvider {
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<LaunchProjectileInteraction> CODEC = BuilderCodec.builder(
         LaunchProjectileInteraction.class, LaunchProjectileInteraction::new, SimpleInstantInteraction.CODEC
      )
      .documentation("Launches a projectile.")
      .<String>appendInherited(
         new KeyedCodec<>("ProjectileId", Codec.STRING),
         (var0, var1) -> var0.projectileId = var1,
         var0 -> var0.projectileId,
         (var0, var1) -> var0.projectileId = var1.projectileId
      )
      .addValidator(Validators.nonNull())
      .addValidator(Projectile.VALIDATOR_CACHE.getValidator().late())
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("IgnorePitch", Codec.BOOLEAN),
         (var0, var1) -> var0.ignorePitch = var1,
         var0 -> var0.ignorePitch,
         (var0, var1) -> var0.ignorePitch = var1.ignorePitch
      )
      .documentation("If true, the shooter's pitch is set to 0 before the launch direction is computed, so the projectile's pitch is fixed by RotationOffset.")
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("IgnoreYaw", Codec.BOOLEAN),
         (var0, var1) -> var0.ignoreYaw = var1,
         var0 -> var0.ignoreYaw,
         (var0, var1) -> var0.ignoreYaw = var1.ignoreYaw
      )
      .documentation("If true, the shooter's yaw is set to 0 before the launch direction is computed, so the projectile's yaw is fixed by RotationOffset.")
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("IgnoreRoll", Codec.BOOLEAN),
         (var0, var1) -> var0.ignoreRoll = var1,
         var0 -> var0.ignoreRoll,
         (var0, var1) -> var0.ignoreRoll = var1.ignoreRoll
      )
      .documentation("If true, the shooter's roll is set to 0 before the launch direction is computed, so the projectile's roll is fixed by RotationOffset.")
      .add()
      .<Direction>appendInherited(new KeyedCodec<>("RotationOffset", ProtocolCodecs.DIRECTION), (var0, var1) -> {
         var0.rotationOffset = var1;
         var0.rotationOffset.yaw *= (float) (Math.PI / 180.0);
         var0.rotationOffset.pitch *= (float) (Math.PI / 180.0);
         var0.rotationOffset.roll *= (float) (Math.PI / 180.0);
      }, var0 -> var0.rotationOffset, (var0, var1) -> var0.rotationOffset = var1.rotationOffset)
      .addValidator(Validators.nonNull())
      .documentation("A fixed rotation offset (in degrees) added to the launch rotation after any ignored axes are zeroed.")
      .add()
      .build();
   class="kw">protected String projectileId;
   class="kw">protected boolean ignorePitch;
   class="kw">protected boolean ignoreYaw;
   class="kw">protected boolean ignoreRoll;
   @Nonnull
   class="kw">protected Direction rotationOffset = new Direction(0.0F, 0.0F, 0.0F);

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

   class="kw">public String getProjectileId() {
      class="kw">return this.projectileId;
   }

   @Nullable
   @Override
   class="kw">public BallisticData getBallisticData() {
      class="kw">return Projectile.getAssetMap().getAsset(this.projectileId);
   }

   @Override
   class="kw">protected void firstRun(@Nonnull InteractionType var1, @Nonnull InteractionContext var2, @Nonnull CooldownHandler var3) {
      CommandBuffer var4 = var2.getCommandBuffer();
      assert var4 != null;
      World var5 = var4.getExternalData().getWorld();
      Ref var6 = var2.getEntity();
      Transform var7 = TargetUtil.getLook(var6, var4);
      Vector3d var8 = var7.getPosition();
      Rotation3f var9 = var7.getRotation();
      if (this.ignorePitch) {
         var9.setPitch(0.0F);
      }

      if (this.ignoreYaw) {
         var9.setYaw(0.0F);
      }

      if (this.ignoreRoll) {
         var9.setRoll(0.0F);
      }

      var9.add(this.rotationOffset.pitch, this.rotationOffset.yaw, this.rotationOffset.roll);
      UUIDComponent var10 = var4.getComponent(var6, UUIDComponent.getComponentType());
      if (var10 != null) {
         UUID var11 = var10.getUuid();
         TimeResource var12 = var4.getResource(TimeResource.getResourceType());
         Holder var13 = ProjectileComponent.assembleDefaultProjectile(var12, this.projectileId, var8, var9);
         ProjectileComponent var14 = var13.getComponent(ProjectileComponent.getComponentType());
         assert var14 != null;
         var13.ensureComponent(Intangible.getComponentType());
         if (var14.getProjectile() == null) {
            var14.initialize();
            if (var14.getProjectile() == null) {
               class="kw">return;
            }
         }

         var14.shoot(var13, var11, var8.x(), var8.y(), var8.z(), var9.yaw(), var9.pitch());
         var4.addEntity(var13, AddReason.SPAWN);
         ItemStack var15 = var2.getHeldItem();
         if (var15 != null && !var15.isEmpty()) {
            Item var16 = var15.getItem();
            if (ItemUtils.canDecreaseItemStackDurability(var6, var4) && !var15.isUnbreakable() && var16.getWeapon() != null) {
               ItemContainer var17 = InventoryUtils.getSectionById(var6, var2.getHeldItemSectionId(), var4);
               if (var17 != null) {
                  ItemUtils.updateItemStackDurability(var6, var15, var17, var2.getHeldItemSlot(), -var16.getDurabilityLossOnHit(), var4);
               }
            }

            if (var15.isBroken()) {
               BrokenPenalties var18 = var5.getGameplayConfig().getItemDurabilityConfig().getBrokenPenalties();
               var14.applyBrokenPenalty((float)var18.getWeapon(1.0));
            }
         }
      }
   }

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