BedInteraction class
Пакет: com.hypixel.hytale.builtin.beds.interactions
Файл: com/hypixel/hytale/builtin/beds/interactions/BedInteraction.java
extends: SimpleBlockInteraction
Поля (27)
| Модификаторы | Тип | Имя |
|---|---|---|
|
Store |
var10 |
|
PlayerRef |
var11 |
|
UUIDComponent |
var12 |
|
UUID |
var13 |
|
Ref |
var14 |
|
Store |
var15 |
|
BlockComponentSection |
var16 |
|
int |
var17 |
|
Ref |
var18 |
|
|
var18 |
|
Holder |
var19 |
|
UUID |
var20 |
|
PageManager |
var21 |
|
boolean |
var22 |
|
PlayerRespawnPointData[] |
var23 |
|
RespawnConfig |
var24 |
|
int |
var25 |
|
PlayerRespawnPointData[] |
var26 |
|
RespawnBlock |
var27 |
|
BlockPosition |
var28 |
|
Vector3d |
var29 |
|
ObjectArrayList |
var3 |
|
BlockMountAPI.BlockMountResult |
var30 |
|
PlayerRespawnPointData |
var5 |
|
Vector3i |
var6 |
|
Ref |
var8 |
|
Player |
var9 |
Методы (10)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
for for(int var4 = 0; var4 < var1.length; var4++) |
|
|
if if(var9 != null) |
|
|
if if(var11 != null) |
|
|
if if(var12 != null) |
|
|
if if(var16 != null) |
|
|
if if(var27 != null) |
|
|
if if(var22) |
|
|
if if(var30 instanceof BlockMountAPI.DidNotMount) |
|
|
if if(var26 != null) |
|
|
if if(var1 != null && var1.length != 0) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.beds.interactions;
class="kw">import com.hypixel.hytale.builtin.beds.respawn.OverrideNearbyRespawnPointPage;
class="kw">import com.hypixel.hytale.builtin.beds.respawn.SelectOverrideRespawnPointPage;
class="kw">import com.hypixel.hytale.builtin.beds.respawn.SetNameRespawnPointPage;
class="kw">import com.hypixel.hytale.builtin.beds.sleep.components.PlayerSleep;
class="kw">import com.hypixel.hytale.builtin.beds.sleep.components.PlayerSomnolence;
class="kw">import com.hypixel.hytale.builtin.beds.sleep.systems.player.SleepNotificationSystem;
class="kw">import com.hypixel.hytale.builtin.mounts.BlockMountAPI;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.component.AddReason;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.Holder;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
class="kw">import com.hypixel.hytale.protocol.BlockPosition;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.asset.type.gameplay.RespawnConfig;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionContext;
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.data.PlayerRespawnPointData;
class="kw">import com.hypixel.hytale.server.core.entity.entities.player.pages.PageManager;
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.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.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockComponentSection;
class="kw">import com.hypixel.hytale.server.core.universe.world.meta.state.RespawnBlock;
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 it.unimi.dsi.fastutil.objects.ObjectArrayList;
class="kw">import java.util.UUID;
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 BedInteraction class="kw">extends SimpleBlockInteraction {
@Nonnull
class="kw">private class="kw">static class="kw">final Message MESSAGE_SERVER_CUSTOM_UI_RESPAWN_POINT_CLAIMED = Message.translation("server.customUI.respawnPointClaimed");
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<BedInteraction> CODEC = BuilderCodec.builder(BedInteraction.class, BedInteraction::new, SimpleBlockInteraction.CODEC)
.documentation("Interact with a bed block, ostensibly to sleep in it.")
.build();
class="kw">public BedInteraction() {
}
@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) {
Store var10 = var2.getStore();
PlayerRef var11 = var2.getComponent(var8, PlayerRef.getComponentType());
if (var11 != null) {
UUIDComponent var12 = var2.getComponent(var8, UUIDComponent.getComponentType());
if (var12 != null) {
UUID var13 = var12.getUuid();
Ref var14 = var1.getChunkStore().getChunkSectionReferenceAtBlock(var6.x, var6.y, var6.z);
if (var14 != null && var14.isValid()) {
Store var15 = var14.getStore();
BlockComponentSection var16 = var15.getComponent(var14, BlockComponentSection.getComponentType());
if (var16 != null) {
int var17 = ChunkUtil.indexBlock(var6.x, var6.y, var6.z);
Ref var18 = var16.getBlockReference(var17);
if (var18 == null || !var18.isValid()) {
Holder var19 = ChunkStore.REGISTRY.newHolder();
var19.putComponent(BlockModule.BlockStateInfo.getComponentType(), new BlockModule.BlockStateInfo(var17, var14));
var19.ensureComponent(RespawnBlock.getComponentType());
var18 = var15.addEntity(var19, AddReason.SPAWN);
}
if (var18 != null && var18.isValid()) {
RespawnBlock var27 = var15.getComponent(var18, RespawnBlock.getComponentType());
if (var27 != null) {
UUID var20 = var27.getOwnerUUID();
PageManager var21 = var9.getPageManager();
boolean var22 = var13.equals(var20);
if (var22) {
BlockPosition var28 = var4.getMetaStore().getMetaObject(TARGET_BLOCK_RAW);
Vector3d var29 = new Vector3d(var28.x + 0.5, var28.y + 0.5, var28.z + 0.5);
BlockMountAPI.BlockMountResult var30 = BlockMountAPI.mountOnBlock(var8, var2, var6, var29);
if (var30 class="kw">instanceof BlockMountAPI.DidNotMount) {
var11.sendMessage(Message.translation("server.interactions.didNotMount").param("state", var30.toString()));
} else if (var30 class="kw">instanceof BlockMountAPI.Mounted) {
var2.putComponent(var8, PlayerSomnolence.getComponentType(), PlayerSleep.NoddingOff.createComponent());
var2.run(var0 -> SleepNotificationSystem.maybeDoNotification(var0, false));
}
} else if (var20 != null) {
var11.sendMessage(MESSAGE_SERVER_CUSTOM_UI_RESPAWN_POINT_CLAIMED);
} else {
PlayerRespawnPointData[] var23 = var9.getPlayerConfigData().getPerWorldData(var1.getName()).getRespawnPoints();
RespawnConfig var24 = var1.getGameplayConfig().getRespawnConfig();
int var25 = var24.getRadiusLimitRespawnPoint();
PlayerRespawnPointData[] var26 = getNearbySavedRespawnPoints(var6, var23, var25);
if (var26 != null) {
var21.openCustomPage(var8, var10, new OverrideNearbyRespawnPointPage(var11, var3, var6, var18, var26, var25));
} else if (var23 != null && var23.length >= var24.getMaxRespawnPointsPerPlayer()) {
var21.openCustomPage(var8, var10, new SelectOverrideRespawnPointPage(var11, var3, var6, var18, var23));
} else {
var21.openCustomPage(var8, var10, new SetNameRespawnPointPage(var11, var3, var6, var18));
}
}
}
}
}
}
}
}
}
}
@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 PlayerRespawnPointData[] getNearbySavedRespawnPoints(@Nonnull Vector3i var0, @Nullable PlayerRespawnPointData[] var1, int var2) {
if (var1 != null && var1.length != 0) {
ObjectArrayList var3 = new ObjectArrayList();
for (int var4 = 0; var4 < var1.length; var4++) {
PlayerRespawnPointData var5 = var1[var4];
Vector3i var6 = var5.getBlockPosition();
if (var6.distance(var0.x, var6.y, var0.z) < var2) {
var3.add(var5);
}
}
class="kw">return var3.isEmpty() ? null : (PlayerRespawnPointData[])var3.toArray(PlayerRespawnPointData[]::new);
} else {
class="kw">return null;
}
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "BedInteraction{} " + super.toString();
}
}