├── .clang-format ├── .docker-ubuntu ├── .dockerignore ├── .gitignore ├── .gitmodules ├── Build.json ├── CMakeLists.txt ├── LICENSE ├── Makefile ├── README.md ├── api └── minecpp │ ├── nbt │ ├── block │ │ ├── Block.schema │ │ └── BlockState.schema │ ├── chunk │ │ └── Chunk.schema │ ├── common │ │ └── Common.schema │ ├── item │ │ └── Item.schema │ ├── level │ │ └── Level.schema │ ├── player │ │ └── Player.schema │ ├── repository │ │ ├── Biome.schema │ │ ├── Chat.schema │ │ ├── Damage.schema │ │ ├── Dimension.schema │ │ ├── Registry.schema │ │ ├── Repository.schema │ │ └── Trim.schema │ └── trace │ │ └── Trace.schema │ └── net │ ├── Chunk.schema │ ├── Common.schema │ ├── engine │ ├── Clientbound.schema │ └── Serverbound.schema │ ├── login │ ├── Clientbound.schema │ └── Serverbound.schema │ ├── play │ ├── Clientbound.schema │ └── Serverbound.schema │ ├── status │ ├── Clientbound.schema │ └── Serverbound.schema │ └── storage │ ├── Clientbound.schema │ └── Serverbound.schema ├── clusterfile-docker ├── clusterfile-local ├── docker-compose.yml ├── docker ├── Core.Dockerfile ├── Engine.Dockerfile ├── Front.Dockerfile ├── Storage.Dockerfile ├── Ubuntu.Dockerfile ├── fdb │ ├── .env │ └── docker-compose.yml └── init_database.sh ├── docs └── InternalDesign.md ├── gameplay.png ├── library ├── CMakeLists.txt ├── api │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ ├── nbt │ │ │ ├── block │ │ │ │ ├── Block.schema.h │ │ │ │ └── BlockState.schema.h │ │ │ ├── chunk │ │ │ │ └── Chunk.schema.h │ │ │ ├── common │ │ │ │ └── Common.schema.h │ │ │ ├── item │ │ │ │ └── Item.schema.h │ │ │ ├── level │ │ │ │ └── Level.schema.h │ │ │ ├── player │ │ │ │ └── Player.schema.h │ │ │ ├── repository │ │ │ │ ├── Biome.schema.h │ │ │ │ ├── Chat.schema.h │ │ │ │ ├── Damage.schema.h │ │ │ │ ├── Dimension.schema.h │ │ │ │ ├── Registry.schema.h │ │ │ │ ├── Repository.schema.h │ │ │ │ └── Trim.schema.h │ │ │ └── trace │ │ │ │ └── Trace.schema.h │ │ │ └── net │ │ │ ├── Chunk.schema.h │ │ │ ├── Common.schema.h │ │ │ ├── engine │ │ │ ├── Clientbound.schema.h │ │ │ └── Serverbound.schema.h │ │ │ ├── login │ │ │ ├── Clientbound.schema.h │ │ │ └── Serverbound.schema.h │ │ │ ├── play │ │ │ ├── Clientbound.schema.h │ │ │ ├── Common.schema.h │ │ │ └── Serverbound.schema.h │ │ │ ├── status │ │ │ ├── Clientbound.schema.h │ │ │ └── Serverbound.schema.h │ │ │ └── storage │ │ │ ├── Clientbound.schema.h │ │ │ └── Serverbound.schema.h │ └── src │ │ ├── CMakeLists.txt │ │ ├── nbt │ │ ├── CMakeLists.txt │ │ ├── block │ │ │ ├── Block.schema.cpp │ │ │ ├── BlockState.schema.cpp │ │ │ └── CMakeLists.txt │ │ ├── chunk │ │ │ ├── CMakeLists.txt │ │ │ └── Chunk.schema.cpp │ │ ├── common │ │ │ ├── CMakeLists.txt │ │ │ └── Common.schema.cpp │ │ ├── item │ │ │ ├── CMakeLists.txt │ │ │ └── Item.schema.cpp │ │ ├── level │ │ │ ├── CMakeLists.txt │ │ │ └── Level.schema.cpp │ │ ├── player │ │ │ ├── CMakeLists.txt │ │ │ └── Player.schema.cpp │ │ ├── repository │ │ │ ├── Biome.schema.cpp │ │ │ ├── CMakeLists.txt │ │ │ ├── Chat.schema.cpp │ │ │ ├── Damage.schema.cpp │ │ │ ├── Dimension.schema.cpp │ │ │ ├── Registry.schema.cpp │ │ │ ├── Repository.schema.cpp │ │ │ └── Trim.schema.cpp │ │ └── trace │ │ │ ├── CMakeLists.txt │ │ │ └── Trace.schema.cpp │ │ └── net │ │ ├── CMakeLists.txt │ │ ├── Chunk.schema.cpp │ │ ├── Common.schema.cpp │ │ ├── engine │ │ ├── CMakeLists.txt │ │ ├── Clientbound.schema.cpp │ │ └── Serverbound.schema.cpp │ │ ├── login │ │ ├── CMakeLists.txt │ │ ├── Clientbound.schema.cpp │ │ └── Serverbound.schema.cpp │ │ ├── play │ │ ├── CMakeLists.txt │ │ ├── Clientbound.schema.cpp │ │ ├── Common.schema.cpp │ │ └── Serverbound.schema.cpp │ │ ├── status │ │ ├── CMakeLists.txt │ │ ├── Clientbound.schema.cpp │ │ └── Serverbound.schema.cpp │ │ └── storage │ │ ├── CMakeLists.txt │ │ ├── Clientbound.schema.cpp │ │ └── Serverbound.schema.cpp ├── chat │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── chat │ │ │ ├── Chat.h │ │ │ └── Parser.h │ └── src │ │ ├── CMakeLists.txt │ │ ├── Chat.cpp │ │ └── Parser.cpp ├── command │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── command │ │ │ ├── Command.h │ │ │ ├── CommandManager.h │ │ │ ├── Object.h │ │ │ ├── Parser.h │ │ │ ├── Result.h │ │ │ ├── RuntimeContext.h │ │ │ ├── StandardStream.h │ │ │ ├── ast │ │ │ └── Ast.h │ │ │ └── core │ │ │ ├── Cord.h │ │ │ ├── Core.h │ │ │ ├── DecimateBlocks.h │ │ │ ├── Echo.h │ │ │ ├── Fly.h │ │ │ ├── Format.h │ │ │ ├── Give.h │ │ │ ├── KillAll.h │ │ │ ├── ListEntities.h │ │ │ ├── ReloadChunk.h │ │ │ ├── Spawn.h │ │ │ ├── Sync.h │ │ │ └── Teleport.h │ ├── src │ │ ├── CMakeLists.txt │ │ ├── Command.cpp │ │ ├── CommandManager.cpp │ │ ├── Object.cpp │ │ ├── Parser.cpp │ │ ├── RuntimeContext.cpp │ │ ├── StandardStream.cpp │ │ ├── ast │ │ │ ├── CMakeLists.txt │ │ │ └── Command.cpp │ │ └── core │ │ │ ├── CMakeLists.txt │ │ │ ├── Cord.cpp │ │ │ ├── Core.cpp │ │ │ ├── DecimateBlocks.cpp │ │ │ ├── Echo.cpp │ │ │ ├── Fly.cpp │ │ │ ├── Format.cpp │ │ │ ├── Give.cpp │ │ │ ├── KillAll.cpp │ │ │ ├── ListEntities.cpp │ │ │ ├── ReloadChunk.cpp │ │ │ ├── Spawn.cpp │ │ │ ├── Sync.cpp │ │ │ └── Teleport.cpp │ └── test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ ├── CMakeLists.txt │ │ └── CommandTest.cpp ├── container │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── container │ │ │ ├── BasicBuffer.hpp │ │ │ ├── BasicBufferView.hpp │ │ │ ├── PalettedVector.h │ │ │ ├── Queue.h │ │ │ ├── TightArray.h │ │ │ └── TightVector.h │ ├── src │ │ ├── CMakeLists.txt │ │ └── TightVector.cpp │ └── test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ ├── BufferTest.cpp │ │ ├── CMakeLists.txt │ │ ├── PalettedVectorTest.cpp │ │ ├── QueueTest.cpp │ │ ├── TightArrayTest.cpp │ │ └── TightVectorTest.cpp ├── controller │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── controller │ │ │ ├── BlockManager.h │ │ │ ├── RootItem.h │ │ │ ├── block │ │ │ ├── Block.h │ │ │ ├── Default.h │ │ │ ├── Door.h │ │ │ ├── Fence.h │ │ │ ├── Foliage.h │ │ │ ├── Grass.h │ │ │ ├── Slab.h │ │ │ ├── Stairs.h │ │ │ ├── Torch.h │ │ │ ├── TrapDoor.h │ │ │ └── Wood.h │ │ │ └── item │ │ │ ├── Bow.h │ │ │ ├── Default.h │ │ │ ├── Food.h │ │ │ ├── Item.h │ │ │ └── Sword.h │ ├── src │ │ ├── BlockManager.cpp │ │ ├── CMakeLists.txt │ │ ├── RootItem.cpp │ │ ├── block │ │ │ ├── Block.cpp │ │ │ ├── CMakeLists.txt │ │ │ ├── Default.cpp │ │ │ ├── Door.cpp │ │ │ ├── Fence.cpp │ │ │ ├── Foliage.cpp │ │ │ ├── Grass.cpp │ │ │ ├── Slab.cpp │ │ │ ├── Stairs.cpp │ │ │ ├── Torch.cpp │ │ │ ├── TrapDoor.cpp │ │ │ └── Wood.cpp │ │ └── item │ │ │ ├── Bow.cpp │ │ │ ├── CMakeLists.txt │ │ │ ├── Default.cpp │ │ │ ├── Food.cpp │ │ │ ├── Item.cpp │ │ │ └── Sword.cpp │ └── template │ │ ├── BlockController.cpp.template │ │ └── BlockController.h.template ├── crypto │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── crypto │ │ │ ├── AESKey.h │ │ │ ├── Error.h │ │ │ └── Key.h │ ├── src │ │ ├── AESKey.cpp │ │ ├── CMakeLists.txt │ │ └── Key.cpp │ └── test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ ├── key.pem │ │ └── src │ │ ├── AesTest.cpp │ │ ├── CMakeLists.txt │ │ └── RsaTest.cpp ├── debug │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── debug │ │ │ └── TraceManager.h │ ├── src │ │ ├── CMakeLists.txt │ │ └── TraceManager.cpp │ └── test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ ├── CMakeLists.txt │ │ └── TraceTest.cpp ├── entity │ ├── Build.json │ ├── CMakeLists.txt │ ├── README.md │ ├── include │ │ └── minecpp │ │ │ └── entity │ │ │ ├── Aliases.hpp │ │ │ ├── EntitySystem.h │ │ │ ├── component │ │ │ ├── Abilities.h │ │ │ ├── DealthScreen.h │ │ │ ├── Health.h │ │ │ ├── Inventory.h │ │ │ ├── ItemSlot.h │ │ │ ├── Location.h │ │ │ ├── Player.h │ │ │ ├── Projectile.h │ │ │ ├── Streamer.h │ │ │ ├── Team.h │ │ │ ├── Test.h │ │ │ ├── Ticker.h │ │ │ ├── Totem.h │ │ │ ├── Trader.h │ │ │ ├── UniqueId.h │ │ │ └── Velocity.h │ │ │ └── factory │ │ │ ├── Arrow.h │ │ │ ├── Item.h │ │ │ ├── Player.h │ │ │ ├── Totem.h │ │ │ └── Trader.h │ ├── src │ │ ├── CMakeLists.txt │ │ ├── EntitySpace.cpp │ │ ├── EntitySpace.h │ │ ├── EntitySystem.cpp │ │ ├── component │ │ │ ├── Abilities.cpp │ │ │ ├── CMakeLists.txt │ │ │ ├── DeathScreen.cpp │ │ │ ├── Health.cpp │ │ │ ├── Inventory.cpp │ │ │ ├── ItemSlot.cpp │ │ │ ├── Location.cpp │ │ │ ├── Player.cpp │ │ │ ├── Projectile.cpp │ │ │ ├── Streamer.cpp │ │ │ ├── Team.cpp │ │ │ ├── Test.cpp │ │ │ ├── TickComponent.cpp │ │ │ ├── Totem.cpp │ │ │ ├── Trader.cpp │ │ │ ├── UniqueId.cpp │ │ │ └── Velocity.cpp │ │ └── factory │ │ │ ├── Arrow.cpp │ │ │ ├── CMakeLists.txt │ │ │ ├── Item.cpp │ │ │ ├── Player.cpp │ │ │ ├── Totem.cpp │ │ │ └── Trader.cpp │ └── test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ ├── CMakeLists.txt │ │ └── SpaceTest.cpp ├── format │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── format │ │ │ └── Format.h │ ├── src │ │ ├── CMakeLists.txt │ │ └── Format.cpp │ └── test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ ├── CMakeLists.txt │ │ └── FormatTest.cpp ├── game │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── game │ │ │ ├── Abilities.hpp │ │ │ ├── BlockPosition.h │ │ │ ├── BlockRange.h │ │ │ ├── ChunkPosition.h │ │ │ ├── ChunkRange.h │ │ │ ├── Concepts.hpp │ │ │ ├── Constants.hpp │ │ │ ├── Delegate.hpp │ │ │ ├── Entity.h │ │ │ ├── EntityData.hpp │ │ │ ├── Entt.hpp │ │ │ ├── Game.h │ │ │ ├── Hand.h │ │ │ ├── Health.h │ │ │ ├── IBlockController.hpp │ │ │ ├── IDispatcher.hpp │ │ │ ├── IEntitySystem.hpp │ │ │ ├── IItemController.hpp │ │ │ ├── IWorld.hpp │ │ │ ├── Light.h │ │ │ ├── Mode.h │ │ │ ├── Rules.h │ │ │ ├── SectionPosition.h │ │ │ ├── SectionRange.h │ │ │ ├── State.h │ │ │ ├── Team.h │ │ │ ├── Types.hpp │ │ │ ├── block │ │ │ ├── Block.h │ │ │ ├── Color.h │ │ │ └── Material.h │ │ │ ├── item │ │ │ ├── Item.h │ │ │ └── Recipe.h │ │ │ ├── player │ │ │ ├── Id.h │ │ │ ├── Player.h │ │ │ └── Provider.hpp │ │ │ └── property │ │ │ ├── Direction.h │ │ │ ├── Face.h │ │ │ ├── Half.hpp │ │ │ ├── HalfPlacement.hpp │ │ │ ├── Side.hpp │ │ │ └── SlabType.h │ ├── src │ │ ├── BlockPosition.cpp │ │ ├── BlockRange.cpp │ │ ├── CMakeLists.txt │ │ ├── ChunkPosition.cpp │ │ ├── ChunkRange.cpp │ │ ├── Entity.cpp │ │ ├── Game.cpp │ │ ├── Light.cpp │ │ ├── Rules.cpp │ │ ├── SectionPosition.cpp │ │ ├── SectionRange.cpp │ │ ├── World.cpp │ │ ├── block │ │ │ ├── Block.cpp │ │ │ ├── CMakeLists.txt │ │ │ └── Material.cpp │ │ ├── item │ │ │ ├── CMakeLists.txt │ │ │ ├── Item.cpp │ │ │ └── Recipe.cpp │ │ ├── player │ │ │ ├── CMakeLists.txt │ │ │ └── Player.cpp │ │ └── property │ │ │ ├── CMakeLists.txt │ │ │ ├── Direction.cpp │ │ │ ├── Face.cpp │ │ │ └── SlabType.cpp │ └── test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ ├── CMakeLists.txt │ │ └── PositionTest.cpp ├── lexer │ ├── Build.json │ ├── CMakeLists.txt │ ├── example │ │ └── python │ │ │ ├── Build.json │ │ │ ├── CMakeLists.txt │ │ │ └── src │ │ │ ├── CMakeLists.txt │ │ │ └── Main.cpp │ ├── include │ │ └── minecpp │ │ │ └── lexer │ │ │ ├── Core.h │ │ │ ├── Error.h │ │ │ ├── IReader.h │ │ │ ├── IStreamReader.h │ │ │ ├── Lexer.h │ │ │ ├── Reader.h │ │ │ ├── Token.h │ │ │ └── TokenFeed.h │ └── src │ │ ├── CMakeLists.txt │ │ ├── IStreamReader.cpp │ │ └── Lexer.cpp ├── math │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── math │ │ │ ├── BaseVector.h │ │ │ ├── Math.h │ │ │ ├── Rotation.h │ │ │ ├── Vector2.h │ │ │ └── Vector3.h │ └── test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ ├── CMakeLists.txt │ │ ├── RotationTest.cpp │ │ └── VectorTest.cpp ├── nbt │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── nbt │ │ │ ├── Exception.h │ │ │ ├── Parser.h │ │ │ ├── Reader.h │ │ │ ├── Tag.h │ │ │ └── Writer.h │ ├── src │ │ ├── CMakeLists.txt │ │ ├── Exception.cpp │ │ ├── Parser.cpp │ │ ├── Reader.cpp │ │ ├── Tag.cpp │ │ └── Writer.cpp │ └── test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ ├── CMakeLists.txt │ │ └── NbtTest.cpp ├── network │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── network │ │ │ ├── Chat.h │ │ │ ├── Network.h │ │ │ ├── NetworkUtil.h │ │ │ ├── Result.hpp │ │ │ └── message │ │ │ ├── Io.h │ │ │ ├── Reader.h │ │ │ └── Writer.h │ ├── src │ │ ├── CMakeLists.txt │ │ ├── Chat.cpp │ │ ├── Network.cpp │ │ ├── NetworkUtil.cpp │ │ └── message │ │ │ ├── CMakeLists.txt │ │ │ ├── Reader.cpp │ │ │ └── Writer.cpp │ └── test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ ├── CMakeLists.txt │ │ ├── IpTest.cpp │ │ └── PacketTest.cpp ├── random │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── random │ │ │ ├── IRandom.h │ │ │ ├── JavaRandom.h │ │ │ ├── Mersenne.h │ │ │ ├── Perlin.h │ │ │ └── Perlin3D.h │ ├── src │ │ ├── CMakeLists.txt │ │ ├── JavaRandom.cpp │ │ ├── Mersenne.cpp │ │ ├── Perlin.cpp │ │ └── Perlin3d.cpp │ └── test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ ├── CMakeLists.txt │ │ └── RandomTest.cpp ├── region │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── region │ │ │ └── File.h │ └── src │ │ ├── CMakeLists.txt │ │ └── File.cpp ├── repository │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── repository │ │ │ ├── Block.h │ │ │ ├── Item.h │ │ │ ├── Repository.h │ │ │ └── State.h │ ├── src │ │ ├── Block.cpp │ │ ├── CMakeLists.txt │ │ ├── Item.cpp │ │ └── State.cpp │ └── test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ ├── CMakeLists.txt │ │ └── StateTest.cpp ├── signal │ ├── Build.json │ ├── CMakeLists.txt │ └── include │ │ └── minecpp │ │ └── signal │ │ ├── Delegate.hpp │ │ └── Entt.hpp ├── stream │ ├── Build.json │ ├── CMakeLists.txt │ ├── example │ │ ├── client │ │ │ ├── Build.json │ │ │ ├── CMakeLists.txt │ │ │ └── src │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── Main.cpp │ │ └── server │ │ │ ├── Build.json │ │ │ ├── CMakeLists.txt │ │ │ └── src │ │ │ ├── CMakeLists.txt │ │ │ └── Main.cpp │ ├── include │ │ └── minecpp │ │ │ └── stream │ │ │ ├── Client.h │ │ │ ├── Host.h │ │ │ ├── Peer.h │ │ │ └── Server.h │ └── src │ │ ├── CMakeLists.txt │ │ ├── Client.cpp │ │ ├── Host.cpp │ │ ├── Peer.cpp │ │ └── Server.cpp ├── util │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── util │ │ │ ├── Case.h │ │ │ ├── Cast.hpp │ │ │ ├── Compression.h │ │ │ ├── Concepts.h │ │ │ ├── Context.h │ │ │ ├── Hex.h │ │ │ ├── Loop.h │ │ │ ├── Packed.h │ │ │ ├── Pool.h │ │ │ ├── Reader.h │ │ │ ├── Scriptw.h │ │ │ ├── StaticQueue.h │ │ │ ├── String.h │ │ │ ├── Threading.h │ │ │ ├── Time.h │ │ │ ├── Util.h │ │ │ └── Uuid.h │ ├── src │ │ ├── CMakeLists.txt │ │ ├── Compression.cpp │ │ ├── Context.cpp │ │ ├── File.cpp │ │ ├── Hex.cpp │ │ ├── Loop.cpp │ │ ├── Packed.cpp │ │ ├── Scriptw.cpp │ │ ├── String.cpp │ │ ├── Threading.cpp │ │ ├── Time.cpp │ │ └── Uuid.cpp │ └── test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ ├── CMakeLists.txt │ │ └── UtilsTest.cpp └── world │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ └── minecpp │ │ └── world │ │ ├── BlockState.h │ │ ├── Chunk.h │ │ ├── ChunkSerializer.h │ │ ├── Generator.h │ │ ├── IChunkSystem.h │ │ ├── LightSystem.h │ │ ├── Section.h │ │ ├── SectionSlice.h │ │ ├── TemporaryWorld.h │ │ ├── Util.h │ │ ├── population │ │ ├── Chunk.h │ │ ├── Object.h │ │ ├── Population.h │ │ └── Tree.h │ │ ├── terrain │ │ ├── Height.h │ │ └── Terrain.h │ │ └── testing │ │ └── BlockContainer.h │ ├── src │ ├── BlockState.cpp │ ├── CMakeLists.txt │ ├── Chunk.cpp │ ├── ChunkSerializer.cpp │ ├── Generator.cpp │ ├── LightSystem.cpp │ ├── Section.cpp │ ├── SectionSlice.cpp │ ├── TemporaryWorld.cpp │ ├── Util.cpp │ ├── population │ │ ├── CMakeLists.txt │ │ ├── Chunk.cpp │ │ ├── Object.cpp │ │ ├── Population.cpp │ │ └── Tree.cpp │ ├── terrain │ │ ├── CMakeLists.txt │ │ ├── Height.cpp │ │ └── Terrain.cpp │ └── testing │ │ ├── BlockContainer.cpp │ │ └── CMakeLists.txt │ └── test │ ├── Build.json │ ├── CMakeLists.txt │ └── src │ ├── CMakeLists.txt │ ├── LightTest.cpp │ └── SectionTest.cpp ├── meta ├── cmake-generate-source.sh ├── cmake-generate-target.sh ├── cmake-generate.sh └── run-clang-format.sh ├── registry.bin ├── repository.bin ├── service ├── CMakeLists.txt ├── engine │ ├── Build.json │ ├── CMakeLists.txt │ ├── README.md │ ├── api │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── minecpp │ │ │ │ └── service │ │ │ │ └── engine │ │ │ │ └── Api.h │ │ └── src │ │ │ ├── Api.cpp │ │ │ └── CMakeLists.txt │ ├── config-docker.yaml │ ├── config-local.yaml │ └── src │ │ ├── ApiHandler.cpp │ │ ├── ApiHandler.h │ │ ├── CMakeLists.txt │ │ ├── ChunkSystem.cpp │ │ ├── ChunkSystem.h │ │ ├── Dispatcher.cpp │ │ ├── Dispatcher.h │ │ ├── EventManager.cpp │ │ ├── EventManager.h │ │ ├── IConnection.h │ │ ├── JobSystem.cpp │ │ ├── JobSystem.h │ │ ├── Main.cpp │ │ ├── PlayerManager.cpp │ │ ├── PlayerManager.h │ │ ├── Service.cpp │ │ ├── Service.h │ │ ├── StorageResponseHandler.cpp │ │ ├── StorageResponseHandler.h │ │ ├── TickSystem.cpp │ │ ├── TickSystem.h │ │ ├── World.cpp │ │ ├── World.h │ │ ├── job │ │ ├── CMakeLists.txt │ │ ├── ChangeBlock.cpp │ │ ├── ChangeBlock.h │ │ ├── ChunkIsComplete.cpp │ │ ├── ChunkIsComplete.h │ │ ├── GenerateChunk.cpp │ │ ├── GenerateChunk.h │ │ ├── HandlePlayerMessage.cpp │ │ └── HandlePlayerMessage.h │ │ └── service │ │ ├── CMakeLists.txt │ │ ├── PlayerInteraction.cpp │ │ ├── PlayerInteraction.h │ │ ├── PlayerInterface.cpp │ │ ├── PlayerInterface.h │ │ ├── PlayerMovement.cpp │ │ ├── PlayerMovement.h │ │ ├── PlayerSession.cpp │ │ └── PlayerSession.h ├── front │ ├── Build.json │ ├── CMakeLists.txt │ ├── config-docker.yaml │ ├── config-local.yaml │ └── src │ │ ├── CMakeLists.txt │ │ ├── Config.cpp │ │ ├── Config.h │ │ ├── Connection.cpp │ │ ├── Connection.h │ │ ├── EventHandler.cpp │ │ ├── EventHandler.h │ │ ├── Main.cpp │ │ ├── Server.cpp │ │ ├── Server.h │ │ ├── Service.cpp │ │ ├── Service.h │ │ ├── Ticks.cpp │ │ ├── Ticks.h │ │ └── protocol │ │ ├── CMakeLists.txt │ │ ├── Handler.h │ │ ├── LoginHandler.cpp │ │ ├── LoginHandler.h │ │ ├── PlayHandler.cpp │ │ ├── PlayHandler.h │ │ ├── Protocol.cpp │ │ ├── Protocol.h │ │ ├── StatusHandler.cpp │ │ └── StatusHandler.h └── storage │ ├── Build.json │ ├── CMakeLists.txt │ ├── api │ ├── Build.json │ ├── CMakeLists.txt │ ├── include │ │ └── minecpp │ │ │ └── service │ │ │ └── storage │ │ │ └── Storage.h │ └── src │ │ ├── CMakeLists.txt │ │ └── Storage.cpp │ ├── example │ ├── api_test │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ │ ├── CMakeLists.txt │ │ │ └── Main.cpp │ └── fdb_request │ │ ├── Build.json │ │ ├── CMakeLists.txt │ │ └── src │ │ ├── CMakeLists.txt │ │ └── Main.cpp │ └── src │ ├── CMakeLists.txt │ ├── IHandler.h │ ├── IResponder.h │ ├── IStorage.h │ ├── Main.cpp │ ├── RequestThreadPool.cpp │ ├── RequestThreadPool.h │ ├── Server.cpp │ ├── Server.h │ ├── Service.cpp │ ├── Service.h │ └── fdb │ ├── Buffer.h │ ├── CMakeLists.txt │ ├── Error.cpp │ ├── Error.h │ ├── Fdb.h │ ├── Future.cpp │ ├── Future.h │ ├── Storage.cpp │ ├── Storage.h │ ├── Transaction.cpp │ └── Transaction.h ├── tool ├── CMakeLists.txt ├── chunk_extractor │ ├── Build.json │ ├── CMakeLists.txt │ ├── r.-1.0.mca │ ├── r.0.0.mca │ └── src │ │ ├── CMakeLists.txt │ │ └── Main.cpp ├── chunk_viewer │ ├── Build.json │ ├── CMakeLists.txt │ └── src │ │ ├── CMakeLists.txt │ │ └── Main.cpp ├── nbt_viewer │ ├── Build.json │ ├── CMakeLists.txt │ └── src │ │ ├── CMakeLists.txt │ │ └── Main.cpp ├── nbtscheme │ ├── Build.json │ ├── CMakeLists.txt │ └── src │ │ ├── CMakeLists.txt │ │ └── Main.cpp ├── recipes │ ├── Build.json │ ├── CMakeLists.txt │ └── src │ │ ├── CMakeLists.txt │ │ └── Main.cpp ├── schema_compiler │ ├── Build.json │ ├── CMakeLists.txt │ ├── README.md │ ├── example │ │ ├── nbt_generator │ │ │ ├── Build.json │ │ │ ├── CMakeLists.txt │ │ │ ├── schema │ │ │ │ ├── Example1.schema │ │ │ │ └── Example2.schema │ │ │ └── src │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Example1.schema.cpp │ │ │ │ ├── Example1.schema.h │ │ │ │ ├── Example2.schema.cpp │ │ │ │ ├── Example2.schema.h │ │ │ │ └── Main.cpp │ │ └── net_generator │ │ │ ├── Build.json │ │ │ ├── CMakeLists.txt │ │ │ ├── schema │ │ │ ├── Example1.schema │ │ │ ├── Example2.schema │ │ │ └── ExampleNbt.schema │ │ │ └── src │ │ │ ├── CMakeLists.txt │ │ │ ├── Example1.schema.cpp │ │ │ ├── Example1.schema.h │ │ │ ├── Example2.schema.cpp │ │ │ ├── Example2.schema.h │ │ │ ├── ExampleNbt.schema.cpp │ │ │ ├── ExampleNbt.schema.h │ │ │ └── Main.cpp │ └── src │ │ ├── Ast.cpp │ │ ├── Ast.h │ │ ├── CMakeLists.txt │ │ ├── IGenerator.h │ │ ├── Lexer.cpp │ │ ├── Lexer.h │ │ ├── Main.cpp │ │ ├── Parser.cpp │ │ ├── Parser.h │ │ ├── SymbolTable.cpp │ │ ├── SymbolTable.h │ │ └── generator │ │ ├── CMakeLists.txt │ │ ├── CppUtil.cpp │ │ ├── CppUtil.h │ │ ├── INetworkProperty.hpp │ │ ├── NbtGenerator.cpp │ │ ├── NbtGenerator.h │ │ ├── NetworkBasicProperty.cpp │ │ ├── NetworkBasicProperty.h │ │ ├── NetworkDeserializeContext.cpp │ │ ├── NetworkDeserializeContext.h │ │ ├── NetworkExternProperty.cpp │ │ ├── NetworkExternProperty.h │ │ ├── NetworkGenerator.cpp │ │ ├── NetworkGenerator.h │ │ ├── NetworkListProperty.cpp │ │ ├── NetworkListProperty.h │ │ ├── NetworkMapProperty.cpp │ │ ├── NetworkMapProperty.h │ │ ├── NetworkOptionalProperty.cpp │ │ ├── NetworkOptionalProperty.h │ │ ├── NetworkPropertyStorage.cpp │ │ ├── NetworkPropertyStorage.h │ │ ├── NetworkRecordProperty.cpp │ │ ├── NetworkRecordProperty.h │ │ ├── NetworkSerializeContext.cpp │ │ ├── NetworkSerializeContext.h │ │ ├── NetworkVariantProperty.cpp │ │ └── NetworkVariantProperty.h ├── snbt_parser │ ├── Build.json │ ├── CMakeLists.txt │ └── src │ │ ├── CMakeLists.txt │ │ ├── Lexer.cpp │ │ ├── Lexer.h │ │ ├── Main.cpp │ │ ├── Parser.cpp │ │ ├── Parser.h │ │ └── Token.h └── trace_tool │ ├── Build.json │ ├── CMakeLists.txt │ └── src │ ├── CMakeLists.txt │ └── Main.cpp └── trace.bin /.docker-ubuntu: -------------------------------------------------------------------------------- 1 | remove this file if you want to rebuild the ubuntu docker image 2 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | docker 2 | .cache 3 | build 4 | build-debug -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | cmake-build-debug 3 | build 4 | build-debug 5 | .cache 6 | compile_commands.json 7 | .docker-grpc -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "boost-cmake"] 2 | path = boost-cmake 3 | url = https://github.com/Orphis/boost-cmake.git 4 | -------------------------------------------------------------------------------- /Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "libraries": [ 3 | "api", 4 | "chat", 5 | "crypto", 6 | "controller", 7 | "container", 8 | "command", 9 | "debug", 10 | "entity", 11 | "format", 12 | "game", 13 | "lexer", 14 | "math", 15 | "nbt", 16 | "network", 17 | "random", 18 | "region", 19 | "repository", 20 | "util", 21 | "world", 22 | "signal", 23 | "stream" 24 | ], 25 | "services": [ 26 | "engine", 27 | "front", 28 | "storage" 29 | ], 30 | "tools": [ 31 | "chunk_extractor", 32 | "chunk_viewer", 33 | "nbt_viewer", 34 | "nbtscheme", 35 | "recipes", 36 | "snbt_parser", 37 | "schema_compiler", 38 | "trace_tool" 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /api/minecpp/nbt/block/Block.schema: -------------------------------------------------------------------------------- 1 | generator = "nbt" 2 | package minecpp.nbt.block 3 | 4 | [NBT] 5 | record EnumProperty { 6 | Name: string 7 | [CC_Name="values"] 8 | Label: list[string] 9 | } 10 | 11 | [NBT] 12 | record IntProperty { 13 | Name: string 14 | MinValue: int32 15 | MaxValue: int32 16 | } 17 | 18 | [NBT] 19 | record BoolProperty { 20 | Name: string 21 | } 22 | 23 | [NBT] 24 | record Block { 25 | PropertyTags: list[string] 26 | } 27 | 28 | [NBT] 29 | record BlockEntityData { 30 | } 31 | -------------------------------------------------------------------------------- /api/minecpp/nbt/block/BlockState.schema: -------------------------------------------------------------------------------- 1 | generator = "nbt" 2 | package minecpp.nbt.block 3 | 4 | [NBT] 5 | record BlockState { 6 | BlocksMovement: int8 7 | Luminance: int32 8 | Opacity: int32 9 | SolidFaces: common.FaceMask 10 | } 11 | 12 | -------------------------------------------------------------------------------- /api/minecpp/nbt/common/Common.schema: -------------------------------------------------------------------------------- 1 | generator = "nbt" 2 | package minecpp.nbt.common 3 | 4 | [NBT] 5 | record ChunkPosition { 6 | x: int32 7 | y: int32 8 | } 9 | 10 | [NBT] 11 | record BlockPosition { 12 | x: int32 13 | y: int32 14 | z: int32 15 | } 16 | 17 | [NBT] 18 | record FaceMask { 19 | down: int8 20 | east: int8 21 | north: int8 22 | south: int8 23 | up: int8 24 | west: int8 25 | } 26 | 27 | -------------------------------------------------------------------------------- /api/minecpp/nbt/item/Item.schema: -------------------------------------------------------------------------------- 1 | generator = "nbt" 2 | package minecpp.nbt.item 3 | 4 | [NBT] 5 | record Item { 6 | IsBlock: int8 7 | CorrespondingBlockTag: string 8 | MaxItemStack: int32 9 | } 10 | 11 | [NBT] 12 | record StoredEnchantment { 13 | id: string 14 | lvl: int16 15 | } 16 | 17 | [NBT] 18 | record SlotData { 19 | StoredEnchantments: optional[list[StoredEnchantment]] 20 | } 21 | -------------------------------------------------------------------------------- /api/minecpp/nbt/repository/Chat.schema: -------------------------------------------------------------------------------- 1 | generator = "nbt" 2 | package minecpp.nbt.repository 3 | 4 | [NBT] 5 | record ChatDecorationStyle { 6 | color: string 7 | italic: int8 8 | bold: int8 9 | } 10 | 11 | [NBT] 12 | record ChatDetails { 13 | parameters: list[string] 14 | style: optional[ChatDecorationStyle] 15 | translation_key: string 16 | } 17 | 18 | [NBT] 19 | record ChatTypeDescription { 20 | chat: ChatDetails 21 | narration: ChatDetails 22 | } 23 | 24 | [NBT] 25 | record ChatTypeEntry { 26 | name: string 27 | id: int32 28 | element: ChatTypeDescription 29 | } 30 | 31 | [NBT] 32 | record ChatTypes { 33 | type: string 34 | value: list[ChatTypeEntry] 35 | } 36 | -------------------------------------------------------------------------------- /api/minecpp/nbt/repository/Damage.schema: -------------------------------------------------------------------------------- 1 | generator = "nbt" 2 | package minecpp.nbt.repository 3 | 4 | [NBT] 5 | record DamageTypeDescription { 6 | exhaustion: float32 7 | message_id: string 8 | scaling: string 9 | } 10 | 11 | [NBT] 12 | record DamageTypeEntry { 13 | element: DamageTypeDescription 14 | id: int32 15 | name: string 16 | } 17 | 18 | [NBT] 19 | record DamageTypes { 20 | type: string 21 | value: list[DamageTypeEntry] 22 | } 23 | -------------------------------------------------------------------------------- /api/minecpp/nbt/repository/Registry.schema: -------------------------------------------------------------------------------- 1 | generator = "nbt" 2 | package minecpp.nbt.repository 3 | 4 | [NBT] 5 | record Registry { 6 | [Namespace="minecraft", Path="chat_type"] 7 | chat_types: ChatTypes 8 | [Namespace="minecraft", Path="damage_type"] 9 | damage_types: DamageTypes 10 | [Namespace="minecraft", Path="dimension_type"] 11 | dimension_types: DimensionTypes 12 | [Namespace="minecraft", Path="trim_material"] 13 | trim_materials: TrimMaterialTypes 14 | [Namespace="minecraft", Path="trim_pattern"] 15 | trim_patterns: TrimPatternTypes 16 | [Namespace="minecraft", Path="worldgen/biome"] 17 | biomes: BiomeTypes 18 | } 19 | 20 | -------------------------------------------------------------------------------- /api/minecpp/nbt/trace/Trace.schema: -------------------------------------------------------------------------------- 1 | generator = "nbt" 2 | package minecpp.nbt.trace 3 | 4 | [NBT] 5 | record ChunkDispatchRequested { 6 | chunk_x: int32 7 | chunk_z: int32 8 | } 9 | 10 | [NBT] 11 | record ChunkSentToPlayer { 12 | chunk_x: int32 13 | chunk_z: int32 14 | player_id: string 15 | } 16 | 17 | [NBT] 18 | record GeneratingChunk { 19 | chunk_x: int32 20 | chunk_z: int32 21 | } 22 | 23 | [NBT] 24 | record HandlingChunkData { 25 | chunk_x: int32 26 | chunk_z: int32 27 | } 28 | 29 | [NBT] 30 | record PreHandlingChunkDataJob { 31 | chunk_x: int32 32 | chunk_z: int32 33 | } 34 | 35 | [NBT] 36 | record PostHandlingChunkDataJob { 37 | chunk_x: int32 38 | chunk_z: int32 39 | } 40 | 41 | [NBT] 42 | record HandlingEmptyChunk { 43 | chunk_x: int32 44 | chunk_z: int32 45 | } 46 | -------------------------------------------------------------------------------- /api/minecpp/net/engine/Clientbound.schema: -------------------------------------------------------------------------------- 1 | generator = "net" 2 | package minecpp.net.engine.cb 3 | 4 | [MessageID=0x00] 5 | record SendMsgToSinglePlayer { 6 | player_id: uuid 7 | data: list[uint8] 8 | } 9 | 10 | [MessageID=0x01] 11 | record SendMsgToSomePlayers { 12 | player_ids: list[uuid] 13 | data: list[uint8] 14 | } 15 | 16 | [MessageID=0x02] 17 | record SendMsgToAllPlayers { 18 | data: list[uint8] 19 | } 20 | 21 | [MessageID=0x03] 22 | record SendMsgToAllPlayersExcept { 23 | player_id: uuid 24 | data: list[uint8] 25 | } 26 | -------------------------------------------------------------------------------- /api/minecpp/net/engine/Serverbound.schema: -------------------------------------------------------------------------------- 1 | generator = "net" 2 | package minecpp.net.engine.sb 3 | 4 | [MessageID=0x00] 5 | record AcceptPlayer { 6 | player_id: uuid 7 | name: string 8 | } 9 | 10 | [MessageID=0x01] 11 | record RemovePlayer { 12 | player_id: uuid 13 | } 14 | 15 | [MessageID=0x02] 16 | record PlayerMessage { 17 | player_id: uuid 18 | data: list[uint8] 19 | } 20 | -------------------------------------------------------------------------------- /api/minecpp/net/login/Clientbound.schema: -------------------------------------------------------------------------------- 1 | generator = "net" 2 | package minecpp.net.login.cb 3 | 4 | [MessageID=0x00] 5 | record Disconnect { 6 | reason: string 7 | } 8 | 9 | [MessageID=0x01] 10 | record EncryptionRequest { 11 | server_id: string 12 | public_key: list[uint8] 13 | token: list[uint8] 14 | } 15 | 16 | record LoginProperty { 17 | key: string 18 | value: string 19 | signature: optional[string] 20 | } 21 | 22 | [MessageID=0x02] 23 | record LoginSuccess { 24 | player_id: uuid 25 | username: string 26 | properties: list[LoginProperty] 27 | } 28 | 29 | [MessageID=0x03] 30 | record SetCompression { 31 | threshold: varint 32 | } 33 | 34 | [MessageID=0x04] 35 | record PluginRequest { 36 | message_id: varint 37 | channel: string 38 | data: list[uint8] 39 | } 40 | -------------------------------------------------------------------------------- /api/minecpp/net/login/Serverbound.schema: -------------------------------------------------------------------------------- 1 | generator = "net" 2 | package minecpp.net.login.sb 3 | 4 | [MessageID=0x00] 5 | record LoginStart { 6 | name: string 7 | player_id: optional[uuid] 8 | } 9 | 10 | [MessageID=0x01] 11 | record EncryptionResponse { 12 | shared_secret: list[uint8] 13 | token: list[uint8] 14 | } 15 | 16 | [MessageID=0x02] 17 | record PluginResponse { 18 | message_id: varint 19 | is_successful: int8 20 | data: list[uint8] 21 | } 22 | -------------------------------------------------------------------------------- /api/minecpp/net/status/Clientbound.schema: -------------------------------------------------------------------------------- 1 | generator = "net" 2 | package minecpp.net.status.cb 3 | 4 | [MessageID=0x00] 5 | record Status { 6 | status: string 7 | } 8 | 9 | [MessageID=0x01] 10 | record Ping { 11 | payload: uint64 12 | } 13 | -------------------------------------------------------------------------------- /api/minecpp/net/status/Serverbound.schema: -------------------------------------------------------------------------------- 1 | generator = "net" 2 | package minecpp.net.status.sb 3 | 4 | [MessageID=0x00] 5 | record Status { 6 | } 7 | 8 | [MessageID=0x01] 9 | record Ping { 10 | payload: uint64 11 | } 12 | -------------------------------------------------------------------------------- /api/minecpp/net/storage/Clientbound.schema: -------------------------------------------------------------------------------- 1 | generator = "net" 2 | package minecpp.net.storage.cb 3 | 4 | [MessageID=0x00] 5 | record ReplyEmptyChunk { 6 | position: Vector2i 7 | } 8 | 9 | [MessageID=0x01] 10 | record ReplyChunk { 11 | chunk: Chunk 12 | } 13 | -------------------------------------------------------------------------------- /api/minecpp/net/storage/Serverbound.schema: -------------------------------------------------------------------------------- 1 | generator = "net" 2 | package minecpp.net.storage.sb 3 | 4 | [MessageID=0x00] 5 | record SetClientId { 6 | client_id: uint64 7 | } 8 | 9 | [MessageID=0x01] 10 | record SubscribeChunk { 11 | position: Vector2i 12 | } 13 | 14 | [MessageID=0x02] 15 | record StoreChunk { 16 | chunk: Chunk 17 | } 18 | 19 | record ChunkSubscription { 20 | client_ids: list[uint64] 21 | } 22 | -------------------------------------------------------------------------------- /clusterfile-docker: -------------------------------------------------------------------------------- 1 | docker:docker@fdb:4500 -------------------------------------------------------------------------------- /clusterfile-local: -------------------------------------------------------------------------------- 1 | docker:docker@127.0.0.1:4500 -------------------------------------------------------------------------------- /docker/Core.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM minecpp/ubuntu:latest 2 | 3 | # Copy the source code 4 | COPY . /root/minecpp 5 | 6 | # Run CMake 7 | WORKDIR /root/minecpp/build-docker 8 | RUN cmake .. -DCMAKE_BUILD_TYPE=Release -G Ninja 9 | 10 | # Build game library as a test that everything works 11 | WORKDIR /root/minecpp/build-docker 12 | RUN cmake --build . -j $(nproc) -t minecpp_game \ 13 | -t minecpp_controller \ 14 | -t minecpp_engine_api \ 15 | -t minecpp_utils \ 16 | -t minecpp_game \ 17 | -t minecpp_api \ 18 | -t minecpp_nbt \ 19 | -t minecpp_chat \ 20 | -t minecpp_format \ 21 | -t minecpp_network \ 22 | -t minecpp_repository \ 23 | -t minecpp_command \ 24 | -t minecpp_storage_api \ 25 | -t minecpp_lexer \ 26 | -t minecpp_crypto \ 27 | -t yaml-cpp 28 | -------------------------------------------------------------------------------- /docker/Engine.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM minecpp/core:latest 2 | 3 | ENV REPOSITORY_FILENAME=/root/minecpp_data/repository.bin 4 | 5 | RUN mkdir /root/minecpp_data 6 | RUN cp /root/minecpp/repository.bin /root/minecpp_data/repository.bin 7 | 8 | WORKDIR /root/minecpp/build-docker 9 | RUN cmake --build . -j $(nproc) --target minecpp_engine 10 | RUN cp /root/minecpp/build-docker/bin/minecpp_engine /usr/bin/minecpp_engine 11 | RUN rm -rf /root/minecpp 12 | 13 | # No entypoint because we need to wait for storage connection first 14 | -------------------------------------------------------------------------------- /docker/Front.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM minecpp/core:latest 2 | 3 | ENV REGISTRY_FILE=/root/minecpp_data/registry.bin 4 | RUN mkdir /root/minecpp_data 5 | RUN cp /root/minecpp/registry.bin /root/minecpp_data/registry.bin 6 | 7 | WORKDIR /root/minecpp/build-docker 8 | 9 | RUN cmake --build . -j $(nproc) --target minecpp_front 10 | RUN cp /root/minecpp/build-docker/bin/minecpp_front /usr/bin/minecpp_front 11 | RUN rm -rf /root/minecpp_front 12 | 13 | # No entypoint because we need to wait for engine and storage connection first 14 | -------------------------------------------------------------------------------- /docker/Storage.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM minecpp/core:latest 2 | 3 | WORKDIR /root/minecpp/build-docker 4 | RUN cmake --build . -j $(nproc) --target minecpp_storage 5 | RUN cp /root/minecpp/build-docker/bin/minecpp_storage /usr/bin/minecpp_storage 6 | RUN rm -rf /root/minecpp 7 | 8 | # No entypoint because we need to configure FDB before starting the service -------------------------------------------------------------------------------- /docker/fdb/.env: -------------------------------------------------------------------------------- 1 | export COMPOSE_PROJECT_NAME=fdb_test 2 | export FDB_API_VERSION=630 3 | export FDB_VERSION=7.1.21 4 | export FDB_COORDINATOR=fdb-coordinator 5 | export FDB_NETWORKING_MODE=host 6 | export FDB_COORDINATOR_PORT=4500 7 | export FDB_ADDITIONAL_VERSIONS="" 8 | -------------------------------------------------------------------------------- /docker/fdb/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | fdb: 4 | image: foundationdb/foundationdb:6.3.24 5 | network_mode: host 6 | ports: 7 | - $FDB_PORT:$FDB_PORT/tcp 8 | environment: 9 | FDB_NETWORKING_MODE: host 10 | FDB_COORDINATOR_PORT: $FDB_PORT 11 | FDB_PORT: $FDB_PORT 12 | -------------------------------------------------------------------------------- /docker/init_database.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | FDB_HOST=$(host "fdb" | head -1 | awk '{print $4}') 4 | if [ $FDB_HOST = 'found:' ]; then 5 | FDB_HOST='127.0.0.1' 6 | fi 7 | 8 | echo "docker:docker@$FDB_HOST:4500" | tee /root/clusterfile 9 | 10 | fdbcli -C "/root/clusterfile" --exec 'configure new single ssd logs=1' 11 | if [ $? -eq 2 ]; then 12 | fdbcli -C "/root/clusterfile" --exec 'configure single ssd logs=1' 13 | fi 14 | -------------------------------------------------------------------------------- /docs/InternalDesign.md: -------------------------------------------------------------------------------- 1 | # Internal Design 2 | 3 | This document described the internal design of the Mine C++ engine. 4 | Engine functionalities are seperated into systems. Systems are dived based on scope: 5 | 6 | + **Engine Scope System** - Systems that manage the inner-workings of the engine or take care of global game resources. 7 | + **World Scope System** - Systems that operate within a specific world. 8 | 9 | ## Engine Scope System 10 | 11 | The game recognised the following engine scope systems. 12 | 13 | + **Job System** 14 | + **Tick System** 15 | + **Resource System** 16 | + **World System** 17 | 18 | ## World Scope System 19 | 20 | The game recognised the following world scope systems. 21 | 22 | + **Light System** 23 | + **Chunk System** 24 | + **Entity System** -------------------------------------------------------------------------------- /gameplay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmbednarek/minecpp/130935326f8e5427113bbc24e7dd8629770520d9/gameplay.png -------------------------------------------------------------------------------- /library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(api) 2 | add_subdirectory(chat) 3 | add_subdirectory(crypto) 4 | add_subdirectory(controller) 5 | add_subdirectory(container) 6 | add_subdirectory(debug) 7 | add_subdirectory(format) 8 | add_subdirectory(random) 9 | add_subdirectory(util) 10 | add_subdirectory(math) 11 | add_subdirectory(nbt) 12 | add_subdirectory(region) 13 | add_subdirectory(game) 14 | add_subdirectory(network) 15 | add_subdirectory(entity) 16 | add_subdirectory(lexer) 17 | add_subdirectory(command) 18 | add_subdirectory(world) 19 | add_subdirectory(repository) 20 | add_subdirectory(signal) 21 | add_subdirectory(stream) 22 | -------------------------------------------------------------------------------- /library/api/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_api", 3 | "include_path": "minecpp", 4 | "dependencies": { 5 | "public": [ 6 | "minecpp_nbt", 7 | "minecpp_network", 8 | "libmb" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /library/api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_api STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_api 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_api 17 | LINK_PUBLIC 18 | minecpp_nbt 19 | minecpp_network 20 | libmb 21 | ) 22 | -------------------------------------------------------------------------------- /library/api/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | # Subdirectories 4 | add_subdirectory("nbt") 5 | add_subdirectory("net") 6 | 7 | -------------------------------------------------------------------------------- /library/api/src/nbt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | # Subdirectories 4 | add_subdirectory("block") 5 | add_subdirectory("chunk") 6 | add_subdirectory("common") 7 | add_subdirectory("item") 8 | add_subdirectory("level") 9 | add_subdirectory("player") 10 | add_subdirectory("repository") 11 | add_subdirectory("trace") 12 | 13 | -------------------------------------------------------------------------------- /library/api/src/nbt/block/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_NBT_BLOCK_INCLUDE_DIR ${MINECPP_API_DIR}/include/minecpp/nbt/block) 4 | target_sources(minecpp_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Block.schema.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/BlockState.schema.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_API_NBT_BLOCK_INCLUDE_DIR}/Block.schema.h 13 | ${MINECPP_API_NBT_BLOCK_INCLUDE_DIR}/BlockState.schema.h 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /library/api/src/nbt/chunk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_NBT_CHUNK_INCLUDE_DIR ${MINECPP_API_DIR}/include/minecpp/nbt/chunk) 4 | target_sources(minecpp_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Chunk.schema.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_API_NBT_CHUNK_INCLUDE_DIR}/Chunk.schema.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /library/api/src/nbt/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_NBT_COMMON_INCLUDE_DIR ${MINECPP_API_DIR}/include/minecpp/nbt/common) 4 | target_sources(minecpp_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Common.schema.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_API_NBT_COMMON_INCLUDE_DIR}/Common.schema.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /library/api/src/nbt/item/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_NBT_ITEM_INCLUDE_DIR ${MINECPP_API_DIR}/include/minecpp/nbt/item) 4 | target_sources(minecpp_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Item.schema.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_API_NBT_ITEM_INCLUDE_DIR}/Item.schema.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /library/api/src/nbt/level/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_NBT_LEVEL_INCLUDE_DIR ${MINECPP_API_DIR}/include/minecpp/nbt/level) 4 | target_sources(minecpp_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Level.schema.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_API_NBT_LEVEL_INCLUDE_DIR}/Level.schema.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /library/api/src/nbt/player/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_NBT_PLAYER_INCLUDE_DIR ${MINECPP_API_DIR}/include/minecpp/nbt/player) 4 | target_sources(minecpp_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Player.schema.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_API_NBT_PLAYER_INCLUDE_DIR}/Player.schema.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /library/api/src/nbt/trace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_NBT_TRACE_INCLUDE_DIR ${MINECPP_API_DIR}/include/minecpp/nbt/trace) 4 | target_sources(minecpp_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Trace.schema.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_API_NBT_TRACE_INCLUDE_DIR}/Trace.schema.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /library/api/src/net/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_NET_INCLUDE_DIR ${MINECPP_API_DIR}/include/minecpp/net) 4 | target_sources(minecpp_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Chunk.schema.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Common.schema.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_API_NET_INCLUDE_DIR}/Chunk.schema.h 13 | ${MINECPP_API_NET_INCLUDE_DIR}/Common.schema.h 14 | ) 15 | 16 | # Subdirectories 17 | add_subdirectory("engine") 18 | add_subdirectory("login") 19 | add_subdirectory("play") 20 | add_subdirectory("status") 21 | add_subdirectory("storage") 22 | 23 | -------------------------------------------------------------------------------- /library/api/src/net/engine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_NET_ENGINE_INCLUDE_DIR ${MINECPP_API_DIR}/include/minecpp/net/engine) 4 | target_sources(minecpp_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Clientbound.schema.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Serverbound.schema.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_API_NET_ENGINE_INCLUDE_DIR}/Clientbound.schema.h 13 | ${MINECPP_API_NET_ENGINE_INCLUDE_DIR}/Serverbound.schema.h 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /library/api/src/net/login/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_NET_LOGIN_INCLUDE_DIR ${MINECPP_API_DIR}/include/minecpp/net/login) 4 | target_sources(minecpp_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Clientbound.schema.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Serverbound.schema.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_API_NET_LOGIN_INCLUDE_DIR}/Clientbound.schema.h 13 | ${MINECPP_API_NET_LOGIN_INCLUDE_DIR}/Serverbound.schema.h 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /library/api/src/net/play/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_NET_PLAY_INCLUDE_DIR ${MINECPP_API_DIR}/include/minecpp/net/play) 4 | target_sources(minecpp_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Clientbound.schema.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Common.schema.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/Serverbound.schema.cpp 10 | 11 | # Header files 12 | PUBLIC 13 | ${MINECPP_API_NET_PLAY_INCLUDE_DIR}/Clientbound.schema.h 14 | ${MINECPP_API_NET_PLAY_INCLUDE_DIR}/Common.schema.h 15 | ${MINECPP_API_NET_PLAY_INCLUDE_DIR}/Serverbound.schema.h 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /library/api/src/net/status/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_NET_STATUS_INCLUDE_DIR ${MINECPP_API_DIR}/include/minecpp/net/status) 4 | target_sources(minecpp_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Clientbound.schema.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Serverbound.schema.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_API_NET_STATUS_INCLUDE_DIR}/Clientbound.schema.h 13 | ${MINECPP_API_NET_STATUS_INCLUDE_DIR}/Serverbound.schema.h 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /library/api/src/net/storage/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_API_NET_STORAGE_INCLUDE_DIR ${MINECPP_API_DIR}/include/minecpp/net/storage) 4 | target_sources(minecpp_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Clientbound.schema.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Serverbound.schema.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_API_NET_STORAGE_INCLUDE_DIR}/Clientbound.schema.h 13 | ${MINECPP_API_NET_STORAGE_INCLUDE_DIR}/Serverbound.schema.h 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /library/chat/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_chat", 3 | "dependencies": { 4 | "public": [ 5 | "minecpp_format" 6 | ], 7 | "private": [ 8 | "minecpp_utils", 9 | "fmt::fmt" 10 | ] 11 | } 12 | } -------------------------------------------------------------------------------- /library/chat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_CHAT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_chat STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_chat 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/chat 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_chat 17 | LINK_PUBLIC 18 | minecpp_format 19 | LINK_PRIVATE 20 | minecpp_utils 21 | fmt::fmt 22 | ) 23 | -------------------------------------------------------------------------------- /library/chat/include/minecpp/chat/Parser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace minecpp::chat { 8 | 9 | enum class TokenType 10 | { 11 | Identifier, 12 | Integer, 13 | Float 14 | }; 15 | 16 | struct Token 17 | { 18 | TokenType type; 19 | std::string value; 20 | int column = 0; 21 | }; 22 | 23 | using Argument = std::variant; 24 | 25 | struct Command 26 | { 27 | std::string name; 28 | std::vector args; 29 | }; 30 | 31 | std::vector lex(std::string_view command); 32 | mb::result parse(std::vector &tokens); 33 | 34 | }// namespace minecpp::chat 35 | -------------------------------------------------------------------------------- /library/chat/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_CHAT_INCLUDE_DIR ${MINECPP_CHAT_DIR}/include/minecpp/chat) 4 | target_sources(minecpp_chat 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Chat.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Parser.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_CHAT_INCLUDE_DIR}/Chat.h 13 | ${MINECPP_CHAT_INCLUDE_DIR}/Parser.h 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /library/command/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_command", 3 | "has_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "libmb", 7 | "fmt::fmt", 8 | "minecpp_format", 9 | "minecpp_game", 10 | "minecpp_entity", 11 | "minecpp_lexer" 12 | ], 13 | "private": [ 14 | "minecpp_repository" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /library/command/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_COMMAND_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_command STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_command 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/command 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_command 17 | LINK_PUBLIC 18 | libmb 19 | fmt::fmt 20 | minecpp_format 21 | minecpp_game 22 | minecpp_entity 23 | minecpp_lexer 24 | LINK_PRIVATE 25 | minecpp_repository 26 | ) 27 | 28 | add_subdirectory("test") 29 | -------------------------------------------------------------------------------- /library/command/include/minecpp/command/Result.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace minecpp::command { 7 | 8 | struct Error 9 | { 10 | int line, column; 11 | std::string message; 12 | 13 | template 14 | Error(int line, int column, fmt::format_string &&message, TArgs &&...args) : 15 | line(line), 16 | column(column), 17 | message(fmt::format(message, std::forward(args)...)) 18 | { 19 | } 20 | }; 21 | 22 | template 23 | using Result = mb::result; 24 | 25 | }// namespace minecpp::command -------------------------------------------------------------------------------- /library/command/include/minecpp/command/StandardStream.h: -------------------------------------------------------------------------------- 1 | #ifndef MINECPP_STANDARD_STREAM_H 2 | #define MINECPP_STANDARD_STREAM_H 3 | #include "Command.h" 4 | #include 5 | 6 | namespace minecpp::command { 7 | 8 | class StandardStream : public OutputStream 9 | { 10 | game::IDispatcher &m_notifier; 11 | 12 | public: 13 | explicit StandardStream(game::IDispatcher ¬ifier); 14 | 15 | bool write(Object::Ptr obj) override; 16 | }; 17 | 18 | }// namespace minecpp::command 19 | 20 | #endif//MINECPP_STANDARD_STREAM_H 21 | -------------------------------------------------------------------------------- /library/command/include/minecpp/command/core/Cord.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Command.h" 4 | 5 | namespace minecpp::command::core { 6 | 7 | class Cord : public Command 8 | { 9 | public: 10 | static constexpr auto command_return_type = ObjectType::BlockPosition; 11 | static constexpr auto command_name = "cord"; 12 | 13 | [[nodiscard]] bool is_flag(std::string_view name) const override; 14 | Object::Ptr run(RuntimeContext &ctx, CommandInput &input) const override; 15 | ObjectType return_type(RuntimeContext &ctx) const override; 16 | }; 17 | 18 | }// namespace minecpp::command::core 19 | -------------------------------------------------------------------------------- /library/command/include/minecpp/command/core/Core.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace minecpp::command { 4 | class CommandManager; 5 | } 6 | 7 | namespace minecpp::command::core { 8 | 9 | void register_commands(CommandManager &command_manager); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /library/command/include/minecpp/command/core/DecimateBlocks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "minecpp/command/Command.h" 4 | 5 | namespace minecpp::command::core { 6 | 7 | class DecimateBlocks : public Command 8 | { 9 | public: 10 | static constexpr auto command_return_type = ObjectType::FormattedString; 11 | static constexpr auto command_name = "decimate-blocks"; 12 | 13 | [[nodiscard]] bool is_flag(std::string_view name) const override; 14 | Object::Ptr run(RuntimeContext &ctx, CommandInput &input) const override; 15 | ObjectType return_type(RuntimeContext &ctx) const override; 16 | }; 17 | 18 | }// namespace minecpp::command::core 19 | -------------------------------------------------------------------------------- /library/command/include/minecpp/command/core/Echo.h: -------------------------------------------------------------------------------- 1 | #ifndef MINECPP_ECHO_H 2 | #define MINECPP_ECHO_H 3 | #include "../Command.h" 4 | #include 5 | 6 | namespace minecpp::command::core { 7 | 8 | class Echo : public Command 9 | { 10 | public: 11 | static constexpr auto command_return_type = ObjectType::String; 12 | static constexpr auto command_name = "echo"; 13 | 14 | [[nodiscard]] bool is_flag(std::string_view name) const override; 15 | Object::Ptr run(RuntimeContext &ctx, CommandInput &input) const override; 16 | ObjectType return_type(RuntimeContext &ctx) const override; 17 | }; 18 | 19 | }// namespace minecpp::command::core 20 | 21 | #endif//MINECPP_ECHO_H 22 | -------------------------------------------------------------------------------- /library/command/include/minecpp/command/core/Fly.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Command.h" 4 | 5 | namespace minecpp::command::core { 6 | 7 | class Fly : public Command 8 | { 9 | public: 10 | static constexpr auto command_return_type = ObjectType::FormattedString; 11 | static constexpr auto command_name = "fly"; 12 | 13 | [[nodiscard]] bool is_flag(std::string_view name) const override; 14 | Object::Ptr run(RuntimeContext &ctx, CommandInput &input) const override; 15 | ObjectType return_type(RuntimeContext &ctx) const override; 16 | }; 17 | 18 | }// namespace minecpp::command::core 19 | -------------------------------------------------------------------------------- /library/command/include/minecpp/command/core/Format.h: -------------------------------------------------------------------------------- 1 | #ifndef MINECPP_FORMAT_H 2 | #define MINECPP_FORMAT_H 3 | #include "../Command.h" 4 | #include 5 | 6 | namespace minecpp::command::core { 7 | 8 | class Format : public Command 9 | { 10 | public: 11 | Format(format::Color color, bool bold); 12 | 13 | [[nodiscard]] bool is_flag(std::string_view name) const override; 14 | ObjectType return_type(RuntimeContext &ctx) const override; 15 | Object::Ptr run(RuntimeContext &ctx, CommandInput &input) const override; 16 | 17 | private: 18 | format::Color m_color; 19 | bool m_bold; 20 | }; 21 | 22 | }// namespace minecpp::command::core 23 | 24 | #endif//MINECPP_FORMAT_H 25 | -------------------------------------------------------------------------------- /library/command/include/minecpp/command/core/Give.h: -------------------------------------------------------------------------------- 1 | #ifndef MINECPP_GIVE_H 2 | #define MINECPP_GIVE_H 3 | #include "../Command.h" 4 | 5 | namespace minecpp::command::core { 6 | 7 | class Give : public Command 8 | { 9 | public: 10 | static constexpr auto command_return_type = ObjectType::String; 11 | static constexpr auto command_name = "give"; 12 | 13 | [[nodiscard]] bool is_flag(std::string_view name) const override; 14 | Object::Ptr run(RuntimeContext &ctx, CommandInput &input) const override; 15 | ObjectType return_type(RuntimeContext &ctx) const override; 16 | }; 17 | 18 | }// namespace minecpp::command::core 19 | 20 | #endif//MINECPP_GIVE_H 21 | -------------------------------------------------------------------------------- /library/command/include/minecpp/command/core/KillAll.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Command.h" 4 | 5 | namespace minecpp::command::core { 6 | 7 | class KillAll : public Command 8 | { 9 | public: 10 | static constexpr auto command_return_type = ObjectType::FormattedString; 11 | static constexpr auto command_name = "killall"; 12 | 13 | [[nodiscard]] bool is_flag(std::string_view name) const override; 14 | Object::Ptr run(RuntimeContext &ctx, CommandInput &input) const override; 15 | ObjectType return_type(RuntimeContext &ctx) const override; 16 | }; 17 | 18 | }// namespace minecpp::command::core 19 | -------------------------------------------------------------------------------- /library/command/include/minecpp/command/core/ListEntities.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Command.h" 4 | 5 | namespace minecpp::command::core { 6 | 7 | class ListEntities : public Command 8 | { 9 | public: 10 | static constexpr auto command_return_type = ObjectType::Array; 11 | static constexpr auto command_name = "lsentity"; 12 | 13 | [[nodiscard]] bool is_flag(std::string_view name) const override; 14 | Object::Ptr run(RuntimeContext &ctx, CommandInput &input) const override; 15 | ObjectType return_type(RuntimeContext &ctx) const override; 16 | }; 17 | 18 | }// namespace minecpp::command::core -------------------------------------------------------------------------------- /library/command/include/minecpp/command/core/ReloadChunk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Command.h" 4 | #include 5 | 6 | namespace minecpp::command::core { 7 | 8 | class ReloadChunk : public Command 9 | { 10 | public: 11 | static constexpr auto command_return_type = ObjectType::String; 12 | static constexpr auto command_name = "reload-chunk"; 13 | 14 | [[nodiscard]] bool is_flag(std::string_view name) const override; 15 | ObjectType return_type(RuntimeContext &ctx) const override; 16 | Object::Ptr run(RuntimeContext &ctx, CommandInput &input) const override; 17 | }; 18 | 19 | }// namespace minecpp::command::core 20 | -------------------------------------------------------------------------------- /library/command/include/minecpp/command/core/Spawn.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Command.h" 4 | 5 | namespace minecpp::command::core { 6 | 7 | class Spawn : public Command 8 | { 9 | public: 10 | static constexpr auto command_return_type = ObjectType::FormattedString; 11 | static constexpr auto command_name = "spawn"; 12 | 13 | [[nodiscard]] bool is_flag(std::string_view name) const override; 14 | Object::Ptr run(RuntimeContext &ctx, CommandInput &input) const override; 15 | ObjectType return_type(RuntimeContext &ctx) const override; 16 | }; 17 | 18 | }// namespace minecpp::command::core 19 | -------------------------------------------------------------------------------- /library/command/include/minecpp/command/core/Sync.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Command.h" 3 | 4 | namespace minecpp::command::core { 5 | 6 | class Sync : public Command 7 | { 8 | public: 9 | static constexpr auto command_return_type = ObjectType::String; 10 | static constexpr auto command_name = "sync"; 11 | 12 | [[nodiscard]] bool is_flag(std::string_view name) const override; 13 | ObjectType return_type(RuntimeContext &ctx) const override; 14 | Object::Ptr run(RuntimeContext &ctx, CommandInput &input) const override; 15 | }; 16 | 17 | }// namespace minecpp::command::core -------------------------------------------------------------------------------- /library/command/include/minecpp/command/core/Teleport.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Command.h" 4 | 5 | namespace minecpp::command::core { 6 | 7 | class Teleport : public Command 8 | { 9 | public: 10 | static constexpr auto command_return_type = ObjectType::FormattedString; 11 | static constexpr auto command_name = "tp"; 12 | 13 | [[nodiscard]] bool is_flag(std::string_view name) const override; 14 | Object::Ptr run(RuntimeContext &ctx, CommandInput &input) const override; 15 | ObjectType return_type(RuntimeContext &ctx) const override; 16 | }; 17 | 18 | }// namespace minecpp::command::core 19 | -------------------------------------------------------------------------------- /library/command/src/Object.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace minecpp::command { 5 | 6 | std::string ArrayObject::to_string() 7 | { 8 | if (this->value.empty()) 9 | return "[]"; 10 | 11 | std::stringstream ss; 12 | ss << '['; 13 | 14 | auto it = this->value.begin(); 15 | ss << (*it)->to_string(); 16 | ++it; 17 | 18 | for (; it != this->value.end(); ++it) { 19 | ss << ", " << (*it)->to_string(); 20 | } 21 | ss << ']'; 22 | 23 | return ss.str(); 24 | } 25 | 26 | }// namespace minecpp::command -------------------------------------------------------------------------------- /library/command/src/ast/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_COMMAND_AST_INCLUDE_DIR ${MINECPP_COMMAND_DIR}/include/minecpp/command/ast) 4 | target_sources(minecpp_command 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Command.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_COMMAND_AST_INCLUDE_DIR}/Ast.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /library/command/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_command_test", 3 | "is_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "GTest::gtest", 7 | "GTest::gtest_main", 8 | "minecpp_command", 9 | "minecpp_repository" 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /library/command/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_COMMAND_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_command_test) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_command_test 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/command_test 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_command_test 17 | LINK_PUBLIC 18 | GTest::gtest 19 | GTest::gtest_main 20 | minecpp_command 21 | minecpp_repository 22 | ) 23 | 24 | add_test(NAME minecpp_command COMMAND minecpp_command_test) 25 | -------------------------------------------------------------------------------- /library/command/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_command_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/CommandTest.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /library/container/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_container", 3 | "has_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "libmb", 7 | "minecpp_api" 8 | ] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /library/container/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_CONTAINER_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_container STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_container 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/container 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_container 17 | LINK_PUBLIC 18 | libmb 19 | minecpp_api 20 | ) 21 | 22 | add_subdirectory("test") 23 | -------------------------------------------------------------------------------- /library/container/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_CONTAINER_INCLUDE_DIR ${MINECPP_CONTAINER_DIR}/include/minecpp/container) 4 | target_sources(minecpp_container 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/TightVector.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_CONTAINER_INCLUDE_DIR}/BasicBuffer.hpp 12 | ${MINECPP_CONTAINER_INCLUDE_DIR}/BasicBufferView.hpp 13 | ${MINECPP_CONTAINER_INCLUDE_DIR}/PalettedVector.h 14 | ${MINECPP_CONTAINER_INCLUDE_DIR}/Queue.h 15 | ${MINECPP_CONTAINER_INCLUDE_DIR}/TightArray.h 16 | ${MINECPP_CONTAINER_INCLUDE_DIR}/TightVector.h 17 | ) 18 | 19 | -------------------------------------------------------------------------------- /library/container/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_container_test", 3 | "is_test": true, 4 | "dependencies": { 5 | "private": [ 6 | "minecpp_container", 7 | "GTest::gtest", 8 | "GTest::gtest_main" 9 | ] 10 | } 11 | } -------------------------------------------------------------------------------- /library/container/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_CONTAINER_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_container_test) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_container_test 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/container_test 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_container_test 17 | LINK_PRIVATE 18 | minecpp_container 19 | GTest::gtest 20 | GTest::gtest_main 21 | ) 22 | 23 | add_test(NAME minecpp_container COMMAND minecpp_container_test) 24 | -------------------------------------------------------------------------------- /library/container/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_container_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/BufferTest.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/PalettedVectorTest.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/QueueTest.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/TightArrayTest.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/TightVectorTest.cpp 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /library/controller/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_controller", 3 | "dependencies": { 4 | "public": [ 5 | "minecpp_world", 6 | "minecpp_repository" 7 | ], 8 | "private": [ 9 | "minecpp_game", 10 | "minecpp_entity", 11 | "minecpp_utils" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /library/controller/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_CONTROLLER_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_controller STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_controller 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/controller 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_controller 17 | LINK_PUBLIC 18 | minecpp_world 19 | minecpp_repository 20 | LINK_PRIVATE 21 | minecpp_game 22 | minecpp_entity 23 | minecpp_utils 24 | ) 25 | -------------------------------------------------------------------------------- /library/controller/include/minecpp/controller/block/Block.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace minecpp::controller { 4 | class BlockManager; 5 | } 6 | 7 | namespace minecpp::controller::block { 8 | 9 | void register_block_controllers(BlockManager &block_manager); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /library/controller/include/minecpp/controller/block/Grass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Default.h" 3 | 4 | namespace minecpp::controller::block { 5 | 6 | class Grass : public Default 7 | { 8 | public: 9 | bool on_player_place_block(game::IWorld &world, game::PlayerId player_id, int block_id, 10 | game::BlockPosition position, game::Face face, 11 | const math::Vector3f &crosshair_position) override; 12 | }; 13 | 14 | }// namespace minecpp::controller::block 15 | -------------------------------------------------------------------------------- /library/controller/include/minecpp/controller/block/Slab.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Default.h" 3 | 4 | namespace minecpp::controller::block { 5 | 6 | class Slab : public Default 7 | { 8 | public: 9 | bool on_player_place_block(game::IWorld &world, game::PlayerId player_id, int block_id, 10 | game::BlockPosition position, game::Face face, 11 | const math::Vector3f &crosshair_position) override; 12 | }; 13 | 14 | }// namespace minecpp::controller::block 15 | -------------------------------------------------------------------------------- /library/controller/include/minecpp/controller/block/Stairs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Default.h" 3 | 4 | namespace minecpp::controller::block { 5 | 6 | class Stairs : public Default 7 | { 8 | public: 9 | bool on_player_place_block(game::IWorld &world, game::PlayerId player_id, game::BlockId block_id, 10 | game::BlockPosition position, game::Face face, 11 | const math::Vector3f &crosshair_position) override; 12 | }; 13 | 14 | }// namespace minecpp::controller::block 15 | -------------------------------------------------------------------------------- /library/controller/include/minecpp/controller/block/TrapDoor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Default.h" 3 | 4 | namespace minecpp::controller::block { 5 | 6 | class TrapDoor : public Default 7 | { 8 | public: 9 | bool on_player_place_block(game::IWorld &world, game::PlayerId player_id, game::BlockId block_id, 10 | game::BlockPosition position, game::Face face, 11 | const math::Vector3f &crosshair_position) override; 12 | 13 | bool on_player_action(game::IWorld &world, game::PlayerId player_id, game::BlockStateId block_state_id, 14 | game::BlockPosition position, game::Face face, 15 | const math::Vector3f &crosshair_position) override; 16 | }; 17 | 18 | }// namespace minecpp::controller::block 19 | -------------------------------------------------------------------------------- /library/controller/include/minecpp/controller/block/Wood.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Default.h" 3 | 4 | namespace minecpp::controller::block { 5 | 6 | class Wood : public Default 7 | { 8 | public: 9 | bool on_player_place_block(game::IWorld &world, game::PlayerId player_id, int block_id, 10 | game::BlockPosition position, game::Face face, 11 | const math::Vector3f &crosshair_position) override; 12 | }; 13 | 14 | }// namespace minecpp::controller::block 15 | -------------------------------------------------------------------------------- /library/controller/include/minecpp/controller/item/Bow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Default.h" 4 | 5 | namespace minecpp::game { 6 | class Entity; 7 | } 8 | 9 | namespace minecpp::controller::item { 10 | 11 | class Bow : public Default 12 | { 13 | public: 14 | void on_item_use(game::IWorld &world, game::PlayerId player_id, game::EntityId player_entity_id, 15 | game::ItemId item_id) override; 16 | void on_released_item(game::IWorld &world, game::ItemId item_id, game::EntityId player_entity_id) override; 17 | 18 | private: 19 | static void fire(game::IWorld &world, game::Entity &player_entity, double strength); 20 | }; 21 | 22 | }// namespace minecpp::controller::item -------------------------------------------------------------------------------- /library/controller/include/minecpp/controller/item/Food.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Default.h" 4 | 5 | namespace minecpp::controller::item { 6 | 7 | class Food : public Default 8 | { 9 | public: 10 | void on_item_use(game::IWorld &world, game::PlayerId player_id, game::EntityId player_entity_id, 11 | game::ItemId item_id) override; 12 | }; 13 | 14 | }// namespace minecpp::controller::item -------------------------------------------------------------------------------- /library/controller/include/minecpp/controller/item/Item.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace minecpp::controller { 4 | class RootItem; 5 | } 6 | 7 | namespace minecpp::controller::item { 8 | 9 | void register_item_controllers(RootItem &root_controller); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /library/controller/include/minecpp/controller/item/Sword.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Default.h" 4 | 5 | namespace minecpp::controller::item { 6 | 7 | class Sword : public Default 8 | { 9 | public: 10 | void on_interact(game::IWorld &world, game::ItemId item_id, game::InteractionType interaction_type, 11 | game::EntityId player_entity_id, game::EntityId interaction_entity_id, 12 | const math::Vector3f &position, bool is_offhand) override; 13 | }; 14 | 15 | }// namespace minecpp::controller::item 16 | -------------------------------------------------------------------------------- /library/controller/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_CONTROLLER_INCLUDE_DIR ${MINECPP_CONTROLLER_DIR}/include/minecpp/controller) 4 | target_sources(minecpp_controller 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/BlockManager.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/RootItem.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_CONTROLLER_INCLUDE_DIR}/BlockManager.h 13 | ${MINECPP_CONTROLLER_INCLUDE_DIR}/RootItem.h 14 | ) 15 | 16 | # Subdirectories 17 | add_subdirectory("block") 18 | add_subdirectory("item") 19 | 20 | -------------------------------------------------------------------------------- /library/controller/src/block/Grass.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace minecpp::controller::block { 6 | 7 | bool Grass::on_player_place_block(game::IWorld &world, game::PlayerId /*player_id*/, int block_id, 8 | game::BlockPosition position, game::Face face, 9 | const math::Vector3f & /*crosshair_position*/) 10 | { 11 | auto neighbour_position = position.neighbour_at(face); 12 | world::BlockState state(block_id, 0); 13 | state.set("snowy", false); 14 | 15 | return world.set_block_at(neighbour_position, state.block_state_id()).ok(); 16 | } 17 | 18 | }// namespace minecpp::controller::block 19 | -------------------------------------------------------------------------------- /library/controller/template/BlockController.cpp.template: -------------------------------------------------------------------------------- 1 | #[[#include]]# "minecpp/repository/Block.h" 2 | #[[#include]]# 3 | 4 | namespace minecpp::controller::block { 5 | 6 | }// namespace minecpp::controller::block 7 | -------------------------------------------------------------------------------- /library/controller/template/BlockController.h.template: -------------------------------------------------------------------------------- 1 | #[[#pragma]]# once 2 | #[[#include]]# "Default.h" 3 | 4 | namespace minecpp::controller::block { 5 | 6 | class ${NAME} : public Default { 7 | public: 8 | }; 9 | 10 | } -------------------------------------------------------------------------------- /library/crypto/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_crypto", 3 | "has_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "minecpp_container" 7 | ], 8 | "private": [ 9 | "OpenSSL::SSL", 10 | "OpenSSL::Crypto" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /library/crypto/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_CRYPTO_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_crypto STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_crypto 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/crypto 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_crypto 17 | LINK_PUBLIC 18 | minecpp_container 19 | LINK_PRIVATE 20 | OpenSSL::SSL 21 | OpenSSL::Crypto 22 | ) 23 | 24 | add_subdirectory("test") 25 | -------------------------------------------------------------------------------- /library/crypto/include/minecpp/crypto/Error.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace minecpp::crypto { 5 | 6 | enum class ErrorType 7 | { 8 | InvalidArgument, 9 | EncryptionInitError, 10 | EncryptionError, 11 | DecryptionInitError, 12 | DecryptionError, 13 | }; 14 | 15 | template 16 | using Result = mb::result; 17 | 18 | using EmptyResult = Result; 19 | 20 | }// namespace minecpp::crypto 21 | -------------------------------------------------------------------------------- /library/crypto/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_CRYPTO_INCLUDE_DIR ${MINECPP_CRYPTO_DIR}/include/minecpp/crypto) 4 | target_sources(minecpp_crypto 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/AESKey.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Key.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_CRYPTO_INCLUDE_DIR}/AESKey.h 13 | ${MINECPP_CRYPTO_INCLUDE_DIR}/Error.h 14 | ${MINECPP_CRYPTO_INCLUDE_DIR}/Key.h 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /library/crypto/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_crypto_test", 3 | "is_test": true, 4 | "resources": [ 5 | "key.pem" 6 | ], 7 | "dependencies": { 8 | "public": [ 9 | ], 10 | "private": [ 11 | "GTest::gtest", 12 | "GTest::gtest_main", 13 | "minecpp_crypto" 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /library/crypto/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_crypto_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/AesTest.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/RsaTest.cpp 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /library/debug/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_debug", 3 | "has_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "minecpp_api", 7 | "minecpp_game" 8 | ], 9 | "private": [] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /library/debug/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_DEBUG_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_debug STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_debug 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/debug 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_debug 17 | LINK_PUBLIC 18 | minecpp_api 19 | minecpp_game 20 | LINK_PRIVATE 21 | ) 22 | 23 | add_subdirectory("test") 24 | -------------------------------------------------------------------------------- /library/debug/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_DEBUG_INCLUDE_DIR ${MINECPP_DEBUG_DIR}/include/minecpp/debug) 4 | target_sources(minecpp_debug 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/TraceManager.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_DEBUG_INCLUDE_DIR}/TraceManager.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /library/debug/src/TraceManager.cpp: -------------------------------------------------------------------------------- 1 | #include "TraceManager.h" 2 | 3 | #include 4 | 5 | namespace minecpp::debug { 6 | 7 | void TraceManager::initialize() 8 | { 9 | m_file_stream.open("trace.bin"); 10 | assert(m_file_stream.is_open()); 11 | } 12 | 13 | void TraceManager::write_trace(TraceObject<> &&object) 14 | { 15 | std::unique_lock lk{m_mutex}; 16 | m_buffer.push_back(std::move(object)); 17 | } 18 | 19 | void TraceManager::flush() 20 | { 21 | std::unique_lock lk{m_mutex}; 22 | for (const auto &trace : m_buffer) { 23 | trace.serialize(m_file_stream); 24 | } 25 | m_buffer.clear(); 26 | m_file_stream.flush(); 27 | } 28 | 29 | TraceManager &TraceManager::the() 30 | { 31 | static TraceManager manager; 32 | return manager; 33 | } 34 | 35 | }// namespace minecpp::debug 36 | -------------------------------------------------------------------------------- /library/debug/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_debug_test", 3 | "is_test": true, 4 | "resources": [], 5 | "dependencies": { 6 | "public": [ 7 | "GTest::gtest", 8 | "GTest::gtest_main", 9 | "minecpp_debug" 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /library/debug/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_DEBUG_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_debug_test) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_debug_test 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/debug_test 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_debug_test 17 | LINK_PUBLIC 18 | GTest::gtest 19 | GTest::gtest_main 20 | minecpp_debug 21 | ) 22 | 23 | add_test(NAME minecpp_debug COMMAND minecpp_debug_test) 24 | -------------------------------------------------------------------------------- /library/debug/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_debug_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/TraceTest.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /library/entity/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_entity", 3 | "has_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "EnTT", 7 | "minecpp_api", 8 | "minecpp_game", 9 | "minecpp_random", 10 | "minecpp_repository", 11 | "minecpp_math", 12 | "minecpp_world", 13 | "minecpp_utils" 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /library/entity/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_ENTITY_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_entity STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_entity 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/entity 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_entity 17 | LINK_PUBLIC 18 | EnTT 19 | minecpp_api 20 | minecpp_game 21 | minecpp_random 22 | minecpp_repository 23 | minecpp_math 24 | minecpp_world 25 | minecpp_utils 26 | ) 27 | 28 | add_subdirectory("test") 29 | -------------------------------------------------------------------------------- /library/entity/README.md: -------------------------------------------------------------------------------- 1 | # Entity Module 2 | 3 | Base for Entity/Component system based on entt. -------------------------------------------------------------------------------- /library/entity/include/minecpp/entity/component/Abilities.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace minecpp::entity::component { 7 | 8 | class Abilities 9 | { 10 | public: 11 | void on_attached(game::Entity &entity); 12 | 13 | void set_is_flying_enabled(game::IWorld &world, bool enabled); 14 | void set_can_instantly_destroy_blocks(game::IWorld &world, bool enabled); 15 | 16 | [[nodiscard]] const game::Abilities &abilities() const; 17 | 18 | private: 19 | game::Abilities m_abilities; 20 | game::EntityId m_entity_id{}; 21 | }; 22 | 23 | }// namespace minecpp::entity::component 24 | -------------------------------------------------------------------------------- /library/entity/include/minecpp/entity/component/DealthScreen.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace minecpp::entity::component { 6 | 7 | class DeathScreen 8 | { 9 | public: 10 | void on_attached(game::Entity &entity); 11 | void on_dead(game::IWorld &world, game::Entity &entity, const game::Damage &damage); 12 | void on_killed(game::IWorld *world, game::Entity *entity); 13 | 14 | private: 15 | [[nodiscard]] static std::string format_death_message(game::IEntitySystem &entity_system, 16 | const game::Damage &damage); 17 | 18 | Health::Dead::OptSink m_dead_sink; 19 | bool m_displayed_death_screen = false; 20 | }; 21 | 22 | }// namespace minecpp::entity::component 23 | -------------------------------------------------------------------------------- /library/entity/include/minecpp/entity/component/ItemSlot.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Location.h" 4 | 5 | #include "minecpp/game/Entity.h" 6 | #include "minecpp/game/EntityData.hpp" 7 | #include "minecpp/game/IWorld.hpp" 8 | 9 | namespace minecpp::entity::component { 10 | 11 | class ItemSlot 12 | { 13 | public: 14 | explicit ItemSlot(game::ItemSlot slot); 15 | 16 | void on_attached(game::Entity &entity); 17 | void on_begin_intersect(game::IWorld &world, game::Entity &entity, game::Entity &other_entity) const; 18 | 19 | void serialize_to_net(game::NetworkEntity *net_entity) const; 20 | 21 | private: 22 | game::ItemSlot m_slot; 23 | Location::BeginIntersect::OptSink m_begin_intersect_sink; 24 | }; 25 | 26 | }// namespace minecpp::entity::component 27 | -------------------------------------------------------------------------------- /library/entity/include/minecpp/entity/component/Test.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Location.h" 3 | #include "Ticker.h" 4 | #include 5 | 6 | namespace minecpp::entity::component { 7 | 8 | class Test 9 | { 10 | public: 11 | Test() = default; 12 | 13 | void tick(game::IWorld &world, game::Entity &entity, double delta_time); 14 | 15 | void on_attached(game::Entity &entity); 16 | void on_position_change(game::IWorld &world, game::Entity &entity, const math::Vector3 &old_position, 17 | const math::Vector3 &new_position); 18 | 19 | private: 20 | int m_position_change_count{}; 21 | Location::PositionChange::OptSink m_position_change_sink; 22 | Ticker::Tick::OptSink m_tick_sink; 23 | }; 24 | 25 | }// namespace minecpp::entity::component 26 | -------------------------------------------------------------------------------- /library/entity/include/minecpp/entity/component/Ticker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace minecpp::game { 7 | class Entity; 8 | } 9 | 10 | namespace minecpp::entity::component { 11 | 12 | class Ticker 13 | { 14 | public: 15 | using Tick = game::Delegate; 16 | Tick on_tick; 17 | 18 | void tick(game::IWorld &world, game::Entity &entity, double delta_time); 19 | }; 20 | 21 | }// namespace minecpp::entity::component -------------------------------------------------------------------------------- /library/entity/include/minecpp/entity/component/Trader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace minecpp::entity::component { 8 | 9 | class Trader 10 | { 11 | public: 12 | void on_interact(game::IWorld &world, game::Entity &self, game::Entity &other); 13 | }; 14 | 15 | }// namespace minecpp::entity::component -------------------------------------------------------------------------------- /library/entity/include/minecpp/entity/component/UniqueId.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "minecpp/game/Entity.h" 4 | #include "minecpp/game/EntityData.hpp" 5 | #include "minecpp/util/Uuid.h" 6 | 7 | namespace minecpp::entity::component { 8 | 9 | class UniqueId 10 | { 11 | public: 12 | UniqueId(); 13 | 14 | void serialize_to_net(game::NetworkEntity *net_entity) const; 15 | 16 | private: 17 | util::Uuid m_id; 18 | }; 19 | 20 | }// namespace minecpp::entity::component -------------------------------------------------------------------------------- /library/entity/include/minecpp/entity/factory/Arrow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace minecpp::entity::factory { 7 | 8 | class Arrow : public IEntityFactory 9 | { 10 | public: 11 | Arrow(const math::Vector3 &initial_velocity, const math::Rotation &rotation, game::EntityId owner_id, 12 | float damage); 13 | game::Entity create_entity(const math::Vector3 &position, game::IEntitySystem &entity_system) override; 14 | 15 | private: 16 | math::Vector3 m_initial_velocity; 17 | math::Rotation m_initial_rotation; 18 | game::EntityId m_owner_id; 19 | float m_damage{0.5f}; 20 | }; 21 | 22 | }// namespace minecpp::entity::factory -------------------------------------------------------------------------------- /library/entity/include/minecpp/entity/factory/Item.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../EntitySystem.h" 3 | #include 4 | 5 | namespace minecpp::entity::factory { 6 | 7 | class Item : public IEntityFactory 8 | { 9 | public: 10 | explicit Item(const game::ItemSlot &slot, random::IRandom &random); 11 | Item(const game::ItemSlot &slot, const math::Vector3 &init_velocity); 12 | game::Entity create_entity(const math::Vector3 &position, game::IEntitySystem &entity_system) override; 13 | 14 | private: 15 | game::ItemSlot m_slot; 16 | math::Vector3 m_init_velocity; 17 | }; 18 | 19 | }// namespace minecpp::entity::factory -------------------------------------------------------------------------------- /library/entity/include/minecpp/entity/factory/Player.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../EntitySystem.h" 3 | #include 4 | #include 5 | 6 | namespace minecpp::entity::factory { 7 | 8 | class Player : public IEntityFactory 9 | { 10 | public: 11 | Player(const game::PlayerId &player_id, std::string name); 12 | 13 | game::Entity create_entity(const math::Vector3 &position, game::IEntitySystem &entity_system) override; 14 | 15 | private: 16 | game::PlayerId m_player_id; 17 | std::string m_name; 18 | }; 19 | 20 | }// namespace minecpp::entity::factory -------------------------------------------------------------------------------- /library/entity/include/minecpp/entity/factory/Totem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace minecpp::entity::factory { 7 | 8 | class Totem : public IEntityFactory 9 | { 10 | public: 11 | Totem(game::Team team, float initial_yaw, float initial_pitch); 12 | 13 | game::Entity create_entity(const math::Vector3 &position, game::IEntitySystem &entity_system) override; 14 | 15 | private: 16 | game::Team m_team; 17 | math::Radians m_initial_yaw; 18 | math::Radians m_initial_pitch; 19 | }; 20 | 21 | 22 | }// namespace minecpp::entity::factory -------------------------------------------------------------------------------- /library/entity/include/minecpp/entity/factory/Trader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace minecpp::entity::factory { 6 | 7 | class Trader : public IEntityFactory 8 | { 9 | public: 10 | Trader(float initial_yaw, float initial_pitch); 11 | 12 | game::Entity create_entity(const math::Vector3 &position, game::IEntitySystem &entity_system) override; 13 | 14 | private: 15 | math::Radians m_initial_yaw; 16 | math::Radians m_initial_pitch; 17 | }; 18 | 19 | }// namespace minecpp::entity::factory 20 | -------------------------------------------------------------------------------- /library/entity/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_ENTITY_INCLUDE_DIR ${MINECPP_ENTITY_DIR}/include/minecpp/entity) 4 | target_sources(minecpp_entity 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/EntitySpace.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/EntitySpace.h 9 | ${CMAKE_CURRENT_SOURCE_DIR}/EntitySystem.cpp 10 | 11 | # Header files 12 | PUBLIC 13 | ${MINECPP_ENTITY_INCLUDE_DIR}/Aliases.hpp 14 | ${MINECPP_ENTITY_INCLUDE_DIR}/EntitySystem.h 15 | ) 16 | 17 | # Subdirectories 18 | add_subdirectory("component") 19 | add_subdirectory("factory") 20 | 21 | -------------------------------------------------------------------------------- /library/entity/src/component/TickComponent.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace minecpp::entity::component { 5 | 6 | void Ticker::tick(game::IWorld &world, game::Entity &entity, double delta_time) 7 | { 8 | on_tick.publish(world, entity, std::move(delta_time)); 9 | } 10 | 11 | }// namespace minecpp::entity::component 12 | -------------------------------------------------------------------------------- /library/entity/src/component/UniqueId.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace minecpp::entity::component { 5 | 6 | boost::uuids::random_generator g_uuid_generator; 7 | 8 | UniqueId::UniqueId() : 9 | m_id(g_uuid_generator()) 10 | { 11 | } 12 | 13 | void UniqueId::serialize_to_net(game::NetworkEntity *net_entity) const 14 | { 15 | assert(net_entity); 16 | net_entity->entity_data.unique_id = m_id; 17 | } 18 | 19 | }// namespace minecpp::entity::component -------------------------------------------------------------------------------- /library/entity/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_entity_test", 3 | "is_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "minecpp_entity", 7 | "GTest::gtest", 8 | "GTest::gtest_main" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /library/entity/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_ENTITY_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_entity_test) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_entity_test 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/entity_test 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_entity_test 17 | LINK_PUBLIC 18 | minecpp_entity 19 | GTest::gtest 20 | GTest::gtest_main 21 | ) 22 | 23 | add_test(NAME minecpp_entity COMMAND minecpp_entity_test) 24 | -------------------------------------------------------------------------------- /library/entity/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_entity_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/SpaceTest.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /library/format/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_format", 3 | "has_test": true, 4 | "dependencies": {} 5 | } 6 | -------------------------------------------------------------------------------- /library/format/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_FORMAT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_format STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_format 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/format 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_format 17 | ) 18 | 19 | add_subdirectory("test") 20 | -------------------------------------------------------------------------------- /library/format/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_FORMAT_INCLUDE_DIR ${MINECPP_FORMAT_DIR}/include/minecpp/format) 4 | target_sources(minecpp_format 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Format.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_FORMAT_INCLUDE_DIR}/Format.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /library/format/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_format_test", 3 | "is_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "GTest::gtest", 7 | "GTest::gtest_main", 8 | "minecpp_format" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /library/format/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_FORMAT_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_format_test) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_format_test 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/format_test 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_format_test 17 | LINK_PUBLIC 18 | GTest::gtest 19 | GTest::gtest_main 20 | minecpp_format 21 | ) 22 | 23 | add_test(NAME minecpp_format COMMAND minecpp_format_test) 24 | -------------------------------------------------------------------------------- /library/format/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_format_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/FormatTest.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /library/format/test/src/FormatTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | TEST(Format, ok) 5 | { 6 | auto text = minecpp::format::Builder() 7 | .text("hello ") 8 | .bold(minecpp::format::Color::DarkPurple, "purple ") 9 | .text(minecpp::format::Color::Green, "world") 10 | .to_string(); 11 | 12 | EXPECT_EQ( 13 | text, 14 | R"({"text": "hello ", "extra": [{"text": "purple ", "color": "dark_purple", "bold": true}, {"text": "world", "color": "green"}]})"); 15 | } -------------------------------------------------------------------------------- /library/game/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_game", 3 | "has_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "EnTT", 7 | "libmb", 8 | "minecpp_api", 9 | "minecpp_chat", 10 | "minecpp_math", 11 | "minecpp_utils", 12 | "minecpp_signal" 13 | ], 14 | "private": [ 15 | "minecpp_nbt", 16 | "minecpp_random", 17 | "spdlog::spdlog" 18 | ] 19 | } 20 | } -------------------------------------------------------------------------------- /library/game/include/minecpp/game/Abilities.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace minecpp::game { 6 | 7 | struct Abilities 8 | { 9 | float fly_speed = 0.05f; 10 | bool flying = false; 11 | bool instant_build = true; 12 | bool invulnerable = false; 13 | bool may_build = false; 14 | bool may_fly = false; 15 | float field_of_view = 0.1f; 16 | 17 | [[nodiscard]] constexpr std::uint32_t flags() const 18 | { 19 | return (invulnerable ? 1u : 0u) | (flying ? 2u : 0u) | (may_fly ? 4u : 0u) | (instant_build ? 8u : 0u); 20 | } 21 | }; 22 | 23 | }// namespace minecpp::game -------------------------------------------------------------------------------- /library/game/include/minecpp/game/Delegate.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace minecpp::game { 8 | 9 | template 10 | using Delegate = signal::Delegate; 11 | 12 | }// namespace minecpp::game -------------------------------------------------------------------------------- /library/game/include/minecpp/game/EntityData.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "minecpp/net/play/Clientbound.schema.h" 4 | 5 | #include 6 | 7 | namespace minecpp::game 8 | { 9 | 10 | struct NetworkEntity 11 | { 12 | net::play::cb::SpawnEntity entity_data; 13 | net::play::cb::SetEntityMetadata metadata; 14 | std::vector equipment; 15 | }; 16 | 17 | struct NetworkPlayer 18 | { 19 | net::play::cb::SpawnPlayer player_data; 20 | net::play::cb::SetEntityMetadata metadata; 21 | std::vector equipment; 22 | }; 23 | 24 | } -------------------------------------------------------------------------------- /library/game/include/minecpp/game/Entt.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /library/game/include/minecpp/game/Hand.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace minecpp::game { 4 | 5 | enum class HandSide 6 | { 7 | Left, 8 | Right 9 | }; 10 | 11 | }// namespace minecpp::game -------------------------------------------------------------------------------- /library/game/include/minecpp/game/IItemController.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IWorld.hpp" 4 | 5 | namespace minecpp::game { 6 | 7 | class IItemController 8 | { 9 | public: 10 | virtual ~IItemController() noexcept = default; 11 | 12 | virtual void on_item_use(IWorld &world, PlayerId player_id, EntityId player_entity_id, ItemId item_id) = 0; 13 | virtual void on_interact(IWorld &world, ItemId item_id, InteractionType interaction_type, 14 | EntityId player_entity_id, EntityId interaction_entity_id, 15 | const math::Vector3f &position, bool is_offhand) = 0; 16 | virtual void on_released_item(IWorld &world, ItemId item_id, EntityId player_entity_id) = 0; 17 | }; 18 | 19 | }// namespace minecpp::game -------------------------------------------------------------------------------- /library/game/include/minecpp/game/Light.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BlockPosition.h" 4 | 5 | #include 6 | #include 7 | 8 | namespace minecpp::game { 9 | 10 | enum class LightTypeValue 11 | { 12 | Block, 13 | Sky 14 | }; 15 | 16 | using LightType_Base = mb::enum_wrapper; 17 | 18 | class LightType final : public LightType_Base 19 | { 20 | public: 21 | MB_ENUM_TRAITS(LightType); 22 | 23 | MB_ENUM_FIELD(Block) 24 | MB_ENUM_FIELD(Sky) 25 | }; 26 | 27 | struct LightSource 28 | { 29 | BlockPosition position{}; 30 | mb::u8 strength{}; 31 | 32 | LightSource(); 33 | 34 | LightSource(const BlockPosition &position, mb::u8 strength); 35 | }; 36 | 37 | }// namespace minecpp::game -------------------------------------------------------------------------------- /library/game/include/minecpp/game/Mode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace minecpp::game { 4 | 5 | enum class Mode 6 | { 7 | Survival, 8 | Creative, 9 | Adventure, 10 | Spectator, 11 | Hardcore, 12 | }; 13 | 14 | }// namespace minecpp::game 15 | -------------------------------------------------------------------------------- /library/game/include/minecpp/game/Types.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace minecpp::game { 7 | 8 | using ChunkHash = mb::u64; 9 | using SlotId = mb::u32; 10 | using PlayerId = util::Uuid; 11 | using BlockId = mb::i32; 12 | using EntityId = mb::u32; 13 | using BlockStateId = mb::u32; 14 | using StateOffset = mb::i32; 15 | using ItemId = mb::i32; 16 | using LightValue = mb::u8; 17 | 18 | }// namespace minecpp::game 19 | -------------------------------------------------------------------------------- /library/game/include/minecpp/game/player/Id.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace minecpp::game::player { 6 | 7 | using Id = game::PlayerId; 8 | 9 | inline Id read_id_from_nbt(const std::vector &id) 10 | { 11 | if (id.size() != 4) 12 | return {}; 13 | return util::read_uuid4(id[0], id[1], id[2], id[3]); 14 | } 15 | 16 | inline std::vector write_id_to_nbt(Id id) 17 | { 18 | auto [a, b, c, d] = util::write_uuid4(id); 19 | return std::vector{a, b, c, d}; 20 | } 21 | 22 | inline std::string format_player_id(Id player_id) 23 | { 24 | return boost::uuids::to_string(player_id); 25 | } 26 | 27 | }// namespace minecpp::game::player -------------------------------------------------------------------------------- /library/game/include/minecpp/game/player/Provider.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Id.h" 3 | #include 4 | 5 | namespace minecpp::game::player { 6 | 7 | class Player; 8 | 9 | class Provider 10 | { 11 | public: 12 | virtual ~Provider() noexcept = default; 13 | 14 | virtual mb::result get_player(Id id) = 0; 15 | }; 16 | 17 | }// namespace minecpp::game::player 18 | -------------------------------------------------------------------------------- /library/game/include/minecpp/game/property/Half.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace minecpp::game { 6 | 7 | enum class HalfValue 8 | { 9 | Lower, 10 | Upper 11 | }; 12 | 13 | using Half_Base = mb::enum_wrapper; 14 | 15 | class Half final : public Half_Base 16 | { 17 | public: 18 | MB_ENUM_TRAITS(Half); 19 | 20 | MB_ENUM_FIELD(Lower) 21 | MB_ENUM_FIELD(Upper) 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /library/game/include/minecpp/game/property/HalfPlacement.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace minecpp::game { 6 | 7 | enum class HalfPlacementValue 8 | { 9 | Top, 10 | Bottom 11 | }; 12 | 13 | using HalfPlacement_Base = mb::enum_wrapper; 14 | 15 | class HalfPlacement final : public HalfPlacement_Base 16 | { 17 | public: 18 | MB_ENUM_TRAITS(HalfPlacement); 19 | 20 | MB_ENUM_FIELD(Top) 21 | MB_ENUM_FIELD(Bottom) 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /library/game/include/minecpp/game/property/Side.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace minecpp::game { 6 | 7 | enum class SideValue 8 | { 9 | Left, 10 | Right 11 | }; 12 | 13 | using Side_Base = mb::enum_wrapper; 14 | 15 | class Side final : public Side_Base 16 | { 17 | public: 18 | MB_ENUM_TRAITS(Side); 19 | 20 | MB_ENUM_FIELD(Left) 21 | MB_ENUM_FIELD(Right) 22 | }; 23 | 24 | }// namespace minecpp::game 25 | -------------------------------------------------------------------------------- /library/game/include/minecpp/game/property/SlabType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace minecpp::game { 6 | 7 | class HalfPlacement; 8 | 9 | enum class SlabTypeValue 10 | { 11 | Top, 12 | Bottom, 13 | Double 14 | }; 15 | 16 | using SlabType_Base = mb::enum_wrapper; 17 | 18 | class SlabType : public SlabType_Base 19 | { 20 | public: 21 | MB_ENUM_TRAITS(SlabType) 22 | 23 | MB_ENUM_FIELD(Top) 24 | MB_ENUM_FIELD(Bottom) 25 | MB_ENUM_FIELD(Double) 26 | 27 | static SlabType from_half_placement(HalfPlacement half); 28 | }; 29 | 30 | }// namespace minecpp::game 31 | -------------------------------------------------------------------------------- /library/game/src/Game.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace minecpp::game { 4 | 5 | FaceMask face_mask_from_nbt(const nbt::common::FaceMask &nbt_mask) 6 | { 7 | FaceMask result{}; 8 | result |= nbt_mask.down ? FaceMask::Bottom : FaceMask::None; 9 | result |= nbt_mask.up ? FaceMask::Top : FaceMask::None; 10 | result |= nbt_mask.north ? FaceMask::North : FaceMask::None; 11 | result |= nbt_mask.south ? FaceMask::South : FaceMask::None; 12 | result |= nbt_mask.west ? FaceMask::West : FaceMask::None; 13 | result |= nbt_mask.east ? FaceMask::East : FaceMask::None; 14 | return result; 15 | } 16 | 17 | }// namespace minecpp::game -------------------------------------------------------------------------------- /library/game/src/Light.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace minecpp::game { 4 | 5 | LightSource::LightSource() = default; 6 | 7 | LightSource::LightSource(const BlockPosition &position, mb::u8 strength) : 8 | position(position), 9 | strength(strength) 10 | { 11 | } 12 | 13 | }// namespace minecpp::game 14 | -------------------------------------------------------------------------------- /library/game/src/Rules.cpp: -------------------------------------------------------------------------------- 1 | namespace minecpp::game { 2 | 3 | }// namespace minecpp::game 4 | -------------------------------------------------------------------------------- /library/game/src/World.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace minecpp::game { 4 | } 5 | -------------------------------------------------------------------------------- /library/game/src/block/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_GAME_BLOCK_INCLUDE_DIR ${MINECPP_GAME_DIR}/include/minecpp/game/block) 4 | target_sources(minecpp_game 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Block.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Material.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_GAME_BLOCK_INCLUDE_DIR}/Block.h 13 | ${MINECPP_GAME_BLOCK_INCLUDE_DIR}/Color.h 14 | ${MINECPP_GAME_BLOCK_INCLUDE_DIR}/Material.h 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /library/game/src/item/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_GAME_ITEM_INCLUDE_DIR ${MINECPP_GAME_DIR}/include/minecpp/game/item) 4 | target_sources(minecpp_game 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Item.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Recipe.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_GAME_ITEM_INCLUDE_DIR}/Item.h 13 | ${MINECPP_GAME_ITEM_INCLUDE_DIR}/Recipe.h 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /library/game/src/item/Item.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace minecpp::game::item { 4 | 5 | Item::Item(Item::Details details) : 6 | m_tag(std::string(details.tag)), 7 | m_is_block(details.is_block), 8 | m_corresponding_block_tag(details.corresponding_block_tag) 9 | { 10 | } 11 | 12 | }// namespace minecpp::game::item 13 | -------------------------------------------------------------------------------- /library/game/src/player/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_GAME_PLAYER_INCLUDE_DIR ${MINECPP_GAME_DIR}/include/minecpp/game/player) 4 | target_sources(minecpp_game 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Player.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_GAME_PLAYER_INCLUDE_DIR}/Id.h 12 | ${MINECPP_GAME_PLAYER_INCLUDE_DIR}/Player.h 13 | ${MINECPP_GAME_PLAYER_INCLUDE_DIR}/Provider.hpp 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /library/game/src/player/Player.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace minecpp::game::player { 5 | 6 | Player::Player(Id id, std::string_view name) : 7 | m_id(id), 8 | m_name(name) 9 | { 10 | } 11 | 12 | Player Player::from_nbt(const nbt::player::Player &player, const std::string_view name) 13 | { 14 | Player result(read_id_from_nbt(player.uuid), name); 15 | return result; 16 | } 17 | 18 | }// namespace minecpp::game::player 19 | 20 | // namespace minecpp::game::player -------------------------------------------------------------------------------- /library/game/src/property/SlabType.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace minecpp::game { 6 | 7 | SlabType SlabType::from_half_placement(HalfPlacement half) 8 | { 9 | switch (half.value()) { 10 | case HalfPlacement::Top: return Top; 11 | case HalfPlacement::Bottom: return Bottom; 12 | } 13 | assert(false); 14 | return {}; 15 | } 16 | 17 | }// namespace minecpp::game -------------------------------------------------------------------------------- /library/game/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_game_test", 3 | "is_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "GTest::gtest", 7 | "GTest::gtest_main", 8 | "minecpp_game" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /library/game/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_GAME_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_game_test) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_game_test 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/game_test 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_game_test 17 | LINK_PUBLIC 18 | GTest::gtest 19 | GTest::gtest_main 20 | minecpp_game 21 | ) 22 | 23 | add_test(NAME minecpp_game COMMAND minecpp_game_test) 24 | -------------------------------------------------------------------------------- /library/game/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_game_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/PositionTest.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /library/lexer/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_lexer", 3 | "examples": [ 4 | "python" 5 | ], 6 | "dependencies": {} 7 | } 8 | -------------------------------------------------------------------------------- /library/lexer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_LEXER_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_lexer STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_lexer 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/lexer 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_lexer 17 | ) 18 | 19 | add_subdirectory("example/python") 20 | -------------------------------------------------------------------------------- /library/lexer/example/python/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_lexer_example_python", 3 | "dependencies": { 4 | "private": [ 5 | "libmb", 6 | "minecpp_utils", 7 | "minecpp_lexer", 8 | "spdlog::spdlog" 9 | ] 10 | } 11 | } -------------------------------------------------------------------------------- /library/lexer/example/python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_LEXER_EXAMPLE_PYTHON_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_lexer_example_python) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_lexer_example_python 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/lexer_example_python 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_lexer_example_python 17 | LINK_PRIVATE 18 | libmb 19 | minecpp_utils 20 | minecpp_lexer 21 | spdlog::spdlog 22 | ) 23 | -------------------------------------------------------------------------------- /library/lexer/example/python/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_lexer_example_python 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /library/lexer/include/minecpp/lexer/Error.h: -------------------------------------------------------------------------------- 1 | #ifndef MINECPP_ERROR_H 2 | #define MINECPP_ERROR_H 3 | #include 4 | #include 5 | 6 | namespace minecpp::lexer { 7 | 8 | enum class ErrorType 9 | { 10 | UnexpectedToken 11 | }; 12 | 13 | struct Error 14 | { 15 | int line, column; 16 | ErrorType type; 17 | }; 18 | 19 | constexpr std::string_view to_string(minecpp::lexer::ErrorType type) 20 | { 21 | using namespace std::string_view_literals; 22 | using minecpp::lexer::ErrorType; 23 | switch (type) { 24 | case minecpp::lexer::ErrorType::UnexpectedToken: return "unexpected token"; 25 | } 26 | return ""; 27 | } 28 | 29 | template 30 | using Result = mb::result; 31 | 32 | }// namespace minecpp::lexer 33 | 34 | #endif//MINECPP_ERROR_H 35 | -------------------------------------------------------------------------------- /library/lexer/include/minecpp/lexer/IReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace minecpp::lexer { 4 | 5 | class IReader 6 | { 7 | public: 8 | virtual bool has_next() = 0; 9 | virtual char next() = 0; 10 | virtual void step_back() = 0; 11 | }; 12 | 13 | }// namespace minecpp::lexer 14 | -------------------------------------------------------------------------------- /library/lexer/include/minecpp/lexer/IStreamReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IReader.h" 4 | 5 | #include 6 | 7 | namespace minecpp::lexer { 8 | 9 | class IStreamReader : public IReader 10 | { 11 | public: 12 | explicit IStreamReader(std::istream &stream); 13 | 14 | bool has_next() override; 15 | char next() override; 16 | void step_back() override; 17 | 18 | private: 19 | std::istream &m_stream; 20 | char m_next_char; 21 | }; 22 | 23 | }// namespace minecpp::lexer -------------------------------------------------------------------------------- /library/lexer/include/minecpp/lexer/Token.h: -------------------------------------------------------------------------------- 1 | #ifndef MINECPP_TOKEN_H 2 | #define MINECPP_TOKEN_H 3 | #include 4 | 5 | namespace minecpp::lexer { 6 | 7 | enum class TokenType 8 | { 9 | Identifier, 10 | Variable, 11 | DollarSign, 12 | String, 13 | Byte, 14 | Short, 15 | Int, 16 | Long, 17 | Float, 18 | Double, 19 | Colon, 20 | Comma, 21 | LeftParen, 22 | RightParen, 23 | LeftBrace, 24 | RightBrace, 25 | LeftSquareBracket, 26 | RightSquareBracket, 27 | }; 28 | 29 | struct Token 30 | { 31 | TokenType type; 32 | std::string value; 33 | int line, column; 34 | }; 35 | 36 | }// namespace minecpp::lexer 37 | 38 | #endif//MINECPP_TOKEN_H 39 | -------------------------------------------------------------------------------- /library/lexer/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_LEXER_INCLUDE_DIR ${MINECPP_LEXER_DIR}/include/minecpp/lexer) 4 | target_sources(minecpp_lexer 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/IStreamReader.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Lexer.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_LEXER_INCLUDE_DIR}/Core.h 13 | ${MINECPP_LEXER_INCLUDE_DIR}/Error.h 14 | ${MINECPP_LEXER_INCLUDE_DIR}/IReader.h 15 | ${MINECPP_LEXER_INCLUDE_DIR}/IStreamReader.h 16 | ${MINECPP_LEXER_INCLUDE_DIR}/Lexer.h 17 | ${MINECPP_LEXER_INCLUDE_DIR}/Reader.h 18 | ${MINECPP_LEXER_INCLUDE_DIR}/TokenFeed.h 19 | ${MINECPP_LEXER_INCLUDE_DIR}/Token.h 20 | ) 21 | 22 | -------------------------------------------------------------------------------- /library/lexer/src/IStreamReader.cpp: -------------------------------------------------------------------------------- 1 | #include "IStreamReader.h" 2 | 3 | namespace minecpp::lexer { 4 | 5 | IStreamReader::IStreamReader(std::istream &stream) : 6 | m_stream(stream) 7 | { 8 | } 9 | 10 | bool IStreamReader::has_next() 11 | { 12 | return m_stream.readsome(&m_next_char, sizeof(char)) == 1; 13 | } 14 | 15 | char IStreamReader::next() 16 | { 17 | return m_next_char; 18 | } 19 | 20 | void IStreamReader::step_back() 21 | { 22 | m_stream.seekg(-1, std::ios::cur); 23 | } 24 | 25 | }// namespace minecpp::lexer 26 | -------------------------------------------------------------------------------- /library/math/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_math", 3 | "header_only": true, 4 | "has_test": true, 5 | "dependencies": { 6 | "interface": [ 7 | "fmt::fmt" 8 | ] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /library/math/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_MATH_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_math INTERFACE) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_math INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) 9 | 10 | target_link_libraries(minecpp_math 11 | INTERFACE 12 | fmt::fmt 13 | ) 14 | 15 | add_subdirectory("test") 16 | -------------------------------------------------------------------------------- /library/math/include/minecpp/math/Math.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace minecpp::math { 5 | 6 | template 7 | constexpr TValue crop(TValue value, TValue min, TValue max) 8 | { 9 | if (value < min) 10 | return min; 11 | if (value > max) 12 | return max; 13 | return value; 14 | } 15 | 16 | template 17 | constexpr TValue lerp(TValue value, TValue min, TValue max) 18 | { 19 | return min + value * (max - min); 20 | } 21 | 22 | template 23 | TFloat fmod(TFloat value, const TFloat mod) 24 | { 25 | static constexpr TFloat zero{}; 26 | 27 | if (value > mod) 28 | return std::fmod(value, mod); 29 | if (value < zero) 30 | return mod + std::fmod(value, mod); 31 | 32 | return value; 33 | } 34 | 35 | }// namespace minecpp::math -------------------------------------------------------------------------------- /library/math/include/minecpp/math/Vector2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BaseVector.h" 4 | 5 | #include 6 | 7 | namespace minecpp::math { 8 | 9 | template 10 | requires std::floating_point || std::integral 11 | class BaseVector 12 | { 13 | public: 14 | MCC_MATH_DEFINE_VECTOR_TRAITS(2) 15 | 16 | MCC_MATH_DEFINE_INDEX_GETTER_SETTER(x, 0) 17 | MCC_MATH_DEFINE_INDEX_GETTER_SETTER(y, 1) 18 | 19 | [[nodiscard]] static SelfType from_yaw(ValueType yaw) 20 | { 21 | return {std::cos(yaw), std::sin(yaw)}; 22 | } 23 | }; 24 | 25 | using Vector2 = BaseVector; 26 | using Vector2f = BaseVector; 27 | using Vector2i = BaseVector; 28 | 29 | }// namespace minecpp::math 30 | -------------------------------------------------------------------------------- /library/math/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_math_test", 3 | "is_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "minecpp_math", 7 | "GTest::gtest", 8 | "GTest::gtest_main" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /library/math/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_MATH_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_math_test) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_math_test 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/math_test 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_math_test 17 | LINK_PUBLIC 18 | minecpp_math 19 | GTest::gtest 20 | GTest::gtest_main 21 | ) 22 | 23 | add_test(NAME minecpp_math COMMAND minecpp_math_test) 24 | -------------------------------------------------------------------------------- /library/math/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_math_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/RotationTest.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/VectorTest.cpp 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /library/nbt/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_nbt", 3 | "has_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "minecpp_utils", 7 | "fmt::fmt" 8 | ] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /library/nbt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_NBT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_nbt STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_nbt 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/nbt 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_nbt 17 | LINK_PUBLIC 18 | minecpp_utils 19 | fmt::fmt 20 | ) 21 | 22 | add_subdirectory("test") 23 | -------------------------------------------------------------------------------- /library/nbt/include/minecpp/nbt/Exception.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Tag.h" 4 | 5 | #include 6 | 7 | namespace minecpp::nbt { 8 | 9 | class InvalidTag : public std::runtime_error 10 | { 11 | public: 12 | InvalidTag(std::string_view structure, std::string_view key, TagId expected, TagId actual); 13 | }; 14 | 15 | void verify_tag(std::string_view structure, std::string_view key, TagId expected, TagId actual); 16 | 17 | 18 | }// namespace minecpp::nbt 19 | -------------------------------------------------------------------------------- /library/nbt/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_NBT_INCLUDE_DIR ${MINECPP_NBT_DIR}/include/minecpp/nbt) 4 | target_sources(minecpp_nbt 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Exception.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Parser.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/Reader.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/Tag.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/Writer.cpp 12 | 13 | # Header files 14 | PUBLIC 15 | ${MINECPP_NBT_INCLUDE_DIR}/Exception.h 16 | ${MINECPP_NBT_INCLUDE_DIR}/Parser.h 17 | ${MINECPP_NBT_INCLUDE_DIR}/Reader.h 18 | ${MINECPP_NBT_INCLUDE_DIR}/Tag.h 19 | ${MINECPP_NBT_INCLUDE_DIR}/Writer.h 20 | ) 21 | 22 | -------------------------------------------------------------------------------- /library/nbt/src/Exception.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace minecpp::nbt { 5 | 6 | InvalidTag::InvalidTag(std::string_view structure, std::string_view key, TagId expected, TagId actual) : 7 | std::runtime_error( 8 | fmt::format("nbt: error parsing field {} in structure {}: unexpected tag {} (expected {})", key, 9 | structure, actual, expected)) 10 | { 11 | } 12 | 13 | void verify_tag(std::string_view structure, std::string_view key, TagId expected, TagId actual) 14 | { 15 | if (expected != actual) { 16 | throw InvalidTag(structure, key, expected, actual); 17 | } 18 | } 19 | 20 | }// namespace minecpp::nbt 21 | -------------------------------------------------------------------------------- /library/nbt/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_nbt_test", 3 | "is_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "GTest::gtest", 7 | "GTest::gtest_main", 8 | "minecpp_nbt" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /library/nbt/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_NBT_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_nbt_test) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_nbt_test 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/nbt_test 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_nbt_test 17 | LINK_PUBLIC 18 | GTest::gtest 19 | GTest::gtest_main 20 | minecpp_nbt 21 | ) 22 | 23 | add_test(NAME minecpp_nbt COMMAND minecpp_nbt_test) 24 | -------------------------------------------------------------------------------- /library/nbt/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_nbt_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/NbtTest.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /library/network/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_network", 3 | "has_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "minecpp_world", 7 | "minecpp_container" 8 | ], 9 | "private": [ 10 | "minecpp_container", 11 | "minecpp_nbt", 12 | "minecpp_game", 13 | "Boost::system" 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /library/network/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_NETWORK_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_network STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_network 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/network 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_network 17 | LINK_PUBLIC 18 | minecpp_world 19 | minecpp_container 20 | LINK_PRIVATE 21 | minecpp_container 22 | minecpp_nbt 23 | minecpp_game 24 | Boost::system 25 | ) 26 | 27 | add_subdirectory("test") 28 | -------------------------------------------------------------------------------- /library/network/include/minecpp/network/Chat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace minecpp::network { 6 | 7 | enum class ChatType : uint8_t 8 | { 9 | Chat, 10 | System, 11 | GameInfo 12 | }; 13 | 14 | enum class ChatVisibility : uint8_t 15 | { 16 | Full, 17 | System, 18 | Hidden 19 | }; 20 | 21 | }// namespace minecpp::network 22 | -------------------------------------------------------------------------------- /library/network/include/minecpp/network/Result.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace minecpp::network { 7 | 8 | enum class ErrorValues 9 | { 10 | AddressLoopUpFailed, 11 | }; 12 | 13 | using Error_Base = mb::enum_wrapper; 14 | 15 | class Error : public Error_Base 16 | { 17 | public: 18 | MB_ENUM_TRAITS(Error) 19 | 20 | MB_ENUM_FIELD(AddressLoopUpFailed) 21 | }; 22 | 23 | template 24 | using Result = mb::result; 25 | 26 | }// namespace minecpp::network -------------------------------------------------------------------------------- /library/network/include/minecpp/network/message/Io.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Reader.h" 3 | #include "Writer.h" 4 | -------------------------------------------------------------------------------- /library/network/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_NETWORK_INCLUDE_DIR ${MINECPP_NETWORK_DIR}/include/minecpp/network) 4 | target_sources(minecpp_network 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Chat.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Network.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/NetworkUtil.cpp 10 | 11 | # Header files 12 | PUBLIC 13 | ${MINECPP_NETWORK_INCLUDE_DIR}/Chat.h 14 | ${MINECPP_NETWORK_INCLUDE_DIR}/Network.h 15 | ${MINECPP_NETWORK_INCLUDE_DIR}/NetworkUtil.h 16 | ${MINECPP_NETWORK_INCLUDE_DIR}/Result.hpp 17 | ) 18 | 19 | # Subdirectories 20 | add_subdirectory("message") 21 | 22 | -------------------------------------------------------------------------------- /library/network/src/Chat.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace minecpp::network { 4 | 5 | }// namespace minecpp::network 6 | -------------------------------------------------------------------------------- /library/network/src/message/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_NETWORK_MESSAGE_INCLUDE_DIR ${MINECPP_NETWORK_DIR}/include/minecpp/network/message) 4 | target_sources(minecpp_network 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Reader.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Writer.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_NETWORK_MESSAGE_INCLUDE_DIR}/Io.h 13 | ${MINECPP_NETWORK_MESSAGE_INCLUDE_DIR}/Reader.h 14 | ${MINECPP_NETWORK_MESSAGE_INCLUDE_DIR}/Writer.h 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /library/network/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_network_test", 3 | "is_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "GTest::gtest", 7 | "GTest::gtest_main", 8 | "minecpp_network" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /library/network/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_NETWORK_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_network_test) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_network_test 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/network_test 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_network_test 17 | LINK_PUBLIC 18 | GTest::gtest 19 | GTest::gtest_main 20 | minecpp_network 21 | ) 22 | 23 | add_test(NAME minecpp_network COMMAND minecpp_network_test) 24 | -------------------------------------------------------------------------------- /library/network/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_network_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/IpTest.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/PacketTest.cpp 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /library/network/test/src/PacketTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | TEST(PacketReader, VarInt) 5 | { 6 | char buff[]{(char) 0xe2, (char) 0xde, 0x0b}; 7 | auto stream = std::stringstream(); 8 | stream.write(buff, sizeof(buff)); 9 | 10 | minecpp::network::message::Reader r(stream); 11 | int v = r.read_varint(); 12 | 13 | ASSERT_EQ(v, 192354); 14 | } 15 | -------------------------------------------------------------------------------- /library/random/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_random", 3 | "has_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "minecpp_math" 7 | ], 8 | "private": [ 9 | "minecpp_utils" 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /library/random/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_RANDOM_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_random STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_random 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/random 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_random 17 | LINK_PUBLIC 18 | minecpp_math 19 | LINK_PRIVATE 20 | minecpp_utils 21 | ) 22 | 23 | add_subdirectory("test") 24 | -------------------------------------------------------------------------------- /library/random/include/minecpp/random/IRandom.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace minecpp::random { 5 | 6 | class IRandom 7 | { 8 | public: 9 | [[nodiscard]] virtual int next_int() = 0; 10 | [[nodiscard]] virtual int next_int(uint32_t bound) = 0; 11 | [[nodiscard]] virtual double next_double() = 0; 12 | virtual void reset_seed(uint64_t seed) = 0; 13 | }; 14 | 15 | }// namespace minecpp::random -------------------------------------------------------------------------------- /library/random/include/minecpp/random/JavaRandom.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "IRandom.h" 3 | #include 4 | 5 | namespace minecpp::random { 6 | 7 | class JavaRandom : public IRandom 8 | { 9 | public: 10 | explicit JavaRandom(uint64_t seed); 11 | 12 | [[nodiscard]] int next_int() override; 13 | [[nodiscard]] int next_int(uint32_t bound) override; 14 | [[nodiscard]] double next_double() override; 15 | void reset_seed(uint64_t seed) override; 16 | 17 | private: 18 | int next(int bits); 19 | 20 | uint64_t m_seed; 21 | }; 22 | 23 | }// namespace minecpp::random 24 | -------------------------------------------------------------------------------- /library/random/include/minecpp/random/Mersenne.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "IRandom.h" 3 | #include 4 | 5 | namespace minecpp::random { 6 | 7 | class Mersenne : public IRandom 8 | { 9 | public: 10 | explicit Mersenne(std::uint64_t seed); 11 | 12 | int next_int() override; 13 | int next_int(std::uint32_t bound) override; 14 | double next_double() override; 15 | void reset_seed(std::uint64_t seed) override; 16 | 17 | private: 18 | std::mt19937_64 m_engine; 19 | }; 20 | 21 | }// namespace minecpp::random 22 | -------------------------------------------------------------------------------- /library/random/include/minecpp/random/Perlin3D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "IRandom.h" 3 | #include 4 | 5 | namespace minecpp::random { 6 | 7 | class Perlin3D 8 | { 9 | public: 10 | explicit Perlin3D(IRandom &rand); 11 | 12 | [[nodiscard]] double dot_grad(int x, int y, int z, const math::Vector3 &pos) const; 13 | [[nodiscard]] double at(const math::Vector3 &pos) const; 14 | [[nodiscard]] math::Vector3 grad(int x, int y, int z) const; 15 | 16 | private: 17 | int m_coefficient1; 18 | int m_coefficient2; 19 | int m_coefficient3; 20 | int m_coefficient4; 21 | }; 22 | 23 | }// namespace minecpp::random -------------------------------------------------------------------------------- /library/random/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_RANDOM_INCLUDE_DIR ${MINECPP_RANDOM_DIR}/include/minecpp/random) 4 | target_sources(minecpp_random 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/JavaRandom.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Mersenne.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/Perlin3d.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/Perlin.cpp 11 | 12 | # Header files 13 | PUBLIC 14 | ${MINECPP_RANDOM_INCLUDE_DIR}/IRandom.h 15 | ${MINECPP_RANDOM_INCLUDE_DIR}/JavaRandom.h 16 | ${MINECPP_RANDOM_INCLUDE_DIR}/Mersenne.h 17 | ${MINECPP_RANDOM_INCLUDE_DIR}/Perlin3D.h 18 | ${MINECPP_RANDOM_INCLUDE_DIR}/Perlin.h 19 | ) 20 | 21 | -------------------------------------------------------------------------------- /library/random/src/Mersenne.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace minecpp::random { 4 | 5 | Mersenne::Mersenne(const std::uint64_t seed) : 6 | m_engine(seed) 7 | { 8 | } 9 | 10 | int Mersenne::next_int() 11 | { 12 | return static_cast(m_engine()); 13 | } 14 | 15 | int Mersenne::next_int(const uint32_t bound) 16 | { 17 | return static_cast(m_engine() % bound); 18 | } 19 | 20 | constexpr auto g_double_precision = 0x1000000000; 21 | 22 | double Mersenne::next_double() 23 | { 24 | return static_cast(m_engine() % g_double_precision) / (double) g_double_precision; 25 | } 26 | 27 | void Mersenne::reset_seed(const uint64_t seed) 28 | { 29 | m_engine.seed(seed); 30 | } 31 | 32 | }// namespace minecpp::random 33 | -------------------------------------------------------------------------------- /library/random/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_random_test", 3 | "is_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "GTest::gtest", 7 | "GTest::gtest_main", 8 | "minecpp_random" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /library/random/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_RANDOM_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_random_test) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_random_test 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/random_test 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_random_test 17 | LINK_PUBLIC 18 | GTest::gtest 19 | GTest::gtest_main 20 | minecpp_random 21 | ) 22 | 23 | add_test(NAME minecpp_random COMMAND minecpp_random_test) 24 | -------------------------------------------------------------------------------- /library/random/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_random_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/RandomTest.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /library/region/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_region", 3 | "dependencies": { 4 | "public": [ 5 | "Boost::iostreams", 6 | "libmb", 7 | "fmt::fmt" 8 | ], 9 | "private": [ 10 | "minecpp_utils" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /library/region/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_REGION_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_region STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_region 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/region 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_region 17 | LINK_PUBLIC 18 | Boost::iostreams 19 | libmb 20 | fmt::fmt 21 | LINK_PRIVATE 22 | minecpp_utils 23 | ) 24 | -------------------------------------------------------------------------------- /library/region/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_REGION_INCLUDE_DIR ${MINECPP_REGION_DIR}/include/minecpp/region) 4 | target_sources(minecpp_region 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/File.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_REGION_INCLUDE_DIR}/File.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /library/repository/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_repository", 3 | "has_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "libmb", 7 | "minecpp_game", 8 | "minecpp_api" 9 | ] 10 | } 11 | } -------------------------------------------------------------------------------- /library/repository/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_REPOSITORY_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_repository STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_repository 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/repository 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_repository 17 | LINK_PUBLIC 18 | libmb 19 | minecpp_game 20 | minecpp_api 21 | ) 22 | 23 | add_subdirectory("test") 24 | -------------------------------------------------------------------------------- /library/repository/include/minecpp/repository/Item.h: -------------------------------------------------------------------------------- 1 | #ifndef MINECPP_ITEM_H 2 | #define MINECPP_ITEM_H 3 | #include "Repository.h" 4 | #include 5 | 6 | namespace minecpp::repository { 7 | 8 | class Item : public Repository 9 | { 10 | static Item g_instance; 11 | 12 | public: 13 | constexpr static Item &the() 14 | { 15 | return g_instance; 16 | } 17 | 18 | mb::result lookup_id(const std::string &tag); 19 | }; 20 | 21 | }// namespace minecpp::repository 22 | 23 | #endif//MINECPP_ITEM_H 24 | -------------------------------------------------------------------------------- /library/repository/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_REPOSITORY_INCLUDE_DIR ${MINECPP_REPOSITORY_DIR}/include/minecpp/repository) 4 | target_sources(minecpp_repository 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Block.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Item.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/State.cpp 10 | 11 | # Header files 12 | PUBLIC 13 | ${MINECPP_REPOSITORY_INCLUDE_DIR}/Block.h 14 | ${MINECPP_REPOSITORY_INCLUDE_DIR}/Item.h 15 | ${MINECPP_REPOSITORY_INCLUDE_DIR}/Repository.h 16 | ${MINECPP_REPOSITORY_INCLUDE_DIR}/State.h 17 | ) 18 | 19 | -------------------------------------------------------------------------------- /library/repository/src/Item.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace minecpp::repository { 5 | 6 | Item Item::g_instance; 7 | 8 | mb::result Item::lookup_id(const std::string &tag) 9 | { 10 | auto item_id = repository::Item::the().find_id_by_tag(tag); 11 | if (item_id.ok()) 12 | return item_id; 13 | 14 | return repository::Item::the().find_id_by_tag(fmt::format("minecraft:{}", tag)); 15 | } 16 | 17 | }// namespace minecpp::repository -------------------------------------------------------------------------------- /library/repository/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_repository_test", 3 | "is_test": true, 4 | "resources": [ 5 | "../../../repository.bin" 6 | ], 7 | "dependencies": { 8 | "public": [ 9 | "GTest::gtest", 10 | "GTest::gtest_main", 11 | "minecpp_repository" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /library/repository/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_repository_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/StateTest.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /library/signal/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_signal", 3 | "header_only": true, 4 | "dependencies": { 5 | "interface": [ 6 | "EnTT" 7 | ] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /library/signal/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_SIGNAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_signal INTERFACE) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_signal INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) 9 | 10 | target_link_libraries(minecpp_signal 11 | INTERFACE 12 | EnTT 13 | ) 14 | -------------------------------------------------------------------------------- /library/signal/include/minecpp/signal/Entt.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(__clang__) 4 | #pragma clang diagnostic push 5 | #pragma clang diagnostic ignored "-Wsign-conversion" 6 | #pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" 7 | #elif defined(__GNUC__) 8 | #pragma GCC diagnostic push 9 | #pragma GCC diagnostic ignored "-Wconversion" 10 | #pragma GCC diagnostic ignored "-Wrestrict" 11 | #endif 12 | 13 | #include 14 | 15 | #if defined(__clang__) 16 | #pragma clang diagnostic pop 17 | #elif defined(__GNUC__) 18 | #pragma GCC diagnostic pop 19 | #endif 20 | -------------------------------------------------------------------------------- /library/stream/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_stream", 3 | "examples": [ 4 | "client", 5 | "server" 6 | ], 7 | "dependencies": { 8 | "public": [ 9 | "minecpp_signal", 10 | "minecpp_container", 11 | "minecpp_network" 12 | ], 13 | "private": [ 14 | "enet::enet" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /library/stream/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_STREAM_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_stream STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_stream 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/stream 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_stream 17 | LINK_PUBLIC 18 | minecpp_signal 19 | minecpp_container 20 | minecpp_network 21 | LINK_PRIVATE 22 | enet::enet 23 | ) 24 | 25 | add_subdirectory("example/client") 26 | 27 | add_subdirectory("example/server") 28 | -------------------------------------------------------------------------------- /library/stream/example/client/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_stream_example_client", 3 | "dependencies": { 4 | "private": [ 5 | "minecpp_utils", 6 | "minecpp_stream", 7 | "spdlog::spdlog" 8 | ] 9 | } 10 | } -------------------------------------------------------------------------------- /library/stream/example/client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_STREAM_EXAMPLE_CLIENT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_stream_example_client) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_stream_example_client 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/stream_example_client 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_stream_example_client 17 | LINK_PRIVATE 18 | minecpp_utils 19 | minecpp_stream 20 | spdlog::spdlog 21 | ) 22 | -------------------------------------------------------------------------------- /library/stream/example/client/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_stream_example_client 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /library/stream/example/server/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_stream_example_server", 3 | "dependencies": { 4 | "private": [ 5 | "minecpp_utils", 6 | "minecpp_stream", 7 | "spdlog::spdlog" 8 | ] 9 | } 10 | } -------------------------------------------------------------------------------- /library/stream/example/server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_STREAM_EXAMPLE_SERVER_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_stream_example_server) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_stream_example_server 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/stream_example_server 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_stream_example_server 17 | LINK_PRIVATE 18 | minecpp_utils 19 | minecpp_stream 20 | spdlog::spdlog 21 | ) 22 | -------------------------------------------------------------------------------- /library/stream/example/server/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_stream_example_server 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /library/stream/include/minecpp/stream/Client.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Host.h" 4 | 5 | #include "minecpp/network/Network.h" 6 | 7 | namespace minecpp::stream { 8 | 9 | class Client : public Host 10 | { 11 | public: 12 | Client(); 13 | 14 | std::shared_ptr create_peer(const network::Endpoint &endpoint); 15 | 16 | protected: 17 | std::shared_ptr new_connection_to_shared_ptr(_ENetPeer *peer) override; 18 | }; 19 | 20 | }// namespace minecpp::stream -------------------------------------------------------------------------------- /library/stream/include/minecpp/stream/Server.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Host.h" 4 | 5 | namespace minecpp::stream { 6 | 7 | class Server : public Host 8 | { 9 | public: 10 | explicit Server(Port port); 11 | 12 | protected: 13 | std::shared_ptr new_connection_to_shared_ptr(_ENetPeer *peer) override; 14 | }; 15 | 16 | }// namespace minecpp::stream -------------------------------------------------------------------------------- /library/stream/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_STREAM_INCLUDE_DIR ${MINECPP_STREAM_DIR}/include/minecpp/stream) 4 | target_sources(minecpp_stream 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Client.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Host.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/Peer.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/Server.cpp 11 | 12 | # Header files 13 | PUBLIC 14 | ${MINECPP_STREAM_INCLUDE_DIR}/Client.h 15 | ${MINECPP_STREAM_INCLUDE_DIR}/Host.h 16 | ${MINECPP_STREAM_INCLUDE_DIR}/Peer.h 17 | ${MINECPP_STREAM_INCLUDE_DIR}/Server.h 18 | ) 19 | 20 | -------------------------------------------------------------------------------- /library/stream/src/Server.cpp: -------------------------------------------------------------------------------- 1 | #include "Server.h" 2 | 3 | #include 4 | 5 | namespace minecpp::stream { 6 | 7 | namespace { 8 | ENetHost *initialize_server(Port port) 9 | { 10 | enet_initialize(); 11 | 12 | ENetAddress address; 13 | address.host = ENET_HOST_ANY; 14 | address.port = port; 15 | return enet_host_create(&address, 32, 2, 0, 0); 16 | } 17 | }// namespace 18 | 19 | Server::Server(Port port) : 20 | Host(initialize_server(port)) 21 | { 22 | } 23 | 24 | std::shared_ptr Server::new_connection_to_shared_ptr(_ENetPeer *raw_peer) 25 | { 26 | auto peer = std::make_shared(*this, raw_peer, false); 27 | this->add_peer(peer->id(), peer); 28 | return peer; 29 | } 30 | 31 | }// namespace minecpp::stream 32 | -------------------------------------------------------------------------------- /library/util/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_utils", 3 | "has_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "libmb" 7 | ], 8 | "private": [ 9 | "Boost::iostreams", 10 | "fmt::fmt" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /library/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_UTIL_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_utils STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_utils 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/util 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_utils 17 | LINK_PUBLIC 18 | libmb 19 | LINK_PRIVATE 20 | Boost::iostreams 21 | fmt::fmt 22 | ) 23 | 24 | add_subdirectory("test") 25 | -------------------------------------------------------------------------------- /library/util/include/minecpp/util/Case.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace minecpp::util { 5 | 6 | template 7 | void convert_to_snake_case(TInIterator beg, TInIterator end, TOutIterator out) 8 | { 9 | bool previous_lower = false; 10 | 11 | for (auto at = beg; at != end; ++at) { 12 | if (std::isupper(*at)) { 13 | if (previous_lower) { 14 | *out = '_'; 15 | ++out; 16 | } 17 | *out = static_cast(std::tolower(*at)); 18 | ++out; 19 | previous_lower = false; 20 | continue; 21 | } 22 | *out = *at; 23 | ++out; 24 | previous_lower = true; 25 | } 26 | } 27 | 28 | }// namespace minecpp::util -------------------------------------------------------------------------------- /library/util/include/minecpp/util/Cast.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace minecpp::util { 6 | 7 | template 8 | TTargetType unsafe_cast(TSourceType&& value) { 9 | using SourceType = std::decay_t; 10 | 11 | union { 12 | SourceType source; 13 | TTargetType target; 14 | }; 15 | 16 | static_assert(sizeof(TTargetType) == sizeof(SourceType), "invalid size"); 17 | 18 | source = std::forward(value); 19 | return target; 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /library/util/include/minecpp/util/Compression.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace minecpp::util { 7 | class GZipInputStream : public boost::iostreams::filtering_stream 8 | { 9 | public: 10 | explicit GZipInputStream(std::istream &s); 11 | }; 12 | 13 | class ZlibInputStream : public boost::iostreams::filtering_stream 14 | { 15 | public: 16 | explicit ZlibInputStream(std::istream &s); 17 | }; 18 | 19 | class ZlibOutputStream : public boost::iostreams::filtering_stream 20 | { 21 | public: 22 | explicit ZlibOutputStream(std::istream &s); 23 | }; 24 | 25 | void compress_zlib(std::vector &sink, std::istream &s); 26 | 27 | }// namespace minecpp::util -------------------------------------------------------------------------------- /library/util/include/minecpp/util/Concepts.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | template 5 | concept IndexAssignable = requires(A a, std::size_t i) { a[i] = (uint16_t) 0; }; 6 | -------------------------------------------------------------------------------- /library/util/include/minecpp/util/Context.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace minecpp::util { 6 | 7 | using ContextId = std::uint32_t; 8 | 9 | class Context 10 | { 11 | public: 12 | Context(); 13 | 14 | [[nodiscard]] ContextId id() const; 15 | 16 | private: 17 | ContextId m_id; 18 | }; 19 | 20 | }// namespace minecpp::util -------------------------------------------------------------------------------- /library/util/include/minecpp/util/Hex.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace minecpp::util { 6 | 7 | std::array char_hex(char c); 8 | std::string data_to_hex(const char *data, std::size_t size); 9 | 10 | }// namespace minecpp::util -------------------------------------------------------------------------------- /library/util/include/minecpp/util/Loop.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace minecpp::util { 5 | 6 | void around(int x, int y, std::function f); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /library/util/include/minecpp/util/Pool.h: -------------------------------------------------------------------------------- 1 | #ifndef MINECPP_POOL_H 2 | #define MINECPP_POOL_H 3 | #include 4 | #include 5 | 6 | namespace minecpp::util { 7 | 8 | template 9 | class AtomicPool 10 | { 11 | boost::object_pool m_pool; 12 | std::mutex m_mutex; 13 | 14 | public: 15 | template 16 | [[nodiscard]] T *construct(TArgs &&...args) 17 | { 18 | std::lock_guard lock(m_mutex); 19 | return m_pool.construct(std::forward(args)...); 20 | } 21 | 22 | void free(T *ptr) 23 | { 24 | std::lock_guard lock(m_mutex); 25 | m_pool.free(ptr); 26 | } 27 | }; 28 | 29 | }// namespace minecpp::util 30 | 31 | #endif//MINECPP_POOL_H 32 | -------------------------------------------------------------------------------- /library/util/include/minecpp/util/String.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace minecpp::util { 6 | 7 | std::string repeat_string(std::string_view s, std::size_t n); 8 | 9 | [[nodiscard]] constexpr std::string_view to_string(bool value) 10 | { 11 | return value ? "true" : "false"; 12 | } 13 | 14 | }// namespace minecpp::util 15 | -------------------------------------------------------------------------------- /library/util/include/minecpp/util/Threading.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace minecpp::util { 6 | 7 | enum class ThreadType : int 8 | { 9 | TickThread = 0, 10 | WorkerThread = 1, 11 | }; 12 | 13 | void set_debug_thread_info(ThreadType type, std::size_t index); 14 | 15 | }// namespace minecpp::util 16 | -------------------------------------------------------------------------------- /library/util/include/minecpp/util/Time.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace minecpp::util { 5 | 6 | int64_t now(); 7 | int64_t now_milis(); 8 | 9 | }// namespace minecpp::util 10 | -------------------------------------------------------------------------------- /library/util/include/minecpp/util/Util.h: -------------------------------------------------------------------------------- 1 | #ifndef MINECPP_UTIL_H 2 | #define MINECPP_UTIL_H 3 | 4 | #define GETTER(name) \ 5 | [[nodiscard]] constexpr auto name() const->decltype(m_##name) \ 6 | { \ 7 | return m_##name; \ 8 | } 9 | 10 | #endif//MINECPP_UTIL_H 11 | -------------------------------------------------------------------------------- /library/util/src/Context.cpp: -------------------------------------------------------------------------------- 1 | #include "Context.h" 2 | 3 | #include 4 | 5 | namespace minecpp::util { 6 | 7 | namespace { 8 | 9 | ContextId next_context_id() 10 | { 11 | static std::atomic context_id{0}; 12 | return ++context_id; 13 | } 14 | 15 | }// namespace 16 | 17 | Context::Context() : 18 | m_id{next_context_id()} 19 | { 20 | } 21 | 22 | ContextId Context::id() const 23 | { 24 | return m_id; 25 | } 26 | 27 | }// namespace minecpp::util 28 | -------------------------------------------------------------------------------- /library/util/src/Loop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace minecpp::util { 4 | 5 | void around(int x, int y, std::function f) 6 | { 7 | for (int oy = -1; oy < 2; oy += 2) { 8 | for (int ox = -1; ox < 2; ox += 2) { 9 | f(x + ox, y + oy); 10 | } 11 | } 12 | for (int ox = -1; ox < 2; ox += 2) { 13 | f(x + ox, y); 14 | } 15 | for (int oy = -1; oy < 2; oy += 2) { 16 | f(x, y + oy); 17 | } 18 | } 19 | 20 | }// namespace minecpp::util -------------------------------------------------------------------------------- /library/util/src/String.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace minecpp::util { 4 | 5 | std::string repeat_string(std::string_view s, std::size_t n) 6 | { 7 | if (n == 1) { 8 | return std::string(s); 9 | } 10 | std::string result; 11 | auto full_size = s.size() * n; 12 | result.reserve(full_size); 13 | 14 | for (std::size_t i = 0; i < full_size; i++) { 15 | result.push_back(s.at(i % s.size())); 16 | } 17 | 18 | return result; 19 | } 20 | 21 | }// namespace minecpp::util -------------------------------------------------------------------------------- /library/util/src/Time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace minecpp::util { 4 | 5 | int64_t now() 6 | { 7 | return std::chrono::duration_cast( 8 | std::chrono::system_clock::now().time_since_epoch()) 9 | .count(); 10 | } 11 | 12 | int64_t now_milis() 13 | { 14 | return std::chrono::duration_cast( 15 | std::chrono::system_clock::now().time_since_epoch()) 16 | .count(); 17 | } 18 | 19 | }// namespace minecpp::util 20 | -------------------------------------------------------------------------------- /library/util/src/Uuid.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace minecpp::util { 6 | 7 | void encode_uuid(char dst[], boost::uuids::uuid id) 8 | { 9 | dst[16] = 0; 10 | std::memcpy(dst, id.data, sizeof(id.data)); 11 | } 12 | 13 | void decode_uuid(boost::uuids::uuid &dst, const char *src) 14 | { 15 | std::memcpy(dst.data, src, 16); 16 | } 17 | 18 | mb::result make_uuid(const std::string &id) 19 | { 20 | Uuid result{}; 21 | if (id.size() != 16) 22 | return result; 23 | 24 | decode_uuid(result, id.data()); 25 | return result; 26 | } 27 | 28 | std::string uuid_to_string(Uuid id) 29 | { 30 | char data[17]; 31 | encode_uuid(data, id); 32 | return {data}; 33 | } 34 | 35 | }// namespace minecpp::util 36 | -------------------------------------------------------------------------------- /library/util/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_utils_test", 3 | "is_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "GTest::gtest", 7 | "GTest::gtest_main", 8 | "minecpp_utils" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /library/util/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_UTIL_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_utils_test) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_utils_test 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/util_test 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_utils_test 17 | LINK_PUBLIC 18 | GTest::gtest 19 | GTest::gtest_main 20 | minecpp_utils 21 | ) 22 | 23 | add_test(NAME minecpp_utils COMMAND minecpp_utils_test) 24 | -------------------------------------------------------------------------------- /library/util/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_utils_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/UtilsTest.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /library/world/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_world", 3 | "has_test": true, 4 | "dependencies": { 5 | "public": [ 6 | "minecpp_container", 7 | "minecpp_entity", 8 | "minecpp_game", 9 | "minecpp_math", 10 | "minecpp_random", 11 | "minecpp_repository" 12 | ] 13 | } 14 | } -------------------------------------------------------------------------------- /library/world/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_WORLD_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_world STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_world 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/world 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_world 17 | LINK_PUBLIC 18 | minecpp_container 19 | minecpp_entity 20 | minecpp_game 21 | minecpp_math 22 | minecpp_random 23 | minecpp_repository 24 | ) 25 | 26 | add_subdirectory("test") 27 | -------------------------------------------------------------------------------- /library/world/include/minecpp/world/Util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace minecpp::world { 6 | 7 | int calculate_ref_count(const std::vector &data, const std::vector &palette); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /library/world/include/minecpp/world/terrain/Height.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace minecpp::world::terrain { 7 | 8 | class HeightGenerator 9 | { 10 | random::Mersenne rand; 11 | random::Perlin base_perlin; 12 | random::Perlin perlin_det_amp; 13 | random::DisplacedPerlin perlin_detail0; 14 | random::DisplacedPerlin perlin_detail1; 15 | 16 | public: 17 | explicit HeightGenerator(uint64_t seed); 18 | 19 | short at(int x, int z); 20 | }; 21 | 22 | }// namespace minecpp::world::terrain -------------------------------------------------------------------------------- /library/world/src/population/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_WORLD_POPULATION_INCLUDE_DIR ${MINECPP_WORLD_DIR}/include/minecpp/world/population) 4 | target_sources(minecpp_world 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Chunk.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Object.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/Population.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/Tree.cpp 11 | 12 | # Header files 13 | PUBLIC 14 | ${MINECPP_WORLD_POPULATION_INCLUDE_DIR}/Chunk.h 15 | ${MINECPP_WORLD_POPULATION_INCLUDE_DIR}/Object.h 16 | ${MINECPP_WORLD_POPULATION_INCLUDE_DIR}/Population.h 17 | ${MINECPP_WORLD_POPULATION_INCLUDE_DIR}/Tree.h 18 | ) 19 | 20 | -------------------------------------------------------------------------------- /library/world/src/terrain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_WORLD_TERRAIN_INCLUDE_DIR ${MINECPP_WORLD_DIR}/include/minecpp/world/terrain) 4 | target_sources(minecpp_world 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Height.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Terrain.cpp 9 | 10 | # Header files 11 | PUBLIC 12 | ${MINECPP_WORLD_TERRAIN_INCLUDE_DIR}/Height.h 13 | ${MINECPP_WORLD_TERRAIN_INCLUDE_DIR}/Terrain.h 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /library/world/src/testing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_WORLD_TESTING_INCLUDE_DIR ${MINECPP_WORLD_DIR}/include/minecpp/world/testing) 4 | target_sources(minecpp_world 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/BlockContainer.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_WORLD_TESTING_INCLUDE_DIR}/BlockContainer.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /library/world/test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_world_test", 3 | "is_test": true, 4 | "resources": [ 5 | "../../../repository.bin" 6 | ], 7 | "dependencies": { 8 | "public": [ 9 | "minecpp_world", 10 | "minecpp_container", 11 | "GTest::gtest", 12 | "GTest::gtest_main" 13 | ] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /library/world/test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_world_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/LightTest.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/SectionTest.cpp 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /meta/run-clang-format.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source_directories=( 4 | include 5 | library 6 | test 7 | service 8 | tool 9 | ) 10 | 11 | if [ -z "${CLANG_FORMAT}" ]; then 12 | CLANG_FORMAT=$(which clang-format) 13 | fi 14 | 15 | for dir in "${source_directories[@]}"; do 16 | while IFS= read -r file; do 17 | echo "formatting $file" 18 | $CLANG_FORMAT -i $file 19 | done < <(find $dir -regex '.+\.h' -or -regex '.+\.cpp') 20 | done 21 | -------------------------------------------------------------------------------- /registry.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmbednarek/minecpp/130935326f8e5427113bbc24e7dd8629770520d9/registry.bin -------------------------------------------------------------------------------- /repository.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmbednarek/minecpp/130935326f8e5427113bbc24e7dd8629770520d9/repository.bin -------------------------------------------------------------------------------- /service/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(engine) 2 | add_subdirectory(front) 3 | add_subdirectory(storage) 4 | -------------------------------------------------------------------------------- /service/engine/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_engine", 3 | "api_library": "true", 4 | "dependencies": { 5 | "private": [ 6 | "minecpp_api", 7 | "minecpp_controller", 8 | "minecpp_debug", 9 | "minecpp_engine_api", 10 | "minecpp_entity", 11 | "minecpp_utils", 12 | "minecpp_game", 13 | "minecpp_nbt", 14 | "minecpp_chat", 15 | "minecpp_format", 16 | "minecpp_network", 17 | "minecpp_repository", 18 | "minecpp_command", 19 | "minecpp_storage_api", 20 | "minecpp_stream", 21 | "minecpp_lexer", 22 | "yaml-cpp", 23 | "Boost::system", 24 | "spdlog::spdlog", 25 | "libmb" 26 | ] 27 | } 28 | } -------------------------------------------------------------------------------- /service/engine/api/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_engine_api", 3 | "include_path": "minecpp/service/engine", 4 | "dependencies": { 5 | "public": [ 6 | "minecpp_stream" 7 | ], 8 | "private": [ 9 | "minecpp_api", 10 | "minecpp_game", 11 | "libmb", 12 | "fmt::fmt", 13 | "spdlog::spdlog" 14 | ] 15 | } 16 | } -------------------------------------------------------------------------------- /service/engine/api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_ENGINE_API_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_engine_api STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_engine_api 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/service/engine 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_engine_api 17 | LINK_PUBLIC 18 | minecpp_stream 19 | LINK_PRIVATE 20 | minecpp_api 21 | minecpp_game 22 | libmb 23 | fmt::fmt 24 | spdlog::spdlog 25 | ) 26 | -------------------------------------------------------------------------------- /service/engine/api/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_ENGINE_API_INCLUDE_DIR ${MINECPP_ENGINE_API_DIR}/include/minecpp/service/engine) 4 | target_sources(minecpp_engine_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Api.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_ENGINE_API_INCLUDE_DIR}/Api.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /service/engine/config-docker.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | bind_address: "0.0.0.0" 3 | bind_port: 7000 4 | worker_count: 16 5 | storage: 6 | endpoints: 7 | - "storage:7000" 8 | resources: 9 | data_file: "/config/repository.bin" 10 | registry_file: "/config/registry.bin" 11 | gameplay: 12 | world_seed: 2300 13 | max_players: 2000 14 | spawn_point: 15 | x: 100 16 | y: 72 17 | z: 50 18 | -------------------------------------------------------------------------------- /service/engine/config-local.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | bind_address: "0.0.0.0" 3 | bind_port: 7800 4 | debug_logger: false 5 | storage: 6 | endpoints: 7 | - "127.0.0.1:8080" 8 | resources: 9 | data_file: "repository.bin" 10 | gameplay: 11 | world_seed: 2300 12 | max_players: 2000 13 | spawn_point: 14 | x: 30 15 | y: 80 16 | z: 50 17 | -------------------------------------------------------------------------------- /service/engine/src/TickSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ApiHandler.h" 4 | #include "minecpp/service/storage/Storage.h" 5 | 6 | #include 7 | #include 8 | 9 | namespace minecpp::service::engine { 10 | 11 | class World; 12 | 13 | class TickSystem 14 | { 15 | public: 16 | explicit TickSystem(World &world, ApiHandler &api_handler, storage::StorageClient &m_client); 17 | 18 | void run_tick(double delta_time); 19 | void loop(); 20 | 21 | private: 22 | World &m_world; 23 | std::atomic_bool m_running{true}; 24 | ApiHandler &m_api_handler; 25 | storage::StorageClient &m_storage_client; 26 | int m_last_tps{200}; 27 | }; 28 | 29 | }// namespace minecpp::service::engine -------------------------------------------------------------------------------- /service/engine/src/job/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_engine 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/ChangeBlock.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/ChangeBlock.h 8 | ${CMAKE_CURRENT_SOURCE_DIR}/ChunkIsComplete.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/ChunkIsComplete.h 10 | ${CMAKE_CURRENT_SOURCE_DIR}/GenerateChunk.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/GenerateChunk.h 12 | ${CMAKE_CURRENT_SOURCE_DIR}/HandlePlayerMessage.cpp 13 | ${CMAKE_CURRENT_SOURCE_DIR}/HandlePlayerMessage.h 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /service/engine/src/job/ChangeBlock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "../JobSystem.h" 7 | 8 | namespace minecpp::service::engine::job { 9 | 10 | class ChangeBlock : public IJob 11 | { 12 | public: 13 | ChangeBlock(game::IWorld &world, world::IChunkSystem &chunk_system, const game::BlockPosition &position, 14 | game::BlockStateId target_state_id); 15 | 16 | void run() override; 17 | 18 | private: 19 | game::IWorld &m_world; 20 | world::IChunkSystem &m_chunk_system; 21 | 22 | game::BlockPosition m_position; 23 | game::BlockStateId m_target_state_id{}; 24 | }; 25 | 26 | }// namespace minecpp::service::engine::job -------------------------------------------------------------------------------- /service/engine/src/job/ChunkIsComplete.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../JobSystem.h" 3 | #include 4 | 5 | namespace minecpp::service::engine { 6 | class ChunkSystem; 7 | } 8 | 9 | namespace minecpp::service::engine::job { 10 | 11 | class ChunkIsComplete : public IJobCondition 12 | { 13 | public: 14 | ChunkIsComplete(ChunkSystem &chunk_system, const game::ChunkPosition &chunk_position); 15 | 16 | [[nodiscard]] JobConditionStatus status() const override; 17 | void resolve(JobSystem &job_system) override; 18 | 19 | private: 20 | ChunkSystem &m_chunk_system; 21 | game::ChunkPosition m_chunk_position; 22 | }; 23 | 24 | }// namespace minecpp::service::engine::job 25 | -------------------------------------------------------------------------------- /service/engine/src/job/GenerateChunk.cpp: -------------------------------------------------------------------------------- 1 | #include "GenerateChunk.h" 2 | 3 | #include "minecpp/debug/TraceManager.h" 4 | 5 | namespace minecpp::service::engine::job { 6 | 7 | GenerateChunk::GenerateChunk(const util::Context &ctx, world::Generator &generator, 8 | const game::ChunkPosition &position) : 9 | IJob(ctx), 10 | m_generator(generator), 11 | m_position(position) 12 | { 13 | } 14 | 15 | void GenerateChunk::run() 16 | { 17 | MCPP_TRACE_CTX(GeneratingChunk, m_context, _.chunk_x = m_position.x(), _.chunk_z = m_position.z()); 18 | m_generator.generate_chunk(m_position); 19 | } 20 | 21 | }// namespace minecpp::service::engine::job 22 | -------------------------------------------------------------------------------- /service/engine/src/job/GenerateChunk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../JobSystem.h" 4 | 5 | #include "minecpp/game/ChunkPosition.h" 6 | #include "minecpp/util/Context.h" 7 | #include "minecpp/world/Generator.h" 8 | 9 | namespace minecpp::service::engine::job { 10 | 11 | class GenerateChunk : public IJob 12 | { 13 | public: 14 | GenerateChunk(const util::Context &ctx, world::Generator &generator, const game::ChunkPosition &position); 15 | 16 | void run() override; 17 | 18 | private: 19 | world::Generator &m_generator; 20 | game::ChunkPosition m_position; 21 | }; 22 | 23 | }// namespace minecpp::service::engine::job -------------------------------------------------------------------------------- /service/engine/src/service/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_engine 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/PlayerInteraction.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/PlayerInteraction.h 8 | ${CMAKE_CURRENT_SOURCE_DIR}/PlayerInterface.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/PlayerInterface.h 10 | ${CMAKE_CURRENT_SOURCE_DIR}/PlayerMovement.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/PlayerMovement.h 12 | ${CMAKE_CURRENT_SOURCE_DIR}/PlayerSession.cpp 13 | ${CMAKE_CURRENT_SOURCE_DIR}/PlayerSession.h 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /service/front/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_front", 3 | "dependencies": { 4 | "private": [ 5 | "minecpp_crypto", 6 | "minecpp_utils", 7 | "minecpp_engine_api", 8 | "minecpp_entity", 9 | "minecpp_api", 10 | "minecpp_network", 11 | "minecpp_format", 12 | "minecpp_repository", 13 | "minecpp_chat", 14 | "minecpp_world", 15 | "yaml-cpp", 16 | "Boost::system", 17 | "spdlog::spdlog", 18 | "libmb" 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /service/front/config-docker.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | bind_address: "0.0.0.0" 3 | bind_port: 25565 4 | engine: 5 | endpoints: 6 | - "engine:7000" 7 | strategy: round_robin 8 | encryption: 9 | enabled: true 10 | private_key: "/var/minecpp_key.pem" 11 | resources: 12 | registry: "/config/registry.bin" 13 | -------------------------------------------------------------------------------- /service/front/config-local.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | bind_address: "0.0.0.0" 3 | bind_port: 7101 4 | engine: 5 | endpoints: 6 | - "localhost:7800" 7 | strategy: round_robin 8 | encryption: 9 | enabled: false 10 | debug_logger: true 11 | resources: 12 | registry: "registry.bin" 13 | -------------------------------------------------------------------------------- /service/front/src/Config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | struct Config 8 | { 9 | std::string server_bind_address; 10 | int server_bind_port; 11 | std::vector engine_endpoints; 12 | std::string resources_registry; 13 | bool encryption_enabled; 14 | std::string encryption_private_key; 15 | std::string encryption_pass_phrase; 16 | bool debug_logger; 17 | }; 18 | 19 | Config get_config(const std::string &file_name); 20 | -------------------------------------------------------------------------------- /service/front/src/Ticks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Server.h" 3 | 4 | #include "minecpp/service/engine/Api.h" 5 | 6 | namespace minecpp::service::front { 7 | 8 | class TickManager 9 | { 10 | public: 11 | explicit TickManager(Server &server, engine::Client &client); 12 | 13 | [[noreturn]] void tick(); 14 | void keep_alive(); 15 | 16 | private: 17 | Server &m_server; 18 | engine::Client &m_client; 19 | }; 20 | 21 | }// namespace minecpp::service::front 22 | -------------------------------------------------------------------------------- /service/front/src/protocol/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_front 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Handler.h 7 | ${CMAKE_CURRENT_SOURCE_DIR}/LoginHandler.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/LoginHandler.h 9 | ${CMAKE_CURRENT_SOURCE_DIR}/PlayHandler.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/PlayHandler.h 11 | ${CMAKE_CURRENT_SOURCE_DIR}/Protocol.cpp 12 | ${CMAKE_CURRENT_SOURCE_DIR}/Protocol.h 13 | ${CMAKE_CURRENT_SOURCE_DIR}/StatusHandler.cpp 14 | ${CMAKE_CURRENT_SOURCE_DIR}/StatusHandler.h 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /service/front/src/protocol/Handler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace minecpp::service::front { 5 | 6 | class Connection; 7 | 8 | namespace protocol { 9 | 10 | class Handler 11 | { 12 | public: 13 | virtual void handle(Connection &connection, minecpp::network::message::Reader &reader) = 0; 14 | virtual void handle_disconnect(Connection &connection) = 0; 15 | }; 16 | 17 | }// namespace protocol 18 | 19 | }// namespace minecpp::service::front 20 | -------------------------------------------------------------------------------- /service/front/src/protocol/PlayHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "PlayHandler.h" 2 | #include "../Connection.h" 3 | #include "../Service.h" 4 | 5 | namespace minecpp::service::front::protocol { 6 | 7 | PlayHandler::PlayHandler(Service &service) : 8 | service(service) 9 | { 10 | } 11 | 12 | void PlayHandler::handle(Connection &connection, Reader &reader) 13 | { 14 | connection.async_read_packet(*this); 15 | auto buffer = container::Buffer::from_istream(reader.raw_stream()); 16 | service.send(buffer.as_view(), connection.uuid()); 17 | } 18 | 19 | void PlayHandler::handle_disconnect(Connection &conn) 20 | { 21 | service.on_player_disconnect(conn.service_id(), conn.uuid()); 22 | } 23 | 24 | }// namespace minecpp::service::front::protocol 25 | -------------------------------------------------------------------------------- /service/front/src/protocol/PlayHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Handler.h" 3 | 4 | #include "minecpp/network/message/Io.h" 5 | 6 | #include 7 | 8 | namespace minecpp::service::front { 9 | class Service; 10 | } 11 | 12 | namespace minecpp::service::front::protocol { 13 | 14 | using minecpp::network::message::Reader; 15 | 16 | class PlayHandler : public Handler 17 | { 18 | Service &service; 19 | 20 | public: 21 | explicit PlayHandler(Service &service); 22 | 23 | void handle(Connection &connection, Reader &reader) override; 24 | void handle_disconnect(Connection &connection) override; 25 | }; 26 | 27 | }// namespace minecpp::service::front::protocol 28 | -------------------------------------------------------------------------------- /service/front/src/protocol/Protocol.cpp: -------------------------------------------------------------------------------- 1 | #include "Protocol.h" 2 | 3 | namespace minecpp::service::front::protocol { 4 | 5 | std::string_view state_to_str(State s) 6 | { 7 | switch (s) { 8 | case Handshake: return "Hand.hake"; 9 | case Play: return "play"; 10 | case Status: return "status"; 11 | case Login: return "login"; 12 | } 13 | return "unknown"; 14 | } 15 | 16 | }// namespace minecpp::service::front::protocol 17 | -------------------------------------------------------------------------------- /service/front/src/protocol/Protocol.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace minecpp::service::front::protocol { 5 | 6 | enum State : char 7 | { 8 | Handshake = -1, 9 | Play = 0, 10 | Status = 1, 11 | Login = 2 12 | }; 13 | 14 | std::string_view state_to_str(State s); 15 | 16 | }// namespace minecpp::service::front::protocol 17 | -------------------------------------------------------------------------------- /service/storage/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_storage", 3 | "api_library": "true", 4 | "examples": [ 5 | "api_test", 6 | "fdb_request" 7 | ], 8 | "dependencies": { 9 | "private": [ 10 | "minecpp_api", 11 | "minecpp_utils", 12 | "minecpp_game", 13 | "minecpp_stream", 14 | "Boost::system", 15 | "spdlog::spdlog", 16 | "libmb", 17 | "fdb::fdb" 18 | ] 19 | } 20 | } -------------------------------------------------------------------------------- /service/storage/api/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_storage_api", 3 | "include_path": "minecpp/service/storage", 4 | "dependencies": { 5 | "public": [ 6 | "minecpp_stream", 7 | "minecpp_network" 8 | ], 9 | "private": [ 10 | "minecpp_utils", 11 | "minecpp_game" 12 | ] 13 | } 14 | } -------------------------------------------------------------------------------- /service/storage/api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_STORAGE_API_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_library(minecpp_storage_api STATIC) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_storage_api 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/service/storage 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_storage_api 17 | LINK_PUBLIC 18 | minecpp_stream 19 | minecpp_network 20 | LINK_PRIVATE 21 | minecpp_utils 22 | minecpp_game 23 | ) 24 | -------------------------------------------------------------------------------- /service/storage/api/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_STORAGE_API_INCLUDE_DIR ${MINECPP_STORAGE_API_DIR}/include/minecpp/service/storage) 4 | target_sources(minecpp_storage_api 5 | # Source files 6 | PRIVATE 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Storage.cpp 8 | 9 | # Header files 10 | PUBLIC 11 | ${MINECPP_STORAGE_API_INCLUDE_DIR}/Storage.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /service/storage/example/api_test/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_storage_example_api_test", 3 | "dependencies": { 4 | "private": [ 5 | "minecpp_utils", 6 | "minecpp_game", 7 | "minecpp_storage_api", 8 | "minecpp_world" 9 | ] 10 | } 11 | } -------------------------------------------------------------------------------- /service/storage/example/api_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_STORAGE_EXAMPLE_API_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_storage_example_api_test) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_storage_example_api_test 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/storage_example_api_test 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_storage_example_api_test 17 | LINK_PRIVATE 18 | minecpp_utils 19 | minecpp_game 20 | minecpp_storage_api 21 | minecpp_world 22 | ) 23 | -------------------------------------------------------------------------------- /service/storage/example/api_test/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_storage_example_api_test 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /service/storage/example/fdb_request/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_storage_fdb_request", 3 | "dependencies": { 4 | "private": [ 5 | "fdb_c", 6 | "spdlog::spdlog", 7 | "fmt::fmt" 8 | ] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /service/storage/example/fdb_request/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_STORAGE_EXAMPLE_FDB_REQUEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_storage_fdb_request) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_storage_fdb_request 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/storage_example_fdb_request 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_storage_fdb_request 17 | LINK_PRIVATE 18 | fdb_c 19 | spdlog::spdlog 20 | fmt::fmt 21 | ) 22 | -------------------------------------------------------------------------------- /service/storage/example/fdb_request/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_storage_fdb_request 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /service/storage/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_storage 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/IHandler.h 7 | ${CMAKE_CURRENT_SOURCE_DIR}/IResponder.h 8 | ${CMAKE_CURRENT_SOURCE_DIR}/IStorage.h 9 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/RequestThreadPool.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/RequestThreadPool.h 12 | ${CMAKE_CURRENT_SOURCE_DIR}/Server.cpp 13 | ${CMAKE_CURRENT_SOURCE_DIR}/Server.h 14 | ${CMAKE_CURRENT_SOURCE_DIR}/Service.cpp 15 | ${CMAKE_CURRENT_SOURCE_DIR}/Service.h 16 | ) 17 | 18 | # Subdirectories 19 | add_subdirectory("fdb") 20 | 21 | -------------------------------------------------------------------------------- /service/storage/src/IHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IResponder.h" 4 | 5 | #include "minecpp/container/BasicBuffer.hpp" 6 | 7 | namespace minecpp::service::storage { 8 | 9 | class IHandler 10 | { 11 | public: 12 | virtual ~IHandler() noexcept = default; 13 | 14 | virtual void handle_request(ConnectionId id, container::Buffer request) = 0; 15 | }; 16 | 17 | }// namespace minecpp::service::storage -------------------------------------------------------------------------------- /service/storage/src/IResponder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace minecpp::service::storage { 5 | 6 | using ConnectionId = std::size_t; 7 | 8 | }// namespace minecpp::service::storage -------------------------------------------------------------------------------- /service/storage/src/IStorage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "minecpp/game/ChunkPosition.h" 4 | #include "minecpp/net/Chunk.schema.h" 5 | 6 | #include 7 | 8 | namespace minecpp::service::storage { 9 | 10 | class IStorage 11 | { 12 | public: 13 | virtual ~IStorage() noexcept = default; 14 | 15 | virtual bool write_chunk(const net::Chunk &chunk) = 0; 16 | virtual std::optional read_chunk(game::ChunkPosition position) = 0; 17 | virtual bool update_chunk(game::ChunkPosition position, 18 | const std::function &callback) = 0; 19 | 20 | virtual bool add_chunk_subscription(game::ChunkPosition position, std::uint64_t client_id) = 0; 21 | }; 22 | 23 | }// namespace minecpp::service::storage 24 | -------------------------------------------------------------------------------- /service/storage/src/fdb/Buffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace minecpp::service::storage::fdb { 5 | 6 | struct Buffer 7 | { 8 | const char *data{}; 9 | std::size_t size{}; 10 | }; 11 | 12 | }// namespace minecpp::service::storage::fdb 13 | -------------------------------------------------------------------------------- /service/storage/src/fdb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_storage 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Buffer.h 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Error.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Error.h 9 | ${CMAKE_CURRENT_SOURCE_DIR}/Fdb.h 10 | ${CMAKE_CURRENT_SOURCE_DIR}/Future.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/Future.h 12 | ${CMAKE_CURRENT_SOURCE_DIR}/Storage.cpp 13 | ${CMAKE_CURRENT_SOURCE_DIR}/Storage.h 14 | ${CMAKE_CURRENT_SOURCE_DIR}/Transaction.cpp 15 | ${CMAKE_CURRENT_SOURCE_DIR}/Transaction.h 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /service/storage/src/fdb/Error.cpp: -------------------------------------------------------------------------------- 1 | #include "Error.h" 2 | 3 | namespace minecpp::service::storage::fdb { 4 | 5 | Error::Error(fdb_error_t error_code) : 6 | m_error_code(error_code) 7 | { 8 | } 9 | 10 | bool Error::ok() const 11 | { 12 | return m_error_code == 0; 13 | } 14 | 15 | std::string Error::to_string() const 16 | { 17 | return fdb_get_error(m_error_code); 18 | } 19 | 20 | }// namespace minecpp::service::storage::fdb -------------------------------------------------------------------------------- /service/storage/src/fdb/Error.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Fdb.h" 3 | #include 4 | #include 5 | 6 | namespace minecpp::service::storage::fdb { 7 | 8 | class Error 9 | { 10 | public: 11 | explicit Error(fdb_error_t error_code); 12 | 13 | [[nodiscard]] std::string to_string() const; 14 | [[nodiscard]] bool ok() const; 15 | 16 | private: 17 | fdb_error_t m_error_code; 18 | }; 19 | 20 | template 21 | using Result = mb::result; 22 | 23 | }// namespace minecpp::service::storage::fdb -------------------------------------------------------------------------------- /service/storage/src/fdb/Fdb.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef FDB_API_VERSION 3 | #define FDB_API_VERSION 630 4 | #endif 5 | #include 6 | -------------------------------------------------------------------------------- /service/storage/src/fdb/Future.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Buffer.h" 3 | #include "Error.h" 4 | #include "Fdb.h" 5 | #include 6 | 7 | namespace minecpp::service::storage::fdb { 8 | 9 | class Future 10 | { 11 | public: 12 | explicit Future(FDBFuture *future); 13 | ~Future(); 14 | 15 | Future(Future &) = delete; 16 | Future &operator=(Future &) = delete; 17 | 18 | Future(Future &&) noexcept; 19 | Future &operator=(Future &&) noexcept; 20 | 21 | [[nodiscard]] Error await() const; 22 | 23 | Result get_value(); 24 | 25 | private: 26 | FDBFuture *m_future; 27 | }; 28 | 29 | }// namespace minecpp::service::storage::fdb 30 | -------------------------------------------------------------------------------- /tool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(chunk_extractor) 2 | add_subdirectory(chunk_viewer) 3 | add_subdirectory(nbtscheme) 4 | add_subdirectory(nbt_viewer) 5 | add_subdirectory(recipes) 6 | add_subdirectory(snbt_parser) 7 | add_subdirectory(schema_compiler) 8 | add_subdirectory(trace_tool) 9 | -------------------------------------------------------------------------------- /tool/chunk_extractor/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_chunk_extractor", 3 | "dependencies": { 4 | "private": [ 5 | "minecpp_region", 6 | "minecpp_network", 7 | "minecpp_repository", 8 | "minecpp_nbt", 9 | "minecpp_utils", 10 | "minecpp_game", 11 | "minecpp_network" 12 | ] 13 | } 14 | } -------------------------------------------------------------------------------- /tool/chunk_extractor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_CHUNK_EXTRACTOR_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_chunk_extractor) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_chunk_extractor 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/chunk_extractor 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_chunk_extractor 17 | LINK_PRIVATE 18 | minecpp_region 19 | minecpp_network 20 | minecpp_repository 21 | minecpp_nbt 22 | minecpp_utils 23 | minecpp_game 24 | minecpp_network 25 | ) 26 | -------------------------------------------------------------------------------- /tool/chunk_extractor/r.-1.0.mca: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmbednarek/minecpp/130935326f8e5427113bbc24e7dd8629770520d9/tool/chunk_extractor/r.-1.0.mca -------------------------------------------------------------------------------- /tool/chunk_extractor/r.0.0.mca: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmbednarek/minecpp/130935326f8e5427113bbc24e7dd8629770520d9/tool/chunk_extractor/r.0.0.mca -------------------------------------------------------------------------------- /tool/chunk_extractor/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_chunk_extractor 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /tool/chunk_viewer/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_chunk_viewer", 3 | "dependencies": { 4 | "private": [ 5 | "minecpp_game", 6 | "minecpp_nbt", 7 | "minecpp_utils", 8 | "fmt::fmt" 9 | ] 10 | } 11 | } -------------------------------------------------------------------------------- /tool/chunk_viewer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_CHUNK_VIEWER_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_chunk_viewer) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_chunk_viewer 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/chunk_viewer 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_chunk_viewer 17 | LINK_PRIVATE 18 | minecpp_game 19 | minecpp_nbt 20 | minecpp_utils 21 | fmt::fmt 22 | ) 23 | -------------------------------------------------------------------------------- /tool/chunk_viewer/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_chunk_viewer 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /tool/chunk_viewer/src/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv) 6 | { 7 | if (argc < 2) { 8 | fmt::print(stderr, "not enough arguments"); 9 | return 1; 10 | } 11 | std::ifstream f(argv[1]); 12 | if (!f.is_open()) { 13 | fmt::print(stderr, "could not open file {}", argv[1]); 14 | return 1; 15 | } 16 | auto chunk = minecpp::nbt::chunk::Chunk::deserialize(f); 17 | 18 | fmt::print("chunk is at x: {}, z: {}", chunk.level.x_pos, chunk.level.z_pos); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /tool/nbt_viewer/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_nbt_viewer", 3 | "dependencies": { 4 | "private": [ 5 | "minecpp_nbt", 6 | "minecpp_utils", 7 | "fmt::fmt" 8 | ] 9 | } 10 | } -------------------------------------------------------------------------------- /tool/nbt_viewer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_NBT_VIEWER_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_nbt_viewer) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_nbt_viewer 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/nbt_viewer 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_nbt_viewer 17 | LINK_PRIVATE 18 | minecpp_nbt 19 | minecpp_utils 20 | fmt::fmt 21 | ) 22 | -------------------------------------------------------------------------------- /tool/nbt_viewer/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_nbt_viewer 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /tool/nbtscheme/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_nbtscheme", 3 | "dependencies": { 4 | "private": [ 5 | "minecpp_nbt", 6 | "minecpp_utils", 7 | "fmt::fmt" 8 | ] 9 | } 10 | } -------------------------------------------------------------------------------- /tool/nbtscheme/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_NBTSCHEME_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_nbtscheme) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_nbtscheme 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/nbtscheme 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_nbtscheme 17 | LINK_PRIVATE 18 | minecpp_nbt 19 | minecpp_utils 20 | fmt::fmt 21 | ) 22 | -------------------------------------------------------------------------------- /tool/nbtscheme/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_nbtscheme 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /tool/recipes/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_recipes", 3 | "dependencies": { 4 | "private": [ 5 | "minecpp_network", 6 | "minecpp_game", 7 | "minecpp_repository", 8 | "Boost::program_options", 9 | "Boost::iostreams" 10 | ] 11 | } 12 | } -------------------------------------------------------------------------------- /tool/recipes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_RECIPES_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_recipes) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_recipes 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/recipes 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_recipes 17 | LINK_PRIVATE 18 | minecpp_network 19 | minecpp_game 20 | minecpp_repository 21 | Boost::program_options 22 | Boost::iostreams 23 | ) 24 | -------------------------------------------------------------------------------- /tool/recipes/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_recipes 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /tool/schema_compiler/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_schema_compiler", 3 | "examples": [ 4 | "nbt_generator", 5 | "net_generator" 6 | ], 7 | "dependencies": { 8 | "private": [ 9 | "minecpp_nbt", 10 | "minecpp_lexer", 11 | "libmb", 12 | "fmt::fmt", 13 | "libmb_codegen", 14 | "Boost::program_options" 15 | ] 16 | } 17 | } -------------------------------------------------------------------------------- /tool/schema_compiler/example/nbt_generator/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_schema_compiler_example_nbt_generator", 3 | "dependencies": { 4 | "private": [ 5 | "minecpp_nbt" 6 | ] 7 | } 8 | } -------------------------------------------------------------------------------- /tool/schema_compiler/example/nbt_generator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_SCHEMA_COMPILER_EXAMPLE_NBT_GENERATOR_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_schema_compiler_example_nbt_generator) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_schema_compiler_example_nbt_generator 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/schema_compiler_example_nbt_generator 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_schema_compiler_example_nbt_generator 17 | LINK_PRIVATE 18 | minecpp_nbt 19 | ) 20 | -------------------------------------------------------------------------------- /tool/schema_compiler/example/nbt_generator/schema/Example1.schema: -------------------------------------------------------------------------------- 1 | package minecpp.example1 2 | 3 | // Some Item Stuff 4 | record Item { 5 | Name: string 6 | Count: int16 7 | Props: example2.Properties 8 | } 9 | 10 | // Some person stuff 11 | record Person { 12 | /* sdfsdfsd */ 13 | Name: string 14 | /* sdfsdf */ Surname: /* type */ string 15 | Age: int32 16 | Inventory: list[list[Item]] 17 | [Namespace="dimension_types", Path="dimension_type/stuff"] 18 | DimensionTypes: int32 19 | FooType: variant[int32, string, int8] 20 | } -------------------------------------------------------------------------------- /tool/schema_compiler/example/nbt_generator/schema/Example2.schema: -------------------------------------------------------------------------------- 1 | package minecpp.example2 2 | 3 | record Properties { 4 | Name: string 5 | Position: float64 6 | Count: int16 7 | Meta: map[string, string] 8 | } 9 | -------------------------------------------------------------------------------- /tool/schema_compiler/example/nbt_generator/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_schema_compiler_example_nbt_generator 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Example1.schema.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Example1.schema.h 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Example2.schema.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/Example2.schema.h 10 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /tool/schema_compiler/example/net_generator/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_schema_compiler_example_net_generator", 3 | "dependencies": { 4 | "private": [ 5 | "minecpp_network", 6 | "minecpp_utils" 7 | ] 8 | } 9 | } -------------------------------------------------------------------------------- /tool/schema_compiler/example/net_generator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_SCHEMA_COMPILER_EXAMPLE_NET_GENERATOR_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_schema_compiler_example_net_generator) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_schema_compiler_example_net_generator 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/schema_compiler_example_net_generator 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_schema_compiler_example_net_generator 17 | LINK_PRIVATE 18 | minecpp_network 19 | minecpp_utils 20 | ) 21 | -------------------------------------------------------------------------------- /tool/schema_compiler/example/net_generator/schema/Example2.schema: -------------------------------------------------------------------------------- 1 | generator = "net" 2 | package minecpp.example2 3 | 4 | record Properties { 5 | Name: string 6 | Position: float64 7 | Count: int16 8 | Meta: map[string, string] 9 | } 10 | -------------------------------------------------------------------------------- /tool/schema_compiler/example/net_generator/schema/ExampleNbt.schema: -------------------------------------------------------------------------------- 1 | generator = "nbt" 2 | package minecpp.nbt 3 | 4 | record Properties { 5 | Name: string 6 | Position: float64 7 | Count: int16 8 | Meta: map[string, string] 9 | } 10 | -------------------------------------------------------------------------------- /tool/schema_compiler/example/net_generator/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_schema_compiler_example_net_generator 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Example1.schema.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Example1.schema.h 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Example2.schema.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/Example2.schema.h 10 | ${CMAKE_CURRENT_SOURCE_DIR}/ExampleNbt.schema.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/ExampleNbt.schema.h 12 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /tool/schema_compiler/example/net_generator/src/Example2.schema.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "minecpp/network/message/Reader.h" 3 | #include "minecpp/network/message/Writer.h" 4 | #include 5 | #include 6 | #include 7 | 8 | namespace minecpp::example2 { 9 | 10 | class Properties 11 | { 12 | public: 13 | std::string name{}; 14 | double position{}; 15 | std::int16_t count{}; 16 | std::map meta{}; 17 | void serialize(::minecpp::network::message::Writer &writer) const; 18 | static Properties deserialize(::minecpp::network::message::Reader &reader); 19 | }; 20 | 21 | }// namespace minecpp::example2 22 | -------------------------------------------------------------------------------- /tool/schema_compiler/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_schema_compiler 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Ast.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Ast.h 8 | ${CMAKE_CURRENT_SOURCE_DIR}/IGenerator.h 9 | ${CMAKE_CURRENT_SOURCE_DIR}/Lexer.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/Lexer.h 11 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 12 | ${CMAKE_CURRENT_SOURCE_DIR}/Parser.cpp 13 | ${CMAKE_CURRENT_SOURCE_DIR}/Parser.h 14 | ${CMAKE_CURRENT_SOURCE_DIR}/SymbolTable.cpp 15 | ${CMAKE_CURRENT_SOURCE_DIR}/SymbolTable.h 16 | ) 17 | 18 | # Subdirectories 19 | add_subdirectory("generator") 20 | 21 | -------------------------------------------------------------------------------- /tool/schema_compiler/src/generator/INetworkProperty.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace minecpp::tool::schema_compiler::generator { 4 | 5 | class NetworkSerializeContext; 6 | class NetworkDeserializeContext; 7 | 8 | class INetworkProperty 9 | { 10 | public: 11 | virtual ~INetworkProperty() = default; 12 | 13 | virtual void write_serializer(NetworkSerializeContext &ctx) = 0; 14 | virtual void write_deserializer(NetworkDeserializeContext &ctx) = 0; 15 | }; 16 | 17 | }// namespace minecpp::tool::schema_compiler::generator 18 | -------------------------------------------------------------------------------- /tool/schema_compiler/src/generator/NetworkBasicProperty.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "INetworkProperty.hpp" 4 | 5 | #include 6 | #include 7 | 8 | namespace minecpp::tool::schema_compiler::generator { 9 | 10 | class NetworkBasicProperty : public INetworkProperty 11 | { 12 | public: 13 | NetworkBasicProperty(std::string_view serialize_call, std::string_view deserialize_call); 14 | 15 | void write_serializer(NetworkSerializeContext &ctx) override; 16 | void write_deserializer(NetworkDeserializeContext &ctx) override; 17 | 18 | private: 19 | std::string m_serialize_call; 20 | std::string m_deserialize_call; 21 | }; 22 | 23 | }// namespace minecpp::tool::schema_compiler::generator 24 | -------------------------------------------------------------------------------- /tool/schema_compiler/src/generator/NetworkExternProperty.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "INetworkProperty.hpp" 4 | 5 | namespace minecpp::tool::schema_compiler::generator { 6 | 7 | class NetworkExternProperty : public INetworkProperty 8 | { 9 | public: 10 | void write_serializer(NetworkSerializeContext &ctx) override; 11 | void write_deserializer(NetworkDeserializeContext &ctx) override; 12 | }; 13 | 14 | }// namespace minecpp::tool::schema_compiler::generator 15 | -------------------------------------------------------------------------------- /tool/schema_compiler/src/generator/NetworkListProperty.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "INetworkProperty.hpp" 4 | 5 | namespace minecpp::tool::schema_compiler::generator { 6 | 7 | class NetworkListProperty : public INetworkProperty 8 | { 9 | public: 10 | void write_serializer(NetworkSerializeContext &ctx) override; 11 | void write_deserializer(NetworkDeserializeContext &ctx) override; 12 | }; 13 | 14 | }// namespace minecpp::tool::schema_compiler::generator 15 | -------------------------------------------------------------------------------- /tool/schema_compiler/src/generator/NetworkMapProperty.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "INetworkProperty.hpp" 4 | 5 | namespace minecpp::tool::schema_compiler::generator { 6 | 7 | class NetworkMapProperty : public INetworkProperty 8 | { 9 | public: 10 | void write_serializer(NetworkSerializeContext &ctx) override; 11 | void write_deserializer(NetworkDeserializeContext &ctx) override; 12 | }; 13 | 14 | }// namespace minecpp::tool::schema_compiler::generator 15 | -------------------------------------------------------------------------------- /tool/schema_compiler/src/generator/NetworkOptionalProperty.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "INetworkProperty.hpp" 4 | 5 | namespace minecpp::tool::schema_compiler::generator { 6 | 7 | class NetworkOptionalProperty : public INetworkProperty 8 | { 9 | public: 10 | void write_serializer(NetworkSerializeContext &ctx) override; 11 | void write_deserializer(NetworkDeserializeContext &ctx) override; 12 | }; 13 | 14 | }// namespace minecpp::tool::schema_compiler::generator 15 | -------------------------------------------------------------------------------- /tool/schema_compiler/src/generator/NetworkPropertyStorage.cpp: -------------------------------------------------------------------------------- 1 | #include "NetworkPropertyStorage.h" 2 | #include "../IGenerator.h" 3 | 4 | namespace minecpp::tool::schema_compiler::generator { 5 | 6 | INetworkProperty &NetworkPropertyStorage::property_of(TypeClass type_class, int line, int col) 7 | { 8 | generator_verify(m_properties.contains(type_class), line, col, "no generator for type class: {}", 9 | static_cast(type_class)); 10 | return *m_properties[type_class]; 11 | } 12 | 13 | }// namespace minecpp::tool::schema_compiler::generator -------------------------------------------------------------------------------- /tool/schema_compiler/src/generator/NetworkPropertyStorage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../SymbolTable.h" 4 | #include "INetworkProperty.hpp" 5 | 6 | #include 7 | #include 8 | 9 | namespace minecpp::tool::schema_compiler::generator { 10 | 11 | class NetworkPropertyStorage 12 | { 13 | public: 14 | INetworkProperty &property_of(TypeClass type_class, int line = 0, int col = 0); 15 | 16 | template 17 | void register_property(TypeClass tc, TArgs &&...args) 18 | { 19 | m_properties.emplace(tc, std::make_unique(std::forward(args)...)); 20 | } 21 | 22 | private: 23 | std::map> m_properties; 24 | }; 25 | 26 | }// namespace minecpp::tool::schema_compiler::generator 27 | -------------------------------------------------------------------------------- /tool/schema_compiler/src/generator/NetworkRecordProperty.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "INetworkProperty.hpp" 4 | 5 | namespace minecpp::tool::schema_compiler::generator { 6 | 7 | class NetworkRecordProperty : public INetworkProperty 8 | { 9 | public: 10 | void write_serializer(NetworkSerializeContext &ctx) override; 11 | void write_deserializer(NetworkDeserializeContext &ctx) override; 12 | }; 13 | 14 | }// namespace minecpp::tool::schema_compiler::generator -------------------------------------------------------------------------------- /tool/schema_compiler/src/generator/NetworkVariantProperty.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "INetworkProperty.hpp" 4 | 5 | namespace minecpp::tool::schema_compiler::generator { 6 | 7 | class NetworkVariantProperty : public INetworkProperty 8 | { 9 | public: 10 | void write_serializer(NetworkSerializeContext &ctx) override; 11 | void write_deserializer(NetworkDeserializeContext &ctx) override; 12 | }; 13 | 14 | }// namespace minecpp::tool::schema_compiler::generator -------------------------------------------------------------------------------- /tool/snbt_parser/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_tool_snbt_parser", 3 | "dependencies": { 4 | "private": [ 5 | "minecpp_nbt", 6 | "Boost::program_options" 7 | ] 8 | } 9 | } -------------------------------------------------------------------------------- /tool/snbt_parser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_SNBT_PARSER_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_tool_snbt_parser) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_tool_snbt_parser 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/snbt_parser 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_tool_snbt_parser 17 | LINK_PRIVATE 18 | minecpp_nbt 19 | Boost::program_options 20 | ) 21 | -------------------------------------------------------------------------------- /tool/snbt_parser/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_tool_snbt_parser 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Lexer.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Lexer.h 8 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/Parser.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/Parser.h 11 | ${CMAKE_CURRENT_SOURCE_DIR}/Token.h 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /tool/snbt_parser/src/Token.h: -------------------------------------------------------------------------------- 1 | #ifndef MINECPP_TOKEN_H 2 | #define MINECPP_TOKEN_H 3 | #include 4 | 5 | namespace minecpp::tool::snbt_parser { 6 | 7 | enum class TokenType 8 | { 9 | Identifier, 10 | String, 11 | Byte, 12 | Short, 13 | Int, 14 | Long, 15 | Float, 16 | Double, 17 | Colon, 18 | Comma, 19 | LeftBrace, 20 | RightBrace, 21 | LeftSquareBracket, 22 | RightSquareBracket, 23 | }; 24 | 25 | struct Token 26 | { 27 | TokenType type; 28 | std::string value; 29 | }; 30 | 31 | }// namespace minecpp::tool::snbt_parser 32 | 33 | #endif//MINECPP_TOKEN_H 34 | -------------------------------------------------------------------------------- /tool/trace_tool/Build.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecpp_trace_tool", 3 | "dependencies": { 4 | "private": [ 5 | "minecpp_nbt", 6 | "minecpp_debug", 7 | "libmb", 8 | "fmt::fmt", 9 | "Boost::program_options" 10 | ] 11 | } 12 | } -------------------------------------------------------------------------------- /tool/trace_tool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | set(MINECPP_TRACE_TOOL_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_executable(minecpp_trace_tool) 6 | 7 | # Public include headers 8 | target_include_directories(minecpp_trace_tool 9 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 10 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/minecpp/trace_tool 11 | ) 12 | 13 | # Source subdirectory 14 | add_subdirectory("src") 15 | 16 | target_link_libraries(minecpp_trace_tool 17 | LINK_PRIVATE 18 | minecpp_nbt 19 | minecpp_debug 20 | libmb 21 | fmt::fmt 22 | Boost::program_options 23 | ) 24 | -------------------------------------------------------------------------------- /tool/trace_tool/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # THIS FILE HAS BEEN GENERATED BY THE BUILD CONFIGURATION SYSTEM - DO NOT EDIT 2 | 3 | target_sources(minecpp_trace_tool 4 | # Source files 5 | PRIVATE 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /trace.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmbednarek/minecpp/130935326f8e5427113bbc24e7dd8629770520d9/trace.bin --------------------------------------------------------------------------------