AddOrRemove class

Пакет: com.hypixel.hytale.builtin.path

Файл: com/hypixel/hytale/builtin/path/PrefabPathSystems.java

extends: HolderSystem<EntityStore>

Поля (21)

МодификаторыТипИмя
private static final Set<Dependency<EntityStore>> DEPENDENCIES
public static final HytaleLogger LOGGER
private static final ComponentType<EntityStore, ModelComponent> MODEL_COMPONENT_TYPE
private static final ComponentType<EntityStore, PatrolPathMarkerEntity> PATH_MARKER_ENTITY_COMPONENT_TYPE
private static final ResourceType<EntityStore, WorldPathData> STORE_WORLD_PATH_DATA_RESOURCE_TYPE
private static final ComponentType<EntityStore, WorldGenId> WORLD_GEN_ID_COMPONENT_TYPE
break
int var10
IPrefabPath var11
PatrolPathMarkerEntity var4
PatrolPathMarkerEntity var4
WorldPathData var5
WorldPathData var5
WorldGenId var6
WorldGenId var6
int var7
int var7
String var8
UUID var8
UUID var9
var9

Методы (10)

МодификаторыВозвратСигнатура
public Set<Dependency<EntityStore>> getDependenciespublic Set<Dependency<EntityStore>> getDependencies()
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
if if(var4 != null)
if if(var8 != null)
if if(var9 == null)
if if(var10 != -1)
if if(var8 != null)
public void onEntityAddpublic void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3)
public void onEntityRemovedpublic void onEntityRemoved(@Nonnull Holder<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3)
switch switch(var2)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.buildertools.BuilderToolsPlugin;
class="kw">import com.hypixel.hytale.builtin.path.entities.PatrolPathMarkerEntity;
class="kw">import com.hypixel.hytale.builtin.path.path.IPrefabPath;
class="kw">import com.hypixel.hytale.builtin.path.path.PatrolPath;
class="kw">import com.hypixel.hytale.component.AddReason;
class="kw">import com.hypixel.hytale.component.Archetype;
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.RemoveReason;
class="kw">import com.hypixel.hytale.component.ResourceType;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.component.SystemGroup;
class="kw">import com.hypixel.hytale.component.dependency.Dependency;
class="kw">import com.hypixel.hytale.component.dependency.Order;
class="kw">import com.hypixel.hytale.component.dependency.SystemDependency;
class="kw">import com.hypixel.hytale.component.query.Query;
class="kw">import com.hypixel.hytale.component.system.HolderSystem;
class="kw">import com.hypixel.hytale.component.system.RefChangeSystem;
class="kw">import com.hypixel.hytale.component.system.WorldEventSystem;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.entity.nameplate.Nameplate;
class="kw">import com.hypixel.hytale.server.core.modules.entity.EntityModule;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.DisplayNameComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.FromWorldGen;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.HiddenFromAdventurePlayers;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.ModelComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.PersistentDisplayName;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.WorldGenId;
class="kw">import com.hypixel.hytale.server.core.modules.entity.system.ModelSystems;
class="kw">import com.hypixel.hytale.server.core.prefab.PrefabCopyableComponent;
class="kw">import com.hypixel.hytale.server.core.prefab.event.PrefabPlaceEntityEvent;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.nio.charset.StandardCharsets;
class="kw">import java.util.Set;
class="kw">import java.util.UUID;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

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

   class="kw">public class="kw">static class AddOrRemove class="kw">extends HolderSystem<EntityStore> {
      class="kw">public class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
      @Nullable
      class="kw">private class="kw">static class="kw">final ComponentType<EntityStore, PatrolPathMarkerEntity> PATH_MARKER_ENTITY_COMPONENT_TYPE = PatrolPathMarkerEntity.getComponentType();
      class="kw">private class="kw">static class="kw">final ComponentType<EntityStore, ModelComponent> MODEL_COMPONENT_TYPE = ModelComponent.getComponentType();
      class="kw">private class="kw">static class="kw">final ResourceType<EntityStore, WorldPathData> STORE_WORLD_PATH_DATA_RESOURCE_TYPE = WorldPathData.getResourceType();
      class="kw">private class="kw">static class="kw">final ComponentType<EntityStore, WorldGenId> WORLD_GEN_ID_COMPONENT_TYPE = WorldGenId.getComponentType();
      class="kw">private class="kw">static class="kw">final Set<Dependency<EntityStore>> DEPENDENCIES = Set.of(new SystemDependency<>(Order.BEFORE, ModelSystems.ModelSpawned.class));

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

      @Nullable
      @Override
      class="kw">public Query<EntityStore> getQuery() {
         class="kw">return PATH_MARKER_ENTITY_COMPONENT_TYPE;
      }

      @Nonnull
      @Override
      class="kw">public Set<Dependency<EntityStore>> getDependencies() {
         class="kw">return DEPENDENCIES;
      }

      @Override
      class="kw">public void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3) {
         PatrolPathMarkerEntity var4 = var1.getComponent(PATH_MARKER_ENTITY_COMPONENT_TYPE);
         WorldPathData var5 = var3.getResource(STORE_WORLD_PATH_DATA_RESOURCE_TYPE);
         WorldGenId var6 = var1.getComponent(WORLD_GEN_ID_COMPONENT_TYPE);
         int var7 = var6 != null ? var6.getWorldGenId() : 0;
         if (var4 != null) {
            String var8 = var4.getPathName();
            if (var8 != null) {
               UUID var9 = var4.getPathId();
               if (var9 == null) {
                  var9 = UUID.nameUUIDFromBytes((var8 + var7).getBytes(StandardCharsets.UTF_8));
                  var4.setPathId(var9);
                  int var10 = var8.lastIndexOf(126);
                  if (var10 != -1) {
                     var4.setPathName(var8.substring(0, var10));
                     var4.markNeedsSave();
                     LOGGER.at(Level.INFO).log("Migrating path marker from path %s to use new UUID %s", var8, var9);
                  }
               }

               IPrefabPath var11 = var5.getOrConstructPrefabPath(var7, var9, var8, PatrolPath::new);
               var11.addLoadedWaypoint(var4, var4.getTempPathLength(), var4.getOrder(), var7);
               var4.setParentPath(var11);
               var1.putComponent(MODEL_COMPONENT_TYPE, new ModelComponent(PathPlugin.get().getPathMarkerModel()));
               var4.markNeedsSave();
               var1.ensureComponent(HiddenFromAdventurePlayers.getComponentType());
               var1.ensureComponent(PrefabCopyableComponent.getComponentType());
            }
         }
      }

      @Override
      class="kw">public void onEntityRemoved(@Nonnull Holder<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3) {
         PatrolPathMarkerEntity var4 = var1.getComponent(PatrolPathMarkerEntity.getComponentType());
         WorldPathData var5 = var3.getResource(WorldPathData.getResourceType());
         WorldGenId var6 = var1.getComponent(WORLD_GEN_ID_COMPONENT_TYPE);
         int var7 = var6 != null ? var6.getWorldGenId() : 0;
         class="kw">switch (var2) {
            case UNLOAD:
               var5.unloadPrefabPathWaypoint(var7, var4.getPathId(), var4.getOrder());
               break;
            case REMOVE:
            case BUILDER_TOOLS_UNDO:
               UUID var8 = var4.getPathId();
               if (var8 != null) {
                  var5.removePrefabPathWaypoint(var7, var8, var4.getOrder());
               }
         }
      }
   }

   class="kw">public class="kw">static class AddedFromWorldGen class="kw">extends HolderSystem<EntityStore> {
      @Nullable
      class="kw">private class="kw">static class="kw">final ComponentType<EntityStore, PatrolPathMarkerEntity> PATH_MARKER_ENTITY_COMPONENT_TYPE = PatrolPathMarkerEntity.getComponentType();
      class="kw">private class="kw">static class="kw">final ComponentType<EntityStore, WorldGenId> WORLD_GEN_ID_COMPONENT_TYPE = WorldGenId.getComponentType();
      class="kw">private class="kw">static class="kw">final ComponentType<EntityStore, FromWorldGen> FROM_WORLD_GEN_COMPONENT_TYPE = FromWorldGen.getComponentType();
      class="kw">private class="kw">static class="kw">final Query<EntityStore> QUERY = Query.and(PATH_MARKER_ENTITY_COMPONENT_TYPE, FROM_WORLD_GEN_COMPONENT_TYPE);
      class="kw">private class="kw">static class="kw">final Set<Dependency<EntityStore>> DEPENDENCIES = Set.of(new SystemDependency<>(Order.BEFORE, PrefabPathSystems.AddOrRemove.class));

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

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

      @Nonnull
      @Override
      class="kw">public Set<Dependency<EntityStore>> getDependencies() {
         class="kw">return DEPENDENCIES;
      }

      @Nullable
      @Override
      class="kw">public SystemGroup<EntityStore> getGroup() {
         class="kw">return EntityModule.get().getPreClearMarkersGroup();
      }

      @Override
      class="kw">public void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3) {
         var1.putComponent(WORLD_GEN_ID_COMPONENT_TYPE, new WorldGenId(var1.getComponent(FROM_WORLD_GEN_COMPONENT_TYPE).getWorldGenId()));
      }

      @Override
      class="kw">public void onEntityRemoved(@Nonnull Holder<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3) {
      }
   }

   class="kw">public class="kw">static class NameplateHolderSystem class="kw">extends HolderSystem<EntityStore> {
      class="kw">public NameplateHolderSystem() {
      }

      @Nonnull
      @Override
      class="kw">public Query<EntityStore> getQuery() {
         class="kw">return Archetype.of(PatrolPathMarkerEntity.getComponentType());
      }

      @Override
      class="kw">public void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3) {
         PatrolPathMarkerEntity var4 = var1.getComponent(PatrolPathMarkerEntity.getComponentType());
         assert var4 != null;
         PersistentDisplayName var6 = var1.getComponent(PersistentDisplayName.getComponentType());
         String var5;
         if (var6 == null) {
            String var7 = var4.getLegacyDisplayName();
            var5 = var7 != null ? var7 : "Path Marker";
            Message var8 = Message.raw(var5);
            var6 = new PersistentDisplayName(var8);
            var1.putComponent(PersistentDisplayName.getComponentType(), var6);
         } else {
            Message var9 = var6.getDisplayName();
            var5 = var9 != null ? var9.getAnsiMessage() : "";
         }

         var1.putComponent(DisplayNameComponent.getComponentType(), new DisplayNameComponent(var6.getDisplayName()));
         Nameplate var10 = var1.getComponent(Nameplate.getComponentType());
         if (var10 == null) {
            var1.putComponent(Nameplate.getComponentType(), new Nameplate(var5));
         }
      }

      @Override
      class="kw">public void onEntityRemoved(@Nonnull Holder<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3) {
      }
   }

   class="kw">public class="kw">static class NameplateRefChangeSystem class="kw">extends RefChangeSystem<EntityStore, DisplayNameComponent> {
      class="kw">public NameplateRefChangeSystem() {
      }

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

      @Nonnull
      @Override
      class="kw">public ComponentType<EntityStore, DisplayNameComponent> componentType() {
         class="kw">return DisplayNameComponent.getComponentType();
      }

      class="kw">public void onComponentAdded(
         @Nonnull Ref<EntityStore> var1, @Nonnull DisplayNameComponent var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
      ) {
         Nameplate var5 = var4.ensureAndGetComponent(var1, Nameplate.getComponentType());
         var5.setText(var2.getDisplayName() != null ? var2.getDisplayName().getAnsiMessage() : "");
      }

      class="kw">public void onComponentSet(
         @Nonnull Ref<EntityStore> var1,
         DisplayNameComponent var2,
         @Nonnull DisplayNameComponent var3,
         @Nonnull Store<EntityStore> var4,
         @Nonnull CommandBuffer<EntityStore> var5
      ) {
         Nameplate var6 = var5.ensureAndGetComponent(var1, Nameplate.getComponentType());
         var6.setText(var3.getDisplayName() != null ? var3.getDisplayName().getAnsiMessage() : "");
      }

      class="kw">public void onComponentRemoved(
         @Nonnull Ref<EntityStore> var1, @Nonnull DisplayNameComponent var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
      ) {
         Nameplate var5 = var4.ensureAndGetComponent(var1, Nameplate.getComponentType());
         var5.setText("");
      }
   }

   class="kw">public class="kw">static class PrefabPlaceEntityEventSystem class="kw">extends WorldEventSystem<EntityStore, PrefabPlaceEntityEvent> {
      class="kw">public PrefabPlaceEntityEventSystem() {
         super(PrefabPlaceEntityEvent.class);
      }

      class="kw">public void handle(@Nonnull Store var1, @Nonnull CommandBuffer var2, @Nonnull PrefabPlaceEntityEvent var3) {
         Holder var4 = var3.getHolder();
         PatrolPathMarkerEntity var5 = var4.getComponent(PatrolPathMarkerEntity.getComponentType());
         if (var5 != null) {
            String var6 = var5.getPathName();
            UUID var7 = var5.getPathId();
            if (var7 == null && var6 != null) {
               int var8 = var6.lastIndexOf(126);
               if (var8 != -1) {
                  var5.setPathName(var6.substring(0, var8));
               }
            }

            UUID var9 = BuilderToolsPlugin.get().getNewPathIdOnPrefabPasted(var7, var5.getPathName(), var3.getPrefabId());
            var5.setPathId(var9);
         }
      }
   }

   class="kw">public class="kw">static class WorldGenChangeSystem class="kw">extends RefChangeSystem<EntityStore, WorldGenId> {
      @Nonnull
      class="kw">private class="kw">static class="kw">final Message MESSAGE_PREFABS_UNKNOWN = Message.translation("server.prefabs.unknown");

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

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

      @Nonnull
      @Override
      class="kw">public ComponentType<EntityStore, WorldGenId> componentType() {
         class="kw">return WorldGenId.getComponentType();
      }

      class="kw">public void onComponentAdded(
         @Nonnull Ref<EntityStore> var1, @Nonnull WorldGenId var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
      ) {
         PatrolPathMarkerEntity var5 = var4.getComponent(var1, PatrolPathMarkerEntity.getComponentType());
         assert var5 != null;
         String var6 = PatrolPathMarkerEntity.generateDisplayName(var2.getWorldGenId(), var5);
         Message var7 = Message.raw(var6);
         var4.putComponent(var1, PersistentDisplayName.getComponentType(), new PersistentDisplayName(var7));
         var4.putComponent(var1, DisplayNameComponent.getComponentType(), new DisplayNameComponent(var7));
      }

      class="kw">public void onComponentSet(
         @Nonnull Ref<EntityStore> var1,
         @Nullable WorldGenId var2,
         @Nonnull WorldGenId var3,
         @Nonnull Store<EntityStore> var4,
         @Nonnull CommandBuffer<EntityStore> var5
      ) {
         PatrolPathMarkerEntity var6 = var5.getComponent(var1, PatrolPathMarkerEntity.getComponentType());
         assert var6 != null;
         String var7 = PatrolPathMarkerEntity.generateDisplayName(var3.getWorldGenId(), var6);
         Message var8 = Message.raw(var7);
         var5.putComponent(var1, PersistentDisplayName.getComponentType(), new PersistentDisplayName(var8));
         var5.putComponent(var1, DisplayNameComponent.getComponentType(), new DisplayNameComponent(var8));
      }

      class="kw">public void onComponentRemoved(
         @Nonnull Ref<EntityStore> var1, @Nonnull WorldGenId var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
      ) {
         var4.putComponent(var1, PersistentDisplayName.getComponentType(), new PersistentDisplayName(MESSAGE_PREFABS_UNKNOWN));
         var4.putComponent(var1, DisplayNameComponent.getComponentType(), new DisplayNameComponent(MESSAGE_PREFABS_UNKNOWN));
      }
   }
}