ReplicateChanges class

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

Файл: com/hypixel/hytale/server/core/modules/blockanimation/BlockAnimationSystems.java

extends: TickingSystem<ChunkStore>

implements: RunWhenPausedSystem<ChunkStore>

Поля (10)

МодификаторыТипИмя
private final ComponentType<ChunkStore, BlockAnimationSection> animationSectionType
private final ResourceType<ChunkStore, BlockAnimationDirtySections> dirtySectionsType
BlockSection var10
SetBlockAnimationSpeeds var11
long var12
ChunkTracker var16
List var4
World var5
BlockAnimationSection var8
ChunkSection var9

Методы (3)

МодификаторыВозвратСигнатура
for for(Ref var7 : var4)
if if(var8 != null && var9 != null && var10 != null)
public void tickpublic void tick(float var1, int var2, @Nonnull Store<ChunkStore> var3)

Исходный код

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

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.Ref;
class="kw">import com.hypixel.hytale.component.ResourceType;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.component.query.Query;
class="kw">import com.hypixel.hytale.component.system.tick.EntityTickingSystem;
class="kw">import com.hypixel.hytale.component.system.tick.RunWhenPausedSystem;
class="kw">import com.hypixel.hytale.component.system.tick.TickingSystem;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
class="kw">import com.hypixel.hytale.protocol.ToClientPacket;
class="kw">import com.hypixel.hytale.protocol.packets.world.SetBlockAnimationSpeeds;
class="kw">import com.hypixel.hytale.server.core.modules.entity.player.ChunkTracker;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.section.ChunkSection;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
class="kw">import java.util.List;
class="kw">import java.util.concurrent.CompletableFuture;
class="kw">import javax.annotation.Nonnull;

class="kw">final class BlockAnimationSystems {
   class="kw">private BlockAnimationSystems() {
   }

   @Nonnull
   class="kw">static SetBlockAnimationSpeeds createPacket(@Nonnull ChunkSection var0, @Nonnull BlockAnimationSection var1, @Nonnull BlockSection var2) {
      class="kw">return new SetBlockAnimationSpeeds(var0.getX(), var0.getY(), var0.getZ(), var1.getRevision(), var1.toEntries(var2));
   }

   class="kw">static class="kw">final class LoadPacket class="kw">extends ChunkStore.LoadFuturePacketDataQuerySystem {
      @Nonnull
      class="kw">private class="kw">final ComponentType<ChunkStore, BlockAnimationSection> animationSectionType;
      @Nonnull
      class="kw">private class="kw">final Query<ChunkStore> query;

      LoadPacket(@Nonnull ComponentType<ChunkStore, BlockAnimationSection> var1) {
         this.animationSectionType = var1;
         this.query = Query.and(var1, ChunkSection.getComponentType(), BlockSection.getComponentType());
      }

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

      class="kw">public void fetch(
         int var1,
         @Nonnull ArchetypeChunk<ChunkStore> var2,
         Store<ChunkStore> var3,
         CommandBuffer<ChunkStore> var4,
         PlayerRef var5,
         @Nonnull List<CompletableFuture<ToClientPacket>> var6
      ) {
         BlockAnimationSection var7 = var2.getComponent(var1, this.animationSectionType);
         assert var7 != null;
         ChunkSection var8 = var2.getComponent(var1, ChunkSection.getComponentType());
         assert var8 != null;
         BlockSection var9 = var2.getComponent(var1, BlockSection.getComponentType());
         assert var9 != null;
         var6.add(CompletableFuture.completedFuture(BlockAnimationSystems.createPacket(var8, var7, var9)));
      }
   }

   class="kw">static class="kw">final class RemoveEmptySections class="kw">extends EntityTickingSystem<ChunkStore> class="kw">implements RunWhenPausedSystem<ChunkStore> {
      @Nonnull
      class="kw">private class="kw">final ComponentType<ChunkStore, BlockAnimationSection> animationSectionType;
      @Nonnull
      class="kw">private class="kw">final Query<ChunkStore> query;

      RemoveEmptySections(@Nonnull ComponentType<ChunkStore, BlockAnimationSection> var1) {
         this.animationSectionType = var1;
         this.query = Query.and(var1, ChunkSection.getComponentType());
      }

      @Override
      class="kw">public void tick(float var1, int var2, @Nonnull ArchetypeChunk<ChunkStore> var3, @Nonnull Store<ChunkStore> var4, @Nonnull CommandBuffer<ChunkStore> var5) {
         BlockAnimationSection var6 = var3.getComponent(var2, this.animationSectionType);
         assert var6 != null;
         if (var6.isEmpty()) {
            ChunkSection var7 = var3.getComponent(var2, ChunkSection.getComponentType());
            assert var7 != null;
            var7.markNeedsSaving();
            BlockAnimationModule.removeSectionIfEmpty(var5, var3.getReferenceTo(var2), this.animationSectionType, var6);
         }
      }

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

   class="kw">static class="kw">final class ReplicateChanges class="kw">extends TickingSystem<ChunkStore> class="kw">implements RunWhenPausedSystem<ChunkStore> {
      @Nonnull
      class="kw">private class="kw">final ComponentType<ChunkStore, BlockAnimationSection> animationSectionType;
      @Nonnull
      class="kw">private class="kw">final ResourceType<ChunkStore, BlockAnimationDirtySections> dirtySectionsType;

      ReplicateChanges(@Nonnull ComponentType<ChunkStore, BlockAnimationSection> var1, @Nonnull ResourceType<ChunkStore, BlockAnimationDirtySections> var2) {
         this.animationSectionType = var1;
         this.dirtySectionsType = var2;
      }

      @Override
      class="kw">public void tick(float var1, int var2, @Nonnull Store<ChunkStore> var3) {
         List var4 = var3.getResource(this.dirtySectionsType).drain();
         World var5 = var3.getExternalData().getWorld();

         for (Ref var7 : var4) {
            if (var7.isValid()) {
               BlockAnimationSection var8 = var3.getComponent(var7, this.animationSectionType);
               ChunkSection var9 = var3.getComponent(var7, ChunkSection.getComponentType());
               BlockSection var10 = var3.getComponent(var7, BlockSection.getComponentType());
               if (var8 != null && var9 != null && var10 != null) {
                  SetBlockAnimationSpeeds var11 = BlockAnimationSystems.createPacket(var9, var8, var10);
                  var8.clearPendingPhases();
                  long var12 = ChunkUtil.indexChunk(var9.getX(), var9.getZ());

                  for (PlayerRef var15 : var5.getPlayerRefs()) {
                     ChunkTracker var16 = var15.getChunkTracker();
                     if (var16 != null && var16.isLoaded(var12)) {
                        var15.getPacketHandler().writeNoCache(var11);
                     }
                  }
               }
            }
         }
      }
   }
}