NPCMemory class

Пакет: com.hypixel.hytale.builtin.adventure.memories.memories.npc

Файл: com/hypixel/hytale/builtin/adventure/memories/memories/npc/NPCMemory.java

extends: Memory

Поля (48)

МодификаторыТипИмя
private final ComponentType<EntityStore, Player> playerComponentType
private final ComponentType<EntityStore, PlayerMemories> playerMemoriesComponentType
private final ComponentType<EntityStore, PlayerRef> playerRefComponentType
private final Query<EntityStore> query
private final double radius
private final ComponentType<EntityStore, TransformComponent> transformComponentType
String var1
I18nModule var1
int var1
List var10
List var10
PlayerRef var11
Ref var12
MemoriesPlugin var13
PlayerRef var13
PlayerMemories var14
NPCMemory var15
var15
World var16
String var17
NPCMemory var2
NPCEntity var20
Role var21
String var22
TransformComponent var23
MemoriesGameplayConfig var24
ItemStack var25
Vector3d var26
BoundingBox var27
Holder var28
float var29
InstanceWorldConfig var3
PickupItemComponent var30
String var31
int var32
InstanceDiscoveryConfig var4
ModelParticle var4
ZoneBiomeResult var5
NetworkId var5
Player var6
com.hypixel.hytale.protocol.ModelParticle[] var6
TransformComponent var7
int var7
SpawnModelParticles var7
Vector3d var8
SpatialResource var8
SpatialResource var9
SpatialStructure var9

Методы (22)

