├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ └── build.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE.txt ├── README.md ├── SConstruct ├── app.ico ├── build.gradle.kts ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── src └── main ├── c ├── Common.cpp ├── Common.hpp ├── MbedTlsAesCipherImpl.cpp ├── MbedTlsSha256HasherImpl.cpp ├── OpenSslAesCipherImpl.cpp ├── OpenSslSha256HasherImpl.cpp └── ZlibCompressorImpl.cpp ├── java └── com │ └── valaphee │ └── tesseract │ ├── log │ └── QueueAppender.java │ └── util │ ├── MbedTlsAesCipherImpl.java │ ├── MbedTlsSha256HasherImpl.java │ ├── ZlibCompressorImpl.java │ └── text │ ├── Color.java │ ├── Format.java │ └── StyleCode.java ├── kotlin └── com │ └── valaphee │ ├── foundry │ └── ecs │ │ ├── Attribute.kt │ │ ├── Context.kt │ │ ├── Engine.kt │ │ ├── Message.kt │ │ ├── Response.kt │ │ ├── accessor │ │ ├── AttributeAccessor.kt │ │ ├── BehaviorAccessor.kt │ │ └── FacetAccessor.kt │ │ ├── entity │ │ ├── Entity.kt │ │ ├── EntityType.kt │ │ └── MutableEntity.kt │ │ ├── message │ │ └── StateChanged.kt │ │ ├── mutator │ │ ├── AttributeMutator.kt │ │ ├── BehaviorMutator.kt │ │ └── FacetMutator.kt │ │ └── system │ │ ├── Actor.kt │ │ ├── Behavior.kt │ │ ├── Facet.kt │ │ ├── StateFacet.kt │ │ ├── StateMachineFacet.kt │ │ └── System.kt │ └── tesseract │ ├── Argument.kt │ ├── Instance.kt │ ├── Main.kt │ ├── ServerInstance.kt │ ├── Tesseract.kt │ ├── actor │ ├── Actor.kt │ ├── ActorAddPacket.kt │ ├── ActorPacketizer.kt │ ├── ActorRemovePacket.kt │ ├── ActorTypeRegistry.kt │ ├── Link.kt │ ├── LinkPacket.kt │ ├── Object.kt │ ├── attribute │ │ ├── AttributeField.kt │ │ ├── AttributeValue.kt │ │ ├── Attributes.kt │ │ └── AttributesPacket.kt │ ├── insentient │ │ └── Chicken.kt │ ├── location │ │ ├── Input.kt │ │ ├── Location.kt │ │ ├── LocationManagerMessage.kt │ │ ├── MoveRotatePacket.kt │ │ ├── TeleportPacket.kt │ │ └── VelocityPacket.kt │ ├── metadata │ │ ├── Flag.kt │ │ ├── Flag2.kt │ │ ├── Metadata.kt │ │ ├── MetadataField.kt │ │ ├── MetadataPacket.kt │ │ ├── MetadataType.kt │ │ └── MetadataValue.kt │ ├── player │ │ ├── Appearance.kt │ │ ├── AppearanceAnimation.kt │ │ ├── AppearanceImage.kt │ │ ├── AuthExtra.kt │ │ ├── EmotePacket.kt │ │ ├── EmotesPacket.kt │ │ ├── InputCorrectPacket.kt │ │ ├── InputPacket.kt │ │ ├── InteractPacket.kt │ │ ├── Player.kt │ │ ├── PlayerActionPacket.kt │ │ ├── PlayerAddPacket.kt │ │ ├── PlayerLocationPacket.kt │ │ ├── PlayerPacketizer.kt │ │ ├── Rank.kt │ │ ├── User.kt │ │ ├── WindowManager.kt │ │ ├── interaction │ │ │ ├── BlockBreak.kt │ │ │ ├── BlockUse.kt │ │ │ ├── ChunkInteractionManager.kt │ │ │ └── ChunkInteractionManagerMessage.kt │ │ └── view │ │ │ ├── ChunkPacket.kt │ │ │ ├── ChunkPublishPacket.kt │ │ │ ├── RadialExpansionView.kt │ │ │ ├── RadialView.kt │ │ │ ├── View.kt │ │ │ ├── ViewChunk.kt │ │ │ ├── ViewChunkPacketizer.kt │ │ │ ├── ViewDistancePacket.kt │ │ │ └── ViewDistanceRequestPacket.kt │ └── stack │ │ ├── Stack.kt │ │ ├── StackAddPacket.kt │ │ ├── StackPacketizer.kt │ │ └── StackWrapper.kt │ ├── command │ ├── Command.kt │ ├── CommandManager.kt │ ├── Message.kt │ ├── Parameter.kt │ ├── Permission.kt │ ├── Result.kt │ ├── SubCommand.kt │ └── net │ │ ├── Command.kt │ │ ├── CommandPacket.kt │ │ ├── CommandResponsePacket.kt │ │ ├── CommandSoftEnumerationPacket.kt │ │ ├── CommandsPacket.kt │ │ ├── Enumeration.kt │ │ ├── EnumerationConstraint.kt │ │ ├── Origin.kt │ │ ├── Parameter.kt │ │ └── Permission.kt │ ├── data │ ├── Component.kt │ ├── ComponentRegistry.kt │ ├── Config.kt │ ├── Data.kt │ ├── DataModule.kt │ ├── Index.kt │ ├── Keyed.kt │ ├── Share.kt │ ├── UnknownComponentException.kt │ ├── block │ │ ├── Air.kt │ │ ├── Block.kt │ │ ├── BlockState.kt │ │ ├── Blocks.kt │ │ ├── ConcretePowder.kt │ │ ├── DistributingFallingBlock.kt │ │ ├── FlowingBlock.kt │ │ ├── FlowingLava.kt │ │ ├── FlowingWater.kt │ │ ├── Gravel.kt │ │ └── Sand.kt │ ├── entity │ │ ├── Entity.kt │ │ ├── EntityFactory.kt │ │ ├── EntityTypeData.kt │ │ └── Runtime.kt │ ├── item │ │ ├── Bucket.kt │ │ ├── Chest.kt │ │ ├── Item.kt │ │ ├── LavaBucket.kt │ │ └── WaterBucket.kt │ ├── locale │ │ ├── I18n.kt │ │ └── LocaleData.kt │ └── recipe │ │ ├── FurnaceRecipeData.kt │ │ ├── ShapedRecipeData.kt │ │ └── ShapelessRecipeData.kt │ ├── inventory │ ├── CreativeInventoryPacket.kt │ ├── Inventory.kt │ ├── InventoryContentPacket.kt │ ├── InventoryRequestPacket.kt │ ├── InventoryResponsePacket.kt │ ├── InventorySlotPacket.kt │ ├── InventoryTransactionPacket.kt │ ├── InventoryWrapper.kt │ ├── OneSlotInventory.kt │ ├── PlayerInventory.kt │ ├── UiInventory.kt │ ├── WindowClosePacket.kt │ ├── WindowId.kt │ ├── WindowOpenPacket.kt │ ├── WindowPropertyPacket.kt │ ├── WindowSlotType.kt │ ├── WindowType.kt │ ├── item │ │ ├── Item.kt │ │ └── stack │ │ │ ├── Stack.kt │ │ │ └── meta │ │ │ ├── DyeableMeta.kt │ │ │ ├── MapMeta.kt │ │ │ ├── Meta.kt │ │ │ ├── WritableBookMeta.kt │ │ │ └── WrittenBookMeta.kt │ └── recipe │ │ ├── ContainerMixRecipe.kt │ │ ├── PotionMixRecipe.kt │ │ ├── Recipe.kt │ │ └── RecipesPacket.kt │ ├── log │ └── Log4JLogHandler.kt │ ├── net │ ├── Compressor.kt │ ├── Connection.kt │ ├── Decompressor.kt │ ├── EncryptionInitializer.kt │ ├── GamePublishMode.kt │ ├── Packet.kt │ ├── PacketBuffer.kt │ ├── PacketDecoder.kt │ ├── PacketEncoder.kt │ ├── PacketHandler.kt │ ├── PacketReader.kt │ ├── Pong.kt │ ├── ProtocolHandler.kt │ ├── ReconnectLimiter.kt │ ├── Remote.kt │ ├── Restrict.kt │ ├── Restriction.kt │ ├── UnconnectedPingHandler.kt │ ├── base │ │ ├── CacheBlobStatusPacket.kt │ │ ├── CacheBlobsPacket.kt │ │ ├── CacheStatusPacket.kt │ │ ├── DisconnectPacket.kt │ │ ├── LatencyPacket.kt │ │ ├── LocalPlayerAsInitializedPacket.kt │ │ ├── TextPacket.kt │ │ ├── TickSyncPacket.kt │ │ └── ViolationPacket.kt │ ├── form │ │ ├── ButtonList.kt │ │ ├── CustomForm.kt │ │ ├── Form.kt │ │ └── Modal.kt │ └── init │ │ ├── BehaviorTreePacket.kt │ │ ├── BiomeDefinitionsPacket.kt │ │ ├── ClientToServerHandshakePacket.kt │ │ ├── EntityIdentifiersPacket.kt │ │ ├── InitPacketHandler.kt │ │ ├── LoginPacket.kt │ │ ├── PackDataChunkPacket.kt │ │ ├── PackDataChunkRequestPacket.kt │ │ ├── PackDataPacket.kt │ │ ├── PacksPacket.kt │ │ ├── PacksResponsePacket.kt │ │ ├── PacksStackPacket.kt │ │ ├── ServerToClientHandshakePacket.kt │ │ └── StatusPacket.kt │ ├── util │ ├── AddressUtil.kt │ ├── ByteBufStringReader.kt │ ├── ByteBufWrapper.kt │ ├── Cipher.kt │ ├── Compressor.kt │ ├── EncryptionUtil.kt │ ├── GsonUtil.kt │ ├── Hasher.kt │ ├── Int2IntObjectOpenHashBiMap.kt │ ├── LazyString.kt │ ├── LittleEndianByteBufInputStream.kt │ ├── LittleEndianByteBufOutputStream.kt │ ├── LittleEndianVarIntByteBufInputStream.kt │ ├── LittleEndianVarIntByteBufOutputStream.kt │ ├── NbtUtil.kt │ ├── NibbleArray.kt │ ├── StringUtil.kt │ ├── jackson │ │ ├── BoundingBox.kt │ │ ├── Float2.kt │ │ ├── Float3.kt │ │ └── JacksonUtil.kt │ ├── math │ │ ├── BoundingBox.kt │ │ ├── Direction.kt │ │ └── Math.kt │ ├── nbt │ │ ├── ArrayTag.kt │ │ ├── ByteArrayTagImpl.kt │ │ ├── ByteTagImpl.kt │ │ ├── CompoundTag.kt │ │ ├── CompoundTagImpl.kt │ │ ├── DoubleTagImpl.kt │ │ ├── EndTagImpl.kt │ │ ├── FloatTagImpl.kt │ │ ├── IntArrayTagImpl.kt │ │ ├── IntTagImpl.kt │ │ ├── ListTag.kt │ │ ├── ListTagImpl.kt │ │ ├── LongArrayTagImpl.kt │ │ ├── LongTagImpl.kt │ │ ├── NbtException.kt │ │ ├── NbtInputStream.kt │ │ ├── NbtOutputStream.kt │ │ ├── NumberTag.kt │ │ ├── ShortTagImpl.kt │ │ ├── StringTagImpl.kt │ │ ├── Tag.kt │ │ ├── TagType.kt │ │ └── Tags.kt │ └── text │ │ ├── Component.kt │ │ └── Emoticon.kt │ └── world │ ├── Clock.kt │ ├── Difficulty.kt │ ├── DifficultyPacket.kt │ ├── Dimension.kt │ ├── DimensionPacket.kt │ ├── Environment.kt │ ├── EnvironmentUpdater.kt │ ├── Experiment.kt │ ├── GameMode.kt │ ├── GameModePacket.kt │ ├── GameRule.kt │ ├── GameRulesPacket.kt │ ├── PlayerListPacket.kt │ ├── Settings.kt │ ├── Sound.kt │ ├── SoundEvent.kt │ ├── SoundEventPacket.kt │ ├── SoundEventPacketV1.kt │ ├── SoundEventPacketV2.kt │ ├── SoundPacket.kt │ ├── SoundStopPacket.kt │ ├── TimePacket.kt │ ├── World.kt │ ├── WorldContext.kt │ ├── WorldEngine.kt │ ├── WorldEventPacket.kt │ ├── WorldPacket.kt │ ├── WorldPacketHandler.kt │ ├── chunk │ ├── Broadcast.kt │ ├── Chunk.kt │ ├── ChunkAcquire.kt │ ├── ChunkBroadcaster.kt │ ├── ChunkManager.kt │ ├── ChunkManagerMessage.kt │ ├── ChunkRelease.kt │ ├── ChunkUsage.kt │ ├── actor │ │ ├── Actors.kt │ │ ├── ChunkActorAdd.kt │ │ ├── ChunkActorRemove.kt │ │ ├── ChunkActorUpdate.kt │ │ ├── ChunkIn.kt │ │ └── location │ │ │ └── LocationManager.kt │ └── terrain │ │ ├── BitArray.kt │ │ ├── BlockStorage.kt │ │ ├── BlockUpdateList.kt │ │ ├── BlockUpdatePacket.kt │ │ ├── BlockUpdateSyncedPacket.kt │ │ ├── BlockUpdater.kt │ │ ├── Layer.kt │ │ ├── PropagationBlockUpdateList.kt │ │ ├── ReadOnlyCartesian.kt │ │ ├── ReadWriteCartesian.kt │ │ ├── Section.kt │ │ ├── Terrain.kt │ │ ├── TerrainRuntime.kt │ │ └── generator │ │ ├── FlatGenerator.kt │ │ └── Generator.kt │ └── provider │ ├── InMemoryProvider.kt │ ├── NullProvider.kt │ ├── Provider.kt │ └── TesseractProvider.kt └── resources ├── META-INF └── LICENSE.txt ├── alex.png ├── biome_definitions.dat ├── creative_items.json ├── data ├── entity_types │ ├── chunk.json │ ├── insentient │ │ └── chicken.json │ ├── player.json │ ├── stack.json │ └── world.json └── locales │ ├── de_de.json │ └── en_us.json ├── entity_identifiers.dat ├── humanoid.json ├── log4j2.xml ├── runtime_block_states.dat └── runtime_item_states.json /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=lf 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | tags: ['*'] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v2 13 | - name: Set up JDK 16 14 | uses: actions/setup-java@v2 15 | with: 16 | java-version: 16 17 | distribution: 'adopt' 18 | cache: gradle 19 | - name: Validate Gradle wrapper 20 | uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b 21 | - name: Build with Gradle 22 | run: gradle shadowJar 23 | - name: Create Release 24 | uses: actions/create-release@v1 25 | id: create_release 26 | env: 27 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 28 | with: 29 | tag_name: ${{ github.ref }} 30 | release_name: Tesseract ${{ github.ref }} 31 | draft: false 32 | prerelease: true 33 | - name: Upload Release Asset 34 | uses: actions/upload-release-asset@v1 35 | env: 36 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 37 | with: 38 | upload_url: ${{ steps.create_release.outputs.upload_url }} 39 | asset_path: build/libs/tesseract.jar 40 | asset_name: tesseract.jar 41 | asset_content_type: application/java-archive 42 | - name: Cleanup Gradle Cache 43 | run: | 44 | rm -f ~/.gradle/caches/modules-2/modules-2.lock 45 | rm -f ~/.gradle/caches/modules-2/gc.properties 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Files that might appear on Windows 2 | Thumbs.db 3 | Thumbs:encryptable 4 | ehthumbs.db 5 | ehthumbs_vista.db 6 | [Dd]esktop.ini 7 | $RECYCLE.BIN/ 8 | 9 | # Files that might appear on Linux 10 | *~ 11 | .fuse_hidden* 12 | .directory 13 | .Trash-* 14 | 15 | # Files that might appear on macOS 16 | .DS_Store 17 | .AppleDouble 18 | .LSOverride 19 | Icon 20 | ._* 21 | .DocumentRevision-V100 22 | .fseventsd 23 | .Spotlight-V100 24 | .TemporaryItems 25 | .Trashes 26 | .VolumeIcon.icns 27 | .com.apple.timemachine.donotpresent 28 | .AppleDB 29 | .AppleDesktop 30 | Network Trash folder 31 | Temporary Items 32 | .apdisk 33 | 34 | # Gradle 35 | .gradle 36 | **/build/ 37 | !src/**/build/ 38 | gradle-app.setting 39 | !gradle-wrapper.jar 40 | .gradletasknamecache 41 | #gradle/wrapper/gradle-wrapper.properties 42 | 43 | # Idea 44 | .idea 45 | *.iws 46 | *.iml 47 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021, Valaphee. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valaphee/tesseract-kotlin/39e8592567b1fc1b363a8ab91b278ae1d339503b/app.ico -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # MIT License 3 | # 4 | # Copyright (c) 2021, Valaphee. 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | # 24 | org.gradle.parallel=true 25 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/valaphee/tesseract-kotlin/39e8592567b1fc1b363a8ab91b278ae1d339503b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | # 2 | # MIT License 3 | # 4 | # Copyright (c) 2021, Valaphee. 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | # 24 | distributionBase=GRADLE_USER_HOME 25 | distributionPath=wrapper/dists 26 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip 27 | zipStoreBase=GRADLE_USER_HOME 28 | zipStorePath=wrapper/dists 29 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | rootProject.name = "tesseract" 26 | -------------------------------------------------------------------------------- /src/main/c/Common.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "Common.hpp" 26 | 27 | jint throwException(JNIEnv *environment, const char *message, int code) { 28 | jclass exceptionClass = environment->FindClass("com/valaphee/tesseract/util/NativeException"); 29 | jmethodID exceptionConstructor = environment->GetMethodID(exceptionClass, "", "(Ljava/lang/String;I)V"); 30 | jstring jmessage = environment->NewStringUTF(message); 31 | jthrowable throwable = (jthrowable) environment->NewObject(exceptionClass, exceptionConstructor, jmessage, code); 32 | return environment->Throw(throwable); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/c/Common.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | #include 27 | #include 28 | 29 | jint throwException(JNIEnv *environment, const char *message, int code); 30 | -------------------------------------------------------------------------------- /src/main/java/com/valaphee/tesseract/util/MbedTlsAesCipherImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.util; 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | public enum MbedTlsAesCipherImpl { 31 | ; 32 | 33 | public static native long init(boolean encrypt, byte[] key, byte[] iv); 34 | 35 | public static native void cipher(long cipherContext, long in, long out, int length); 36 | 37 | public static native void free(long cipherContext); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/valaphee/tesseract/util/MbedTlsSha256HasherImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.util; 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | public enum MbedTlsSha256HasherImpl { 31 | ; 32 | 33 | public static native long init(); 34 | 35 | public static native void update(long mbedTlsSha256Context, long buffer, int length); 36 | 37 | public static native byte[] digest(long mbedTlsSha256Context); 38 | 39 | public static native void free(long mbedTlsSha256Context); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/valaphee/tesseract/util/ZlibCompressorImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.util; 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | public final class ZlibCompressorImpl { 31 | static { 32 | startup(); 33 | } 34 | 35 | public int consumed; 36 | public boolean finished; 37 | 38 | public static native void startup(); 39 | 40 | public native long init(boolean compress, int level, boolean raw); 41 | 42 | public native int process(long zStream, long in, int inLength, long out, int outLength, boolean compress); 43 | 44 | public native void reset(long zStream, boolean compress); 45 | 46 | public native void free(long zStream, boolean compress); 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/valaphee/tesseract/util/text/StyleCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.util.text; 26 | 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | /** 31 | * @author Kevin Ludwig 32 | */ 33 | public interface StyleCode { 34 | char Prefix = '\u00A7'; 35 | char AlternativePrefix = '&'; 36 | List values = new ArrayList<>(); 37 | 38 | char getCode(); 39 | 40 | String getKey(); 41 | 42 | int ordinal(); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/foundry/ecs/Attribute.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.foundry.ecs 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | interface Attribute 31 | 32 | /** 33 | * @author Kevin Ludwig 34 | */ 35 | abstract class BaseAttribute : Attribute 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/foundry/ecs/Context.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.foundry.ecs 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | interface Context 31 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/foundry/ecs/Engine.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.foundry.ecs 26 | 27 | import com.valaphee.foundry.ecs.entity.Entity 28 | import com.valaphee.foundry.ecs.entity.EntityType 29 | 30 | /** 31 | * @author Kevin Ludwig 32 | */ 33 | interface Engine { 34 | fun addEntity(entity: Entity) 35 | 36 | fun removeEntity(entity: Entity) 37 | 38 | fun run(context: C) 39 | } 40 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/foundry/ecs/Message.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.foundry.ecs 26 | 27 | import com.valaphee.foundry.ecs.entity.Entity 28 | import com.valaphee.foundry.ecs.entity.EntityType 29 | 30 | /** 31 | * @author Kevin Ludwig 32 | */ 33 | interface Message { 34 | val context: C 35 | val source: Entity? 36 | val entity: Entity? 37 | } 38 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/foundry/ecs/Response.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.foundry.ecs 26 | 27 | import com.valaphee.foundry.ecs.system.Facet 28 | 29 | /** 30 | * @author Kevin Ludwig 31 | */ 32 | sealed class Response 33 | 34 | /** 35 | * @author Kevin Ludwig 36 | */ 37 | object Consumed : Response() 38 | 39 | /** 40 | * @author Kevin Ludwig 41 | */ 42 | object Pass : Response() 43 | 44 | /** 45 | * @author Kevin Ludwig 46 | */ 47 | data class MessageResponse( 48 | val message: Message 49 | ) : Response() 50 | 51 | /** 52 | * @author Kevin Ludwig 53 | */ 54 | data class StateResponse, F : Facet>( 55 | val facet: F 56 | ) : Response() 57 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/foundry/ecs/accessor/AttributeAccessor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.foundry.ecs.accessor 26 | 27 | import com.valaphee.foundry.ecs.Attribute 28 | import com.valaphee.foundry.ecs.mutator.DefaultAttributeMutator 29 | import kotlin.reflect.KClass 30 | 31 | /** 32 | * @author Kevin Ludwig 33 | */ 34 | interface AttributeAccessor { 35 | val attributes: Sequence 36 | val hasAttributes: Boolean 37 | 38 | fun findAttribute(`class`: KClass) = checkNotNull(findAttributeOrNull(`class`)) 39 | 40 | fun findAttributeOrNull(`class`: KClass): T? 41 | } 42 | 43 | fun attributeAccessor(attributes: Set): AttributeAccessor = DefaultAttributeMutator(attributes) 44 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/foundry/ecs/accessor/BehaviorAccessor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.foundry.ecs.accessor 26 | 27 | import com.valaphee.foundry.ecs.Context 28 | import com.valaphee.foundry.ecs.mutator.DefaultBehaviorMutator 29 | import com.valaphee.foundry.ecs.system.Behavior 30 | import kotlin.reflect.KClass 31 | 32 | /** 33 | * @author Kevin Ludwig 34 | */ 35 | interface BehaviorAccessor { 36 | val behaviors: Sequence> 37 | val hasBehaviors: Boolean 38 | 39 | fun > findBehavior(`class`: KClass) = checkNotNull(findBehaviorOrNull(`class`)) 40 | 41 | fun > findBehaviorOrNull(`class`: KClass): T? 42 | } 43 | 44 | fun behaviorAccessor(behaviors: Set>): BehaviorAccessor = DefaultBehaviorMutator(behaviors) 45 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/foundry/ecs/accessor/FacetAccessor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.foundry.ecs.accessor 26 | 27 | import com.valaphee.foundry.ecs.Context 28 | import com.valaphee.foundry.ecs.mutator.DefaultFacetMutator 29 | import com.valaphee.foundry.ecs.system.FacetWithContext 30 | import kotlin.reflect.KClass 31 | 32 | /** 33 | * @author Kevin Ludwig 34 | */ 35 | interface FacetAccessor { 36 | val facets: Sequence> 37 | val hasFacets: Boolean 38 | 39 | fun > findFacet(`class`: KClass) = checkNotNull(findFacetOrNull(`class`)) 40 | 41 | fun > findFacetOrNull(`class`: KClass): T? 42 | } 43 | 44 | fun facetAccessor(facets: Set>): FacetAccessor = DefaultFacetMutator(facets) 45 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/foundry/ecs/entity/EntityType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.foundry.ecs.entity 26 | 27 | import com.valaphee.foundry.ecs.Attribute 28 | 29 | /** 30 | * @author Kevin Ludwig 31 | */ 32 | interface EntityType : Attribute { 33 | val key: String 34 | } 35 | 36 | /** 37 | * @author Kevin Ludwig 38 | */ 39 | abstract class BaseEntityType( 40 | override val key: String, 41 | val id: Long = 0L, 42 | ) : EntityType { 43 | override fun equals(other: Any?): Boolean { 44 | if (this === other) return true 45 | if (javaClass != other?.javaClass) return false 46 | 47 | other as BaseEntityType 48 | 49 | if (key != other.key) return false // TODO 50 | 51 | return true 52 | } 53 | 54 | override fun hashCode() = key.hashCode() // TODO 55 | 56 | override fun toString() = key 57 | } 58 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/foundry/ecs/entity/MutableEntity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.foundry.ecs.entity 26 | 27 | import com.valaphee.foundry.ecs.Context 28 | import com.valaphee.foundry.ecs.mutator.AttributeMutator 29 | import com.valaphee.foundry.ecs.mutator.BehaviorMutator 30 | import com.valaphee.foundry.ecs.mutator.FacetMutator 31 | 32 | /** 33 | * @author Kevin Ludwig 34 | */ 35 | interface MutableEntity : Entity, AttributeMutator, FacetMutator, BehaviorMutator 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/foundry/ecs/message/StateChanged.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.foundry.ecs.message 26 | 27 | import com.valaphee.foundry.ecs.Context 28 | import com.valaphee.foundry.ecs.Message 29 | import com.valaphee.foundry.ecs.entity.Entity 30 | import com.valaphee.foundry.ecs.entity.EntityType 31 | import com.valaphee.foundry.ecs.system.Facet 32 | 33 | /** 34 | * @author Kevin Ludwig 35 | */ 36 | data class StateChanged( 37 | override val context: C, 38 | override val source: Entity?, 39 | val oldState: Facet>, 40 | val newState: Facet> 41 | ) : Message { 42 | override val entity: Entity? = null 43 | } 44 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/foundry/ecs/system/StateFacet.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.foundry.ecs.system 26 | 27 | import com.valaphee.foundry.ecs.Attribute 28 | import com.valaphee.foundry.ecs.Context 29 | import com.valaphee.foundry.ecs.Message 30 | import kotlin.reflect.KClass 31 | 32 | /** 33 | * @author Kevin Ludwig 34 | */ 35 | interface StateFacet> : Facet { 36 | suspend fun onEnter(message: M) {} 37 | 38 | suspend fun onExit(message: M) {} 39 | } 40 | 41 | /** 42 | * @author Kevin Ludwig 43 | */ 44 | abstract class BaseStateFacet>( 45 | messageType: KClass

