BlockEventView class

Пакет: com.hypixel.hytale.server.npc.blackboard.view.event.block

Файл: com/hypixel/hytale/server/npc/blackboard/view/event/block/BlockEventView.java

extends: EventView<BlockEventView, BlockEventType, EventNotification>

Поля (7)

МодификаторыТипИмя
World var3
Blackboard var4
BlockEventType var4
IntSet var5
Store var5
String var6
int var7

Методы (11)

МодификаторыВозвратСигнатура
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Unknown key! " + var6)
for for(BlockEventType var5 : BlockEventType.VALUES)
for for(int var3 = 0; var3 < BlockEventType.VALUES.length; var3++)
public BlockEventView getUpdatedViewBlockEventView getUpdatedView(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2)
if if(var5 != null)
if if(var7 == Integer.MIN_VALUE)
public void onEntityBreakBlockvoid onEntityBreakBlock(@Nonnull Ref<EntityStore> var1, @Nonnull BreakBlockEvent var2)
public void onEntityDamageBlockvoid onEntityDamageBlock(@Nonnull Ref<EntityStore> var1, @Nonnull DamageBlockEvent var2)
public void onEntityUseBlockvoid onEntityUseBlock(@Nonnull Ref<EntityStore> var1, @Nonnull UseBlockEvent.Post var2)
protected void onEventvoid onEvent(int var1, double var2, double var4, double var6, Ref<EntityStore> var8, Ref<EntityStore> var9, @Nonnull ComponentAccessor<EntityStore> var10, BlockEventType var11)
private void processBlockEventvoid processBlockEvent(@Nonnull Ref<EntityStore> var1, @Nonnull BlockType var2, @Nonnull Vector3i var3, @Nonnull BlockEventType var4)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.blackboard.view.event.block;

class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.event.events.ecs.BreakBlockEvent;
class="kw">import com.hypixel.hytale.server.core.event.events.ecs.DamageBlockEvent;
class="kw">import com.hypixel.hytale.server.core.event.events.ecs.UseBlockEvent;
class="kw">import com.hypixel.hytale.server.core.modules.blockset.BlockSetModule;
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.npc.blackboard.Blackboard;
class="kw">import com.hypixel.hytale.server.npc.blackboard.BlackboardSubscription;
class="kw">import com.hypixel.hytale.server.npc.blackboard.view.event.EventNotification;
class="kw">import com.hypixel.hytale.server.npc.blackboard.view.event.EventTypeRegistration;
class="kw">import com.hypixel.hytale.server.npc.blackboard.view.event.EventView;
class="kw">import com.hypixel.hytale.server.npc.util.EntityDetectionUtil;
class="kw">import it.unimi.dsi.fastutil.ints.IntSet;
class="kw">import java.util.Objects;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3i;

class="kw">public class BlockEventView class="kw">extends EventView<BlockEventView, BlockEventType, EventNotification> {
   class="kw">public BlockEventView(@Nonnull World var1) {
      super(BlockEventType.class, BlockEventType.VALUES, new EventNotification(), var1);

      for (BlockEventType var5 : BlockEventType.VALUES) {
         this.entityMapsByEventType
            .put(
               var5,
               new EventTypeRegistration<>(
                  var5,
                  (var0, var1x) -> BlockSetModule.getInstance().blockInSet(var0, var1x),
                  (var0, var1x, var2, var3, var4) -> BlackboardSubscription.notifyBlockChange(var1x, var2, var3, var4)
               )
            );
      }
   }

   class="kw">public BlockEventView getUpdatedView(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
      World var3 = var2.getExternalData().getWorld();
      if (!var3.equals(this.world)) {
         Blackboard var4 = var2.getResource(Blackboard.getResourceType());
         class="kw">return var4.getView(BlockEventView.class, var1, var2);
      } else {
         class="kw">return this;
      }
   }

   @Override
   class="kw">public void initialiseEntity(@Nonnull Ref<EntityStore> var1, @Nonnull BlackboardSubscription var2) {
      for (int var3 = 0; var3 < BlockEventType.VALUES.length; var3++) {
         BlockEventType var4 = BlockEventType.VALUES[var3];
         IntSet var5 = var2.getBlockChangeSet(var4);
         if (var5 != null) {
            this.entityMapsByEventType.get(var4).initialiseEntity(var1, var5);
         }
      }
   }

   class="kw">protected void onEvent(
      int var1,
      double var2,
      double var4,
      double var6,
      Ref<EntityStore> var8,
      Ref<EntityStore> var9,
      @Nonnull ComponentAccessor<EntityStore> var10,
      BlockEventType var11
   ) {
      super.onEvent(var1, var2 + 0.5, var4 + 0.5, var6 + 0.5, var8, var9, var10, var11);
   }

   class="kw">public void onEntityDamageBlock(@Nonnull Ref<EntityStore> var1, @Nonnull DamageBlockEvent var2) {
      if (!var2.isCancelled()) {
         this.processBlockEvent(var1, var2.getBlockType(), var2.getTargetBlock(), BlockEventType.DAMAGE);
      }
   }

   class="kw">public void onEntityBreakBlock(@Nonnull Ref<EntityStore> var1, @Nonnull BreakBlockEvent var2) {
      if (!var2.isCancelled()) {
         this.processBlockEvent(var1, var2.getBlockType(), var2.getTargetBlock(), BlockEventType.DESTRUCTION);
      }
   }

   class="kw">public void onEntityUseBlock(@Nonnull Ref<EntityStore> var1, @Nonnull UseBlockEvent.Post var2) {
      if (var2.getInteractionType() == InteractionType.Use) {
         this.processBlockEvent(var1, var2.getBlockType(), var2.getTargetBlock(), BlockEventType.INTERACTION);
      }
   }

   class="kw">private void processBlockEvent(@Nonnull Ref<EntityStore> var1, @Nonnull BlockType var2, @Nonnull Vector3i var3, @Nonnull BlockEventType var4) {
      Store var5 = var1.getStore();
      if (EntityDetectionUtil.isDetectableByNPCs(var1, var5)) {
         String var6 = Objects.requireNonNullElse(var2.getDefaultStateKey(), var2.getId());
         int var7 = BlockType.getAssetMap().getIndex(var6);
         if (var7 == Integer.MIN_VALUE) {
            throw new IllegalArgumentException("Unknown key! " + var6);
         }

         this.onEvent(var7, var3.x, var3.y, var3.z, var1, null, var5, var4);
      }
   }
}