PortalDeviceSummonPage class
Пакет: com.hypixel.hytale.builtin.portals.ui
Файл: com/hypixel/hytale/builtin/portals/ui/PortalDeviceSummonPage.java
extends: InteractiveCustomUIPage<PortalDeviceSummonPage.Data>
Поля (102)
| Модификаторы | Тип | Имя |
|---|---|---|
|
NOTHING_OFFERED,
OFFERED_IS_NOT_HELD,
NOT_A_PORTAL_KEY,
INVALID_BLOCK,
INVALID_DESTINATION,
PORTAL_INSIDE_PORTAL, |
BOTCHED_GAMEPLAY_CONFIG |
|
public static final BuilderCodec<PortalDeviceSummonPage.Data> |
CODEC |
|
private static final String |
KEY_ACTION |
|
private String |
action |
final |
PortalDeviceConfig |
config |
|
int |
var1 |
|
int |
var10 |
|
String |
var10 |
|
|
var10 |
|
BlockComponentSection |
var10 |
|
Ref |
var10 |
|
int |
var11 |
|
BlockType |
var11 |
|
Ref |
var11 |
|
World |
var11 |
|
Ref |
var12 |
|
PortalRemovalCondition |
var12 |
|
BlockChunk |
var12 |
|
ItemStack |
var12 |
|
Store |
var13 |
|
Item |
var13 |
|
ChunkSection |
var14 |
|
BlockModule.BlockStateInfo |
var14 |
|
PortalKey |
var14 |
|
long |
var15 |
|
BlockSection |
var15 |
|
String |
var15 |
|
PortalKey |
var16 |
|
PortalType |
var16 |
|
long |
var17 |
|
PortalDevice |
var17 |
|
String |
var17 |
|
BlockType |
var18 |
|
boolean |
var18 |
|
int |
var19 |
|
PortalWorld |
var19 |
|
List |
var2 |
|
Message |
var2 |
|
ISpawnProvider |
var2 |
|
BlockType |
var20 |
|
String |
var20 |
|
BlockType |
var21 |
|
GameplayConfig |
var21 |
|
PortalKey |
var22 |
|
BlockType |
var22 |
|
PortalGameplayConfig |
var22 |
|
PortalType |
var23 |
|
int |
var23 |
|
PortalDescription |
var24 |
|
int |
var24 |
|
String[] |
var25 |
|
int |
var25 |
|
String[] |
var26 |
|
int |
var26 |
|
PortalGameplayConfig |
var27 |
|
ItemStack |
var27 |
|
Transform |
var28 |
|
UUIDComponent |
var29 |
|
Message |
var3 |
|
PortalSpawnConfig |
var3 |
|
Transform[] |
var3 |
|
World |
var3 |
|
InventoryComponent.Tool |
var3 |
|
long |
var30 |
|
PlayerRef |
var30 |
|
PortalType |
var31 |
|
UUID |
var32 |
|
PortalGameplayConfig |
var33 |
|
CompletableFuture |
var34 |
|
UICommandBuilder |
var35 |
|
UICommandBuilder |
var36 |
|
PillTag |
var4 |
|
String |
var4 |
|
PortalType |
var4 |
|
ISpawnProvider |
var4 |
|
Transform |
var4 |
|
FragmentOriginGameplayConfig |
var4 |
|
InventoryComponent.Hotbar |
var4 |
|
PortalDeviceSummonPage.State |
var5 |
|
String |
var5 |
|
String |
var5 |
|
PortalSpawnConfig |
var5 |
|
Vector3d |
var5 |
|
Transform |
var5 |
|
int |
var5 |
|
byte |
var5 |
|
Player |
var6 |
|
Transform |
var6 |
|
int |
var6 |
|
ItemStack |
var6 |
|
World |
var7 |
|
InstanceWorldConfig |
var7 |
|
Store |
var7 |
|
Store |
var7 |
|
int |
var8 |
|
InstanceDiscoveryConfig |
var8 |
|
ChunkSection |
var8 |
|
BlockModule.BlockStateInfo |
var8 |
|
int |
var9 |
|
PortalWorld |
var9 |
|
BlockSection |
var9 |
|
PortalDevice |
var9 |
Методы (46)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
protected |
Dataprotected Data() |
|
|
Error Error() |
abstract |
throw new |
RuntimeExceptionthrow new RuntimeException("Return block type on PortalDevice is misconfigured") |
static |
ItemStack |
decrementItemInHandItemStack decrementItemInHand(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1, int var2) |
static |
List<Vector3d> |
fetchHintedSpawnsList<Vector3d> fetchHintedSpawns(World var0, UUID var1) |
|
|
for for(int var3 = 0; var3 < var2.length; var3++) |
|
|
for for(int var7 = 0; var7 < 3; var7++) |
|
|
for for(int var8 = -1; var8 <= 1; var8++) |
|
|
for for(int var9 = -1; var9 <= 1; var9++) |
abstract |
|
for for(int var3 = 0; var3 < var2.size() |
public |
void |
handleDataEventvoid handleDataEvent(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2, @Nonnull PortalDeviceSummonPage.Data var3) |
|
|
if if(var5 != PortalDeviceSummonPage.Error.INVALID_BLOCK) |
|
|
if if(var5 instanceof PortalDeviceSummonPage.CanSpawnPortal var6) |
|
|
if if(var5 == PortalDeviceSummonPage.Error.NOTHING_OFFERED || var5 == PortalDeviceSummonPage.Error.NOT_A_PORTAL_KEY) |
|
|
if if(var0 < 0) |
|
|
if if(var14 != null && var15 != null) |
|
|
if if(var10 == null) |
|
|
if if(var11 != null) |
|
|
if if(var14 != null) |
|
|
if if(var8 != null && var9 != null && var10 != null) |
|
|
if if(var12 == null) |
|
|
if if(var4x == null) |
|
|
if if(var4 != null) |
|
|
if if(var2 == null) |
|
|
if if(var3 != null && var3.length > 0) |
|
|
if if(var6 >= var5) |
|
|
if if(var8 != null && var9 != null) |
|
|
if if(this.offeredItemStack == null) |
|
|
if if(var14 == null) |
|
|
if if(var16 == null) |
|
|
if if(!var18) |
|
|
if if(var4 == null) |
|
|
if if(var5 == -1) |
|
|
if if(var6 == null) |
static |
void |
refundKeyvoid refundKey(@Nonnull Ref<EntityStore> var0, @Nonnull Store<EntityStore> var1, @Nonnull ItemStack var2, @Nonnull UUID var3) |
abstract |
|
refundKey refundKey(var1, var2, var27, var32) |
static |
boolean |
setDeviceBlockboolean setDeviceBlock(@Nonnull Ref<ChunkStore> var0, int var1, int var2, int var3, @Nonnull BlockType var4, int var5, int var6) |
abstract |
|
setDeviceBlock setDeviceBlock(var12, var24, var25, var26, var20, var19, 6) |
abstract |
|
setDeviceBlock setDeviceBlock(var12, var24, var25, var26, var22, var19, 6) |
abstract |
return |
spawnReturnPortalreturn spawnReturnPortal(var5x, var9, var32, var10) |
abstract |
|
super super(var1, CustomPageLifetime.CanDismissOrCloseThroughInteraction, PortalDeviceSummonPage.Data.CODEC) |
static |
void |
updateBulletListvoid updateBulletList(@Nonnull UICommandBuilder var0, @Nonnull String var1, @Nonnull String[] var2) |
abstract |
|
updateBulletList updateBulletList(var2, "#ObjectivesList", var25) |
abstract |
|
updateBulletList updateBulletList(var2, "#TipsList", var26) |
static |
void |
updateCustomPillsvoid updateCustomPills(@Nonnull UICommandBuilder var0, @Nonnull PortalType var1) |
abstract |
|
updateCustomPills updateCustomPills(var2, var23) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.portals.ui;
class="kw">import com.hypixel.hytale.builtin.instances.InstancesPlugin;
class="kw">import com.hypixel.hytale.builtin.instances.config.InstanceDiscoveryConfig;
class="kw">import com.hypixel.hytale.builtin.instances.config.InstanceWorldConfig;
class="kw">import com.hypixel.hytale.builtin.portals.PortalInstanceLinks;
class="kw">import com.hypixel.hytale.builtin.portals.PortalsPlugin;
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.integrations.FragmentOriginGameplayConfig;
class="kw">import com.hypixel.hytale.builtin.portals.integrations.PortalGameplayConfig;
class="kw">import com.hypixel.hytale.builtin.portals.integrations.PortalRemovalCondition;
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.Codec;
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.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.logger.sentry.SkipSentryException;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
class="kw">import com.hypixel.hytale.math.vector.Transform;
class="kw">import com.hypixel.hytale.protocol.SoundCategory;
class="kw">import com.hypixel.hytale.protocol.packets.interface_.CustomPageLifetime;
class="kw">import com.hypixel.hytale.protocol.packets.interface_.CustomUIEventBindingType;
class="kw">import com.hypixel.hytale.protocol.packets.interface_.Page;
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.asset.type.gameplay.GameplayConfig;
class="kw">import com.hypixel.hytale.server.core.asset.type.item.config.Item;
class="kw">import com.hypixel.hytale.server.core.asset.type.item.config.PortalKey;
class="kw">import com.hypixel.hytale.server.core.asset.type.portalworld.PillTag;
class="kw">import com.hypixel.hytale.server.core.asset.type.portalworld.PortalDescription;
class="kw">import com.hypixel.hytale.server.core.asset.type.portalworld.PortalSpawnConfig;
class="kw">import com.hypixel.hytale.server.core.asset.type.portalworld.PortalType;
class="kw">import com.hypixel.hytale.server.core.asset.util.ColorParseUtil;
class="kw">import com.hypixel.hytale.server.core.entity.UUIDComponent;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
class="kw">import com.hypixel.hytale.server.core.entity.entities.player.pages.InteractiveCustomUIPage;
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.ui.builder.EventData;
class="kw">import com.hypixel.hytale.server.core.ui.builder.UICommandBuilder;
class="kw">import com.hypixel.hytale.server.core.ui.builder.UIEventBuilder;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.SoundUtil;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.WorldConfig;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.BlockOperations;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockComponentSection;
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.spawn.ISpawnProvider;
class="kw">import com.hypixel.hytale.server.core.universe.world.spawn.IndividualSpawnProvider;
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 java.util.Arrays;
class="kw">import java.util.Collections;
class="kw">import java.util.List;
class="kw">import java.util.UUID;
class="kw">import java.util.concurrent.CompletableFuture;
class="kw">import java.util.concurrent.TimeUnit;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;
class="kw">public class PortalDeviceSummonPage class="kw">extends InteractiveCustomUIPage<PortalDeviceSummonPage.Data> {
class="kw">private class="kw">final PortalDeviceConfig config;
class="kw">private class="kw">final Ref<ChunkStore> blockRef;
@Nullable
class="kw">private class="kw">final ItemStack offeredItemStack;
class="kw">public PortalDeviceSummonPage(@Nonnull PlayerRef var1, PortalDeviceConfig var2, Ref<ChunkStore> var3, @Nullable ItemStack var4) {
super(var1, CustomPageLifetime.CanDismissOrCloseThroughInteraction, PortalDeviceSummonPage.Data.CODEC);
this.config = var2;
this.blockRef = var3;
this.offeredItemStack = var4;
}
@Override
class="kw">public void build(@Nonnull Ref<EntityStore> var1, @Nonnull UICommandBuilder var2, @Nonnull UIEventBuilder var3, @Nonnull Store<EntityStore> var4) {
PortalDeviceSummonPage.State var5 = this.computeState(var1, var4);
if (var5 != PortalDeviceSummonPage.Error.INVALID_BLOCK) {
if (var5 class="kw">instanceof PortalDeviceSummonPage.CanSpawnPortal var6) {
var2.append("Pages/PortalDeviceSummon.ui");
PortalKey var22 = var6.portalKey();
PortalType var23 = var6.portalType();
PortalDescription var24 = var23.getDescription();
var2.set("#Artwork.Background", "Pages/Portals/" + var24.getSplashImageFilename());
var2.set("#Title0.TextSpans", var24.getDisplayName());
var2.set("#FlavorLabel.TextSpans", var24.getFlavorText());
updateCustomPills(var2, var23);
String[] var25 = var24.getObjectivesKeys();
String[] var26 = var24.getWisdomKeys();
var2.set("#Objectives.Visible", var25.length > 0);
var2.set("#Tips.Visible", var26.length > 0);
updateBulletList(var2, "#ObjectivesList", var25);
updateBulletList(var2, "#TipsList", var26);
PortalGameplayConfig var27 = var23.getGameplayConfig().getPluginConfig().get(PortalGameplayConfig.class);
long var30 = TimeUnit.SECONDS.toMinutes(var22.getTimeLimitSeconds());
if (var23.isVoidInvasionEnabled()) {
long var15 = TimeUnit.SECONDS.toMinutes(var27.getVoidEvent().getDurationSeconds());
long var17 = var30 - var15;
var2.set("#ExplorationTimeText.TextSpans", Message.translation("server.customUI.portalDevice.minutesToExplore").param("time", var17));
var2.set("#BreachTimeBullet.Visible", true);
var2.set("#BreachTimeText.TextSpans", Message.translation("server.customUI.portalDevice.minutesVoidInvasion").param("time", var15));
} else {
var2.set("#ExplorationTimeText.TextSpans", Message.translation("server.customUI.portalDevice.durationMins").param("time", var30));
}
var3.addEventBinding(CustomUIEventBindingType.Activating, "#SummonButton", EventData.of("Action", "SummonActivated"), false);
var3.addEventBinding(CustomUIEventBindingType.MouseEntered, "#SummonButton", EventData.of("Action", "SummonMouseEntered"), false);
var3.addEventBinding(CustomUIEventBindingType.MouseExited, "#SummonButton", EventData.of("Action", "SummonMouseExited"), false);
} else {
var2.append("Pages/PortalDeviceError.ui");
if (var5 == PortalDeviceSummonPage.Error.NOTHING_OFFERED || var5 == PortalDeviceSummonPage.Error.NOT_A_PORTAL_KEY) {
var2.set("#UsageErrorTitle.Text", Message.translation("server.customUI.portalDevice.needPortalKey"));
var2.set("#UsageErrorLabel.Text", Message.translation("server.customUI.portalDevice.nothingHeld"));
} else if (var5 == PortalDeviceSummonPage.Error.PORTAL_INSIDE_PORTAL) {
var2.set("#UsageErrorLabel.Text", Message.translation("server.customUI.portalDevice.portalInsidePortal"));
} else if (var5 class="kw">instanceof PortalDeviceSummonPage.MaxActivePortals(int var8)) {
var2.set("#UsageErrorLabel.Text", Message.translation("server.customUI.portalDevice.maxFragments").param("max", var8));
} else if (var5 class="kw">instanceof PortalDeviceSummonPage.InstanceKeyNotFound(String var10)) {
var2.set("#UsageErrorLabel.Text", "The instance id '" + var10 + "' does not exist, this is a developer error with the portaltype.");
} else if (var5 class="kw">instanceof PortalDeviceSummonPage.PortalTypeNotFound(String var12)) {
var2.set("#UsageErrorLabel.Text", "The portaltype id '" + var12 + "' does not exist, this is a developer error with the portal key.");
} else if (var5 == PortalDeviceSummonPage.Error.BOTCHED_GAMEPLAY_CONFIG) {
var2.set(
"#UsageErrorLabel.Text",
"The gameplay config set on the PortalType set in the key does not have a Portal plugin configuration, this is a developer error."
);
} else {
var2.set("#UsageErrorLabel.Text", Message.translation("server.customUI.portalDevice.unknownError").param("state", var5.toString()));
}
}
}
}
class="kw">private class="kw">static void updateCustomPills(@Nonnull UICommandBuilder var0, @Nonnull PortalType var1) {
List var2 = var1.getDescription().getPillTags();
for (int var3 = 0; var3 < var2.size(); var3++) {
PillTag var4 = var2.get(var3);
String var5 = "#Pills[" + var3 + "]";
var0.append("#Pills", "Pages/Portals/Pill.ui");
var0.set(var5 + ".Background.Color", ColorParseUtil.colorToHexString(var4.getColor()));
var0.set(var5 + " #Label.TextSpans", var4.getMessage());
}
}
class="kw">private class="kw">static void updateBulletList(@Nonnull UICommandBuilder var0, @Nonnull String var1, @Nonnull String[] var2) {
for (int var3 = 0; var3 < var2.length; var3++) {
String var4 = var2[var3];
String var5 = var1 + "[" + var3 + "]";
var0.append(var1, "Pages/Portals/BulletPoint.ui");
var0.set(var5 + " #Label.TextSpans", Message.translation(var4));
}
}
@Nonnull
class="kw">public class="kw">static Message createDescription(@Nonnull PortalType var0, int var1) {
Message var2 = Message.empty();
Message var3 = formatDurationCrudely(var1);
var2.insert(Message.translation("server.customUI.portalDevice.timeLimit").param("limit", var3.color("#f9cb13")));
class="kw">return var2;
}
@Nonnull
class="kw">private class="kw">static Message formatDurationCrudely(int var0) {
if (var0 < 0) {
class="kw">return Message.translation("server.customUI.portalDevice.durationUnlimited");
} else if (var0 >= 120) {
int var1 = var0 / 60;
class="kw">return Message.translation("server.customUI.portalDevice.durationMinutes").param("duration", var1);
} else {
class="kw">return Message.translation("server.customUI.portalDevice.durationSeconds").param("duration", var0);
}
}
class="kw">public void handleDataEvent(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2, @Nonnull PortalDeviceSummonPage.Data var3) {
if (this.computeState(var1, var2) class="kw">instanceof PortalDeviceSummonPage.CanSpawnPortal var5) {
if ("SummonMouseEntered".equals(var3.action)) {
UICommandBuilder var36 = new UICommandBuilder();
var36.set("#Vignette.Visible", true);
this.sendUpdate(var36, null, false);
} else if ("SummonMouseExited".equals(var3.action)) {
UICommandBuilder var35 = new UICommandBuilder();
var35.set("#Vignette.Visible", false);
this.sendUpdate(var35, null, false);
} else {
Player var6 = var2.getComponent(var1, Player.getComponentType());
assert var6 != null;
var6.getPageManager().setPage(var1, var2, Page.None);
World var7 = var2.getExternalData().getWorld();
int var8 = var5.blockState().getIndex();
int var9 = ChunkUtil.xFromIndex(var8);
int var10 = ChunkUtil.yFromIndex(var8);
int var11 = ChunkUtil.zFromIndex(var8);
Ref var12 = var5.blockState().getSectionRef();
Store var13 = var12.getStore();
ChunkSection var14 = var13.getComponent(var12, ChunkSection.getComponentType());
BlockSection var15 = var13.getComponent(var12, BlockSection.getComponentType());
if (var14 != null && var15 != null) {
PortalKey var16 = var5.portalKey();
PortalDevice var17 = var5.portalDevice();
BlockType var18 = BlockType.getAssetMap().getAsset(var15.get(var9, var10, var11));
if (var18 == var17.getBaseBlockType()) {
if (this.config.areBlockStatesValid(var18)) {
int var19 = var15.getRotationIndex(var9, var10, var11);
BlockType var20 = var18.getBlockForState(this.config.getSpawningState());
BlockType var21 = var18.getBlockForState(this.config.getOnState());
BlockType var22 = BlockTypeUtils.getBlockForState(var18, this.config.getOffState());
int var23 = 6;
int var24 = ChunkUtil.worldCoordFromLocalCoord(var14.getX(), var9);
int var25 = ChunkUtil.worldCoordFromLocalCoord(var14.getY(), var10);
int var26 = ChunkUtil.worldCoordFromLocalCoord(var14.getZ(), var11);
setDeviceBlock(var12, var24, var25, var26, var20, var19, 6);
if (var20.getInteractionSoundEventIndex() != 0) {
SoundUtil.playSoundEvent3d(var20.getInteractionSoundEventIndex(), SoundCategory.SFX, var24 + 0.5, var25 + 0.5, var26 + 0.5, var2);
}
ItemStack var27 = decrementItemInHand(var1, var2, 1);
Transform var28 = new Transform(var9 + 0.5, var25 + 1.0, var11 + 0.5);
UUIDComponent var29 = var2.getComponent(var1, UUIDComponent.getComponentType());
assert var29 != null;
PlayerRef var30 = var2.getComponent(var1, PlayerRef.getComponentType());
assert var30 != null;
PortalType var31 = var5.portalType;
UUID var32 = var29.getUuid();
PortalGameplayConfig var33 = var5.portalGameplayConfig;
CompletableFuture var34 = InstancesPlugin.get()
.spawnInstance(var31.getInstanceId(), var7, var28)
.thenCompose(var5x -> {
WorldConfig var6 = var5x.getWorldConfig();
var6.setDeleteOnUniverseStart(true);
var6.setDeleteOnRemove(true);
var6.setGameplayConfig(var31.getGameplayConfigId());
InstanceWorldConfig var7 = InstanceWorldConfig.ensureAndGet(var6);
if (var7.getDiscovery() == null) {
InstanceDiscoveryConfig var8 = new InstanceDiscoveryConfig();
var8.setTitleKey(var31.getDescription().getDisplayNameKey());
var8.setSubtitleKey("server.portals.discoverySubtitle");
var8.setDisplay(true);
var8.setAlwaysDisplay(true);
var7.setDiscovery(var8);
}
PortalRemovalCondition var12 = new PortalRemovalCondition(var16.getTimeLimitSeconds());
var7.setRemovalConditions(var12);
PortalWorld var9 = var5x.getEntityStore().getStore().getResource(PortalWorld.getResourceType());
var9.init(var31, var16.getTimeLimitSeconds(), var12, var33);
String var10 = var17.getConfig().getReturnBlock();
if (var10 == null) {
throw new RuntimeException("Return block type on PortalDevice is misconfigured");
}
BlockType var11 = var31.getSpawn().getReturnBlockOverride();
if (var11 != null) {
var10 = var11.getId();
}
class="kw">return spawnReturnPortal(var5x, var9, var32, var10);
})
.thenAcceptAsync(
var13x -> {
if (!var12.isValid() || !this.blockRef.isValid()) {
HytaleLogger.getLogger()
.at(Level.WARNING)
.log("Portal device removed before its instance world finished spawning; refunding key and discarding %s", var13x.getName());
refundKey(var1, var2, var27, var32);
} else if (setDeviceBlock(var12, var24, var25, var26, var21, var19, 6)) {
var17.setDestinationWorld(var13x);
PortalInstanceLinks.record(var7, var24, var25, var26, var13x, this.config);
BlockModule.BlockStateInfo var14 = this.blockRef
.getStore()
.getComponent(this.blockRef, BlockModule.BlockStateInfo.getComponentType());
if (var14 != null) {
var14.markNeedsSaving();
}
} else {
refundKey(var1, var2, var27, var32);
}
},
var7
)
.exceptionallyAsync(
var13x -> {
if (SkipSentryException.hasSkipSentry(var13x)) {
((HytaleLogger.Api)HytaleLogger.getLogger().at(Level.WARNING).withCause(var13x))
.log("Could not create world for Portal Device %s", var16);
} else {
((HytaleLogger.Api)HytaleLogger.getLogger().at(Level.SEVERE).withCause(var13x))
.log("Error creating instance for Portal Device %s", var16);
}
try {
var30.sendMessage(Message.translation("server.portals.device.internalErrorSpawning"));
refundKey(var1, var2, var27, var32);
if (var12.isValid() && this.blockRef.isValid()) {
setDeviceBlock(var12, var24, var25, var26, var22, var19, 6);
}
} catch (Throwable var15) {
((HytaleLogger.Api)HytaleLogger.getLogger().at(Level.SEVERE).withCause(var15))
.log("Error while resolving portal device error");
}
class="kw">return null;
},
var7
)
.whenComplete((var1x, var2x) -> var17.setPendingWorld(null));
var17.setPendingWorld(var34);
}
}
}
}
}
}
class="kw">private class="kw">static boolean setDeviceBlock(@Nonnull Ref<ChunkStore> var0, int var1, int var2, int var3, @Nonnull BlockType var4, int var5, int var6) {
Store var7 = var0.getStore();
ChunkSection var8 = var7.getComponent(var0, ChunkSection.getComponentType());
BlockSection var9 = var7.getComponent(var0, BlockSection.getComponentType());
BlockComponentSection var10 = var7.getComponent(var0, BlockComponentSection.getComponentType());
if (var8 != null && var9 != null && var10 != null) {
Ref var11 = var8.getChunkColumnReference();
if (var11 != null && var11.isValid()) {
BlockChunk var12 = var7.getComponent(var11, BlockChunk.getComponentType());
if (var12 == null) {
HytaleLogger.getLogger()
.at(Level.WARNING)
.log("Could not set portal device block to %s at %d, %d, %d: the block chunk is missing", var4.getId(), var1, var2, var3);
class="kw">return false;
} else {
BlockOperations.setBlock(
var7.getExternalData(), var0, var8, var9, var10, var12, var1, var2, var3, BlockType.getAssetMap().getIndex(var4.getId()), var4, var5, 0, var6
);
class="kw">return true;
}
} else {
HytaleLogger.getLogger()
.at(Level.WARNING)
.log("Could not set portal device block to %s at %d, %d, %d: the chunk column is gone", var4.getId(), var1, var2, var3);
class="kw">return false;
}
} else {
HytaleLogger.getLogger()
.at(Level.WARNING)
.log("Could not set portal device block to %s at %d, %d, %d: section components are missing", var4.getId(), var1, var2, var3);
class="kw">return false;
}
}
@Nonnull
class="kw">private class="kw">static CompletableFuture<World> spawnReturnPortal(@Nonnull World var0, @Nonnull PortalWorld var1, @Nonnull UUID var2, @Nonnull String var3) {
PortalType var4 = var1.getPortalType();
PortalSpawnConfig var5 = var4.getSpawn();
class="kw">return getSpawnTransform(var4, var0, var2).thenCompose(var4x -> {
if (var4x == null) {
throw new SkipSentryException("No valid spawn location for portal world " + var0.getName(), null);
}
Vector3d var5 = var4x.getPosition();
Transform var6 = new Transform(var4x);
class="kw">return var0.getChunkAsync(ChunkUtil.indexChunkFromBlock((int)var5.x, (int)var5.z)).thenAccept(var6x -> {
if (var5.isSpawningReturnPortal()) {
for (int var7 = 0; var7 < 3; var7++) {
for (int var8 = -1; var8 <= 1; var8++) {
for (int var9 = -1; var9 <= 1; var9++) {
var6x.setBlock((int)var5.x + var8, (int)var5.y + var7, (int)var5.z + var9, BlockType.EMPTY);
}
}
}
var6x.setBlock((int)var5.x, (int)var5.y, (int)var5.z, var3);
var6.getPosition().add(0.0, 0.5, 0.0);
HytaleLogger.getLogger().at(Level.INFO).log("Spawned class="kw">return portal for %s at %d, %d, %d", var0.getName(), (int)var5.x, (int)var5.y, (int)var5.z);
}
var1.setSpawnPoint(var6);
var0.getWorldConfig().setSpawnProvider(new IndividualSpawnProvider(var6));
if (!var5.isSpawningReturnPortal()) {
HytaleLogger.getLogger().at(Level.INFO).log("Fragment spawn point for %s at %d, %d, %d", var0.getName(), (int)var5.x, (int)var5.y, (int)var5.z);
}
}).thenApply(var1x -> var0);
});
}
@Nonnull
class="kw">private class="kw">static CompletableFuture<Transform> getSpawnTransform(@Nonnull PortalType var0, @Nonnull World var1, @Nonnull UUID var2) {
PortalSpawnConfig var3 = var0.getSpawn();
ISpawnProvider var4 = var3.getSpawnProviderOverride();
if (var4 != null) {
Transform var5 = var4.getSpawnPoint(var1, var2);
class="kw">return CompletableFuture.completedFuture(var5);
} else {
class="kw">return CompletableFuture.<List<Vector3d>>supplyAsync(() -> fetchHintedSpawns(var1, var2), var1)
.thenCompose(var1x -> PortalSpawnFinder.computeSpawnTransform(var1, (List<Vector3d>)var1x));
}
}
class="kw">private class="kw">static List<Vector3d> fetchHintedSpawns(World var0, UUID var1) {
ISpawnProvider var2 = var0.getWorldConfig().getSpawnProvider();
if (var2 == null) {
class="kw">return Collections.emptyList();
}
Transform[] var3 = var2.getSpawnPoints();
if (var3 != null && var3.length > 0) {
class="kw">return Arrays.stream(var3).map(Transform::getPosition).toList();
}
Transform var4 = var2.getSpawnPoint(var0, var1);
class="kw">return var4 != null ? Collections.singletonList(var4.getPosition()) : Collections.emptyList();
}
@Nonnull
class="kw">private PortalDeviceSummonPage.State computeState(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
if (!this.blockRef.isValid()) {
class="kw">return PortalDeviceSummonPage.Error.INVALID_BLOCK;
}
World var3 = var2.getExternalData().getWorld();
FragmentOriginGameplayConfig var4 = var3.getGameplayConfig().getPluginConfig().get(FragmentOriginGameplayConfig.class);
int var5 = var4 == null ? 4 : var4.getMaxConcurrentFragments();
int var6 = PortalsPlugin.getInstance().countActiveFragments();
if (var6 >= var5) {
class="kw">return new PortalDeviceSummonPage.MaxActivePortals(var5);
}
Store var7 = this.blockRef.getStore();
BlockModule.BlockStateInfo var8 = var7.getComponent(this.blockRef, BlockModule.BlockStateInfo.getComponentType());
PortalDevice var9 = var7.getComponent(this.blockRef, PortalDevice.getComponentType());
if (var8 != null && var9 != null) {
Ref var10 = var8.getSectionRef();
if (!var10.isValid()) {
class="kw">return PortalDeviceSummonPage.Error.INVALID_BLOCK;
}
World var11 = var9.getDestinationWorld();
if (var11 != null || var9.isLoadingWorld()) {
class="kw">return PortalDeviceSummonPage.Error.INVALID_DESTINATION;
}
if (this.offeredItemStack == null) {
class="kw">return PortalDeviceSummonPage.Error.NOTHING_OFFERED;
}
ItemStack var12 = InventoryComponent.getItemInHand(var2, var1);
if (!this.offeredItemStack.equals(var12)) {
class="kw">return PortalDeviceSummonPage.Error.OFFERED_IS_NOT_HELD;
}
Item var13 = this.offeredItemStack.getItem();
PortalKey var14 = var13.getPortalKey();
if (var14 == null) {
class="kw">return PortalDeviceSummonPage.Error.NOT_A_PORTAL_KEY;
}
String var15 = var14.getPortalTypeId();
PortalType var16 = PortalType.getAssetMap().getAsset(var15);
if (var16 == null) {
class="kw">return new PortalDeviceSummonPage.PortalTypeNotFound(var15);
}
String var17 = var16.getInstanceId();
boolean var18 = InstancesPlugin.doesInstanceAssetExist(var17);
if (!var18) {
class="kw">return new PortalDeviceSummonPage.InstanceKeyNotFound(var17);
}
PortalWorld var19 = var2.getResource(PortalWorld.getResourceType());
if (var19.exists()) {
class="kw">return PortalDeviceSummonPage.Error.PORTAL_INSIDE_PORTAL;
}
String var20 = var16.getGameplayConfigId();
GameplayConfig var21 = GameplayConfig.getAssetMap().getAsset(var20);
PortalGameplayConfig var22 = var21 == null ? null : var21.getPluginConfig().get(PortalGameplayConfig.class);
class="kw">return var22 == null
? PortalDeviceSummonPage.Error.BOTCHED_GAMEPLAY_CONFIG
: new PortalDeviceSummonPage.CanSpawnPortal(var14, var16, var8, var9, var22);
} else {
class="kw">return PortalDeviceSummonPage.Error.INVALID_BLOCK;
}
}
class="kw">private class="kw">static ItemStack decrementItemInHand(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1, int var2) {
InventoryComponent.Tool var3 = var1.getComponent(var0, InventoryComponent.Tool.getComponentType());
if (var3 != null && var3.isUsingToolsItem()) {
class="kw">return ItemStack.EMPTY;
}
InventoryComponent.Hotbar var4 = var1.getComponent(var0, InventoryComponent.Hotbar.getComponentType());
if (var4 == null) {
class="kw">return ItemStack.EMPTY;
}
byte var5 = var4.getActiveSlot();
if (var5 == -1) {
class="kw">return ItemStack.EMPTY;
}
ItemStack var6 = var4.getInventory().getItemStack(var5);
if (var6 == null) {
class="kw">return ItemStack.EMPTY;
}
var4.getInventory().removeItemStackFromSlot(var5, var6, var2, false, true);
class="kw">return var6.withQuantity(var2);
}
class="kw">private class="kw">static void refundKey(@Nonnull Ref<EntityStore> var0, @Nonnull Store<EntityStore> var1, @Nonnull ItemStack var2, @Nonnull UUID var3) {
if (var0.isValid()) {
InventoryComponent.getCombined(var1, var0, InventoryComponent.HOTBAR_FIRST).addItemStack(var2);
} else if (!var2.isEmpty()) {
HytaleLogger.getLogger().at(Level.WARNING).log("Could not refund portal key %s to player %s; they are no longer in this world", var2, var3);
}
}
class="kw">private record CanSpawnPortal(
PortalKey portalKey, PortalType portalType, BlockModule.BlockStateInfo blockState, PortalDevice portalDevice, PortalGameplayConfig portalGameplayConfig
) class="kw">implements PortalDeviceSummonPage.State {
class="kw">private CanSpawnPortal {
}
}
class="kw">protected class="kw">static class Data {
@Nonnull
class="kw">private class="kw">static class="kw">final String KEY_ACTION = "Action";
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<PortalDeviceSummonPage.Data> CODEC = BuilderCodec.builder(
PortalDeviceSummonPage.Data.class, PortalDeviceSummonPage.Data::new
)
.append(new KeyedCodec<>("Action", Codec.STRING), (var0, var1) -> var0.action = var1, var0 -> var0.action)
.add()
.build();
class="kw">private String action;
class="kw">protected Data() {
}
}
class="kw">private enum Error class="kw">implements PortalDeviceSummonPage.State {
NOTHING_OFFERED,
OFFERED_IS_NOT_HELD,
NOT_A_PORTAL_KEY,
INVALID_BLOCK,
INVALID_DESTINATION,
PORTAL_INSIDE_PORTAL,
BOTCHED_GAMEPLAY_CONFIG;
Error() {
}
}
class="kw">private record InstanceKeyNotFound(String instanceId) class="kw">implements PortalDeviceSummonPage.State {
class="kw">private InstanceKeyNotFound {
}
}
class="kw">private record MaxActivePortals(int maxConcurrentFragments) class="kw">implements PortalDeviceSummonPage.State {
class="kw">private MaxActivePortals {
}
}
class="kw">private record PortalTypeNotFound(String portalTypeId) class="kw">implements PortalDeviceSummonPage.State {
class="kw">private PortalTypeNotFound {
}
}
class="kw">private sealed class="kw">interface State
permits PortalDeviceSummonPage.CanSpawnPortal,
PortalDeviceSummonPage.Error,
PortalDeviceSummonPage.InstanceKeyNotFound,
PortalDeviceSummonPage.PortalTypeNotFound,
PortalDeviceSummonPage.MaxActivePortals {
}
}