// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.core.entity.entities;

import java.util.concurrent.CompletionStage;
import com.hypixel.hytale.server.core.entity.InteractionChain;
import com.hypixel.hytale.server.core.modules.interaction.interaction.config.RootInteraction;
import com.hypixel.hytale.server.core.entity.InteractionContext;
import com.hypixel.hytale.protocol.InteractionType;
import com.hypixel.hytale.server.core.modules.interaction.InteractionModule;
import com.hypixel.hytale.server.core.entity.InteractionManager;
import com.hypixel.hytale.server.core.modules.entity.component.RespondToHit;
import com.hypixel.hytale.server.core.modules.entity.player.PlayerSettings;
import com.hypixel.hytale.server.core.modules.entity.component.Invulnerable;
import com.hypixel.hytale.server.core.asset.type.gamemode.GameModeType;
import com.hypixel.hytale.protocol.packets.player.SetGameMode;
import com.hypixel.hytale.server.core.event.events.ecs.ChangeGameModeEvent;
import com.hypixel.hytale.metrics.MetricResults;
import com.hypixel.hytale.server.core.inventory.transaction.ItemStackSlotTransaction;
import com.hypixel.hytale.server.core.inventory.container.ItemContainer;
import com.hypixel.hytale.server.core.modules.collision.CollisionResult;
import com.hypixel.hytale.server.core.modules.collision.CollisionModule;
import it.unimi.dsi.fastutil.longs.LongIterator;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.math.util.ChunkUtil;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import java.util.concurrent.Executor;
import com.hypixel.hytale.math.shape.Box;
import java.util.List;
import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerRespawnPointData;
import com.hypixel.hytale.server.core.modules.entity.component.BoundingBox;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.math.vector.Transform;
import java.util.Arrays;
import com.hypixel.hytale.server.core.modules.physics.component.Velocity;
import com.hypixel.hytale.server.core.modules.entity.component.CollisionResultComponent;
import com.hypixel.hytale.server.core.permissions.PermissionsModule;
import com.hypixel.hytale.protocol.packets.player.SetBlockPlacementOverride;
import com.hypixel.hytale.server.core.universe.world.SoundUtil;
import com.hypixel.hytale.protocol.SoundCategory;
import com.hypixel.hytale.server.core.util.TempAssetIdUtil;
import com.hypixel.hytale.server.core.util.NotificationUtil;
import com.hypixel.hytale.server.core.Message;
import javax.annotation.Nullable;
import com.hypixel.hytale.server.core.inventory.ItemStack;
import com.hypixel.hytale.server.core.entity.entities.player.movement.MovementManager;
import com.hypixel.hytale.server.core.entity.entities.player.CameraManager;
import com.hypixel.hytale.server.core.modules.entity.tracker.LegacyEntityTrackerSystems;
import com.hypixel.hytale.server.core.io.PacketHandler;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.entity.UUIDComponent;
import com.hypixel.hytale.server.core.entity.movement.MovementStatesComponent;
import java.util.concurrent.CompletableFuture;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.event.IEventDispatcher;
import com.hypixel.hytale.server.core.event.events.player.PlayerReadyEvent;
import java.util.concurrent.TimeUnit;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.protocol.Packet;
import com.hypixel.hytale.protocol.packets.player.SetMovementStates;
import com.hypixel.hytale.protocol.MovementStates;
import com.hypixel.hytale.protocol.SavedMovementStates;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.Ref;
import java.util.logging.Level;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.modules.entity.player.ChunkTracker;
import com.hypixel.hytale.server.core.inventory.Inventory;
import java.util.UUID;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.ComponentType;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicInteger;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.server.core.entity.entities.player.HotbarManager;
import com.hypixel.hytale.server.core.entity.entities.player.hud.HudManager;
import com.hypixel.hytale.server.core.entity.entities.player.pages.PageManager;
import com.hypixel.hytale.server.core.entity.entities.player.windows.WindowManager;
import com.hypixel.hytale.server.core.universe.world.WorldMapTracker;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerConfigData;
import com.hypixel.hytale.codec.KeyedCodec;
import javax.annotation.Nonnull;
import com.hypixel.hytale.metrics.MetricsRegistry;
import com.hypixel.hytale.metrics.MetricProvider;
import com.hypixel.hytale.server.core.permissions.PermissionHolder;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.entity.LivingEntity;

public class Player extends LivingEntity implements CommandSender, PermissionHolder, MetricProvider
{
    @Nonnull
    public static final MetricsRegistry<Player> METRICS_REGISTRY;
    @Nonnull
    public static final KeyedCodec<PlayerConfigData> PLAYER_CONFIG_DATA;
    @Nonnull
    public static final BuilderCodec<Player> CODEC;
    public static final int DEFAULT_VIEW_RADIUS_CHUNKS = 6;
    public static final long RESPAWN_INVULNERABILITY_TIME_NANOS;
    public static final long MAX_TELEPORT_INVULNERABILITY_MILLIS = 10000L;
    @Deprecated(forRemoval = true)
    private PlayerRef playerRef;
    @Nonnull
    private PlayerConfigData data;
    @Nonnull
    private final WorldMapTracker worldMapTracker;
    @Nonnull
    private final WindowManager windowManager;
    @Nonnull
    private final PageManager pageManager;
    @Nonnull
    private final HudManager hudManager;
    @Nonnull
    private HotbarManager hotbarManager;
    private GameMode gameMode;
    private int clientViewRadius;
    protected long lastSpawnTimeNanos;
    private static final int MAX_VELOCITY_SAMPLE_COUNT = 2;
    private static final int VELOCITY_SAMPLE_LENGTH = 12;
    private static final double[][] velocitySampleWeights;
    private final double[] velocitySamples;
    private int velocitySampleCount;
    private int velocitySampleIndex;
    private boolean overrideBlockPlacementRestrictions;
    private final AtomicInteger readyId;
    private final AtomicReference<ScheduledFuture<?>> waitingForClientReady;
    public boolean executeTriggers;
    public boolean executeBlockDamage;
    private boolean firstSpawn;
    private int mountEntityId;
    static final /* synthetic */ boolean $assertionsDisabled;
    
    @Nonnull
    public static ComponentType<EntityStore, Player> getComponentType() {
        return EntityModule.get().getPlayerComponentType();
    }
    
