PrefabPreviewSystems class

Пакет: com.hypixel.hytale.server.core.modules.entity.prefabpreview

Файл: com/hypixel/hytale/server/core/modules/entity/prefabpreview/PrefabPreviewSystems.java

Поля (36)

МодификаторыТипИмя
final HytaleLogger LOGGER
private final ComponentType<EntityStore, PersistentPrefabPreview> persistentType
private final ComponentType<EntityStore, PrefabPreview> prefabPreviewType
private final ComponentType<EntityStore, PrefabPreview> prefabPreviewType
private final Query<EntityStore> query
private final Query<EntityStore> query
return
Environment var10
FluidChange[] var10
PrefabPreviewUpdate var10
Color var11
PrefabPreviewSystems.Tint var11
PrefabPreviewUpdate var13
TransformComponent var2
Vector3d var3
int var4
PersistentPrefabPreview var4
int var5
EntityTrackerSystems.Visible var5
String var5
int var6
Path var6
EntityTrackerSystems.Visible var6
WorldChunk var7
BlockSelection var7
var7
PrefabPreview var7
BlockChunk var8
EditorBlocksChange var8
Ref var8
int var9
var9
BlockChange[] var9
boolean var9
private final ComponentType<EntityStore, EntityTrackerSystems.Visible> visibleComponentType
private final ComponentType<EntityStore, EntityTrackerSystems.Visible> visibleComponentType

Методы (21)

МодификаторыВозвратСигнатура
public PrefabPreviewEntityTrackerRemovepublic PrefabPreviewEntityTrackerRemove(ComponentType<EntityStore, EntityTrackerSystems.Visible> var1)
public PrefabPreviewSetuppublic PrefabPreviewSetup()
public PrefabPreviewTrackerpublic PrefabPreviewTracker(@Nonnull ComponentType<EntityStore, EntityTrackerSystems.Visible> var1)
private record Tintrecord Tint(int biome, int water)
public ComponentType<EntityStore, PrefabPreview> componentTypepublic ComponentType<EntityStore, PrefabPreview> componentType()
private static PrefabPreviewUpdate fullUpdateprivate static PrefabPreviewUpdate fullUpdate(@Nonnull PrefabPreview var0)
public SystemGroup<EntityStore> getGrouppublic SystemGroup<EntityStore> getGroup()
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
if if(var5 != null)
if if(var6 == null)
if if(var9)
public boolean isParallelpublic boolean isParallel(int var1, int var2)
private static PrefabPreviewUpdate layerUpdateprivate static PrefabPreviewUpdate layerUpdate(@Nonnull PrefabPreview var0)
public void onComponentAddedpublic void onComponentAdded(@Nonnull Ref<EntityStore> var1, @Nonnull PrefabPreview var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4)
public void onComponentRemovedpublic void onComponentRemoved(@Nonnull Ref<EntityStore> var1, @Nonnull PrefabPreview var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4)
public void onComponentSetpublic void onComponentSet(@Nonnull Ref<EntityStore> var1, PrefabPreview var2, @Nonnull PrefabPreview var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5)
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)
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.server.core.modules.entity.prefabpreview;

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.RemoveReason;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.component.SystemGroup;
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.tick.EntityTickingSystem;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
class="kw">import com.hypixel.hytale.protocol.Color;
class="kw">import com.hypixel.hytale.protocol.ComponentUpdateType;
class="kw">import com.hypixel.hytale.protocol.PrefabPreviewUpdate;
class="kw">import com.hypixel.hytale.protocol.packets.interface_.BlockChange;
class="kw">import com.hypixel.hytale.protocol.packets.interface_.EditorBlocksChange;
class="kw">import com.hypixel.hytale.protocol.packets.interface_.FluidChange;
class="kw">import com.hypixel.hytale.server.core.asset.type.environment.config.Environment;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.PersistentPrefabPreview;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.PrefabPreview;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.tracker.EntityTrackerSystems;
class="kw">import com.hypixel.hytale.server.core.prefab.PrefabStore;
class="kw">import com.hypixel.hytale.server.core.prefab.selection.standard.BlockSelection;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.nio.file.Path;
class="kw">import java.util.Map.Entry;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;