, 46 | vararg mandatoryAttributes: KClass 47 | ) : BaseFacet(messageType, *mandatoryAttributes), StateFacet 48 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/foundry/ecs/system/System.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.foundry.ecs.system 26 | 27 | import com.valaphee.foundry.ecs.Attribute 28 | import com.valaphee.foundry.ecs.Context 29 | import kotlin.reflect.KClass 30 | 31 | /** 32 | * @author Kevin Ludwig 33 | */ 34 | interface System { 35 | val mandatoryAttributes: Set> 36 | } 37 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/Actor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor 26 | 27 | import com.valaphee.foundry.ecs.entity.BaseEntityType 28 | import com.valaphee.tesseract.world.EntityOfWorld 29 | 30 | /** 31 | * @author Kevin Ludwig 32 | */ 33 | abstract class ActorType(key: String) : BaseEntityType(key, ActorTypeRegistry.idByKey(key).toLong()) 34 | 35 | typealias AnyActorOfWorld = EntityOfWorld 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/ActorTypeRegistry.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor 26 | 27 | import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap 28 | 29 | /** 30 | * @author Kevin Ludwig 31 | */ 32 | object ActorTypeRegistry { 33 | private val idByKey = Object2IntOpenHashMap() 34 | 35 | fun register(key: String, id: Int) { 36 | idByKey[key] = id 37 | } 38 | 39 | fun idByKey(key: String) = idByKey.getInt(key) 40 | 41 | val size get() = idByKey.size 42 | } 43 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/Object.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor 26 | 27 | import com.valaphee.foundry.ecs.BaseAttribute 28 | import com.valaphee.foundry.math.collision.BoundingBox 29 | import com.valaphee.tesseract.data.Component 30 | import com.valaphee.tesseract.data.Share 31 | import com.valaphee.tesseract.data.entity.Runtime 32 | 33 | /** 34 | * @author Kevin Ludwig 35 | */ 36 | @Runtime 37 | @Share 38 | @Component("tesseract:actor.object") 39 | class Object( 40 | val boundingBox: BoundingBox, 41 | val yOffset: Float, 42 | val gravity: Float 43 | ) : BaseAttribute() 44 | 45 | val AnyActorOfWorld.`object` get() = findAttribute(Object::class) 46 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/location/Input.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor.location 26 | 27 | import com.valaphee.foundry.math.Float2 28 | import com.valaphee.foundry.math.Float3 29 | import com.valaphee.tesseract.actor.AnyActorOfWorld 30 | import com.valaphee.tesseract.world.WorldContext 31 | import com.valaphee.tesseract.world.chunk.Chunk 32 | 33 | /** 34 | * @author Kevin Ludwig 35 | */ 36 | class Input( 37 | context: WorldContext, 38 | source: AnyActorOfWorld, 39 | entity: Chunk, 40 | val position: Float3, 41 | val rotation: Float2, 42 | ) : LocationManagerMessage(context, source, entity) 43 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/location/Location.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor.location 26 | 27 | import com.valaphee.foundry.ecs.BaseAttribute 28 | import com.valaphee.foundry.math.Float2 29 | import com.valaphee.foundry.math.Float3 30 | import com.valaphee.tesseract.actor.AnyActorOfWorld 31 | 32 | /** 33 | * @author Kevin Ludwig 34 | */ 35 | class Location( 36 | var position: Float3, 37 | var velocity: Float3 = Float3.Zero, 38 | var rotation: Float2 = Float2.Zero, 39 | var headRotationYaw: Float = 0.0f, 40 | ) : BaseAttribute() 41 | 42 | val AnyActorOfWorld.location get() = findAttribute(Location::class) 43 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/location/LocationManagerMessage.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor.location 26 | 27 | import com.valaphee.foundry.ecs.Message 28 | import com.valaphee.tesseract.actor.AnyActorOfWorld 29 | import com.valaphee.tesseract.world.WorldContext 30 | import com.valaphee.tesseract.world.chunk.Chunk 31 | 32 | /** 33 | * @author Kevin Ludwig 34 | */ 35 | sealed class LocationManagerMessage( 36 | override val context: WorldContext, 37 | override val source: AnyActorOfWorld, 38 | override val entity: Chunk 39 | ) : Message 40 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/metadata/MetadataValue.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor.metadata 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | class MetadataValue( 31 | val type: MetadataType, 32 | value: Any?, 33 | ) { 34 | var value = value 35 | set(value) { 36 | field = value 37 | modified = true 38 | } 39 | 40 | var modified = true 41 | } 42 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/player/AppearanceAnimation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor.player 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | data class AppearanceAnimation constructor( 31 | val image: AppearanceImage, 32 | val type: Type, 33 | val frames: Float, 34 | val expression: Expression = Expression.Linear 35 | ) { 36 | enum class Type { 37 | None, Head, Body32, Body128 38 | } 39 | 40 | enum class Expression { 41 | Linear, Blinking 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/player/InputCorrectPacket.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor.player 26 | 27 | import com.valaphee.foundry.math.Float3 28 | import com.valaphee.tesseract.net.Packet 29 | import com.valaphee.tesseract.net.PacketBuffer 30 | import com.valaphee.tesseract.net.PacketHandler 31 | 32 | /** 33 | * @author Kevin Ludwig 34 | */ 35 | data class InputCorrectPacket( 36 | var position: Float3, 37 | var positionDelta: Float3, 38 | var onGround: Boolean, 39 | var tick: Long 40 | ) : Packet { 41 | override val id get() = 0xA1 42 | 43 | override fun write(buffer: PacketBuffer, version: Int) { 44 | buffer.writeFloat3(position) 45 | buffer.writeFloat3(positionDelta) 46 | buffer.writeBoolean(onGround) 47 | buffer.writeVarULong(tick) 48 | } 49 | 50 | override fun handle(handler: PacketHandler) = handler.inputCorrect(this) 51 | } 52 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/player/Player.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor.player 26 | 27 | import com.valaphee.foundry.math.Float2 28 | import com.valaphee.foundry.math.Float3 29 | import com.valaphee.tesseract.actor.ActorType 30 | import com.valaphee.tesseract.actor.location.Location 31 | import com.valaphee.tesseract.data.entity.EntityFactory 32 | import com.valaphee.tesseract.world.EntityOfWorld 33 | import com.valaphee.tesseract.world.WorldContext 34 | 35 | /** 36 | * @author Kevin Ludwig 37 | */ 38 | object PlayerType : ActorType("minecraft:player") 39 | 40 | typealias Player = EntityOfWorld 41 | 42 | fun EntityFactory.player(position: Float3, rotation: Float2) = invoke( 43 | PlayerType, setOf( 44 | Location(position, Float3.Zero, rotation, rotation.x) 45 | ) 46 | ) 47 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/player/Rank.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor.player 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | enum class Rank { 31 | Visitor, Member, Operator, Custom 32 | } 33 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/player/interaction/ChunkInteractionManagerMessage.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor.player.interaction 26 | 27 | import com.valaphee.tesseract.world.chunk.ChunkUsage 28 | 29 | /** 30 | * @author Kevin Ludwig 31 | */ 32 | interface ChunkInteractionManagerMessage : ChunkUsage 33 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/player/view/ChunkPublishPacket.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor.player.view 26 | 27 | import com.valaphee.foundry.math.Int3 28 | import com.valaphee.tesseract.net.Packet 29 | import com.valaphee.tesseract.net.PacketBuffer 30 | import com.valaphee.tesseract.net.PacketHandler 31 | import com.valaphee.tesseract.net.Restrict 32 | import com.valaphee.tesseract.net.Restriction 33 | 34 | /** 35 | * @author Kevin Ludwig 36 | */ 37 | @Restrict(Restriction.Clientbound) 38 | data class ChunkPublishPacket( 39 | var position: Int3, 40 | var radius: Int 41 | ) : Packet { 42 | override val id get() = 0x79 43 | 44 | override fun write(buffer: PacketBuffer, version: Int) { 45 | buffer.writeInt3(position) 46 | buffer.writeVarUInt(radius) 47 | } 48 | 49 | override fun handle(handler: PacketHandler) = handler.chunkPublish(this) 50 | } 51 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/player/view/View.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor.player.view 26 | 27 | import com.valaphee.foundry.ecs.system.BaseBehavior 28 | import com.valaphee.tesseract.data.Config 29 | import com.valaphee.tesseract.world.WorldContext 30 | import com.valaphee.tesseract.actor.location.Location 31 | import it.unimi.dsi.fastutil.longs.LongOpenHashSet 32 | 33 | /** 34 | * @author Kevin Ludwig 35 | */ 36 | abstract class View( 37 | private val config: Config 38 | ) : BaseBehavior(Location::class) { 39 | protected val _acquiredChunks = LongOpenHashSet() 40 | val acquiredChunks: LongArray get() = _acquiredChunks.toLongArray() 41 | 42 | var distance = config.maximumViewDistance 43 | set(value) { 44 | field = Integer.min(value, config.maximumViewDistance) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/player/view/ViewChunk.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor.player.view 26 | 27 | import com.valaphee.foundry.math.Int3 28 | import com.valaphee.tesseract.actor.player.Player 29 | import com.valaphee.tesseract.world.WorldContext 30 | import com.valaphee.tesseract.world.chunk.Chunk 31 | import com.valaphee.tesseract.world.chunk.ChunkUsage 32 | 33 | /** 34 | * @author Kevin Ludwig 35 | */ 36 | class ViewChunk( 37 | override val context: WorldContext, 38 | override val source: Player, 39 | val center: Int3, 40 | val radius: Int 41 | ) : ChunkUsage { 42 | override val entity get() = source 43 | 44 | override lateinit var chunks: Array 45 | } 46 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/actor/stack/StackWrapper.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.actor.stack 26 | 27 | import com.valaphee.foundry.ecs.BaseAttribute 28 | 29 | /** 30 | * @author Kevin Ludwig 31 | */ 32 | class StackWrapper( 33 | var value: com.valaphee.tesseract.inventory.item.stack.Stack<*>? 34 | ) : BaseAttribute() 35 | 36 | val Stack.stack get() = findAttribute(StackWrapper::class).value 37 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/command/Command.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.command 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) 31 | annotation class Command( 32 | val value: String, 33 | val aliases: Array = [], 34 | val permission: Permission = Permission() 35 | ) 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/command/CommandManager.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.command 26 | 27 | import com.google.inject.Singleton 28 | import kotlin.reflect.KClass 29 | import kotlin.reflect.full.findAnnotation 30 | import kotlin.reflect.full.functions 31 | 32 | /** 33 | * @author Kevin Ludwig 34 | */ 35 | @Singleton 36 | class CommandManager { 37 | fun register(`class`: KClass) { 38 | `class`.findAnnotation()?.let { 39 | `class`.functions.forEach { function -> 40 | function.findAnnotation()?.let { 41 | function.parameters.forEach { parameter -> 42 | parameter.findAnnotation()?.let { 43 | 44 | } 45 | } 46 | } 47 | } 48 | } 49 | } 50 | 51 | fun dispatch(command: String): Result = TODO() 52 | } 53 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/command/Parameter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.command 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | @Target(AnnotationTarget.VALUE_PARAMETER) 31 | annotation class Parameter( 32 | val value: String 33 | ) 34 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/command/Permission.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.command 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | @Target(AnnotationTarget.TYPE) 31 | annotation class Permission( 32 | val value: String = "", 33 | ) 34 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/command/Result.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.command 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | class Result { 31 | private val _messages = mutableListOf() 32 | val messages: List get() = _messages 33 | 34 | fun fail(message: String) = apply { 35 | _messages.add(Message(false, message, emptyArray())) 36 | } 37 | 38 | fun success(message: String) = apply { 39 | _messages.add(Message(true, message, emptyArray())) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/command/SubCommand.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.command 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | @Target(AnnotationTarget.FUNCTION) 31 | annotation class SubCommand( 32 | val value: String = "", 33 | val aliases: Array = [], 34 | val permission: Permission = Permission() 35 | ) 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/command/net/EnumerationConstraint.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.command.net 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | data class EnumerationConstraint( 31 | val option: String, 32 | val enumeration: Enumeration, 33 | val flags: Collection 34 | ) { 35 | enum class Flag { 36 | CheatsEnabled, OperatorPermissions, HostPermissions, Unknown3 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/command/net/Permission.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.command.net 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | enum class Permission { 31 | Normal, Operator, Host, Automation, Administrator 32 | } 33 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/Component.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | @Target(AnnotationTarget.CLASS) 31 | annotation class Component( 32 | val value: String 33 | ) 34 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/Data.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data 26 | 27 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties 28 | import com.fasterxml.jackson.annotation.JsonTypeInfo 29 | import com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver 30 | 31 | /** 32 | * @author Kevin Ludwig 33 | */ 34 | @JsonIgnoreProperties(ignoreUnknown = true) 35 | @JsonTypeInfo( 36 | use = JsonTypeInfo.Id.NAME, 37 | include = JsonTypeInfo.As.WRAPPER_OBJECT 38 | ) 39 | @JsonTypeIdResolver(ComponentKeyResolver::class) 40 | interface Data 41 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/Index.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | @Target(AnnotationTarget.CLASS) 31 | annotation class Index 32 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/Keyed.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | interface Keyed { 31 | val key: String 32 | } 33 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/Share.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | @Target(AnnotationTarget.CLASS) 31 | annotation class Share 32 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/UnknownComponentException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | class UnknownComponentException : Exception { 31 | constructor() : super() 32 | 33 | constructor(message: String) : super(message) 34 | 35 | constructor(message: String, cause: Throwable) : super(message, cause) 36 | 37 | constructor(cause: Throwable) : super(cause) 38 | } 39 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/block/Air.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.block 26 | 27 | import com.valaphee.tesseract.data.Index 28 | 29 | /** 30 | * @author Kevin Ludwig 31 | */ 32 | @Index 33 | class Air : Block { 34 | override val key get() = "minecraft:air" 35 | 36 | override val transparent get() = true 37 | } 38 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/block/Block.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.block 26 | 27 | import com.valaphee.foundry.math.Float3 28 | import com.valaphee.tesseract.actor.player.Player 29 | import com.valaphee.tesseract.data.Data 30 | import com.valaphee.tesseract.data.Keyed 31 | import com.valaphee.tesseract.util.math.Direction 32 | import com.valaphee.tesseract.world.WorldContext 33 | import com.valaphee.tesseract.world.chunk.terrain.PropagationBlockUpdateList 34 | 35 | /** 36 | * @author Kevin Ludwig 37 | */ 38 | interface Block : Data, Keyed { 39 | val transparent get() = false 40 | 41 | fun onUse(context: WorldContext, player: Player, blockUpdates: PropagationBlockUpdateList, x: Int, y: Int, z: Int, direction: Direction, clickPosition: Float3) = false 42 | 43 | fun onUpdate(blockUpdates: PropagationBlockUpdateList, x: Int, y: Int, z: Int, blockState: BlockState) = Unit 44 | } 45 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/block/Blocks.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.block 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | object Blocks { 31 | private val transparentIds = BlockState.all.filter { it.block?.transparent == true }.map { it.id } 32 | 33 | val airId = BlockState.byKeyWithStates("minecraft:air").id 34 | 35 | fun isTransparent(id: Int) = transparentIds.contains(id) 36 | } 37 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/block/ConcretePowder.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.block 26 | 27 | import com.valaphee.tesseract.data.Index 28 | 29 | /** 30 | * @author Kevin Ludwig 31 | */ 32 | @Index 33 | class ConcretePowder : DistributingFallingBlock() { 34 | override val key get() = "minecraft:concretePowder" 35 | } 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/block/FlowingLava.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.block 26 | 27 | import com.valaphee.tesseract.data.Index 28 | 29 | /** 30 | * @author Kevin Ludwig 31 | */ 32 | @Index 33 | class FlowingLava : FlowingBlock(0b111) { 34 | override val key get() = "minecraft:flowing_lava" 35 | } 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/block/FlowingWater.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.block 26 | 27 | import com.valaphee.tesseract.data.Index 28 | 29 | /** 30 | * @author Kevin Ludwig 31 | */ 32 | @Index 33 | class FlowingWater : FlowingBlock(0b11) { 34 | override val key get() = "minecraft:flowing_water" 35 | } 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/block/Gravel.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.block 26 | 27 | import com.valaphee.tesseract.data.Index 28 | 29 | /** 30 | * @author Kevin Ludwig 31 | */ 32 | @Index 33 | class Gravel : DistributingFallingBlock() { 34 | override val key get() = "minecraft:gravel" 35 | } 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/block/Sand.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.block 26 | 27 | import com.valaphee.tesseract.data.Index 28 | 29 | /** 30 | * @author Kevin Ludwig 31 | */ 32 | @Index 33 | class Sand : DistributingFallingBlock() { 34 | override val key get() = "minecraft:sand" 35 | } 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/entity/EntityTypeData.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.entity 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize 29 | import com.valaphee.tesseract.data.Component 30 | import com.valaphee.tesseract.data.ComponentKeyDeserializer 31 | import com.valaphee.tesseract.data.ComponentKeySerializer 32 | import com.valaphee.tesseract.data.Data 33 | import com.valaphee.tesseract.data.Keyed 34 | import kotlin.reflect.KClass 35 | 36 | /** 37 | * @author Kevin Ludwig 38 | */ 39 | @Component("tesseract:entity_type") 40 | class EntityTypeData( 41 | override val key: String, 42 | @JsonSerialize(keyUsing = ComponentKeySerializer::class) 43 | @JsonDeserialize(keyUsing = ComponentKeyDeserializer::class) 44 | val components: Map, Map>, 45 | ) : Data, Keyed 46 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/entity/Runtime.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.entity 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | @Target(AnnotationTarget.CLASS) 31 | annotation class Runtime 32 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/item/Item.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.item 26 | 27 | import com.valaphee.foundry.math.Float3 28 | import com.valaphee.foundry.math.Int2 29 | import com.valaphee.tesseract.actor.player.Player 30 | import com.valaphee.tesseract.data.Data 31 | import com.valaphee.tesseract.data.Keyed 32 | import com.valaphee.tesseract.util.math.Direction 33 | import com.valaphee.tesseract.world.WorldContext 34 | import com.valaphee.tesseract.world.chunk.terrain.PropagationBlockUpdateList 35 | 36 | /** 37 | * @author Kevin Ludwig 38 | */ 39 | interface Item : Data, Keyed { 40 | fun onUseBlock(context: WorldContext, player: Player, chunk: Int2, blockUpdates: PropagationBlockUpdateList, x: Int, y: Int, z: Int, direction: Direction, clickPosition: Float3) = false 41 | } 42 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/item/LavaBucket.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.item 26 | 27 | import com.valaphee.tesseract.data.Index 28 | 29 | /** 30 | * @author Kevin Ludwig 31 | */ 32 | @Index 33 | class LavaBucket : Bucket("minecraft:flowing_lava") { 34 | override val key get() = "minecraft:lava_bucket" 35 | } 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/item/WaterBucket.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.item 26 | 27 | import com.valaphee.tesseract.data.Index 28 | 29 | /** 30 | * @author Kevin Ludwig 31 | */ 32 | @Index 33 | class WaterBucket : Bucket("minecraft:flowing_water") { 34 | override val key get() = "minecraft:water_bucket" 35 | } 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/locale/I18n.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.locale 26 | 27 | import com.google.inject.Inject 28 | import java.util.Locale 29 | 30 | /** 31 | * @author Kevin Ludwig 32 | */ 33 | class I18n @Inject constructor( 34 | private val locales: Map 35 | ) { 36 | val default = locales["tesseract:en_us"] ?: locales.values.first() 37 | 38 | operator fun get(locale: Locale) = locales["tesseract:${locale.toLanguageTag().replace('-', '_')}"] ?: default 39 | } 40 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/recipe/FurnaceRecipeData.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.recipe 26 | 27 | import com.valaphee.tesseract.data.Component 28 | import com.valaphee.tesseract.data.Data 29 | import com.valaphee.tesseract.data.Keyed 30 | import com.valaphee.tesseract.inventory.item.stack.Stack 31 | 32 | /** 33 | * @author Kevin Ludwig 34 | */ 35 | @Component("tesseract:recipe_furnace") 36 | class FurnaceRecipeData( 37 | override val key: String, 38 | val tags: Array, 39 | val input: Stack<*>, 40 | val output: Stack<*> 41 | ) : Data, Keyed 42 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/recipe/ShapedRecipeData.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.recipe 26 | 27 | import com.valaphee.tesseract.data.Component 28 | import com.valaphee.tesseract.data.Data 29 | import com.valaphee.tesseract.data.Keyed 30 | import com.valaphee.tesseract.inventory.item.stack.Stack 31 | 32 | /** 33 | * @author Kevin Ludwig 34 | */ 35 | @Component("tesseract:recipe_shaped") 36 | class ShapedRecipeData( 37 | override val key: String, 38 | val tags: Array, 39 | val map: Map>, 40 | val pattern: Array, 41 | val priority: Int = 0, 42 | val result: Stack<*> 43 | ) : Data, Keyed 44 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/data/recipe/ShapelessRecipeData.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.data.recipe 26 | 27 | import com.valaphee.tesseract.data.Component 28 | import com.valaphee.tesseract.data.Data 29 | import com.valaphee.tesseract.data.Keyed 30 | import com.valaphee.tesseract.inventory.item.stack.Stack 31 | 32 | /** 33 | * @author Kevin Ludwig 34 | */ 35 | @Component("tesseract:recipe_shapeless") 36 | class ShapelessRecipeData( 37 | override val key: String, 38 | val tags: Array, 39 | val ingredients: Array>, 40 | val priority: Int = 0, 41 | val result: Stack<*> 42 | ) : Data, Keyed 43 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/inventory/InventoryWrapper.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.inventory 26 | 27 | import com.valaphee.foundry.ecs.BaseAttribute 28 | import com.valaphee.tesseract.actor.AnyActorOfWorld 29 | import com.valaphee.tesseract.data.entity.Runtime 30 | 31 | /** 32 | * @author Kevin Ludwig 33 | */ 34 | @Runtime 35 | class InventoryWrapper( 36 | val value: T 37 | ) : BaseAttribute() 38 | 39 | inline fun AnyActorOfWorld.inventory() = findAttribute(InventoryWrapper::class).value as T 40 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/inventory/OneSlotInventory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.inventory 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | class OneSlotInventory : Inventory(WindowType.None, 1) 31 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/inventory/PlayerInventory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.inventory 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | class PlayerInventory : Inventory(WindowType.Inventory) { 31 | var hotbarSlot = 0 32 | val stackInHand get() = content[hotbarSlot] 33 | } 34 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/inventory/UiInventory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.inventory 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | class UiInventory : Inventory(WindowType.None, 51) 31 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/inventory/WindowPropertyPacket.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.inventory 26 | 27 | import com.valaphee.tesseract.net.Packet 28 | import com.valaphee.tesseract.net.PacketBuffer 29 | import com.valaphee.tesseract.net.PacketHandler 30 | import com.valaphee.tesseract.net.Restrict 31 | import com.valaphee.tesseract.net.Restriction 32 | 33 | /** 34 | * @author Kevin Ludwig 35 | */ 36 | @Restrict(Restriction.Clientbound) 37 | data class WindowPropertyPacket( 38 | var windowId: Int, 39 | var property: Int, 40 | var value: Int 41 | ) : Packet { 42 | override val id get() = 0x33 43 | 44 | override fun write(buffer: PacketBuffer, version: Int) { 45 | buffer.writeByte(windowId) 46 | buffer.writeVarInt(property) 47 | buffer.writeVarInt(value) 48 | } 49 | 50 | override fun handle(handler: PacketHandler) = handler.windowProperty(this) 51 | } 52 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/inventory/item/stack/meta/DyeableMeta.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.inventory.item.stack.meta 26 | 27 | import com.valaphee.tesseract.util.getIntOrNull 28 | import com.valaphee.tesseract.util.nbt.CompoundTag 29 | 30 | /** 31 | * @author Kevin Ludwig 32 | */ 33 | class DyeableMeta( 34 | name: String? = null, 35 | lore: List? = null, 36 | damage: Int = 0, 37 | repairCost: Int = 0, 38 | var color: Int? = null 39 | ) : Meta(name, lore, damage, repairCost) { 40 | override fun fromTag(tag: CompoundTag) { 41 | super.fromTag(tag) 42 | color = tag.getIntOrNull("customColor") 43 | } 44 | 45 | override fun toTag() = super.toTag().apply { color?.let { setInt("customColor", it) } } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/inventory/recipe/ContainerMixRecipe.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.inventory.recipe 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | data class ContainerMixRecipe( 31 | var inputId: Int, 32 | var reagentId: Int, 33 | var outputId: Int 34 | ) 35 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/inventory/recipe/PotionMixRecipe.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.inventory.recipe 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | data class PotionMixRecipe( 31 | var inputId: Int, 32 | var inputSubId: Int, 33 | var reagentId: Int, 34 | var reagentSubId: Int, 35 | var outputId: Int, 36 | var outputSubId: Int 37 | ) { 38 | constructor(inputId: Int, reagentId: Int, outputId: Int) : this(inputId, 0, reagentId, 0, outputId, 0) 39 | } 40 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/net/GamePublishMode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.net 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | enum class GamePublishMode { 31 | Local, InviteOnly, FriendsOnly, FriendsOfFriends, Public 32 | } 33 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/net/Packet.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.net 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | interface Packet { 31 | val id: Int 32 | 33 | fun write(buffer: PacketBuffer, version: Int) 34 | 35 | fun handle(handler: PacketHandler) 36 | 37 | companion object { 38 | internal const val idMask = 0x3FF 39 | internal const val senderIdShift = 10 40 | internal const val senderIdClientIdMask = 0x3 41 | internal const val clientIdShift = 12 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/net/PacketReader.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.net 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | interface PacketReader { 31 | fun read(buffer: PacketBuffer, version: Int): Packet 32 | } 33 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/net/ProtocolHandler.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.net 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | interface ProtocolHandler { 31 | fun initialize() {} 32 | 33 | fun exceptionCaught(cause: Throwable) {} 34 | 35 | fun writabilityChanged() {} 36 | 37 | fun destroy() {} 38 | } 39 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/net/Remote.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.net 26 | 27 | import com.valaphee.foundry.ecs.BaseAttribute 28 | import com.valaphee.tesseract.actor.player.Player 29 | import com.valaphee.tesseract.data.entity.Runtime 30 | 31 | /** 32 | * @author Kevin Ludwig 33 | */ 34 | @Runtime 35 | class Remote( 36 | val connection: Connection 37 | ) : BaseAttribute() 38 | 39 | val Player.connection get() = findAttribute(Remote::class).connection 40 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/net/Restrict.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.net 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | @Target(AnnotationTarget.CLASS) 31 | annotation class Restrict( 32 | vararg val value: Restriction 33 | ) 34 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/net/Restriction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021, Valaphee. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.valaphee.tesseract.net 26 | 27 | /** 28 | * @author Kevin Ludwig 29 | */ 30 | enum class Restriction { 31 | Clientbound, Serverbound, OncePerCycle 32 | } 33 | -------------------------------------------------------------------------------- /src/main/kotlin/com/valaphee/tesseract/net/form/ButtonList.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, GrieferGames, Valaphee. 3 | * All rights reserved. 4 | */ 5 | 6 | package com.valaphee.tesseract.net.form 7 | 8 | import com.fasterxml.jackson.annotation.JsonIgnore 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties 10 | import com.fasterxml.jackson.annotation.JsonProperty 11 | import com.google.gson.JsonElement 12 | 13 | /** 14 | * @author Kevin Ludwig 15 | */ 16 | class ButtonList( 17 | title: String, 18 | @get:JsonProperty("content") val content: String, 19 | @get:JsonProperty("buttons") val buttons: List