    public Player() {
        this.data = new PlayerConfigData();
        this.worldMapTracker = new WorldMapTracker(this);
        this.windowManager = new WindowManager();
        this.pageManager = new PageManager();
        this.hudManager = new HudManager();
        this.hotbarManager = new HotbarManager();
        this.clientViewRadius = 6;
        this.velocitySamples = new double[12];
        this.velocitySampleIndex = 4;
        this.readyId = new AtomicInteger();
        this.waitingForClientReady = new AtomicReference<ScheduledFuture<?>>();
    }
    
    public void copyFrom(@Nonnull final Player oldPlayerComponent) {
        this.init(this.legacyUuid, this.playerRef);
        this.worldMapTracker.copyFrom(oldPlayerComponent.worldMapTracker);
        this.clientViewRadius = oldPlayerComponent.clientViewRadius;
        this.readyId.set(oldPlayerComponent.readyId.get());
    }
    
    public void init(@Nonnull final UUID uuid, @Nonnull final PlayerRef playerRef) {
        this.legacyUuid = uuid;
        this.playerRef = playerRef;
        this.windowManager.init(playerRef);
        this.pageManager.init(playerRef, this.windowManager);
    }
    
    public void setNetworkId(final int id) {
        this.networkId = id;
    }
    
    @Nonnull
    @Override
    protected Inventory createDefaultInventory() {
        return new Inventory();
    }
    
    @Nonnull
    @Override
    public Inventory setInventory(final Inventory inventory) {
        return super.setInventory(inventory, true);
    }
    
    @Override
    public boolean remove() {
        if (this.wasRemoved.getAndSet(true)) {
            return false;
        }
        this.removedBy = new Throwable();
        if (this.world != null && this.world.isAlive()) {
            if (this.world.isInThread()) {
                final Ref<EntityStore> ref = this.playerRef.getReference();
                if (ref != null) {
                    final Store<EntityStore> store = ref.getStore();
                    final ChunkTracker tracker = store.getComponent(ref, ChunkTracker.getComponentType());
                    if (tracker != null) {
                        tracker.clear();
                    }
                    this.playerRef.removeFromStore();
                }
            }
            else {
                this.world.execute(() -> {
                    final Ref<EntityStore> ref2 = this.playerRef.getReference();
                    if (ref2 == null) {
                        return;
                    }
                    else {
                        final Store<EntityStore> store2 = ref2.getStore();
                        final ChunkTracker tracker2 = store2.getComponent(ref2, ChunkTracker.getComponentType());
                        if (tracker2 != null) {
                            tracker2.clear();
                        }
                        this.playerRef.removeFromStore();
                        return;
                    }
                });
            }
        }
        if (this.playerRef.getPacketHandler().getChannel().isActive()) {
            this.playerRef.getPacketHandler().disconnect("Player removed from world!");
            Player.LOGGER.at(Level.WARNING).withCause(this.removedBy).log("Player removed from world! %s", this);
        }
        final ScheduledFuture<?> task;
        if ((task = this.waitingForClientReady.getAndSet(null)) != null) {
            task.cancel(false);
        }
        return true;
    }
    
    @Override
    public void moveTo(@Nonnull final Ref<EntityStore> ref, final double locX, final double locY, final double locZ, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        final TransformComponent transformComponent = componentAccessor.getComponent(ref, TransformComponent.getComponentType());
        assert transformComponent != null;
        final Vector3d position = transformComponent.getPosition();
        this.addLocationChange(ref, locX - position.getX(), locY - position.getY(), locZ - position.getZ(), componentAccessor);
        super.moveTo(ref, locX, locY, locZ, componentAccessor);
        this.windowManager.validateWindows(ref, componentAccessor);
    }
    
    @Nonnull
    public PlayerConfigData getPlayerConfigData() {
        return this.data;
    }
    
    @Override
    public void markNeedsSave() {
        this.data.markChanged();
    }
    
    @Override
    public void unloadFromWorld() {
        super.unloadFromWorld();
    }
    
    public void applyMovementStates(@Nonnull final Ref<EntityStore> ref, @Nonnull final SavedMovementStates savedMovementStates, @Nonnull final MovementStates movementStates, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        movementStates.flying = savedMovementStates.flying;
        final PlayerRef playerRefComponent = componentAccessor.getComponent(ref, PlayerRef.getComponentType());
        assert playerRefComponent != null;
        playerRefComponent.getPacketHandler().writeNoCache(new SetMovementStates(new SavedMovementStates(movementStates.flying)));
    }
    
    public void startClientReadyTimeout() {
        final ScheduledFuture<?> task = HytaleServer.SCHEDULED_EXECUTOR.schedule(() -> this.handleClientReady(true), 10000L, TimeUnit.MILLISECONDS);
        final ScheduledFuture<?> oldTask = this.waitingForClientReady.getAndSet(task);
        if (oldTask != null) {
            oldTask.cancel(false);
        }
    }
    
    public void handleClientReady(final boolean forced) {
        final ScheduledFuture<?> task;
        if ((task = this.waitingForClientReady.getAndSet(null)) != null) {
            task.cancel(false);
            if (this.world == null) {
                return;
            }
            final IEventDispatcher<PlayerReadyEvent, PlayerReadyEvent> dispatcher = HytaleServer.get().getEventBus().dispatchFor((Class<? super PlayerReadyEvent>)PlayerReadyEvent.class, this.world.getName());
            if (dispatcher.hasListener()) {
                dispatcher.dispatch(new PlayerReadyEvent(this.reference, this, this.readyId.getAndIncrement()));
            }
        }
    }
    
    public void sendInventory() {
        this.getInventory().consumeIsDirty();
        this.playerRef.getPacketHandler().write(this.getInventory().toPacket());
    }
    
    @Nonnull
    public CompletableFuture<Void> saveConfig(@Nonnull final World world, @Nonnull final Holder<EntityStore> holder) {
        final MovementStatesComponent movementStatesComponent = holder.getComponent(MovementStatesComponent.getComponentType());
        assert movementStatesComponent != null;
        final UUIDComponent uuidComponent = holder.getComponent(UUIDComponent.getComponentType());
        assert uuidComponent != null;
        this.data.getPerWorldData(world.getName()).setLastMovementStates(movementStatesComponent.getMovementStates(), false);
        return Universe.get().getPlayerStorage().save(uuidComponent.getUuid(), holder);
    }
    
    @Deprecated(forRemoval = true)
    public PacketHandler getPlayerConnection() {
        return this.playerRef.getPacketHandler();
    }
    
    @Nonnull
    public WorldMapTracker getWorldMapTracker() {
        return this.worldMapTracker;
    }
    
