TeleportConfigInstanceInteraction class
Пакет: com.hypixel.hytale.builtin.instances.interactions
Файл: com/hypixel/hytale/builtin/instances/interactions/TeleportConfigInstanceInteraction.java
extends: SimpleBlockInteraction
Поля (48)
| Модификаторы | Тип | Имя |
|---|---|---|
|
PlayerRef |
var10 |
|
BlockChunk |
var10 |
|
Archetype |
var11 |
|
WorldChunk |
var11 |
|
InstancesPlugin |
var12 |
|
BlockType |
var12 |
|
Universe |
var13 |
|
IndexedLookupTableAssetMap |
var13 |
|
ChunkStore |
var14 |
|
BlockSection |
var14 |
|
Ref |
var15 |
|
int |
var15 |
|
ConfigurableInstanceBlock |
var16 |
|
RotationTuple |
var16 |
|
World |
var17 |
|
|
var17 |
|
|
var17 |
|
BlockBoundingBoxes |
var17 |
|
CompletableFuture |
var18 |
|
|
var18 |
|
|
var18 |
|
|
var18 |
|
Box |
var18 |
|
Transform |
var19 |
|
|
var19 |
|
|
var19 |
|
Vector3d |
var19 |
|
UUID |
var20 |
|
Rotation3f |
var20 |
|
|
var20 |
|
|
var20 |
|
BlockModule.BlockStateInfo |
var21 |
|
long |
var22 |
|
WorldChunk |
var24 |
|
Transform |
var25 |
|
Transform |
var26 |
|
double |
var27 |
|
int |
var28 |
|
long |
var3 |
|
BlockPosition |
var3 |
|
World |
var4 |
|
WorldChunk |
var5 |
|
ChunkStore |
var5 |
|
Store |
var6 |
|
long |
var7 |
|
Ref |
var8 |
|
Player |
var9 |
|
Ref |
var9 |
Методы (20)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
throw new |
IllegalArgumentExceptionthrow new IllegalArgumentException("Can't use OriginSource.BLOCK without a target block") |
abstract |
throw new |
IllegalArgumentExceptionthrow new IllegalArgumentException("Block chunk component not found") |
abstract |
throw new |
IllegalArgumentExceptionthrow new IllegalArgumentException("World chunk component not found") |
abstract |
throw new |
IllegalArgumentExceptionthrow new IllegalArgumentException("Block type not found") |
abstract |
throw new |
IllegalArgumentExceptionthrow new IllegalArgumentException("Chunk not loaded") |
abstract |
return new |
Transformreturn new Transform(var19, var20) |
|
|
if if(var15 != null) |
|
|
if if(var16 != null) |
|
|
if if(var17 == null) |
|
|
if if(var17 == null && var18 == null) |
|
|
if if(var18 != null) |
|
|
if if(var27 >= 0.0) |
|
|
if if(var27 == 0.0) |
|
|
if if(var24 != null) |
|
|
if if(var5 != null) |
|
|
if if(var3 == null) |
|
|
if if(var10 == null) |
|
|
if if(var11 == null) |
|
|
if if(var12 == null) |
|
|
if if(var17 == null) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.instances.interactions;
class="kw">import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
class="kw">import com.hypixel.hytale.builtin.instances.InstancesPlugin;
class="kw">import com.hypixel.hytale.builtin.instances.blocks.ConfigurableInstanceBlock;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.common.util.CompletableFutureUtil;
class="kw">import com.hypixel.hytale.component.Archetype;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
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.math.Axis;
class="kw">import com.hypixel.hytale.math.shape.Box;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.math.vector.Transform;
class="kw">import com.hypixel.hytale.protocol.BlockPosition;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.protocol.WaitForDataFrom;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.asset.type.blockhitbox.BlockBoundingBoxes;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
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.inventory.ItemStack;
class="kw">import com.hypixel.hytale.server.core.modules.block.BlockModule;
class="kw">import com.hypixel.hytale.server.core.modules.entity.teleport.PendingTeleport;
class="kw">import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.client.SimpleBlockInteraction;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.Universe;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
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.chunk.section.BlockSection;
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.UUID;
class="kw">import java.util.concurrent.CompletableFuture;
class="kw">import java.util.concurrent.TimeUnit;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3i;
class="kw">public class TeleportConfigInstanceInteraction class="kw">extends SimpleBlockInteraction {
@Nonnull
class="kw">private class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
@Nonnull
class="kw">private class="kw">static class="kw">final Message MESSAGE_GENERAL_INTERACTION_CONFIGURE_INSTANCE_NO_INSTANCE_NAME = Message.translation(
"server.general.interaction.configureInstance.noInstanceName"
);
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<TeleportConfigInstanceInteraction> CODEC = BuilderCodec.builder(
TeleportConfigInstanceInteraction.class, TeleportConfigInstanceInteraction::new, SimpleBlockInteraction.CODEC
)
.documentation(
"Teleports the **Player** to the named instance, creating it if required.\n\nThis is configured via a UI instead of inside the interaction. This interaction just executes that set configuration."
)
.build();
class="kw">private class="kw">static class="kw">final int SET_BLOCK_SETTINGS = 256;
class="kw">public TeleportConfigInstanceInteraction() {
}
@Nonnull
@Override
class="kw">public WaitForDataFrom getWaitForDataFrom() {
class="kw">return WaitForDataFrom.Server;
}
@Override
class="kw">protected void interactWithBlock(
@Nonnull World var1,
@Nonnull CommandBuffer<EntityStore> var2,
@Nonnull InteractionType var3,
@Nonnull InteractionContext var4,
@Nullable ItemStack var5,
@Nonnull Vector3i var6,
@Nonnull CooldownHandler var7
) {
Ref var8 = var4.getEntity();
Player var9 = var2.getComponent(var8, Player.getComponentType());
if (var9 != null && !var9.isWaitingForClientReady()) {
PlayerRef var10 = var2.getComponent(var8, PlayerRef.getComponentType());
assert var10 != null;
Archetype var11 = var2.getArchetype(var8);
if (!var11.contains(Teleport.getComponentType()) && !var11.contains(PendingTeleport.getComponentType())) {
InstancesPlugin var12 = InstancesPlugin.get();
Universe var13 = Universe.get();
ChunkStore var14 = var1.getChunkStore();
Ref var15 = BlockModule.getBlockEntity(var1, var6.x, var6.y, var6.z);
if (var15 != null) {
ConfigurableInstanceBlock var16 = var14.getStore().getComponent(var15, ConfigurableInstanceBlock.getComponentType());
if (var16 != null) {
if (var16.getInstanceName() == null) {
var10.sendMessage(MESSAGE_GENERAL_INTERACTION_CONFIGURE_INSTANCE_NO_INSTANCE_NAME);
} else {
CompletableFuture var18 = null;
Transform var19 = null;
World var17;
if (var16.getInstanceKey() != null) {
var17 = var13.getWorld(var16.getInstanceKey());
if (var17 == null) {
var19 = makeReturnPoint(var16, var4, var2);
var18 = var12.spawnInstance(var16.getInstanceName(), var16.getInstanceKey(), var1, var19);
}
} else {
UUID var20 = var16.getWorldUUID();
var18 = var16.getWorldFuture();
var17 = var20 != null ? var13.getWorld(var20) : null;
if (var17 == null && var18 == null) {
BlockModule.BlockStateInfo var21 = var14.getStore().getComponent(var15, BlockModule.BlockStateInfo.getComponentType());
var19 = makeReturnPoint(var16, var4, var2);
var18 = var12.spawnInstance(var16.getInstanceName(), var1, var19);
var16.setWorldFuture(var18);
CompletableFutureUtil._catch(var18.thenAcceptAsync(var3x -> {
if (var15.isValid()) {
var16.setWorldFuture(null);
var16.setWorldUUID(var3x.getWorldConfig().getUuid());
var21.markNeedsSaving();
}
}, var1));
}
}
if (var18 != null) {
Transform var25 = getPersonalReturnPoint(var16, var4, var19, var2);
InstancesPlugin.teleportPlayerToLoadingInstance(var8, var2, var18, var25);
} else if (var17 != null) {
Transform var26 = getPersonalReturnPoint(var16, var4, var19, var2);
InstancesPlugin.teleportPlayerToInstance(var8, var2, var17, var26);
}
double var27 = var16.getRemoveBlockAfter();
if (var27 >= 0.0) {
if (var27 == 0.0) {
long var22 = ChunkUtil.indexChunkFromBlock(var6.x, var6.z);
WorldChunk var24 = var1.getChunk(var22);
if (var24 != null) {
var24.setBlock(var6.x, var6.y, var6.z, 0, 256);
} else {
((HytaleLogger.Api)LOGGER.atWarning()).log("Failed to remove block at %s,%s,%s as chunk is not loaded", var6.x, var6.y, var6.z);
}
} else {
int var28 = var1.getBlock(var6);
new CompletableFuture()
.completeOnTimeout(null, (long)(var27 * 1.0E9), TimeUnit.NANOSECONDS)
.thenRunAsync(
() -> {
if (var1.getBlock(var6) == var28) {
long var3 = ChunkUtil.indexChunkFromBlock(var6.x, var6.z);
WorldChunk var5 = var1.getChunk(var3);
if (var5 != null) {
var5.setBlock(var6.x, var6.y, var6.z, 0, 256);
} else {
((HytaleLogger.Api)LOGGER.atWarning())
.log("Failed to remove block at %s,%s,%s as chunk is not loaded", var6.x, var6.y, var6.z);
}
}
},
var1
);
}
}
}
}
}
}
}
}
@Override
class="kw">protected void simulateInteractWithBlock(
@Nonnull InteractionType var1, @Nonnull InteractionContext var2, @Nullable ItemStack var3, @Nonnull World var4, @Nonnull Vector3i var5
) {
}
@Nullable
class="kw">private class="kw">static Transform getPersonalReturnPoint(
@Nonnull ConfigurableInstanceBlock var0, @Nonnull InteractionContext var1, @Nullable Transform var2, @Nonnull ComponentAccessor<EntityStore> var3
) {
if (!var0.isPersonalReturnPoint()) {
class="kw">return null;
} else {
class="kw">return var2 == null ? makeReturnPoint(var0, var1, var3) : var2;
}
}
@Nonnull
class="kw">private class="kw">static Transform makeReturnPoint(
@Nonnull ConfigurableInstanceBlock var0, @Nonnull InteractionContext var1, @Nonnull ComponentAccessor<EntityStore> var2
) {
BlockPosition var3 = var1.getTargetBlock();
if (var3 == null) {
throw new IllegalArgumentException("Can't use OriginSource.BLOCK without a target block");
}
World var4 = var2.getExternalData().getWorld();
ChunkStore var5 = var4.getChunkStore();
Store var6 = var5.getStore();
long var7 = ChunkUtil.indexChunkFromBlock(var3.x, var3.z);
Ref var9 = var5.getChunkReference(var7);
if (var9 != null && var9.isValid()) {
BlockChunk var10 = var6.getComponent(var9, BlockChunk.getComponentType());
if (var10 == null) {
throw new IllegalArgumentException("Block chunk component not found");
}
WorldChunk var11 = var6.getComponent(var9, WorldChunk.getComponentType());
if (var11 == null) {
throw new IllegalArgumentException("World chunk component not found");
}
BlockType var12 = var11.getBlockType(var3.x, var3.y, var3.z);
if (var12 == null) {
throw new IllegalArgumentException("Block type not found");
}
IndexedLookupTableAssetMap var13 = BlockBoundingBoxes.getAssetMap();
BlockSection var14 = var10.getSectionAtBlockY(var3.y);
int var15 = var14.getRotationIndex(var3.x, var3.y, var3.z);
RotationTuple var16 = RotationTuple.get(var15);
BlockBoundingBoxes var17 = var13.getAsset(var12.getHitboxTypeIndex());
if (var17 == null) {
throw new IllegalArgumentException("Hitbox asset not found for block type: " + var12.getId());
}
Box var18 = var17.get(var15).getBoundingBox();
Vector3d var19 = var0.getPositionOffset() != null ? var16.rotatedVector(var0.getPositionOffset()) : new Vector3d();
var19.x = var19.x + (var18.middleX() + var3.x);
var19.y = var19.y + (var18.middleY() + var3.y);
var19.z = var19.z + (var18.middleZ() + var3.z);
Rotation3f var20;
if (var0.getRotation() != null) {
var20 = new Rotation3f(var0.getRotation());
var20.addRotationOnAxis(Axis.Y, var16.yaw().getDegrees());
var20.addRotationOnAxis(Axis.X, var16.pitch().getDegrees());
} else {
var20 = new Rotation3f(Rotation3f.NaN);
}
class="kw">return new Transform(var19, var20);
} else {
throw new IllegalArgumentException("Chunk not loaded");
}
}
}