PortalDevicePageSupplier class

Пакет: com.hypixel.hytale.builtin.portals.ui

Файл: com/hypixel/hytale/builtin/portals/ui/PortalDevicePageSupplier.java

implements: OpenCustomUIInteraction.CustomPageSupplier

Поля (14)

МодификаторыТипИмя
Store var1
BlockType var14
boolean var15
BlockType var16
ChunkStore var17
Ref var18
PortalDevice var19
PortalWorld var2
World var20
BlockPosition var5
Player var6
ItemStack var7
World var8
BlockType var9

Методы (9)

МодификаторыВозвратСигнатура
abstract return new PortalDeviceActivePagereturn new PortalDeviceActivePage(var3, this.config, var18)
abstract return new PortalDeviceSummonPagereturn new PortalDeviceSummonPage(var3, this.config, var18, var7)
if if(var5 == null)
if if(var6 == null)
if if(var9 == null)
if if(var14 == null)
if if(var18 == null)
if if(var0 == null)
static boolean isPortalWorldValidboolean isPortalWorldValid(@Nullable World var0)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.portals.components.PortalDevice;
class="kw">import com.hypixel.hytale.builtin.portals.components.PortalDeviceConfig;
class="kw">import com.hypixel.hytale.builtin.portals.resources.PortalWorld;
class="kw">import com.hypixel.hytale.builtin.portals.utils.BlockTypeUtils;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
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.BlockPosition;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionContext;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
class="kw">import com.hypixel.hytale.server.core.entity.entities.player.pages.CustomUIPage;
class="kw">import com.hypixel.hytale.server.core.inventory.InventoryComponent;
class="kw">import com.hypixel.hytale.server.core.inventory.ItemStack;
class="kw">import com.hypixel.hytale.server.core.modules.block.BlockModule;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.server.OpenCustomUIInteraction;
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.storage.ChunkStore;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3i;

class="kw">public class PortalDevicePageSupplier class="kw">implements OpenCustomUIInteraction.CustomPageSupplier {
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<PortalDevicePageSupplier> CODEC = BuilderCodec.builder(PortalDevicePageSupplier.class, PortalDevicePageSupplier::new)
      .appendInherited(
         new KeyedCodec<>("Config", PortalDeviceConfig.CODEC),
         (var0, var1) -> var0.config = var1,
         var0 -> var0.config,
         (var0, var1) -> var0.config = var1.config
      )
      .documentation("The portal device's config.")
      .add()
      .build();
   class="kw">private PortalDeviceConfig config;

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

   @Override
   class="kw">public CustomUIPage tryCreate(
      @Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2, @Nonnull PlayerRef var3, @Nonnull InteractionContext var4
   ) {
      BlockPosition var5 = var4.getTargetBlock();
      if (var5 == null) {
         class="kw">return null;
      }

      Player var6 = var2.getComponent(var1, Player.getComponentType());
      if (var6 == null) {
         class="kw">return null;
      }

      ItemStack var7 = InventoryComponent.getItemInHand(var2, var1);
      World var8 = var2.getExternalData().getWorld();
      BlockType var9 = var8.getBlockType(var5.x, var5.y, var5.z);
      if (var9 == null) {
         var3.sendMessage(Message.translation("server.portals.device.blockTypeMisconfigured").param("x", var5.x).param("y", var5.y).param("z", var5.z));
         class="kw">return null;
      }

      for (String var13 : this.config.getBlockStates()) {
         BlockType var14 = BlockTypeUtils.getBlockForState(var9, var13);
         if (var14 == null) {
            var3.sendMessage(Message.translation("server.portals.device.blockStateMisconfigured").param("state", var13));
            class="kw">return null;
         }
      }

      BlockType var16 = BlockTypeUtils.getBlockForState(var9, this.config.getOnState());
      ChunkStore var17 = var8.getChunkStore();
      Ref var18 = BlockModule.getBlockEntity(var8, var5.x, var5.y, var5.z);
      if (var18 == null) {
         var3.sendMessage(Message.translation("server.portals.device.blockEntityMisconfigured"));
         class="kw">return null;
      } else {
         PortalDevice var19 = var17.getStore().getComponent(var18, PortalDevice.getComponentType());
         World var20 = var19 == null ? null : var19.getDestinationWorld();
         if (var19 != null && var9 == var16 && !isPortalWorldValid(var20)) {
            var8.setBlockInteractionState(new Vector3i(var5.x, var5.y, var5.z), var9, this.config.getOffState());
            var3.sendMessage(Message.translation("server.portals.device.adjusted").color("#ff0000"));
            class="kw">return null;
         } else {
            boolean var15 = var19 != null && var19.isLoadingWorld();
            if ((var19 == null || var20 == null) && !var15) {
               var17.getStore().putComponent(var18, PortalDevice.getComponentType(), new PortalDevice(this.config, var9.getId()));
               class="kw">return new PortalDeviceSummonPage(var3, this.config, var18, var7);
            } else {
               class="kw">return new PortalDeviceActivePage(var3, this.config, var18);
            }
         }
      }
   }

   class="kw">private class="kw">static boolean isPortalWorldValid(@Nullable World var0) {
      if (var0 == null) {
         class="kw">return false;
      }

      Store var1 = var0.getEntityStore().getStore();
      PortalWorld var2 = var1.getResource(PortalWorld.getResourceType());
      class="kw">return var2.exists();
   }
}