    @Nonnull
    public WindowManager getWindowManager() {
        return this.windowManager;
    }
    
    @Nonnull
    public PageManager getPageManager() {
        return this.pageManager;
    }
    
    @Nonnull
    public HudManager getHudManager() {
        return this.hudManager;
    }
    
    @Nonnull
    public HotbarManager getHotbarManager() {
        return this.hotbarManager;
    }
    
    public boolean isFirstSpawn() {
        return this.firstSpawn;
    }
    
    public void setFirstSpawn(final boolean firstSpawn) {
        this.firstSpawn = firstSpawn;
    }
    
    public void resetManagers(@Nonnull final Holder<EntityStore> holder) {
        final PlayerRef playerRef = this.playerRef;
        LegacyEntityTrackerSystems.clear(this, holder);
        this.worldMapTracker.clear();
        this.hudManager.resetUserInterface(this.playerRef);
        this.hudManager.resetHud(this.playerRef);
        final CameraManager cameraManagerComponent = playerRef.getComponent(CameraManager.getComponentType());
        assert cameraManagerComponent != null;
        cameraManagerComponent.resetCamera(playerRef);
        final MovementManager movementManagerComponent = playerRef.getComponent(MovementManager.getComponentType());
        assert movementManagerComponent != null;
        movementManagerComponent.applyDefaultSettings();
        movementManagerComponent.update(playerRef.getPacketHandler());
    }
    
    public void notifyPickupItem(@Nonnull final Ref<EntityStore> ref, @Nonnull final ItemStack itemStack, @Nullable final Vector3d position, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        final World world = componentAccessor.getExternalData().getWorld();
        if (world.getGameplayConfig().getShowItemPickupNotifications()) {
            final PlayerRef playerRefComponent = componentAccessor.getComponent(ref, PlayerRef.getComponentType());
            assert playerRefComponent != null;
            final Message itemNameMessage = Message.translation(itemStack.getItem().getTranslationKey());
            NotificationUtil.sendNotification(playerRefComponent.getPacketHandler(), Message.translation("server.general.pickedUpItem").param("item", itemNameMessage), null, itemStack.toPacket());
        }
        if (position != null) {
            SoundUtil.playSoundEvent3dToPlayer(ref, TempAssetIdUtil.getSoundEventIndex("SFX_Player_Pickup_Item"), SoundCategory.UI, position, componentAccessor);
        }
        else {
            SoundUtil.playSoundEvent2d(ref, TempAssetIdUtil.getSoundEventIndex("SFX_Player_Pickup_Item"), SoundCategory.UI, componentAccessor);
        }
    }
    
    public boolean isOverrideBlockPlacementRestrictions() {
        return this.overrideBlockPlacementRestrictions;
    }
    
    public void setOverrideBlockPlacementRestrictions(@Nonnull final Ref<EntityStore> ref, final boolean overrideBlockPlacementRestrictions, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        this.overrideBlockPlacementRestrictions = overrideBlockPlacementRestrictions;
        final PlayerRef playerRefComponent = componentAccessor.getComponent(ref, PlayerRef.getComponentType());
        assert playerRefComponent != null;
        playerRefComponent.getPacketHandler().writeNoCache(new SetBlockPlacementOverride(overrideBlockPlacementRestrictions));
    }
    
    @Override
    public void sendMessage(@Nonnull final Message message) {
        this.playerRef.sendMessage(message);
    }
    
    @Override
    public boolean hasPermission(@Nonnull final String id) {
        return PermissionsModule.get().hasPermission(this.getUuid(), id);
    }
    
    @Override
    public boolean hasPermission(@Nonnull final String id, final boolean def) {
        return PermissionsModule.get().hasPermission(this.getUuid(), id, def);
    }
    
    public void addLocationChange(@Nonnull final Ref<EntityStore> ref, final double deltaX, final double deltaY, final double deltaZ, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        final CollisionResultComponent collisionResultComponent = componentAccessor.getComponent(ref, CollisionResultComponent.getComponentType());
        assert collisionResultComponent != null;
        collisionResultComponent.getCollisionPositionOffset().add(deltaX, deltaY, deltaZ);
        if (!collisionResultComponent.isPendingCollisionCheck()) {
            final TransformComponent transformComponent = componentAccessor.getComponent(ref, TransformComponent.getComponentType());
            assert transformComponent != null;
            final Vector3d position = transformComponent.getPosition();
            collisionResultComponent.getCollisionStartPosition().assign(position);
            collisionResultComponent.markPendingCollisionCheck();
        }
    }
    
    public void configTriggerBlockProcessing(final boolean triggers, final boolean blockDamage, @Nonnull final CollisionResultComponent collisionResultComponent) {
        this.executeTriggers = triggers;
        this.executeBlockDamage = blockDamage;
        if (triggers || blockDamage) {
            collisionResultComponent.getCollisionResult().enableTriggerBlocks();
        }
        else {
            collisionResultComponent.getCollisionResult().disableTriggerBlocks();
        }
    }
    
    public void resetVelocity(@Nonnull final Velocity velocity) {
        Arrays.fill(this.velocitySamples, 0.0);
        this.velocitySampleIndex = 4;
        this.velocitySampleCount = 0;
        velocity.setZero();
    }
    
    public void processVelocitySample(final double dt, @Nonnull final Vector3d position, @Nonnull final Velocity velocity) {
        final double x = position.x;
        final double y = position.y;
        final double z = position.z;
        if (dt == 0.0) {
            return;
        }
        this.velocitySamples[this.velocitySampleIndex] = x;
        this.velocitySamples[this.velocitySampleIndex + 1] = y;
        this.velocitySamples[this.velocitySampleIndex + 2] = z;
        this.velocitySamples[this.velocitySampleIndex + 3] = dt;
        int index = this.velocitySampleIndex;
        this.velocitySampleIndex += 4;
        if (this.velocitySampleIndex >= 12) {
            this.velocitySampleIndex = 4;
        }
        if (this.velocitySampleCount < 2) {
            ++this.velocitySampleCount;
        }
        if (this.velocitySampleCount < 2) {
            velocity.setZero();
            return;
        }
        for (int i = 0; i < 4; ++i) {
            this.velocitySamples[i] = 0.0;
        }
        final double[] weights = Player.velocitySampleWeights[this.velocitySampleCount - 2];
        for (int j = 0; j < this.velocitySampleCount - 1; ++j) {
            int previousIndex = index - 4;
            if (previousIndex < 4) {
                previousIndex = 8;
            }
            final double k = weights[j] / this.velocitySamples[index + 3];
            final double[] velocitySamples = this.velocitySamples;
            final int n = 0;
            velocitySamples[n] += k * (this.velocitySamples[index] - this.velocitySamples[previousIndex]);
            final double[] velocitySamples2 = this.velocitySamples;
            final int n2 = 1;
            velocitySamples2[n2] += k * (this.velocitySamples[index + 1] - this.velocitySamples[previousIndex + 1]);
            final double[] velocitySamples3 = this.velocitySamples;
            final int n3 = 2;
            velocitySamples3[n3] += k * (this.velocitySamples[index + 2] - this.velocitySamples[previousIndex + 2]);
            index = previousIndex;
        }
        velocity.set(this.velocitySamples[0], this.velocitySamples[1], this.velocitySamples[2]);
    }
    
