예제 #1
0
        /// <inheritdoc />
        public override void HandleMcpeBlockEntityData(McpeBlockEntityData message)
        {
            var playerPosition = KnownPosition.ToBlockCoordinates();

            if (playerPosition.DistanceTo(message.coordinates) > 1000)
            {
                return;
            }

            var nbt = message.namedtag.NbtFile.RootTag;

            if (nbt is NbtCompound compound)
            {
                var blockEntity = Level.GetBlockEntity(message.coordinates);
                EventDispatcher.DispatchEventAsync(new PlayerSetBlockEntityDataEvent(this, blockEntity, compound)).Then(
                    (result) =>
                {
                    if (result.IsCancelled)
                    {
                        return;
                    }

                    blockEntity.SetCompound(compound);
                    Level.SetBlockEntity(blockEntity);
                });
            }

            //base.HandleMcpeBlockEntityData(message);
        }