class="kw">public class PrefabPreviewSystems {
   class="kw">private class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
   class="kw">private class="kw">static class="kw">final int DEFAULT_BIOME_TINT = 6004264;
   class="kw">private class="kw">static class="kw">final int DEFAULT_WATER_TINT = 668501;

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

   @Nonnull
   class="kw">private class="kw">static PrefabPreviewSystems.Tint deriveTint(@Nonnull Store<EntityStore> var0, @Nonnull Holder<EntityStore> var1) {
      TransformComponent var2 = var1.getComponent(TransformComponent.getComponentType());
      if (var2 != null && var2.getPosition() != null) {
         Vector3d var3 = var2.getPosition();
         int var4 = MathUtil.floor(var3.x());
         int var5 = MathUtil.floor(var3.y());
         int var6 = MathUtil.floor(var3.z());
         WorldChunk var7 = var0.getExternalData().getWorld().getNonTickingChunk(ChunkUtil.indexChunkFromBlock(var4, var6));
         if (var7 != null && var7.getBlockChunk() != null) {
            BlockChunk var8 = var7.getBlockChunk();
            int var9 = 668501;
            Environment var10 = Environment.getAssetMap().getAsset(var8.getEnvironment(var4, var5, var6));
            if (var10 != null && var10.getWaterTint() != null) {
               Color var11 = var10.getWaterTint();
               var9 = (var11.red & 255) << 16 | (var11.green & 255) << 8 | var11.blue & 255;
            }

            class="kw">return new PrefabPreviewSystems.Tint(var8.getTint(var4, var6), var9);
         } else {
            class="kw">return new PrefabPreviewSystems.Tint(6004264, 668501);
         }
      } else {
         class="kw">return new PrefabPreviewSystems.Tint(6004264, 668501);
      }
   }

   class="kw">public class="kw">static class PrefabPreviewEntityTrackerRemove class="kw">extends RefChangeSystem<EntityStore, PrefabPreview> {
      class="kw">private class="kw">final ComponentType<EntityStore, EntityTrackerSystems.Visible> visibleComponentType;

      class="kw">public PrefabPreviewEntityTrackerRemove(ComponentType<EntityStore, EntityTrackerSystems.Visible> var1) {
         this.visibleComponentType = var1;
      }

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

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

      class="kw">public void onComponentAdded(
         @Nonnull Ref<EntityStore> var1, @Nonnull PrefabPreview var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
      ) {
      }

      class="kw">public void onComponentSet(
         @Nonnull Ref<EntityStore> var1,
         PrefabPreview var2,
         @Nonnull PrefabPreview var3,
         @Nonnull Store<EntityStore> var4,
         @Nonnull CommandBuffer<EntityStore> var5
      ) {
      }

      class="kw">public void onComponentRemoved(
         @Nonnull Ref<EntityStore> var1, @Nonnull PrefabPreview var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
      ) {
         EntityTrackerSystems.Visible var5 = var4.getComponent(var1, this.visibleComponentType);
         if (var5 != null) {
            for (EntityTrackerSystems.EntityViewer var7 : var5.visibleTo.values()) {
               var7.queueRemove(var1, ComponentUpdateType.PrefabPreview);
            }
         }
      }
   }

   class="kw">public class="kw">static class PrefabPreviewSetup class="kw">extends HolderSystem<EntityStore> {
      class="kw">private class="kw">final ComponentType<EntityStore, PrefabPreview> prefabPreviewType = PrefabPreview.getComponentType();
      class="kw">private class="kw">final ComponentType<EntityStore, PersistentPrefabPreview> persistentType = PersistentPrefabPreview.getComponentType();
      class="kw">private class="kw">final Query<EntityStore> query = Query.and(this.persistentType, Query.not(this.prefabPreviewType));

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