    @Nonnull
    public static CompletableFuture<Transform> getRespawnPosition(@Nonnull final Ref<EntityStore> ref, @Nonnull final String worldName, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        final Player playerComponent = componentAccessor.getComponent(ref, getComponentType());
        assert playerComponent != null;
        final World world = componentAccessor.getExternalData().getWorld();
        final PlayerConfigData playerConfigData = playerComponent.data;
        final PlayerRespawnPointData[] respawnPoints = playerConfigData.getPerWorldData(worldName).getRespawnPoints();
        if (respawnPoints == null || respawnPoints.length == 0) {
            final Transform worldSpawnPoint = world.getWorldConfig().getSpawnProvider().getSpawnPoint(ref, componentAccessor);
            worldSpawnPoint.setRotation(Vector3f.ZERO);
            return CompletableFuture.completedFuture(worldSpawnPoint);
        }
        final TransformComponent transformComponent = componentAccessor.getComponent(ref, TransformComponent.getComponentType());
        assert transformComponent != null;
        final Vector3d playerPosition = transformComponent.getPosition();
        final List<PlayerRespawnPointData> sortedRespawnPoints = Arrays.stream(respawnPoints).sorted((a, b) -> {
            final Vector3d posA = a.getRespawnPosition();
            final Vector3d posB = b.getRespawnPosition();
            final double distA = playerPosition.distanceSquaredTo(posA.x, playerPosition.y, posA.z);
            final double distB = playerPosition.distanceSquaredTo(posB.x, playerPosition.y, posB.z);
            return Double.compare(distA, distB);
        }).toList();
        final BoundingBox playerBoundingBoxComponent = componentAccessor.getComponent(ref, BoundingBox.getComponentType());
        if (playerBoundingBoxComponent == null) {
            return CompletableFuture.completedFuture(new Transform(sortedRespawnPoints.getFirst().getRespawnPosition()));
        }
        return tryUseSpawnPoint(world, sortedRespawnPoints, 0, ref, playerComponent, playerBoundingBoxComponent.getBoundingBox());
    }
    
    @Nonnull
    private static CompletableFuture<Transform> tryUseSpawnPoint(final World world, final List<PlayerRespawnPointData> sortedRespawnPoints, final int index, final Ref<EntityStore> ref, final Player playerComponent, final Box boundingBox) {
        if (sortedRespawnPoints == null || index >= sortedRespawnPoints.size()) {
            playerComponent.sendMessage(Message.translation("server.general.allRespawnPointsObstructed"));
            return CompletableFuture.supplyAsync(() -> {
                if (!ref.isValid()) {
                    return new Transform();
                }
                else {
                    final Transform worldSpawnPoint = world.getWorldConfig().getSpawnProvider().getSpawnPoint(ref, ref.getStore());
                    worldSpawnPoint.setRotation(Vector3f.ZERO);
                    return worldSpawnPoint;
                }
            }, world);
        }
        final PlayerRespawnPointData respawnPoint = sortedRespawnPoints.get(index);
        final LongOpenHashSet requiredChunks = new LongOpenHashSet();
        if (respawnPoint.getRespawnPosition() != null) {
            boundingBox.forEachBlock(respawnPoint.getRespawnPosition(), 2.0, requiredChunks, (x, y, z, chunks) -> {
                chunks.add(ChunkUtil.indexChunkFromBlock(x, z));
                return true;
            });
        }
        if (respawnPoint.getBlockPosition() != null) {
            boundingBox.forEachBlock(respawnPoint.getBlockPosition().toVector3d(), 2.0, requiredChunks, (x, y, z, chunks) -> {
                chunks.add(ChunkUtil.indexChunkFromBlock(x, z));
                return true;
            });
        }
        final CompletableFuture<WorldChunk>[] chunkFutures = new CompletableFuture[requiredChunks.size()];
        int i = 0;
        final LongIterator iterator = requiredChunks.iterator();
        while (iterator.hasNext()) {
            final long chunkIndex = iterator.nextLong();
            chunkFutures[i++] = world.getChunkStore().getChunkReferenceAsync(chunkIndex).thenApplyAsync(v -> {
                if (v == null || !v.isValid()) {
                    return null;
                }
                else {
                    final WorldChunk wc = v.getStore().getComponent(v, WorldChunk.getComponentType());
                    if (!Player.$assertionsDisabled && wc == null) {
                        throw new AssertionError();
                    }
                    else {
                        wc.addKeepLoaded();
                        return (WorldChunk)(WorldChunk)wc;
                    }
                }
            }, (Executor)world);
        }
        return CompletableFuture.allOf((CompletableFuture<?>[])chunkFutures).thenApplyAsync(v -> {
            final Vector3d pos = ensureNoCollisionAtRespawnPosition(respawnPoint, boundingBox, world);
            if (pos != null) {
                return new Transform(pos, Vector3f.ZERO);
            }
            else {
                playerComponent.sendMessage(Message.translation("server.general.respawnPointObstructed").param("respawnPointName", respawnPoint.getName()));
                return null;
            }
        }, (Executor)world).whenComplete((unused, throwable) -> {
            for (final CompletableFuture<WorldChunk> future : chunkFutures) {
                future.thenAccept(WorldChunk::removeKeepLoaded);
            }
        }).thenCompose(v -> {
            if (v != null) {
                return CompletableFuture.completedFuture(v);
            }
            else {
                return tryUseSpawnPoint(world, sortedRespawnPoints, index + 1, ref, playerComponent, boundingBox);
            }
        });
    }
    