МодификаторыВозвратСигнатура
public GatherMemoriesSystempublic GatherMemoriesSystem(@Nonnull ComponentType<EntityStore, TransformComponent> var1, @Nonnull ComponentType<EntityStore, Player> var2, @Nonnull ComponentType<EntityStore, PlayerRef> var3, @Nonnull ComponentType<EntityStore, PlayerMemories> var4, double var5)
private static void displayCatchEntityParticlesprivate static void displayCatchEntityParticles(@Nonnull MemoriesGameplayConfig var0, @Nonnull Vector3d var1, @Nonnull Ref<EntityStore> var2, @Nonnull CommandBuffer<EntityStore> var3)
abstract displayCatchEntityParticles displayCatchEntityParticles(var24, var26, var19, var5)
private static String findLocationZoneNameprivate static String findLocationZoneName(@Nonnull World var0, @Nonnull Vector3d var1)
for for(Ref var19 : var10)
for for(Ref var12 : var10)
public long getCapturedTimestamplong getCapturedTimestamp()
public String getFoundLocationZoneNameKeyString getFoundLocationZoneNameKey()
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
if if(this.foundLocationGeneralNameKey != null)
if if(var20 != null)
if if(var23 != null)
if if(var24 != null)
if if(var27 != null)
if if(var31 != null)
if if(var32 != 0)
if if(var3 != null)
if if(var4 != null)
if if(var5 != null)
if if(var13 != null)
static boolean messageExistsboolean messageExists(@Nonnull String var0)
public void tickpublic void tick(float var1, int var2, @Nonnull ArchetypeChunk<EntityStore> var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.adventure.memories.MemoriesGameplayConfig;
class="kw">import com.hypixel.hytale.builtin.adventure.memories.MemoriesPlugin;
class="kw">import com.hypixel.hytale.builtin.adventure.memories.component.PlayerMemories;
class="kw">import com.hypixel.hytale.builtin.adventure.memories.memories.Memory;
class="kw">import com.hypixel.hytale.builtin.instances.config.InstanceDiscoveryConfig;
class="kw">import com.hypixel.hytale.builtin.instances.config.InstanceWorldConfig;
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.ArchetypeChunk;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Holder;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.component.query.Query;
class="kw">import com.hypixel.hytale.component.spatial.SpatialResource;
class="kw">import com.hypixel.hytale.component.spatial.SpatialStructure;
class="kw">import com.hypixel.hytale.component.system.tick.EntityTickingSystem;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
class="kw">import com.hypixel.hytale.protocol.GameMode;
class="kw">import com.hypixel.hytale.protocol.SoundCategory;
class="kw">import com.hypixel.hytale.protocol.packets.entities.SpawnModelParticles;
class="kw">import com.hypixel.hytale.protocol.packets.player.UpdateMemoriesCount;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.asset.type.model.config.ModelParticle;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
class="kw">import com.hypixel.hytale.server.core.inventory.ItemStack;
class="kw">import com.hypixel.hytale.server.core.modules.entity.EntityModule;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.BoundingBox;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.item.ItemComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.item.PickupItemComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.tracker.NetworkId;
class="kw">import com.hypixel.hytale.server.core.modules.i18n.I18nModule;
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 com.hypixel.hytale.server.core.util.NotificationUtil;
class="kw">import com.hypixel.hytale.server.npc.NPCPlugin;
class="kw">import com.hypixel.hytale.server.npc.entities.NPCEntity;
class="kw">import com.hypixel.hytale.server.npc.role.Role;
class="kw">import com.hypixel.hytale.server.worldgen.chunk.ChunkGenerator;
class="kw">import com.hypixel.hytale.server.worldgen.chunk.ZoneBiomeResult;
class="kw">import java.util.List;
class="kw">import java.util.Objects;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;

class="kw">public class NPCMemory class="kw">extends Memory {
   @Nonnull
   class="kw">public class="kw">static class="kw">final String ID = "NPC";
   @Nonnull
   class="kw">public class="kw">static class="kw">final String ZONE_NAME_UNKNOWN = "???";
   @Nonnull
   class="kw">public class="kw">static class="kw">final String DESCRIPTION_KEY_PREFIX = "server.memories.entries.";
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<NPCMemory> CODEC = BuilderCodec.builder(NPCMemory.class, NPCMemory::new)
      .append(new KeyedCodec<>("NPCRole", Codec.STRING), (var0, var1) -> var0.npcRole = var1, var0 -> var0.npcRole)
      .addValidator(Validators.nonNull())
      .add()
      .append(new KeyedCodec<>("TranslationKey", Codec.STRING), (var0, var1) -> var0.memoryTitleKey = var1, var0 -> var0.memoryTitleKey)
      .add()
      .append(new KeyedCodec<>("CapturedTimestamp", Codec.LONG), (var0, var1) -> var0.capturedTimestamp = var1, var0 -> var0.capturedTimestamp)
      .add()
      .append(
         new KeyedCodec<>("FoundLocationZoneNameKey", Codec.STRING),
         (var0, var1) -> var0.foundLocationZoneNameKey = var1,
         var0 -> var0.foundLocationZoneNameKey
      )
      .add()
      .append(
         new KeyedCodec<>("FoundLocationNameKey", Codec.STRING),
         (var0, var1) -> var0.foundLocationGeneralNameKey = var1,
         var0 -> var0.foundLocationGeneralNameKey
      )
      .add()
      .build();
   class="kw">private String npcRole;
   class="kw">private long capturedTimestamp;
   class="kw">private String foundLocationZoneNameKey;
   class="kw">private String foundLocationGeneralNameKey;
   class="kw">private String memoryTitleKey;

   class="kw">private NPCMemory() {
   }

   class="kw">public NPCMemory(@Nonnull String var1, @Nonnull String var2) {
      this.npcRole = var1;
      this.memoryTitleKey = var2;
   }

   @Override
   class="kw">public String getId() {
      class="kw">return this.npcRole;
   }

   @Nonnull
   @Override
   class="kw">public String getTitle() {
      class="kw">return this.memoryTitleKey;
   }

   @Nonnull
   @Override
   class="kw">public Message getTooltipText() {
      class="kw">return Message.translation("server.memories.general.discovered.tooltipText");
   }

   @Nonnull
   @Override
   class="kw">public String getIconPath() {
      class="kw">return "Icons/ModelsGenerated/" + this.npcRole + ".png";
   }

   @Nonnull
   @Override
   class="kw">public Message getUndiscoveredTooltipText() {
      class="kw">return Message.translation("server.memories.general.undiscovered.tooltipText");
   }

   @Nullable
   @Override
   class="kw">public Message getDescription() {
      String var1 = "server.memories.entries." + this.getId() + ".description";
      class="kw">return messageExists(var1) ? Message.translation(var1) : null;
   }

   @Nonnull
   class="kw">public String getNpcRole() {
      class="kw">return this.npcRole;
   }

   class="kw">public long getCapturedTimestamp() {
      class="kw">return this.capturedTimestamp;
   }

   class="kw">public String getFoundLocationZoneNameKey() {
      class="kw">return this.foundLocationZoneNameKey;
   }

   @Nonnull
   class="kw">public Message getLocationMessage() {
      if (this.foundLocationGeneralNameKey != null) {
         class="kw">return Message.translation(this.foundLocationGeneralNameKey);
      } else {
         class="kw">return this.foundLocationZoneNameKey != null ? Message.translation("server.map.region." + this.foundLocationZoneNameKey) : Message.raw("???");
      }
   }

   class="kw">private class="kw">static boolean messageExists(@Nonnull String var0) {
      I18nModule var1 = I18nModule.get();
      class="kw">return var1 != null && var1.getMessage("en-US", var0) != null;
   }

   @Override
   class="kw">public boolean equals(@Nullable Object var1) {
      if (var1 == null || this.getClass() != var1.getClass()) {
         class="kw">return false;
      }

      if (!super.equals(var1)) {
         class="kw">return false;
      }

      NPCMemory var2 = (NPCMemory)var1;
      class="kw">return Objects.equals(this.npcRole, var2.npcRole);
   }

   @Override
   class="kw">public int hashCode() {
      int var1 = super.hashCode();
      class="kw">return 31 * var1 + Objects.hashCode(this.npcRole);
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "NPCMemory{npcRole='"
         + this.npcRole
         + "', capturedTimestamp="
         + this.capturedTimestamp
         + ", foundLocationZoneNameKey='"
         + this.foundLocationZoneNameKey
         + "'}";
   }

   class="kw">public class="kw">static class GatherMemoriesSystem class="kw">extends EntityTickingSystem<EntityStore> {
      @Nonnull
      class="kw">private class="kw">final ComponentType<EntityStore, TransformComponent> transformComponentType;
      @Nonnull
      class="kw">private class="kw">final ComponentType<EntityStore, Player> playerComponentType;
      @Nonnull
      class="kw">private class="kw">final ComponentType<EntityStore, PlayerRef> playerRefComponentType;
      @Nonnull
      class="kw">private class="kw">final ComponentType<EntityStore, PlayerMemories> playerMemoriesComponentType;
      @Nonnull
      class="kw">private class="kw">final Query<EntityStore> query;
      class="kw">private class="kw">final double radius;

      class="kw">public GatherMemoriesSystem(
         @Nonnull ComponentType<EntityStore, TransformComponent> var1,
         @Nonnull ComponentType<EntityStore, Player> var2,
         @Nonnull ComponentType<EntityStore, PlayerRef> var3,
         @Nonnull ComponentType<EntityStore, PlayerMemories> var4,
         double var5
      ) {
         this.transformComponentType = var1;
         this.playerComponentType = var2;
         this.playerRefComponentType = var3;
         this.playerMemoriesComponentType = var4;
         this.query = Query.and(var1, var2, var3, var4);
         this.radius = var5;
      }

      @Override
      class="kw">public void tick(
         float var1, int var2, @Nonnull ArchetypeChunk<EntityStore> var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5
      ) {
         Player var6 = var3.getComponent(var2, this.playerComponentType);
         assert var6 != null;
         if (var6.getGameMode() == GameMode.Adventure) {
            TransformComponent var7 = var3.getComponent(var2, this.transformComponentType);
            assert var7 != null;
            Vector3d var8 = var7.getPosition();
            SpatialResource var9 = var4.getResource(NPCPlugin.get().getNpcSpatialResource());
            List var10 = SpatialResource.getThreadLocalReferenceList();
            var9.getSpatialStructure().collect(var8, this.radius, var10);
            if (!var10.isEmpty()) {
               PlayerRef var11 = var3.getComponent(var2, this.playerRefComponentType);
               assert var11 != null;
               Ref var12 = var3.getReferenceTo(var2);
               MemoriesPlugin var13 = MemoriesPlugin.get();
               PlayerMemories var14 = var3.getComponent(var2, this.playerMemoriesComponentType);
               assert var14 != null;
               NPCMemory var15 = new NPCMemory();
               World var16 = var5.getExternalData().getWorld();
               String var17 = findLocationZoneName(var16, var8);

               for (Ref var19 : var10) {
                  NPCEntity var20 = var5.getComponent(var19, NPCEntity.getComponentType());
                  if (var20 != null) {
                     Role var21 = var20.getRole();
                     if (var21 != null && var21.isMemory()) {
                        String var22 = var21.getMemoriesNameOverride();
                        var15.npcRole = var22 != null && !var22.isEmpty() ? var22 : var20.getRoleName();
                        var15.memoryTitleKey = var21.getNameTranslationKey();
                        var15.capturedTimestamp = System.currentTimeMillis();
                        var15.foundLocationGeneralNameKey = var17;
                        if (!var13.hasRecordedMemory(var15) && var14.recordMemory(var15)) {
                           NotificationUtil.sendNotification(
                              var11.getPacketHandler(),
                              Message.translation("server.memories.general.collected").param("memoryTitle", Message.translation(var15.getTitle())),
                              null,
                              "NotificationIcons/MemoriesIcon.png"
                           );
                           var11.getPacketHandler().writeNoCache(new UpdateMemoriesCount(var14.getRecordedMemories().size()));
                           var15 = new NPCMemory();
                           TransformComponent var23 = var5.getComponent(var19, TransformComponent.getComponentType());
                           if (var23 != null) {
                              MemoriesGameplayConfig var24 = MemoriesGameplayConfig.get(var4.getExternalData().getWorld().getGameplayConfig());
                              if (var24 != null) {
                                 ItemStack var25 = new ItemStack(var24.getMemoriesCatchItemId());
                                 Vector3d var26 = new Vector3d(var23.getPosition());
                                 BoundingBox var27 = var5.getComponent(var19, BoundingBox.getComponentType());
                                 if (var27 != null) {
                                    var26.y = var26.y + var27.getBoundingBox().middleY();
                                 }

                                 Holder var28 = ItemComponent.generatePickedUpItem(var25, var26, var5, var12);
                                 float var29 = 0.62F;
                                 PickupItemComponent var30 = var28.getComponent(PickupItemComponent.getComponentType());
                                 assert var30 != null;
                                 var30.setInitialLifeTime(0.62F);
                                 var5.addEntity(var28, AddReason.SPAWN);
                                 displayCatchEntityParticles(var24, var26, var19, var5);
                                 String var31 = var24.getMemoriesCatchSoundEventId();
                                 if (var31 != null) {
                                    int var32 = SoundEvent.getAssetMap().getIndex(var31);
                                    if (var32 != 0) {
                                       SoundUtil.playSoundEvent3d(var32, SoundCategory.SFX, var23.getPosition(), var5);
                                    }
                                 }
                              }
                           }
                        }
                     }
                  }
               }
            }
         }
      }

      class="kw">private class="kw">static String findLocationZoneName(@Nonnull World var0, @Nonnull Vector3d var1) {
         if (var0.getChunkStore().getGenerator() class="kw">instanceof ChunkGenerator var6) {
            int var7 = (int)var0.getWorldConfig().getSeed();
            ZoneBiomeResult var5 = var6.getZoneBiomeResultAt(var7, MathUtil.floor(var1.x), MathUtil.floor(var1.z));
            class="kw">return "server.map.region." + var5.getZoneResult().getZone().name();
         } else {
            InstanceWorldConfig var3 = var0.getWorldConfig().getPluginConfig().get(InstanceWorldConfig.class);
            if (var3 != null) {
               InstanceDiscoveryConfig var4 = var3.getDiscovery();
               if (var4 != null && var4.getTitleKey() != null) {
                  class="kw">return var4.getTitleKey();
               }
            }

            class="kw">return "???";
         }
      }

      class="kw">private class="kw">static void displayCatchEntityParticles(
         @Nonnull MemoriesGameplayConfig var0, @Nonnull Vector3d var1, @Nonnull Ref<EntityStore> var2, @Nonnull CommandBuffer<EntityStore> var3
      ) {
         ModelParticle var4 = var0.getMemoriesCatchEntityParticle();
         if (var4 != null) {
            NetworkId var5 = var3.getComponent(var2, NetworkId.getComponentType());
            if (var5 != null) {
               com.hypixel.hytale.protocol.ModelParticle[] var6 = new com.hypixel.hytale.protocol.ModelParticle[]{var4.toPacket()};
               SpawnModelParticles var7 = new SpawnModelParticles(var5.getId(), var6);
               SpatialResource var8 = var3.getResource(EntityModule.get().getPlayerSpatialResourceType());
               SpatialStructure var9 = var8.getSpatialStructure();
               List var10 = SpatialResource.getThreadLocalReferenceList();
               var9.ordered(var1, var0.getMemoriesCatchParticleViewDistance(), var10);

               for (Ref var12 : var10) {
                  PlayerRef var13 = var3.getComponent(var12, PlayerRef.getComponentType());
                  if (var13 != null) {
                     var13.getPacketHandler().write(var7);
                  }
               }
            }
         }
      }

      @Nonnull
      @Override
      class="kw">public Query<EntityStore> getQuery() {
         class="kw">return this.query;
      }
   }
}