      @Override
      class="kw">public void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3) {
         PersistentPrefabPreview var4 = var1.getComponent(this.persistentType);
         String var5 = var4.getPrefabKey();
         Path var6 = PrefabStore.get().findBrowsablePrefabPath(var5);
         if (var6 == null) {
            ((HytaleLogger.Api)PrefabPreviewSystems.LOGGER.atWarning()).log("Prefab '%s' not found for prefab preview; skipping.", var5);
         } else {
            BlockSelection var7;
            try {
               var7 = PrefabStore.get().getPrefab(var6);
            } catch (Exception var12) {
               ((HytaleLogger.Api)((HytaleLogger.Api)PrefabPreviewSystems.LOGGER.atWarning()).withCause(var12))
                  .log("Failed to load prefab '%s' for prefab preview; skipping.", var5);
               class="kw">return;
            }

            EditorBlocksChange var8 = var7.toPacket();
            BlockChange[] var9 = var8.blocksChange != null ? var8.blocksChange : new BlockChange[0];
            FluidChange[] var10 = var8.fluidsChange != null ? var8.fluidsChange : new FluidChange[0];
            PrefabPreviewSystems.Tint var11 = var4.hasTintOverride()
               ? new PrefabPreviewSystems.Tint(var4.getBiomeTint(), var4.getWaterTint())
               : PrefabPreviewSystems.deriveTint(var3, var1);
            var1.putComponent(this.prefabPreviewType, new PrefabPreview(var9, var10, var4.getVisibleLayerCount(), var11.biome(), var11.water()));
         }
      }

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

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

   class="kw">public class="kw">static class PrefabPreviewTracker class="kw">extends EntityTickingSystem<EntityStore> {
      @Nonnull
      class="kw">private class="kw">final ComponentType<EntityStore, EntityTrackerSystems.Visible> visibleComponentType;
      @Nonnull
      class="kw">private class="kw">final ComponentType<EntityStore, PrefabPreview> prefabPreviewType;
      @Nonnull
      class="kw">private class="kw">final Query<EntityStore> query;

      class="kw">public PrefabPreviewTracker(@Nonnull ComponentType<EntityStore, EntityTrackerSystems.Visible> var1) {
         this.visibleComponentType = var1;
         this.prefabPreviewType = PrefabPreview.getComponentType();
         this.query = Query.and(var1, this.prefabPreviewType);
      }

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

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

      @Override
      class="kw">public boolean isParallel(int var1, int var2) {
         class="kw">return EntityTickingSystem.maybeUseParallel(var1, var2);
      }

      @Override
      class="kw">public void tick(
         float var1, int var2, @Nonnull ArchetypeChunk<EntityStore> var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5
      ) {
         EntityTrackerSystems.Visible var6 = var3.getComponent(var2, this.visibleComponentType);
         assert var6 != null;
         PrefabPreview var7 = var3.getComponent(var2, this.prefabPreviewType);
         assert var7 != null;
         Ref var8 = var3.getReferenceTo(var2);
         boolean var9 = var7.consumeNetworkOutdated();
         if (!var6.newlyVisibleTo.isEmpty()) {
            PrefabPreviewUpdate var10 = fullUpdate(var7);

            for (EntityTrackerSystems.EntityViewer var12 : var6.newlyVisibleTo.values()) {
               var12.queueUpdate(var8, var10);
            }
         }

         if (var9) {
            PrefabPreviewUpdate var13 = layerUpdate(var7);

            for (Entry var15 : var6.visibleTo.entrySet()) {
               if (!var6.newlyVisibleTo.containsKey(var15.getKey())) {
                  var15.getValue().queueUpdate(var8, var13);
               }
            }
         }
      }

      @Nonnull
      class="kw">private class="kw">static PrefabPreviewUpdate fullUpdate(@Nonnull PrefabPreview var0) {
         class="kw">return new PrefabPreviewUpdate(var0.getBlocks(), var0.getFluids(), var0.getVisibleLayerCount(), var0.getBiomeTint(), var0.getWaterTint());
      }

      @Nonnull
      class="kw">private class="kw">static PrefabPreviewUpdate layerUpdate(@Nonnull PrefabPreview var0) {
         class="kw">return new PrefabPreviewUpdate(null, null, var0.getVisibleLayerCount(), var0.getBiomeTint(), var0.getWaterTint());
      }
   }

   class="kw">private record Tint(int biome, int water) {
      class="kw">private Tint {
      }
   }
}