    @Nullable
    private static Vector3d ensureNoCollisionAtRespawnPosition(final PlayerRespawnPointData playerRespawnPointData, final Box playerHitbox, final World world) {
        final Vector3d respawnPosition = new Vector3d(playerRespawnPointData.getRespawnPosition());
        if (CollisionModule.get().validatePosition(world, playerHitbox, respawnPosition, new CollisionResult()) != -1) {
            return respawnPosition;
        }
        respawnPosition.x = playerRespawnPointData.getBlockPosition().x + 0.5f;
        respawnPosition.y = playerRespawnPointData.getBlockPosition().y;
        respawnPosition.z = playerRespawnPointData.getBlockPosition().z + 0.5f;
        for (int distance = 1; distance <= 2; ++distance) {
            for (int offset = -distance; offset <= distance; ++offset) {
                Vector3d newPosition = new Vector3d(respawnPosition.x + offset, respawnPosition.y, respawnPosition.z - distance);
                if (CollisionModule.get().validatePosition(world, playerHitbox, newPosition, new CollisionResult()) != -1) {
                    return newPosition;
                }
                newPosition = new Vector3d(respawnPosition.x + offset, respawnPosition.y, respawnPosition.z + distance);
                if (CollisionModule.get().validatePosition(world, playerHitbox, newPosition, new CollisionResult()) != -1) {
                    return newPosition;
                }
            }
            for (int offset = -distance + 1; offset < distance; ++offset) {
                Vector3d newPosition = new Vector3d(respawnPosition.x - distance, respawnPosition.y, respawnPosition.z + offset);
                if (CollisionModule.get().validatePosition(world, playerHitbox, newPosition, new CollisionResult()) != -1) {
                    return newPosition;
                }
                newPosition = new Vector3d(respawnPosition.x + distance, respawnPosition.y, respawnPosition.z + offset);
                if (CollisionModule.get().validatePosition(world, playerHitbox, newPosition, new CollisionResult()) != -1) {
                    return newPosition;
                }
            }
        }
        return null;
    }
    
    public boolean hasSpawnProtection() {
        return System.nanoTime() - this.lastSpawnTimeNanos <= Player.RESPAWN_INVULNERABILITY_TIME_NANOS || this.waitingForClientReady.get() != null;
    }
    
    public boolean isWaitingForClientReady() {
        return this.waitingForClientReady.get() != null;
    }
    
    @Override
    public boolean isHiddenFromLivingEntity(@Nonnull final Ref<EntityStore> ref, @Nonnull final Ref<EntityStore> targetRef, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        final UUIDComponent uuidComponent = componentAccessor.getComponent(ref, UUIDComponent.getComponentType());
        assert uuidComponent != null;
        final PlayerRef targetPlayerComponent = componentAccessor.getComponent(targetRef, PlayerRef.getComponentType());
        return targetPlayerComponent != null && targetPlayerComponent.getHiddenPlayersManager().isPlayerHidden(uuidComponent.getUuid());
    }
    
    public void setClientViewRadius(final int clientViewRadius) {
        this.clientViewRadius = clientViewRadius;
    }
    
    public int getClientViewRadius() {
        return this.clientViewRadius;
    }
    
    public int getViewRadius() {
        return Math.min(this.clientViewRadius, HytaleServer.get().getConfig().getMaxViewRadius());
    }
    
    @Override
    public boolean canDecreaseItemStackDurability(@Nonnull final Ref<EntityStore> ref, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        final Player playerComponent = componentAccessor.getComponent(ref, getComponentType());
        assert playerComponent != null;
        return playerComponent.gameMode != GameMode.Creative;
    }
    
    @Override
    public boolean canApplyItemStackPenalties(@Nonnull final Ref<EntityStore> ref, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        final Player playerComponent = componentAccessor.getComponent(ref, getComponentType());
        assert playerComponent != null;
        return playerComponent.gameMode != GameMode.Creative;
    }
    
    @Nullable
    @Override
    public ItemStackSlotTransaction updateItemStackDurability(@Nonnull final Ref<EntityStore> ref, @Nonnull final ItemStack itemStack, final ItemContainer container, final int slotId, final double durabilityChange, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        final ItemStackSlotTransaction transaction = super.updateItemStackDurability(ref, itemStack, container, slotId, durabilityChange, componentAccessor);
        if (transaction != null && transaction.getSlotAfter().isBroken() && !itemStack.isBroken()) {
            final Message itemNameMessage = Message.translation(itemStack.getItem().getTranslationKey());
            this.sendMessage(Message.translation("server.general.repair.itemBroken").param("itemName", itemNameMessage).color("#ff5555"));
            final PlayerRef playerRefComponent = componentAccessor.getComponent(ref, PlayerRef.getComponentType());
            assert playerRefComponent != null;
            final int soundEventIndex = TempAssetIdUtil.getSoundEventIndex("SFX_Item_Break");
            SoundUtil.playSoundEvent2dToPlayer(playerRefComponent, soundEventIndex, SoundCategory.SFX);
        }
        return transaction;
    }
    
    @Nonnull
    @Override
    public MetricResults toMetricResults() {
        return Player.METRICS_REGISTRY.toMetricResults(this);
    }
    
    public void setLastSpawnTimeNanos(final long lastSpawnTimeNanos) {
        this.lastSpawnTimeNanos = lastSpawnTimeNanos;
    }
    
    public long getSinceLastSpawnNanos() {
        return System.nanoTime() - this.lastSpawnTimeNanos;
    }
    
    @Deprecated(forRemoval = true)
    public PlayerRef getPlayerRef() {
        return this.playerRef;
    }
    
    public int getMountEntityId() {
        return this.mountEntityId;
    }
    
    public void setMountEntityId(final int mountEntityId) {
        this.mountEntityId = mountEntityId;
    }
    
    public GameMode getGameMode() {
        return this.gameMode;
    }
    
    public static void setGameMode(@Nonnull final Ref<EntityStore> playerRef, @Nonnull final GameMode gameMode, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        final MovementManager movementManagerComponent = componentAccessor.getComponent(playerRef, MovementManager.getComponentType());
        assert movementManagerComponent != null;
        final Player playerComponent = componentAccessor.getComponent(playerRef, getComponentType());
        assert playerComponent != null;
        final GameMode oldGameMode = playerComponent.gameMode;
        if (oldGameMode != gameMode) {
            final ChangeGameModeEvent event = new ChangeGameModeEvent(gameMode);
            componentAccessor.invoke(playerRef, event);
            if (event.isCancelled()) {
                return;
            }
            setGameModeInternal(playerRef, event.getGameMode(), movementManagerComponent, componentAccessor);
            runOnSwitchToGameMode(playerRef, gameMode);
        }
    }
    
    public static void initGameMode(@Nonnull final Ref<EntityStore> playerRef, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        final MovementManager movementManagerComponent = componentAccessor.getComponent(playerRef, MovementManager.getComponentType());
        assert movementManagerComponent != null;
        final Player playerComponent = componentAccessor.getComponent(playerRef, getComponentType());
        assert playerComponent != null;
        GameMode gameMode = playerComponent.gameMode;
        if (gameMode == null) {
            final World world = componentAccessor.getExternalData().getWorld();
            gameMode = world.getWorldConfig().getGameMode();
            Player.LOGGER.at(Level.INFO).log("Assigning default gamemode %s to player!", gameMode);
        }
        setGameModeInternal(playerRef, gameMode, movementManagerComponent, componentAccessor);
    }
    
    private static void setGameModeInternal(@Nonnull final Ref<EntityStore> playerRef, @Nonnull final GameMode gameMode, @Nonnull final MovementManager movementManager, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        final Player playerComponent = componentAccessor.getComponent(playerRef, getComponentType());
        assert playerComponent != null;
        final PlayerRef playerRefComponent = componentAccessor.getComponent(playerRef, PlayerRef.getComponentType());
        assert playerRefComponent != null;
        final GameMode oldGameMode = playerComponent.gameMode;
        playerComponent.gameMode = gameMode;
        playerRefComponent.getPacketHandler().writeNoCache(new SetGameMode(gameMode));
        if (movementManager.getDefaultSettings() != null) {
            movementManager.getDefaultSettings().canFly = (gameMode == GameMode.Creative);
            movementManager.getSettings().canFly = (gameMode == GameMode.Creative);
            movementManager.update(playerRefComponent.getPacketHandler());
        }
        final PermissionsModule permissionsModule = PermissionsModule.get();
        if (oldGameMode != null) {
            final GameModeType oldGameModeType = GameModeType.fromGameMode(oldGameMode);
            for (final String group : oldGameModeType.getPermissionGroups()) {
                permissionsModule.removeUserFromGroup(playerRefComponent.getUuid(), group);
            }
        }
        final GameModeType gameModeType = GameModeType.fromGameMode(gameMode);
        for (final String group : gameModeType.getPermissionGroups()) {
            permissionsModule.addUserToGroup(playerRefComponent.getUuid(), group);
        }
        if (gameMode == GameMode.Creative) {
            componentAccessor.putComponent(playerRef, Invulnerable.getComponentType(), Invulnerable.INSTANCE);
        }
        else {
            componentAccessor.tryRemoveComponent(playerRef, Invulnerable.getComponentType());
        }
        if (gameMode == GameMode.Creative) {
            PlayerSettings settings = componentAccessor.getComponent(playerRef, PlayerSettings.getComponentType());
            if (settings == null) {
                settings = PlayerSettings.defaults();
            }
            if (settings.creativeSettings().respondToHit()) {
                componentAccessor.putComponent(playerRef, RespondToHit.getComponentType(), RespondToHit.INSTANCE);
            }
            else {
                componentAccessor.tryRemoveComponent(playerRef, RespondToHit.getComponentType());
            }
        }
        else {
            componentAccessor.tryRemoveComponent(playerRef, RespondToHit.getComponentType());
        }
        final World world = componentAccessor.getExternalData().getWorld();
        playerComponent.worldMapTracker.sendSettings(world);
    }
    
    private static void runOnSwitchToGameMode(@Nonnull final Ref<EntityStore> ref, @Nonnull final GameMode gameMode) {
        final Store<EntityStore> store = ref.getStore();
        final GameModeType gameModeType = GameModeType.fromGameMode(gameMode);
        final InteractionManager interactionManagerComponent = store.getComponent(ref, InteractionModule.get().getInteractionManagerComponent());
        if (interactionManagerComponent == null) {
            return;
        }
        final String interactions = gameModeType.getInteractionsOnEnter();
        if (interactions == null) {
            return;
        }
        final InteractionContext context = InteractionContext.forInteraction(interactionManagerComponent, ref, InteractionType.GameModeSwap, store);
        final RootInteraction rootInteraction = RootInteraction.getRootInteractionOrUnknown(interactions);
        if (rootInteraction == null) {
            return;
        }
        final InteractionChain chain = interactionManagerComponent.initChain(InteractionType.EntityStatEffect, context, rootInteraction, true);
        interactionManagerComponent.queueExecuteChain(chain);
    }
    
    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + ((this.getUuid() != null) ? this.getUuid().hashCode() : 0);
        return result;
    }
    
    @Override
    public boolean equals(@Nullable final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || this.getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        final Player player = (Player)o;
        return (this.getUuid() != null) ? this.getUuid().equals(player.getUuid()) : (player.getUuid() == null);
    }
    
    @Nonnull
    @Override
    public String toString() {
        return "Player{uuid=" + String.valueOf(this.getUuid()) + ", clientViewRadius='" + this.clientViewRadius + "', " + super.toString();
    }
    
    @Override
    public String getDisplayName() {
        return this.playerRef.getUsername();
    }
    
    static {
        // 
        // This method could not be decompiled.
        // 
        // Original Bytecode:
        // 
        //     2: invokevirtual   java/lang/Class.desiredAssertionStatus:()Z
        //     5: ifne            12
        //     8: iconst_1       
        //     9: goto            13
        //    12: iconst_0       
        //    13: putstatic       com/hypixel/hytale/server/core/entity/entities/Player.$assertionsDisabled:Z
        //    16: new             Lcom/hypixel/hytale/metrics/MetricsRegistry;
        //    19: dup            
        //    20: invokespecial   com/hypixel/hytale/metrics/MetricsRegistry.<init>:()V
        //    23: ldc_w           "Uuid"
        //    26: invokedynamic   BootstrapMethod #12, apply:()Ljava/util/function/Function;
        //    31: getstatic       com/hypixel/hytale/codec/Codec.UUID_STRING:Lcom/hypixel/hytale/codec/function/FunctionCodec;
        //    34: invokevirtual   com/hypixel/hytale/metrics/MetricsRegistry.register:(Ljava/lang/String;Ljava/util/function/Function;Lcom/hypixel/hytale/codec/Codec;)Lcom/hypixel/hytale/metrics/MetricsRegistry;
        //    37: ldc_w           "ClientViewRadius"
        //    40: invokedynamic   BootstrapMethod #13, apply:()Ljava/util/function/Function;
        //    45: getstatic       com/hypixel/hytale/codec/Codec.INTEGER:Lcom/hypixel/hytale/codec/codecs/simple/IntegerCodec;
        //    48: invokevirtual   com/hypixel/hytale/metrics/MetricsRegistry.register:(Ljava/lang/String;Ljava/util/function/Function;Lcom/hypixel/hytale/codec/Codec;)Lcom/hypixel/hytale/metrics/MetricsRegistry;
        //    51: putstatic       com/hypixel/hytale/server/core/entity/entities/Player.METRICS_REGISTRY:Lcom/hypixel/hytale/metrics/MetricsRegistry;
        //    54: new             Lcom/hypixel/hytale/codec/KeyedCodec;
        //    57: dup            
        //    58: ldc_w           "PlayerData"
        //    61: getstatic       com/hypixel/hytale/server/core/entity/entities/player/data/PlayerConfigData.CODEC:Lcom/hypixel/hytale/codec/builder/BuilderCodec;
        //    64: invokespecial   com/hypixel/hytale/codec/KeyedCodec.<init>:(Ljava/lang/String;Lcom/hypixel/hytale/codec/Codec;)V
        //    67: putstatic       com/hypixel/hytale/server/core/entity/entities/Player.PLAYER_CONFIG_DATA:Lcom/hypixel/hytale/codec/KeyedCodec;
        //    70: ldc             Lcom/hypixel/hytale/server/core/entity/entities/Player;.class
        //    72: invokedynamic   BootstrapMethod #14, get:()Ljava/util/function/Supplier;
        //    77: getstatic       com/hypixel/hytale/server/core/entity/LivingEntity.CODEC:Lcom/hypixel/hytale/codec/builder/BuilderCodec;
        //    80: invokestatic    com/hypixel/hytale/codec/builder/BuilderCodec.builder:(Ljava/lang/Class;Ljava/util/function/Supplier;Lcom/hypixel/hytale/codec/builder/BuilderCodec;)Lcom/hypixel/hytale/codec/builder/BuilderCodec$Builder;
        //    83: getstatic       com/hypixel/hytale/server/core/entity/entities/Player.PLAYER_CONFIG_DATA:Lcom/hypixel/hytale/codec/KeyedCodec;
        //    86: invokedynamic   BootstrapMethod #15, accept:()Ljava/util/function/BiConsumer;
        //    91: invokedynamic   BootstrapMethod #16, apply:()Ljava/util/function/Function;
        //    96: invokevirtual   com/hypixel/hytale/codec/builder/BuilderCodec$Builder.append:(Lcom/hypixel/hytale/codec/KeyedCodec;Ljava/util/function/BiConsumer;Ljava/util/function/Function;)Lcom/hypixel/hytale/codec/builder/BuilderField$FieldBuilder;
        //    99: invokevirtual   com/hypixel/hytale/codec/builder/BuilderField$FieldBuilder.add:()Lcom/hypixel/hytale/codec/builder/BuilderCodec$BuilderBase;
        //   102: checkcast       Lcom/hypixel/hytale/codec/builder/BuilderCodec$Builder;
        //   105: new             Lcom/hypixel/hytale/codec/KeyedCodec;
        //   108: dup            
        //   109: ldc_w           "BlockPlacementOverride"
        //   112: getstatic       com/hypixel/hytale/codec/Codec.BOOLEAN:Lcom/hypixel/hytale/codec/codecs/simple/BooleanCodec;
        //   115: invokespecial   com/hypixel/hytale/codec/KeyedCodec.<init>:(Ljava/lang/String;Lcom/hypixel/hytale/codec/Codec;)V
        //   118: invokedynamic   BootstrapMethod #17, accept:()Ljava/util/function/BiConsumer;
        //   123: invokedynamic   BootstrapMethod #18, apply:()Ljava/util/function/Function;
        //   128: invokevirtual   com/hypixel/hytale/codec/builder/BuilderCodec$Builder.append:(Lcom/hypixel/hytale/codec/KeyedCodec;Ljava/util/function/BiConsumer;Ljava/util/function/Function;)Lcom/hypixel/hytale/codec/builder/BuilderField$FieldBuilder;
        //   131: invokevirtual   com/hypixel/hytale/codec/builder/BuilderField$FieldBuilder.add:()Lcom/hypixel/hytale/codec/builder/BuilderCodec$BuilderBase;
        //   134: checkcast       Lcom/hypixel/hytale/codec/builder/BuilderCodec$Builder;
        //   137: new             Lcom/hypixel/hytale/codec/KeyedCodec;
        //   140: dup            
        //   141: ldc_w           "HotbarManager"
        //   144: getstatic       com/hypixel/hytale/server/core/entity/entities/player/HotbarManager.CODEC:Lcom/hypixel/hytale/codec/builder/BuilderCodec;
        //   147: invokespecial   com/hypixel/hytale/codec/KeyedCodec.<init>:(Ljava/lang/String;Lcom/hypixel/hytale/codec/Codec;)V
        //   150: invokedynamic   BootstrapMethod #19, accept:()Ljava/util/function/BiConsumer;
        //   155: invokedynamic   BootstrapMethod #20, apply:()Ljava/util/function/Function;
        //   160: invokevirtual   com/hypixel/hytale/codec/builder/BuilderCodec$Builder.append:(Lcom/hypixel/hytale/codec/KeyedCodec;Ljava/util/function/BiConsumer;Ljava/util/function/Function;)Lcom/hypixel/hytale/codec/builder/BuilderField$FieldBuilder;
        //   163: invokevirtual   com/hypixel/hytale/codec/builder/BuilderField$FieldBuilder.add:()Lcom/hypixel/hytale/codec/builder/BuilderCodec$BuilderBase;
        //   166: checkcast       Lcom/hypixel/hytale/codec/builder/BuilderCodec$Builder;
        //   169: new             Lcom/hypixel/hytale/codec/KeyedCodec;
        //   172: dup            
        //   173: ldc_w           "GameMode"
        //   176: getstatic       com/hypixel/hytale/server/core/codec/ProtocolCodecs.GAMEMODE_LEGACY:Lcom/hypixel/hytale/codec/codecs/EnumCodec;
        //   179: invokespecial   com/hypixel/hytale/codec/KeyedCodec.<init>:(Ljava/lang/String;Lcom/hypixel/hytale/codec/Codec;)V
        //   182: invokedynamic   BootstrapMethod #21, accept:()Ljava/util/function/BiConsumer;
        //   187: invokedynamic   BootstrapMethod #22, apply:()Ljava/util/function/Function;
        //   192: invokedynamic   BootstrapMethod #23, accept:()Ljava/util/function/BiConsumer;
        //   197: invokevirtual   com/hypixel/hytale/codec/builder/BuilderCodec$Builder.appendInherited:(Lcom/hypixel/hytale/codec/KeyedCodec;Ljava/util/function/BiConsumer;Ljava/util/function/Function;Ljava/util/function/BiConsumer;)Lcom/hypixel/hytale/codec/builder/BuilderField$FieldBuilder;
        //   200: ldc_w           "The last known game-mode of the entity."
        //   203: invokevirtual   com/hypixel/hytale/codec/builder/BuilderField$FieldBuilder.documentation:(Ljava/lang/String;)Lcom/hypixel/hytale/codec/builder/BuilderField$FieldBuilder;
        //   206: invokevirtual   com/hypixel/hytale/codec/builder/BuilderField$FieldBuilder.add:()Lcom/hypixel/hytale/codec/builder/BuilderCodec$BuilderBase;
        //   209: checkcast       Lcom/hypixel/hytale/codec/builder/BuilderCodec$Builder;
        //   212: invokevirtual   com/hypixel/hytale/codec/builder/BuilderCodec$Builder.build:()Lcom/hypixel/hytale/codec/builder/BuilderCodec;
        //   215: putstatic       com/hypixel/hytale/server/core/entity/entities/Player.CODEC:Lcom/hypixel/hytale/codec/builder/BuilderCodec;
        //   218: getstatic       java/util/concurrent/TimeUnit.MILLISECONDS:Ljava/util/concurrent/TimeUnit;
        //   221: ldc2_w          3000
        //   224: invokevirtual   java/util/concurrent/TimeUnit.toNanos:(J)J
        //   227: putstatic       com/hypixel/hytale/server/core/entity/entities/Player.RESPAWN_INVULNERABILITY_TIME_NANOS:J
        //   230: iconst_2       
        //   231: anewarray       [D
        //   234: dup            
        //   235: iconst_0       
        //   236: iconst_1       
        //   237: newarray        D
        //   239: dup            
        //   240: iconst_0       
        //   241: dconst_1       
        //   242: dastore        
        //   243: aastore        
        //   244: dup            
        //   245: iconst_1       
        //   246: iconst_2       
        //   247: newarray        D
        //   249: dup            
        //   250: iconst_0       
        //   251: ldc2_w          0.9
        //   254: dastore        
        //   255: dup            
        //   256: iconst_1       
        //   257: ldc2_w          0.1
        //   260: dastore        
        //   261: aastore        
        //   262: putstatic       com/hypixel/hytale/server/core/entity/entities/Player.velocitySampleWeights:[[D
        //   265: return         
        //    StackMapTable: 00 02 0C 40 01
        // 
        // The error that occurred was:
        // 
        // java.lang.UnsupportedOperationException: The requested operation is not supported.
        //     at com.strobel.util.ContractUtils.unsupported(ContractUtils.java:27)
        //     at com.strobel.assembler.metadata.TypeReference.getRawType(TypeReference.java:284)
        //     at com.strobel.assembler.metadata.TypeReference.getRawType(TypeReference.java:279)
        //     at com.strobel.assembler.metadata.TypeReference.makeGenericType(TypeReference.java:154)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visitParameterizedType(TypeSubstitutionVisitor.java:225)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visitParameterizedType(TypeSubstitutionVisitor.java:25)
        //     at com.strobel.assembler.metadata.ParameterizedType.accept(ParameterizedType.java:103)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visit(TypeSubstitutionVisitor.java:40)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visitParameterizedType(TypeSubstitutionVisitor.java:211)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visitParameterizedType(TypeSubstitutionVisitor.java:25)
        //     at com.strobel.assembler.metadata.ParameterizedType.accept(ParameterizedType.java:103)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visit(TypeSubstitutionVisitor.java:40)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visitMethod(TypeSubstitutionVisitor.java:314)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferCall(TypeAnalysis.java:2611)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1040)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:790)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferCall(TypeAnalysis.java:2689)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1040)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:782)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:778)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1510)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:790)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferCall(TypeAnalysis.java:2689)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1040)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:790)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferCall(TypeAnalysis.java:2689)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1040)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:790)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferCall(TypeAnalysis.java:2689)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1040)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:782)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:778)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1510)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:790)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferCall(TypeAnalysis.java:2689)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1040)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:782)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:778)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1083)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.runInference(TypeAnalysis.java:684)
        //     at com.strobel.decompiler.ast.TypeAnalysis.runInference(TypeAnalysis.java:667)
        //     at com.strobel.decompiler.ast.TypeAnalysis.runInference(TypeAnalysis.java:373)
        //     at com.strobel.decompiler.ast.TypeAnalysis.run(TypeAnalysis.java:95)
        //     at com.strobel.decompiler.ast.AstOptimizer.optimize(AstOptimizer.java:344)
        //     at com.strobel.decompiler.ast.AstOptimizer.optimize(AstOptimizer.java:42)
        //     at com.strobel.decompiler.languages.java.ast.AstMethodBodyBuilder.createMethodBody(AstMethodBodyBuilder.java:206)
        //     at com.strobel.decompiler.languages.java.ast.AstMethodBodyBuilder.createMethodBody(AstMethodBodyBuilder.java:93)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createMethodBody(AstBuilder.java:868)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createMethod(AstBuilder.java:761)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.addTypeMembers(AstBuilder.java:638)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createTypeCore(AstBuilder.java:605)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createTypeNoCache(AstBuilder.java:195)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createType(AstBuilder.java:162)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.addType(AstBuilder.java:137)
        //     at com.strobel.decompiler.languages.java.JavaLanguage.buildAst(JavaLanguage.java:71)
        //     at com.strobel.decompiler.languages.java.JavaLanguage.decompileType(JavaLanguage.java:59)
        //     at com.strobel.decompiler.DecompilerDriver.decompileType(DecompilerDriver.java:333)
        //     at com.strobel.decompiler.DecompilerDriver.decompileJar(DecompilerDriver.java:254)
        //     at com.strobel.decompiler.DecompilerDriver.main(DecompilerDriver.java:129)
        // 
        throw new IllegalStateException("An error occurred while decompiling this method.");
    }
}
