Compare commits

...
963 Commits
Author SHA1 Message Date
Nassim Jahnke 6efeb16822 4.9.0 Release 2023-12-04 10:11:08 +01:00
RK_01 9b09b1f5f8 Fix #3542 (#3543) 2023-12-04 10:09:25 +01:00
RK_01 851295d48c Ignore invalid chunk data in legacy versions (#3538) 2023-12-03 18:37:57 +01:00
RK_01 1f453dc0d9 Change gamemode data type in JOIN_GAME handlers (#3541) 2023-12-03 18:35:19 +01:00
RK_01 916c08ce7e Handle invalid entity equipment slots properly (#3540) 2023-12-03 18:34:14 +01:00
RK_01 0ac29fb2c2 Return air instead of stone for unknown block ids (#3539) 2023-12-03 18:33:34 +01:00
Nassim Jahnke 45d08e9066 Directly send pong, plugin message, and keep alive in 1.20.2->1.20 2023-12-03 10:02:36 +01:00
Nassim Jahnke bc0bef2e07 1.20.3-rc1 2023-11-30 15:56:05 +01:00
Nassim Jahnke 6d82839e6d 1.20.3-pre4 2023-11-28 16:58:32 +01:00
Nassim Jahnke c039f4e24c 1.20.3-pre3 2023-11-27 17:09:59 +01:00
Nassim Jahnke 4add75cda7 Fix reset score writing 2023-11-26 15:31:33 +01:00
Nassim Jahnke 28f661f270 1.20.3-pre2 2023-11-22 16:31:21 +01:00
Nassim Jahnke 42f38c3209 Drop old resource packs 2023-11-21 07:35:44 +01:00
Nassim Jahnke 151ecdcd72 Don't resend pack in 1.20->1.20.2 for 1.20.3 clients 2023-11-20 20:01:06 +01:00
Nassim Jahnke a0f8ab7bbb Some cleanup 2023-11-20 19:56:48 +01:00
Nassim Jahnke 1af2103f6c And the serverbound one 2023-11-20 19:07:23 +01:00
Nassim Jahnke 8769742917 Also handle play resource pack 2023-11-20 19:04:32 +01:00
Nassim Jahnke 20f4907a23 1.20.3-pre1 (probably) 2023-11-20 17:55:28 +01:00
Nassim Jahnke 6fb27e5c17 A more probable probably 2023-11-19 16:18:56 +01:00
Nassim Jahnke 07b173bb74 23w46a (probably) 2023-11-19 16:13:04 +01:00
Nassim Jahnke dbf4271c9d Fix 1.20.3 component meta type 2023-11-09 17:34:06 +10:00
Nassim Jahnke a2d287ff9f 23w45a 2023-11-09 15:35:07 +10:00
Nassim Jahnke 58ca2024e1 Add static chunkKey method in ChunkPosition 2023-11-06 20:17:42 +10:00
Nassim Jahnke 2881fb18e0 Include api sources in common sources jar 2023-11-06 20:04:45 +10:00
Nassim Jahnke ffdddeeb0a Add back sources collection in universal jar publishing 2023-11-06 14:52:37 +10:00
Nassim Jahnke e356a35aa7 Improve Gradle scripts
Don't create runnable platform jars anymore, since all they really do is increase build time. Also fix texts and Gradle deprecations. Also also publish common with its shadowed configuration, not the plain java components.
2023-11-06 14:31:44 +10:00
Nassim Jahnke 0474810b8d 23w44a 2023-11-02 10:46:28 +10:00
Nassim Jahnke ea818b272e FU 8.5.13 doesn't exist yet 2023-10-31 18:56:38 +10:00
Nassim Jahnke 9342b19aad Update dependencies 2023-10-31 13:38:43 +10:00
Nassim Jahnke 2968047571 Merge remote-tracking branch 'origin/master' into dev 2023-10-31 13:01:34 +10:00
Nassim Jahnke dccac81286 Fix Bungee pipeline clearing, some cleanup 2023-10-31 13:00:35 +10:00
Myles bc67e8d952 Merge pull request #3511 from Jo0001/master-link 2023-10-29 14:39:19 +00:00
Myles f9ab1bd811 Merge pull request #3510 from Jo0001/dev-link 2023-10-29 14:39:10 +00:00
Jo0001 8776e8bdc0 Update ViaSetup Link 2023-10-29 15:36:14 +01:00
Jo0001 ba882f8f98 Update ViaSetup Link 2023-10-29 15:35:22 +01:00
fren_gor a022620712 Fix reflection field search on Spigot 1.20.2 (#3503) 2023-10-28 13:47:59 +10:00
EnZaXD f618cdec99 Don't mention Spigot page anymore and move setting to right place in config.yml (#3505) 2023-10-27 09:16:14 +10:00
Nassim Jahnke ec2093cf5d 23w43a 2023-10-26 10:20:18 +10:00
EnZaXD eb9bc2fdce Remove permission requirements for root command (#3502) 2023-10-24 13:34:29 +10:00
EnZaXD f35b4f1fac Add own permission for every sub command (#3501) 2023-10-24 12:59:10 +10:00
EnZaXD abe880dae6 Implement provider to allow signed commands in 1.19.x protocols (#3493) 2023-10-24 10:04:54 +10:00
EnZaXD 0f030c86a7 Implement size var int in all chunk types correctly (#3495) 2023-10-24 10:03:32 +10:00
EnZaXD 2c6e18e4fe Match current command input for sub argument tab completions (#3496) 2023-10-24 10:02:08 +10:00
RK_01 78c7f03923 Fix and improved custom payload handling (#3497) 2023-10-24 10:01:33 +10:00
RK_01 68a32ed2f0 Fix identifier handling and validation (#3498) 2023-10-24 09:58:43 +10:00
EnZaXD 7cf008bb62 Delete unused config option and add missing documentation (#3500) 2023-10-24 09:56:29 +10:00
RK_01 a60342359b Fix 1.19.0 chat signing causing error message (#3494) 2023-10-23 10:28:44 +10:00
RK_01 0e269fa493 Implement support for chat signing (#3490) 2023-10-22 19:33:59 +10:00
Nassim Jahnke 815e0820da Fix 1.13->1.13.1 recipes, rename ITEM1_8_ARRAY 2023-10-21 13:22:25 +10:00
Nassim Jahnke faedf26b5b Clean up Particle 2023-10-21 13:00:39 +10:00
RK_01 c7c38e70c0 Make ClientChunks a StorableObject (#3487) 2023-10-21 12:13:24 +10:00
Nassim Jahnke 21d293dd7f Rneame CustomByteType -> FixedByteArrayType 2023-10-20 17:22:00 +10:00
Nassim Jahnke 6481cec270 Just store whether to read skylight directly 2023-10-20 17:09:40 +10:00
Nassim Jahnke 54c04a62e0 Store environment instead of clientlevel in chunk types 2023-10-20 16:56:53 +10:00
Nassim Jahnke 7edde72416 Reuse 1.15, 1.16 and 1.16.2 chunk types as well 2023-10-20 12:43:46 +10:00
Nassim Jahnke 84a054aac1 Give PacketValue a generic type 2023-10-20 12:31:16 +10:00
Nassim Jahnke 8ebc8c34f3 Reuse old chunk type instances, more type cleanup 2023-10-20 12:30:03 +10:00
Nassim Jahnke 50e55529d9 Rename old position type 2023-10-19 21:15:26 +10:00
Nassim Jahnke 553dd2cb45 Move missed type 2023-10-19 21:08:00 +10:00
Nassim Jahnke a30d62a995 Move and rename chunk types 2023-10-19 21:03:00 +10:00
Nassim Jahnke 08f6b3ce36 Only remove id field if it actually is a uuid 2023-10-19 12:16:22 +10:00
Nassim Jahnke 7d1b0d83ce Fix minecart block state id 2023-10-19 11:03:39 +10:00
Nassim Jahnke e7d0b01eee 23w42a 2023-10-19 10:53:14 +10:00
Nassim Jahnke fdfc528a9a Cleanup and renames around types 2023-10-19 09:28:21 +10:00
Nassim Jahnke dccb6f234b Add missing switch breaks 2023-10-18 19:48:19 +10:00
Nassim Jahnke 6e7f936e83 Move methods from VB to VV ComponentRewriter 2023-10-18 13:50:08 +10:00
Nassim Jahnke ec26bafd53 Update ComponentRewriter with nbt methods 2023-10-18 13:26:09 +10:00
Nassim Jahnke d7d7940d0b Move protocol templates from wiki to extra module 2023-10-16 22:30:12 +10:00
Nassim Jahnke 667278f9e6 Handle booleans in json->tag conversion 2023-10-16 15:35:16 +10:00
Nassim Jahnke fa7096c5c1 Convert boss bar packets 2023-10-13 23:28:16 +10:00
Kichura 958064b44c Suggest Fabric loader 0.14.0+ and ViaFabric 0.4.10+ (#3474) 2023-10-13 23:26:38 +10:00
Nassim Jahnke 26dad99265 23w41a 2023-10-12 01:32:00 +10:00
Pablo Herrera d8007dc73c Fix valid block placements being prevented (#3407) 2023-10-11 23:29:45 +10:00
Nassim Jahnke 5850a9852d More spring cleaning 2023-10-11 23:14:41 +10:00
Nassim Jahnke 095fe16447 Don't use not yet loaded platform logger in config 2023-10-11 13:23:40 +10:00
Nassim Jahnke cbf8b8f401 Send last tags when re-entering config phase 2023-10-11 01:09:36 +10:00
Nassim Jahnke d600b0cbe1 Queue join game first, then send config packets 2023-10-11 00:06:48 +10:00
Nassim Jahnke 0d70cdbe15 Fix uuid nbt conversion 2023-10-10 23:46:24 +10:00
Nassim Jahnke b1b0874c0f Some cosmetic code changes and typo fixes 2023-10-08 20:54:04 +10:00
Nassim Jahnke 67ba0e9566 Fix typos of entity 2023-10-08 19:03:14 +10:00
Nassim Jahnke bebdc34b4b Register config during manager init 2023-10-08 19:01:00 +10:00
Nassim Jahnke 3e0eb90662 Update OpenNBT (now ViaNBT) 2023-10-08 18:44:54 +10:00
Nassim Jahnke d8f98945e2 Refactor ConfigurationProvider 2023-10-08 14:23:55 +10:00
RK_01 0c3d709456 Clear input buffer instead of reading remaining bytes (#3471) 2023-10-08 03:05:25 +00:00
EnZaXD 868c5ba203 Make registry fields in 1.8 ItemRewriter public (#3472) 2023-10-08 03:05:11 +00:00
Nassim Jahnke 0953ff77e4 Implement dumb nbt<->json component conversion 2023-10-07 23:28:42 +10:00
Nassim Jahnke c211b10eaa Rename NBT and NBT_ARRAY types, add TagType
In theory the nameless compound tag type doesn't exist as it is written as any tag, but in practice is almost always cast and checked for its type, so we keep the extra CompoundTagType (nameless) and add the proper TagType (nameless, any tag) used for components
2023-10-06 22:35:00 +10:00
Nassim Jahnke def3bf9d4a Add remaining packet transformers, missing actual component conversion 2023-10-06 08:57:00 +10:00
Nassim Jahnke cb1b33b3e7 Start working on 23w40a 2023-10-05 18:22:13 +10:00
Nassim Jahnke a8acae2d5f 4.8.1 Release 2023-10-03 20:57:47 +10:00
Nassim Jahnke fdb7f47749 Properly throw the client information packet into the queue instead 2023-10-03 20:54:51 +10:00
Nassim Jahnke cabb95a3a4 Schedule send client information 2023-10-03 20:39:46 +10:00
Nassim Jahnke 0b93af88a3 Re-send client information when re-entering play state
Fixes #3442
2023-10-03 19:49:55 +10:00
Unoqwy 11cb113619 Fix disconnecting error for unknown mobs with metadata (#3443) 2023-10-03 09:46:02 +00:00
Nassim Jahnke 429e4f0bff Switch server state after sending game profile
Probably fixes #3453
2023-09-28 11:12:46 +10:00
Nassim Jahnke 3b0d1d961a Fix secondary effect reading in serverbound beacon
Fixes #3455
2023-09-28 09:34:26 +10:00
Nassim Jahnke b4720c723a Fix biome and chunk size preconditions 2023-09-27 14:35:20 +10:00
Nassim Jahnke 215cbc6310 Fix 1.20.2 custom potion effect handling
Fixes #3448
2023-09-27 11:30:35 +10:00
RK_01 f07ba9b527 Reduce delay for sequence acknowledgements (#3445) 2023-09-26 10:53:36 +10:00
Misode 5a20030ff3 [ci skip] Update Minecraft Wiki link to new domain after fork (#3446) 2023-09-26 10:52:03 +10:00
Nassim Jahnke 1b350c0c53 Try to fix ci 2023-09-26 10:40:44 +10:00
Nassim Jahnke 87db6fc75a [ci skip] Fix branch check 2023-09-26 00:17:33 +10:00
Nassim Jahnke 840770a350 Fix missing server state change 2023-09-25 20:11:29 +10:00
Nassim Jahnke 3997ea70f7 Fixup state splitting 2023-09-25 18:59:15 +10:00
Nassim Jahnke 854696abff Add separate client and server protocol state 2023-09-25 16:44:41 +10:00
Nassim Jahnke d92b9fdeaa Fix connection field search on 1.20.2 2023-09-25 09:57:55 +10:00
Nassim Jahnke 270d28f259 Don't cancel custom query answer 2023-09-25 08:56:26 +10:00
RK_01 ed1852ba40 Fix 1.20.2 -> 1.20.1 brand custom payloads properly (#3440) 2023-09-25 08:52:17 +10:00
riku6460 f91e6a83f9 Fix sign nbt on 1.20 client (#3436) 2023-09-24 13:02:31 +10:00
Nassim Jahnke 8a0e187621 Drop custom payloads with non-alphanumerical brands
For some reason the client errors only if it contains certain characters, needs further investigation. Mojang changed their string writing implementation, though the actual encoding does not seem to have changed, and this error does not occur anywhere else
2023-09-24 10:48:47 +10:00
Nassim Jahnke 0e8b5e8e98 Bump version to 4.8.1-SNAPSHOT 2023-09-24 10:47:43 +10:00
Nassim Jahnke e30dd63b3c [ci skip] Only publish releases from the main branch 2023-09-22 15:32:14 +10:00
Nassim Jahnke 489b28e520 4.8.0 Release 2023-09-21 10:34:20 +10:00
Nassim Jahnke d23e743550 Fix particle handling 2023-09-21 10:33:58 +10:00
Nassim Jahnke 16f89f2638 Don't re-enter config state if the dimension registry did not change 2023-09-19 21:14:45 +10:00
Nassim Jahnke fe5646a68c Re-send last resource pack on server switch 2023-09-19 11:54:03 +10:00
Nassim Jahnke 53aca791dd Fix reentering of the configuration state 2023-09-19 00:37:55 +10:00
Nassim Jahnke 1f0a4c26db 1.20.2-rc2 2023-09-19 00:07:43 +10:00
Nassim Jahnke 4c34ced240 Fix record handling due to no mappings
Fixes #3422
2023-09-16 13:28:15 +10:00
Nassim Jahnke 18c4f90cb0 Don't cancel system chat messages 2023-09-16 13:27:44 +10:00
Nassim Jahnke 9c90445c9c Release ConfigurationState buffers on disconnect
They're heap buffers, but still good practice
2023-09-16 13:27:23 +10:00
Nassim Jahnke 494e6ffc05 1.20.2-rc1 2023-09-16 10:19:49 +10:00
Nassim Jahnke a196dbc16b 1.20.2-pre4 2023-09-14 09:03:13 +10:00
Nassim Jahnke 8934bbdfc3 1.20.2-pre3 2023-09-12 23:06:54 +10:00
Myles 8316c59010 Merge pull request #3420 from Kichura/dev 2023-09-11 19:55:27 +01:00
Kichura 5ea1c1ec95 Use https instead of http for wiki.vg source. 2023-09-11 20:06:27 +02:00
Nassim Jahnke cc7c571a3c 1.20.2-pre2 2023-09-08 09:05:31 +10:00
Nassim Jahnke 06b4678b2d [ci skip] Add IDEA extension plugin 2023-09-06 11:20:32 +10:00
Nassim Jahnke a109118a97 1.20.2-pre1 2023-09-06 00:56:31 +10:00
Nassim Jahnke a135a1414c [ci skip] Update Gradle wrapper 2023-09-05 21:16:24 +10:00
Nassim Jahnke f50751ed48 [ci skip] Update blossom 2023-09-05 21:10:43 +10:00
Kichura 4b7998b4ea [ci skip] Update checkout to v4, Check for latest JDK 11 build (#3416) 2023-09-05 20:48:36 +10:00
Nassim Jahnke 6db1a2a614 Fix wrong packet type being used 2023-08-31 11:49:54 +10:00
Nassim Jahnke 625373827c Fix MetaTypes1_20_2 item type 2023-08-31 11:44:55 +10:00
Nassim Jahnke a9288ebd3a 23w35a 2023-08-31 00:42:47 +10:00
Nassim Jahnke 01bbb2c1c2 [ci skip] Update Hangar publish plugin 2023-08-26 20:04:06 +10:00
Nassim Jahnke 8dbc8e8eba Update mappings file for 23w33a 2023-08-18 01:28:55 +10:00
Nassim Jahnke 0c9f3aa080 23w33a 2023-08-18 01:27:00 +10:00
EnZaXD 00625be890 Move 1.9 backwards protocols to VB and move Chunk Types to the correct package (#3404) 2023-08-14 10:46:30 +10:00
Pablo Herrera e112f81ec8 Optimize memory allocation for data palette (#3402) 2023-08-14 10:40:10 +10:00
Nassim Jahnke 23f776a6ee Handle minecart blocks 2023-08-11 21:12:23 +10:00
Nassim Jahnke 0050872950 Update README 2023-08-11 21:12:03 +10:00
Nassim Jahnke 7e53f55509 Also publish dev branch builds to Hangar 2023-08-11 20:33:47 +10:00
Nassim Jahnke 1bf7962dc3 Call latestCommitHash only once 2023-08-11 16:24:27 +10:00
Nassim Jahnke 50176dc317 Include link to commit in autopublished changelog 2023-08-11 16:21:44 +10:00
Nassim Jahnke 9ed074d0d5 Handle changes block state ids 2023-08-11 15:52:53 +10:00
Nassim Jahnke 8bad8a10be Finish publishing action 2023-08-11 12:28:38 +10:00
Nassim Jahnke 34509e86c0 [ci skip] Add Velocity and Waterfall to publish config 2023-08-11 00:39:45 +10:00
Nassim Jahnke ef75bd567d [ci skip] GH already skips all actions with ci skip 2023-08-10 22:48:22 +10:00
Nassim Jahnke 7ed3e50e93 [ci skip] Skip commits with ci skip prefix 2023-08-10 22:46:15 +10:00
Nassim Jahnke a45eceaf1d Hello Hangar 😎 2023-08-10 22:18:23 +10:00
Nassim Jahnke 573cdfb3ac Merge remote-tracking branch 'origin/master' into dev 2023-08-10 21:49:26 +10:00
Nassim Jahnke 28787340d1 Setup Hangar and modrinth autopublishing 2023-08-10 21:29:03 +10:00
Nassim Jahnke c358245c0b Fix spawn tracker mapping data check 2023-08-10 17:14:01 +10:00
Nassim Jahnke cb073405b7 Effect ids start at 1 before 1.20.2 2023-08-10 17:08:36 +10:00
Nassim Jahnke f618f6a7d6 Actually write effect key 2023-08-10 13:51:15 +10:00
Nassim Jahnke c5e066e050 23w32a 2023-08-10 13:35:47 +10:00
riku6460 d954e1745d Fix itemArrayType of ItemRewriter on dev branch (#3398) 2023-08-09 07:38:24 +10:00
Nassim Jahnke 9c92ccea77 Finish up state switching 2023-08-06 15:40:15 +10:00
RK_01 2b9e0cec5c Fix maps with no map id set showing up as empty on 1.17+ (#3395) 2023-08-06 11:11:42 +10:00
RK_01 c1cd8bc03e Allow skylight to be set to null (#3396) 2023-08-06 11:08:52 +10:00
Nassim Jahnke 39efc5262e Add todo 2023-08-05 13:31:43 +10:00
Nassim Jahnke 6e5e115c3b Remove unnecessary rewriting code, fix recipe handlers 2023-08-05 12:28:39 +10:00
Nassim Jahnke fbcbd33c66 Small refactors 2023-08-04 12:35:35 +10:00
Nassim Jahnke 7bea3142bc Fix baseprotocol registration 2023-08-04 12:26:07 +10:00
Nassim Jahnke fb472c3454 Cleanup imports 2023-08-04 12:25:29 +10:00
Nassim Jahnke ac10bb3fd0 Complete 23w31a protocol 2023-08-04 12:22:18 +10:00
Nassim Jahnke 1bc3d407d1 More juicy, untested work 2023-08-03 23:03:42 +10:00
Nassim Jahnke 62c0ef360f More absolutely cursed WIP 2023-08-03 21:58:23 +10:00
Nassim Jahnke 8c6d104faa 23w31a eletric boogaloo 2023-08-03 19:47:18 +10:00
Nassim Jahnke f6b8c4a8c8 Rename rewriter classes 2023-08-03 18:38:18 +10:00
Nassim Jahnke 6586fc1436 More work on the snapshot 2023-08-03 18:36:30 +10:00
Nassim Jahnke 6dfd4747ee Start working on 23w31a 2023-08-03 13:58:22 +10:00
Nassim Jahnke 6377721ebd Fix non item display rotation
Fixes #3383
2023-07-24 20:56:45 +10:00
RK_01 2ec6185c46 Fix <= 1.14 position y sign reading (#3381) 2023-07-12 19:10:49 +02:00
Nassim Jahnke b22907748a Update gradle wrapper 2023-07-11 23:34:37 +02:00
Nassim Jahnke 1aee8a7a6c Don't create ack task when already disabled
Fixes #3373
2023-07-02 13:29:07 +02:00
Nassim Jahnke 7edb43844c Properly handle item display rotation change
Fixes #3354
2023-07-02 13:27:03 +02:00
sandtechnology f28aac5eb3 Handle more null TextComponent for 1.19 to 1.18.2 (#3366) 2023-06-24 11:12:14 +02:00
Nassim Jahnke 4971eeab6a Don't check block items for armor swapping 2023-06-22 11:03:11 +02:00
Pablo Herrera 0bb940e42d Fix missing block connection updates on cancelled place/remove (#3359) 2023-06-20 13:39:02 +02:00
Pablo Herrera e32933ada9 Fix late registration of join listener (#3360) 2023-06-19 17:02:05 +02:00
EnZaXD a817746edc Remove requirement for MovementTransmitterProvider (#3355) 2023-06-18 15:30:58 +02:00
RK_01 408392e796 Fixed some 1.9 -> 1.8 movement issues (#3353) 2023-06-18 14:51:37 +02:00
Kichura 20a4ae3e4b Use friendly names in CI tasks, Update shadow and blossom (#3349) 2023-06-15 09:48:13 +02:00
Nassim Jahnke 08b2d78165 Move dump creation to util class 2023-06-14 23:13:44 +02:00
FlorianMichael 17eb7b676a Remap old smithing menu to furnace in 1.20 2023-06-12 18:57:20 +02:00
Nassim Jahnke 9a1598b9ed Update 1.20/1.20.1 protocol version 2023-06-12 16:47:22 +02:00
Myles 9e7cd151bc Update version table to 1.20 2023-06-11 12:02:25 +01:00
David Luedtke 2a14f9a0cd Fix display rotation change 2023-06-09 12:17:11 +02:00
Ossi Erkkilä bf825d5ef6 Fix SpongeViaInjector#getServerProtocolVersion() for Sponge API-10+ (#3337) 2023-06-09 11:29:55 +02:00
EnZaXD 28ba4afc27 Added VersionInfo#getVersion to bypass Java inlining (#3344) 2023-06-09 08:52:30 +02:00
Nassim Jahnke 7f347231bb Bump version to 4.7.1-SNAPSHOT 2023-06-08 13:21:19 +02:00
Nassim Jahnke f1b5f9223a 4.7.0 Release 2023-06-06 13:30:57 +02:00
Nassim Jahnke e4a1530aa8 Fix >1.18 vibration particle handling 2023-06-06 13:28:02 +02:00
Nassim Jahnke 09b67fad63 Small cleanup 2023-06-06 12:30:56 +02:00
Nassim Jahnke 1b3c5b4032 Create its own packets enum for 1.14.4
Acknowledge player digging was only added then, make sure this is represented correctly
2023-06-05 09:06:15 +02:00
Nassim Jahnke b7d8a3c8d5 1.20-rc1 2023-05-31 15:40:23 +02:00
Kichura 9a515df0f3 Update dependencies (#3332) 2023-05-30 09:25:18 +02:00
Nassim Jahnke c6103f2f51 1.20-pre7 2023-05-29 16:54:45 +02:00
Nassim Jahnke 5c0eda76e8 Don't replace unchanged 1.12->1.13 translations with hard text
Also add the remaining unchanged keys to the file
Fixes #3284
2023-05-28 13:48:22 +02:00
Nassim Jahnke 544a28b06b 1.20-pre6 2023-05-25 15:09:42 +02:00
RK_01 5c145d0184 Fixed high CPU usage on Java 8 (#3325)
Fixed https://bugs.openjdk.java.net/browse/JDK-8129861 by setting the core size of the TaskScheduler ThreadPool to 1
2023-05-23 18:18:10 +02:00
Nassim Jahnke ed55bccfe4 Fix 1.19.3->1.19.4 statistics handling
Fixes #3324
2023-05-23 16:39:20 +02:00
Nassim Jahnke 5acc2fefbc 1.20-pre5 2023-05-23 15:40:54 +02:00
Nassim Jahnke 7f748b5c68 1.20-pre4 2023-05-19 15:40:54 +02:00
Nassim Jahnke 0ec03f8b09 1.20-pre3 2023-05-19 14:22:14 +02:00
Nassim Jahnke a70034e0b5 Remove early static initializer call
Weird NoClassDefFoundError going on
2023-05-18 11:53:34 +02:00
Nassim Jahnke 98a0fdca94 1.20-pre2 2023-05-16 16:00:36 +02:00
Nassim JahnkeandPantera 82961cc153 Add 1.20 sound mappings
Co-authored-by: Pantera (Mad_Daniel) <89838384+Pantera07@users.noreply.github.com>
2023-05-14 08:42:51 +02:00
Nassim Jahnke 6c0d891c9f Don't print mapping validity warning if conversion warnings are disabled 2023-05-14 08:38:24 +02:00
Nassim Jahnke 6fa387e6ab Update the rest of nbt files to be uncompressed 2023-05-10 15:53:53 +02:00
Nassim Jahnke 07bdb57694 1.20-pre1 2023-05-10 15:46:03 +02:00
Nassim Jahnke 75dd79347a Update mappings 2023-05-05 21:05:35 +02:00
Nassim Jahnke 9257890d3c Update protocol version 2023-05-05 18:50:15 +02:00
Nassim Jahnke 891f55192d 23w18a, maybe 2023-05-03 15:21:24 +02:00
EnZaXD 7adadc0d21 added PlayerAbilities Provider (#3311) 2023-05-03 09:17:51 +02:00
Camotoy 638378cddf Let records properly stop in 1.19.3 -> 1.19.4 (#3308)
Fixes #3307
2023-04-28 14:44:29 +02:00
Nassim Jahnke 56d772df34 23w17a 2023-04-26 18:46:52 +02:00
Nassim Jahnke 7bb5cf3ae9 Update Gradle wrapper 2023-04-26 12:23:02 +02:00
Nassim Jahnke b67e3c30fd Move packet construction of schedule send methods to event loop as well
Fixes #3306
2023-04-26 12:18:08 +02:00
EnZaXD a2e214ae18 Improve InventoryTracker16 Code (#3302) 2023-04-22 08:57:47 +02:00
Nassim Jahnke 54d8e29a7e 23w16a 2023-04-20 17:28:30 +02:00
Joseph Burton a2daa9c989 Fix PlayerLookTargetProvider, apparently this packet is written in two different places (#3301) 2023-04-19 14:43:39 +02:00
Nassim Jahnke 74cc42fecf Merge remote-tracking branch 'origin/master' into dev 2023-04-19 12:08:15 +02:00
Joseph Burton dd59ddbd4f Add PlayerLookTargetProvider (#3299) 2023-04-19 12:04:17 +02:00
Nassim Jahnke bcfc77aa7d Merge branch 'master' into dev 2023-04-18 13:35:14 +02:00
Nassim Jahnke 1a46346789 Handle optional block state entity meta 2023-04-18 13:34:20 +02:00
RK_01 394be165fd Handle ENTITY_TELEPORT's targeting the client player (#3296) 2023-04-14 16:38:39 +02:00
Nassim Jahnke 20d86374b5 23w14a 2023-04-05 15:25:37 +02:00
Nassim Jahnke 8864b161f9 Print plugin name in unsupported software matching 2023-04-02 09:41:20 +02:00
Nassim Jahnke 7b0160d6c3 Fix redstone blockconnections
Fixes #3281
2023-03-31 16:41:06 +02:00
Nassim Jahnke 7e5173982d 23w13a 2023-03-29 16:32:50 +02:00
Nassim Jahnke ee75f19790 Merge branch 'master' into dev
# Conflicts:
#	gradle.properties
2023-03-29 16:28:57 +02:00
Nassim Jahnke e54f6d1999 Override metatypeimpl tostring 2023-03-28 17:27:22 +02:00
Nassim Jahnke c46bb5bcf5 Update Folia check 2023-03-25 00:31:50 +01:00
Nassim Jahnke d08f15c095 4.6.2 Release 2023-03-24 22:00:05 +01:00
Nassim Jahnke 8aa7898755 Cherry-pick some changes from dev 2023-03-24 17:58:53 +01:00
Nassim Jahnke 9682b68251 Handle sign nbt changes 2023-03-24 11:19:51 +01:00
Nassim Jahnke 364cfad9d8 23w12a 2023-03-22 18:49:18 +01:00
RK_01 641171a14f Properly handle dismount in PLAYER_POSITION packet (#3272) 2023-03-21 21:53:44 +01:00
Nassim Jahnke 23f045feee Fix glass pane and iron bars block connections
Fixes #3269
2023-03-20 10:31:13 +01:00
Nassim Jahnke f1bde8ba2a Handle shifted 1.19.4 boat types 2023-03-18 12:28:00 +01:00
Nassim Jahnke 9ccc3aed30 Keep all 1.12 translation mappings cached 2023-03-18 10:01:37 +01:00
Nassim Jahnke ad56caeb88 Double the trouble 2023-03-17 21:47:55 +01:00
Nassim Jahnke 573201c0b1 Only load JoinListener things early 2023-03-17 18:37:48 +01:00
Nassim Jahnke e298a7efac Fix protocol detection on some versions of Spigot
Fixes #3263
2023-03-17 18:36:48 +01:00
Nassim Jahnke 2e59a51734 Add PacketValue toString 2023-03-17 13:26:13 +01:00
Nassim Jahnke d4894ca4b5 Fix #3260 2023-03-17 13:15:56 +01:00
Nassim Jahnke 7f7c6241de Fix 1.12->1.13 stop sound handling
Fixes #3247
2023-03-17 11:37:37 +01:00
Nassim Jahnke 51606eb5ef Bump version to 4.6.2-SNAPSHOT 2023-03-17 11:34:35 +01:00
Nassim Jahnke c9883c2638 4.6.1 Release 2023-03-16 20:44:53 +01:00
Nassim Jahnke 74fb55d96b Update yaml compat checker 2023-03-16 20:41:03 +01:00
Nassim Jahnke 4e844a0095 Small startup time improvements 2023-03-16 12:48:39 +01:00
Nassim Jahnke da7f8ea3b6 Be more safe 2023-03-15 16:21:15 +01:00
Nassim Jahnke 81c4e530e9 Possibly fix joinlistener on 1.19.4 Spigot 2023-03-15 16:15:21 +01:00
Nassim Jahnke b1524642aa Fix protocol detection on 1.19.4 Spigot
Fixes #3241
2023-03-15 10:09:45 +01:00
Nassim Jahnke a828c43f99 Remove ignoreCancelled from ArmorToggleListener, small cleanup
Spigot considers interacting with air "cancelled"
Fixes #3240
2023-03-15 09:20:21 +01:00
Nassim Jahnke fccfadf1b7 Handle falling blocks
Fixes #3244
2023-03-15 09:04:13 +01:00
lixfel 18b41c82c4 1.15.2 Spigot/Paper NoSuchMethodError YamlCompat fix (#3242) 2023-03-14 21:48:40 +01:00
Nassim Jahnke 27ee6f519e Bump version to 4.6.1-SNAPSHOT 2023-03-14 21:48:18 +01:00
Nassim Jahnke 7aa0aed5ec 4.6.0 Release 2023-03-13 14:18:40 +01:00
Nassim Jahnke 10c4d9408e 1.19.4-rc3 2023-03-13 14:17:59 +01:00
Nassim Jahnke e8b4496289 1.19.4-rc2 2023-03-10 14:58:40 +01:00
Nassim Jahnke 10737f17e2 Delay version detection when using legacy injector 2023-03-10 14:29:28 +01:00
Nassim Jahnke 7c9c602cec Support Folia (leaf's region threaded Paper fork) 2023-03-10 12:20:02 +01:00
Nassim Jahnke 2ee2819759 1.19.4-rc1 2023-03-09 17:52:41 +01:00
Nassim Jahnke 72197ddca8 Lots of small and less small blockconnection optimization
- blockConnections.json data is now stored more compact and with direct block state ids in blockConnections.nbt
- For PacketBlockConnectionProvider, the server now longer spams unnecessary block change packets if the connectable block did not actually change
- Some other, small optimizations within the individual connection handlers
2023-03-09 17:46:03 +01:00
Nassim Jahnke 9781b7962f 1.19.4-pre4 2023-03-08 15:28:59 +01:00
Nassim Jahnke d180c8fe2f Small ConnectionData cleanup 2023-03-08 15:13:29 +01:00
Nassim Jahnke d8a9480bf1 Clean up BiMappings impl 2023-03-07 11:27:25 +01:00
Howard ZHY a3efb676cf Fix #2912 (#3221) 2023-03-07 11:25:32 +01:00
Pablo Herrera 68d1843496 Optimize block connections on neighbour chunk calculation (#3228) 2023-03-06 12:21:17 +01:00
Nassim Jahnke 3ced95903a Cache identifiers files 2023-03-05 15:20:16 +01:00
Nassim Jahnke b3825e637e Fix heightmap file, hotfix enchantment rewriting without mappings 2023-03-05 09:32:56 +01:00
Nassim Jahnke c765f20558 Readd enableMappingsCache stub until reimplemented 2023-03-04 21:03:53 +01:00
Nassim Jahnke b5259beef7 Update README 2023-03-04 19:43:08 +01:00
Nassim Jahnke 712bbcdc02 More fixes to mapping data loading 2023-03-04 17:17:47 +01:00
Nassim Jahnke b94c71b699 Register tagrewriter in 1.19.3->1.19.4 protocol 2023-03-04 00:23:02 +01:00
Nassim Jahnke 51d4e11b5f Minimize/optimize mapping data files 2023-03-04 00:08:08 +01:00
Nassim Jahnke d94ed4ebd4 Allow null rewrite function in TagRewriter 2023-03-03 15:14:52 +01:00
Nassim Jahnke 9ce3d8e567 Update OpenNBT to 2.1.2 2023-03-03 14:20:41 +01:00
Nassim Jahnke 9fd0d3e565 Reduce mappings file sizes and optimize item mappings 2023-03-02 13:14:11 +01:00
Nassim Jahnke 7b91c25379 1.19.4-pre3 2023-03-01 16:07:23 +01:00
Nassim Jahnke 7161377794 Add PacketWrapper#setCancelled(boolean) 2023-02-28 21:49:08 +01:00
Nassim Jahnke 8f97f43f12 Update Gradle wrapper 2023-02-28 21:41:32 +01:00
Nassim Jahnke 57f0d58d58 1.19.4-pre2 2023-02-27 16:12:35 +01:00
Nassim Jahnke b45be1944e Support snakeyaml 2 2023-02-27 14:16:40 +01:00
Nassim Jahnke c4019fadd8 Fixes 2023-02-24 16:50:28 +01:00
Nassim Jahnke 5cad29c754 Expose PacketTypesProvider in Protocol 2023-02-24 10:07:25 +01:00
Nassim Jahnke a6e1cb6534 I didn't read the changelogs 🛌 2023-02-22 19:08:50 +01:00
Nassim Jahnke 26615a11d3 23w08a 2023-02-22 18:51:28 +01:00
Nassim Jahnke 3e2ee37829 Allow custom PacketMappings implementation in AbstractProtocol 2023-02-22 16:54:54 +01:00
Nassim Jahnke 35263e36ff Let VB handle mapping cache enabling
Soon™️ to be fixed by Paper
2023-02-20 17:34:32 +01:00
Nassim Jahnke bf4e4d771f Uncap mapping loader executor pool, less logging 2023-02-20 17:30:56 +01:00
Nassim Jahnke 1157029f23 Remove unused config option, hotfix mapping data cache 2023-02-20 13:19:10 +01:00
Nassim Jahnke 7b5cb92982 Small refactor 2023-02-20 13:19:03 +01:00
Nassim Jahnke d74f91d606 Handle item/block/particle metadata 2023-02-18 10:00:57 +01:00
Nassim Jahnke 1376312449 23w07a 2023-02-17 23:02:02 +01:00
Nassim Jahnke 1faf1f3f49 Reduce RecipeRewriter extends chain 2023-02-16 12:27:31 +01:00
Nassim Jahnke fb0381e76a Update Gradle wrapper 2023-02-15 14:56:12 +01:00
Nassim Jahnke 45fcc9ef7d Rename Protocol generics to be clearer 2023-02-12 21:14:10 +01:00
Nassim Jahnke f5ddc6550d Optimize/improve Protocol packet mapping
Also makes it possible to work with packet types of different states in a Protocol
2023-02-12 17:27:36 +01:00
Nassim Jahnke cb2165eb93 Greatly reduce the number of (anonymous) inner classes
Reduces code complexity, and much more importantly, reduces the number of classes loaded at runtime by *hundreds*
2023-02-12 11:46:48 +01:00
Nassim Jahnke de5b7bf828 Allow registration of simple packet handlers over extending an abstract class 2023-02-12 10:54:47 +01:00
Nassim Jahnke 98c645f7ed Store tracked entity data a little differently 2023-02-10 12:00:20 +01:00
Nassim Jahnke b03765a828 23w06a 2023-02-08 18:49:06 +01:00
Nassim Jahnke 088f654159 Remove some deprecated api usage, small cleanup 2023-02-04 19:42:26 +01:00
Nassim Jahnke 1a5f83619d Ensure correct packet types are used on rewriters 2023-02-04 18:29:22 +01:00
Camotoy 734bc9e88c Add armor toggle patch for Bukkit (#3210) 2023-02-03 17:02:22 +01:00
Nassim Jahnke 93654b8eaf Don't load mappings in 1.19.4 protocol 2023-02-03 10:48:46 +01:00
Nassim Jahnke 64b3771899 23w05a 2023-02-01 16:30:21 +01:00
Nassim Jahnke 4031429430 23w04a 2023-01-24 17:03:08 +01:00
Nassim Jahnke 50b94abcb1 Move changed time handling out of base CommandRewriter 2023-01-18 18:03:09 +01:00
Nassim Jahnke 50adff90f2 23w03a 2023-01-18 16:49:05 +01:00
Nassim Jahnke 7d0b838474 Update dependencies 2023-01-14 20:05:21 +01:00
Nassim Jahnke 4fb95581ce Update copyright headers 2023-01-12 12:45:53 +01:00
Nassim Jahnke 0ae64203f5 Add player versions and sample pipelines to dump 2023-01-10 19:05:54 +01:00
Nassim Jahnke 4067107b52 Improve exception handling 2023-01-06 20:51:21 +01:00
Camotoy 8d7270a2ff Fill in creeper igniter tag for 1.19.3 (#3184) 2022-12-25 10:52:50 +01:00
Nassim Jahnke ece8857535 Handle missed 1.19.3 pose change 2022-12-21 10:45:54 +01:00
Nassim Jahnke 9688b3df5d Bump version to 4.5.2-SNAPSHOT 2022-12-21 10:45:06 +01:00
Nassim Jahnke 58442ec177 4.5.1 Release 2022-12-11 14:40:34 +01:00
Nassim Jahnke 2a49fc0bf8 Fix chat command decode
Fixes #3161
2022-12-09 13:15:42 +01:00
Nassim Jahnke 7fb8675271 Thank you gradle, very cool 2022-12-09 11:18:26 +01:00
Myles 57a8744a53 Use scheduleSend for enabled features packet 2022-12-07 22:16:50 +00:00
Myles 09222f1024 4.5.1-SNAPSHOT 2022-12-07 22:14:14 +00:00
Nassim Jahnke b4870a49e3 1.19.3-rc3 protocol changes (but not actually supporting the snapshot)
Definitely still 4.5.0
2022-12-06 12:20:48 +01:00
Nassim Jahnke f7a48d028b 4.5.0 Release 2022-12-05 20:29:24 +01:00
Nassim Jahnke 382ef3953a Merge remote-tracking branch 'origin/master' into dev 2022-12-05 19:55:29 +01:00
Nassim Jahnke 9be32ca18b Make slightly more sense of CompactArrayUtil
... and make it less vanilla copy pasty

The magic array is a reciprocal table of 3-tuples, although 1 and 2 are always the same but for the ones including right shifts
2022-12-02 14:34:32 +01:00
Nassim Jahnke e0cd121a58 1.19.3-rc1 2022-12-01 16:41:19 +01:00
Nassim Jahnke 96631cee0c 1.19.3-pre3 2022-11-29 17:26:51 +01:00
Nassim Jahnke 8c0487fc05 1.19.3-pre2 2022-11-23 18:02:33 +01:00
Nassim Jahnke aec60f8cef 1.19.3-pre1 2022-11-22 17:11:11 +01:00
Nassim Jahnke a3080800b0 More minor refactoring 2022-11-22 17:04:06 +01:00
Kevin Ludwig 85f9414b95 Fix recipe book not being empty when using a multi-server configuration, with servers which are pre-1.12. (#3156) 2022-11-20 12:31:01 +01:00
Nassim Jahnke e7f07d1fdb Update mappings file 2022-11-16 16:39:16 +01:00
Nassim Jahnke 83efd0a267 22w46a (maybe) 2022-11-16 16:03:18 +01:00
Nassim Jahnke 5c05c61fbf 22w45a 2022-11-09 16:09:23 +01:00
Nassim Jahnke fad350c811 Small refactoring 2022-11-03 18:30:59 +01:00
Nassim Jahnke d3d8d1cab3 22w44a (maybe) 2022-11-02 15:49:40 +01:00
RK_01 a3437ca6ba Fix 1.19 -> 1.18.2 player info display name translation: Empty text edge case (#3146) 2022-10-27 10:36:46 +02:00
Kevin Ludwig 17bd048d10 Fix missing zombie_pigman (1.15.2) => zombified_piglin (1.16) translation in mob_spawner entity (#3147) 2022-10-27 10:32:31 +02:00
F 955b76f599 Fix use-new-effect-indicator option for 1.13+ clients (#3127) 2022-10-27 10:30:03 +02:00
Nassim Jahnke e3dc9e5b66 22w43a 2022-10-26 18:09:42 +02:00
Nassim Jahnke 6095128007 Remove javassist dependency, reduces file size by ~1mb 2022-10-25 17:31:13 +02:00
Nassim Jahnke 0355447d53 Remove more of the old compat layer 2022-10-25 15:55:42 +02:00
Nassim Jahnke 58fd0bdc9e Remove 1.8 PS compat hack 2022-10-25 10:36:09 +02:00
Nassim Jahnke cdc35aa5dc Merge remote-tracking branch 'origin/master' into dev 2022-10-25 10:36:02 +02:00
RK_01 10efba31cf Update 1.9 -> 1.8 ATTACH_ENTITY data reading (#3144) 2022-10-25 10:35:45 +02:00
Nassim Jahnke ef204c2ab2 Fix argument type handling 2022-10-23 18:27:44 +02:00
Nassim Jahnke 555e1a7722 Fix long metatype reading, some internal type reading changes 2022-10-22 10:19:27 +02:00
Nassim Jahnke 7400784e4f 22w42 (except for command completions) 2022-10-20 19:34:04 +02:00
Nassim Jahnke 2154f0a2cf Almost works 2022-10-19 23:18:39 +02:00
Nassim Jahnke 14b11bdd10 Start working on 22w42a 2022-10-19 21:58:08 +02:00
Nassim Jahnke c5738a2203 Add Via channel handlers instead of wrapping Vanilla handlers on Bukkit (#3132) 2022-10-19 21:29:24 +02:00
MrMicky 43ad855499 Rewrite signs and books components on 1.16 (#2712) 2022-10-16 21:22:48 +02:00
Kichura 2533619339 Update actions, Gradle 7.5.1 (#3139) 2022-10-15 19:20:20 +02:00
Nassim Jahnke b133dad642 Fix random long gen for seeded sounds 2022-10-08 21:50:09 +02:00
RK_01 464a85c52b Replaced hardcoded chunk section out of bounds check (#3136) 2022-10-07 23:07:50 +02:00
Gero 7698ee7683 Some minor performance improvements and cleanups (#3134) 2022-10-04 13:25:55 +02:00
BuzzTheGamer23 c7eb2e4b97 Change Maven version from deprecated LATEST (#2913) 2022-10-01 11:23:02 +02:00
creeper123123321 e71c88f860 Add sanity checks for some block nbt (#3129) 2022-10-01 10:14:41 +02:00
RK_01 c96b2bd859 Fix 1.19 -> 1.18.2 title translation: empty text edge case (#3115) 2022-09-02 16:00:45 +02:00
Nassim Jahnke ce4f21b7d8 Fix Paper packet limiter check on new versions 2022-08-25 13:03:40 +02:00
Nassim Jahnke 2a55025e99 Version bump 2022-08-21 14:58:00 +02:00
Nassim Jahnke c86da22f4e Fix config header duplication on reload
Fixes #3100
2022-08-21 14:57:32 +02:00
Nassim Jahnke adb10f5fe7 4.4.2 Release 2022-08-21 09:42:05 +02:00
Pablo Herrera a268d3d298 Fix userconnection availability on join event (PoC) (#2849) 2022-08-19 11:59:48 +02:00
creeper123123321 b60771e96e Fix block connection on non-full chunks (#3068) 2022-08-15 11:58:57 +02:00
Nassim Jahnke 435a986068 Properly enclose limiting of nbt reading
Fixes #3093
2022-08-14 22:24:31 +02:00
Nassim Jahnke 6c58f0980c Add utility method for initializing entity types 2022-08-13 15:36:57 +02:00
Nassim Jahnke e3dde71821 And the default return value 2022-08-11 19:09:33 +02:00
Nassim Jahnke 47b15e5fef Forgot a lock 2022-08-11 19:08:33 +02:00
Nassim Jahnke ed196bdf99 Clean up proxy protocol detector service 2022-08-11 19:04:22 +02:00
Nassim Jahnke 9247e87bbf Update InformativeException message 2022-08-08 21:01:27 +02:00
Nassim Jahnke 08727f959f Update 1.19.1 protocol version string 2022-08-05 16:05:31 +02:00
Nassim Jahnke 78342da180 And make the 1.19 chat registry nbt public 2022-08-04 16:29:35 +02:00
Nassim Jahnke 2b735172bd Make 1.19 chat decoration method public 2022-08-04 16:23:21 +02:00
_tomcraft b032a868bb add flamecord warking message (#3079) 2022-08-04 16:19:08 +02:00
Nassim Jahnke c4fa3b0ff8 Fix worldDataTrackerHandlerByKey world index 2022-08-04 15:51:51 +02:00
Nassim Jahnke 0c3a1803e1 Send block entity data after block break cancellation
Fixes #3077
2022-08-03 19:45:00 +02:00
Gero 04f9971dee Alter velocity modern forwarding version (#3078) 2022-08-03 16:17:52 +02:00
Elioby 9c3395b76b Use default painting mapping of 0 instead of -1 (#3073) 2022-08-01 21:07:40 +02:00
Nassim Jahnke f9bbb5b1a3 Fixup config comment saving
Fixes #3052, #2536
2022-08-01 12:28:44 +02:00
Nassim Jahnke 087bbdce1f Fix 1.19+ sign opening on ~1.12 servers
Fixes #3027
2022-07-30 18:10:45 +02:00
Nassim Jahnke 494bf62535 Bump version to 4.4.2-SNAPSHOT 2022-07-30 18:05:04 +02:00
Nassim Jahnke 4f2a5bb7e2 4.4.1 Release 2022-07-28 18:49:40 +02:00
Nassim Jahnke 1c511a82b2 Simplify component building 2022-07-28 14:56:35 +02:00
Nassim Jahnke 0c39723d1a Use translation key as text if not found 2022-07-28 13:43:08 +02:00
Nassim Jahnke 322af00e80 Handle 1.19 chat types 2022-07-28 13:14:28 +02:00
Nassim Jahnke a88747d904 Check for dimension equality after adding/replacing new fields 2022-07-28 11:47:12 +02:00
Nassim Jahnke e194d27bea Allow for more control over max path distance delta increase 2022-07-28 11:29:02 +02:00
Nassim Jahnke 22daa60eb6 4.4.0 Release 2022-07-27 19:01:23 +02:00
Nassim Jahnke 6eca07966c 1.19.1-rc3 2022-07-26 18:27:32 +02:00
Nassim Jahnke 56cc711c01 Update legacy palette handling as well 2022-07-25 13:18:13 +02:00
Nassim Jahnke c2ee558235 Fix reading of cursed Hypixel block palettes
Fixes #3037
2022-07-24 18:42:25 +02:00
Nassim Jahnke c8a010c390 Handle negative bits per value in palette 2022-07-24 17:30:30 +02:00
Nassim Jahnke 53c54485eb Cleanup optional types 2022-07-21 19:56:42 +02:00
Nassim Jahnke f42a308f2c 1.19.1-rc2 2022-07-21 19:06:34 +02:00
Nassim Jahnke 44250cbb99 1.19.1-pre6 2022-07-20 18:36:28 +02:00
Nassim Jahnke 55ffe72198 Fix overlay type check, update some comments 2022-07-15 21:33:55 +02:00
Nassim Jahnke a47dd2ecdb Support 1.19.1 clients on 1.19.0 servers 2022-07-15 21:03:56 +02:00
Nassim Jahnke 8a5233b6a1 what am I doing 2022-07-15 18:07:59 +02:00
Nassim Jahnke c8a1279e75 I was too hopeful 2022-07-15 16:51:12 +02:00
Nassim Jahnke 57ef90e851 1.19.1-pre5 2022-07-15 16:26:58 +02:00
_tomcraft 2262681351 Reference command permission to filter root suggestions (/via<tab>) (#3018) 2022-07-13 10:24:14 +02:00
Nassim Jahnke 56e1d0a69d Add optional type for smol cleanup 2022-07-09 11:47:58 +02:00
Nassim Jahnke 63ffb51df5 Fix player chat packet id
Mojang didn't register that in the correct spot alphabetically :(
2022-07-08 21:07:42 +02:00
Nassim Jahnke b33bd2ac2b 1.19.1-pre4 2022-07-08 16:20:54 +02:00
Nassim Jahnke 1afff77a0f 1.19.1-pre3 2022-07-06 17:47:47 +02:00
Nassim Jahnke 26af09f2a4 Update unsupported software list 2022-07-05 20:37:19 +02:00
Nassim Jahnke a8e475dbf0 Bump version to 4.4.0-SNAPSHOT
Too many funky things for a patch version
2022-07-01 12:35:57 +02:00
Nassim Jahnke 6388021c6d Fix 1.18.2->1.19.0 transforming, warn on 1.19.0 server 2022-06-30 20:00:55 +02:00
Nassim Jahnke f4aa96a5f8 1.19.1-pre2 2022-06-30 19:34:14 +02:00
Nassim Jahnke 6baae5e4f7 Merge remote-tracking branch 'origin/master' into dev 2022-06-30 10:42:27 +02:00
Nassim Jahnke 189b244a3a Delay ack by a tick, update warning for bad dimension registry 2022-06-30 10:41:54 +02:00
creeper123123321 12d538fe0d Use most similar dimension when the proper is not found (#2990) 2022-06-30 10:31:10 +02:00
_tomcraft 34f0dbf642 Safely handle bad configuration of 'block-protocols' and 'block-versions' (#2983) 2022-06-28 11:22:42 +02:00
Myles 548f80bb7c Add label for Feature Requests 2022-06-27 13:36:10 +01:00
Nassim Jahnke 9113a77331 1.19.1-rc1 except not really 2022-06-23 20:45:42 +02:00
Nassim Jahnke e3e85db02a 1.19.1-pre1 2022-06-21 21:01:24 +02:00
Camotoy c4d9209c81 Rewrite statistics for 1.19 (#2954) 2022-06-15 10:13:14 +02:00
Nassim Jahnke 24d887a53d Properly handle 1.19 acks on backend
Fixes #2935
2022-06-12 11:14:05 +02:00
Owen 702ced200e Generate a random seed to simulate random sounds (#2944) 2022-06-11 19:02:54 +02:00
qlowandqlow 40f5cb6e71 Fixed Bungeecord madness (#2934)
Co-authored-by: qlow <info@qlow.eu>
2022-06-09 17:10:22 +02:00
Nassim Jahnke 7ab0c41be6 Fix villager trade offers
Fixes #2919
2022-06-08 10:07:47 +02:00
Nassim Jahnke 66b21431f2 Fix sending of empty titles
Fixes #2923
2022-06-08 09:51:38 +02:00
Nassim Jahnke c6cd655f7e Bump version to 4.3.2-SNAPSHOT 2022-06-08 09:09:37 +02:00
Myles e9bccda259 4.3.1 Release - Fix set display preview being sent prematurely #2918 2022-06-07 23:11:21 +01:00
Nassim Jahnke 9a34ff2a51 4.3.0 Release 2022-06-05 11:31:07 +02:00
trickypr f01d9408de 1.19-rc2 (#2910) 2022-06-04 11:08:04 +02:00
Nassim Jahnke 15ff7b4c9d 1.19-rc1 2022-06-02 17:49:25 +02:00
Nassim Jahnke d47765ce45 1.19-pre5 2022-06-01 15:16:47 +02:00
Gero b82b067745 Actually make every message a system message (#2903) 2022-05-25 21:24:26 +02:00
Nassim Jahnke b7005f2400 1.19-pre3 2022-05-25 14:33:39 +02:00
roro1506HD 312fe3a851 Fixed wrong packet in MovementTransmitter when not using NMS player ticking (#2900) 2022-05-23 20:29:21 +02:00
Nassim Jahnke 69d50fa992 Join game fixes 2022-05-23 19:38:38 +02:00
Nassim Jahnke 1308dcb8dd No need to queue messages anymore
The client now uses the main registry instead of the level registry
2022-05-23 18:24:32 +02:00
Nassim Jahnke b4ecba8382 1.19-pre2 2022-05-23 18:03:18 +02:00
Nassim Jahnke 3529d6a229 Sanity check for queued messages 2022-05-21 11:00:55 +02:00
Nassim Jahnke 4213c4cce5 Queue up messages before the chat type registry has been sent
Fixes #2898
2022-05-20 15:32:10 +02:00
Nassim Jahnke 3d3e09977c Fix big fat dumb 2022-05-20 14:16:31 +02:00
Nassim Jahnke 90feac8c83 Update DebugHandler 2022-05-20 14:10:23 +02:00
Nassim Jahnke 80a807e366 Fix head yaw and pitch being swapped for mob spawns 2022-05-20 10:00:31 +02:00
Nassim Jahnke 3eba8ba922 More consistent client entity tracking 2022-05-20 09:53:39 +02:00
Nassim Jahnke 71a68bf36e Fix the client entity being untracked on world changes
Fixes #2894 and probably other things
2022-05-19 23:04:18 +02:00
Nassim Jahnke e67501cde3 Fix painting id being used too early
Fixes #2893
2022-05-19 19:54:27 +02:00
Nassim Jahnke 9aa7f5e879 Fix data stored on join being lost on Bungee
Bungee doesn't resend a join game for old servers, so we will have to keep data stored there across server switches
This likely fixes other issues with chunk data writing after server switches on legacy servers as well
2022-05-19 12:37:04 +02:00
Nassim Jahnke 854ecf0b47 1.19-pre1 2022-05-18 21:29:18 +02:00
Nassim Jahnke f538f25d63 Update OpenNBT 2022-05-16 13:33:41 +02:00
Nassim Jahnke 48a7fdc1d1 Fix command rewriter npe 2022-05-15 18:11:36 +02:00
Nassim Jahnke 1d5ae0e3e0 Use mappings instead of hardcoding entity ids 2022-05-14 11:58:45 +02:00
Nassim Jahnke f0462085d3 Add id->string methods to FullMappingData 2022-05-13 13:23:57 +02:00
Nassim Jahnke 7dc7b62cc9 22w19a (and a varying mix of removed and added dread) 2022-05-12 23:49:15 +02:00
Nassim Jahnke b9f80754e0 22w18a 2022-05-04 19:15:23 +02:00
Nassim Jahnke 5b9f775743 Use normal uuid type in gameprofile packet 2022-04-27 21:49:37 +02:00
Nassim Jahnke 0e66228a96 22w17a (and a lot of dread) 2022-04-27 21:06:34 +02:00
Nassim Jahnke 8df48bc378 StoredEntityData#remove 2022-04-20 20:16:08 +02:00
Nassim Jahnke d36d5d6def 22w16b 2022-04-20 20:00:46 +02:00
Nassim Jahnke 8b51430555 22w16a (except you have off-centered paintings) 2022-04-20 19:42:43 +02:00
Nassim Jahnke f71288e299 22w15a 2022-04-13 18:36:26 +02:00
Nassim Jahnke c0fc8195ce ?????????????????????????????????????????????????????
Also add removeTags and renameTag method to TagRewriter
2022-04-06 22:50:59 +02:00
Nassim Jahnke dd189411e6 New meta types (oh no) 2022-04-06 20:16:00 +02:00
Nassim Jahnke 4693b95bea 22w14a 2022-04-06 19:07:16 +02:00
Nassim Jahnke 596a42e312 22w13a 2022-03-31 18:46:35 +02:00
Nassim Jahnke 71944be482 Minor improvement to var int writing 2022-03-26 18:12:12 +01:00
Nassim Jahnke d1699fbb8d Merge remote-tracking branch 'origin/master' into dev 2022-03-24 19:07:28 +01:00
Nassim Jahnke bd880b608f 22w12a 2022-03-24 18:52:38 +01:00
Nassim Jahnke 3386431749 Comment out entity effect transformer 2022-03-21 10:40:52 +01:00
Nassim Jahnke c3fc8b5f18 Actually fix particles
Fixes #2850
2022-03-19 16:04:13 +01:00
Nassim Jahnke ec740476da Check world in BukkitBlockConnectionProvider
ignoring all of that still being unsafe
2022-03-19 09:37:34 +01:00
Nassim Jahnke a536ad1d10 Fix particles 2022-03-16 22:51:18 +01:00
Nassim Jahnke a1ae7818a2 Add namespace to argument type mappings 2022-03-16 20:25:00 +01:00
Nassim Jahnke 365b3a8a38 22w11a 2022-03-16 19:48:17 +01:00
RK_01 823eb1f392 Fix inventory acknowledgements being dropped sometimes (#2848) 2022-03-16 18:35:58 +01:00
Nassim Jahnke a12dfa405f 1.19 Experimental Snapshot 1 2022-03-16 18:21:41 +01:00
Nassim Jahnke 9798ec296a Update gradle wrapper to 7.4.1 2022-03-09 18:48:56 +01:00
Nassim Jahnke c1b993c01b Hotfix ProtocolLib 5.0.0 compatibility 2022-03-09 17:41:36 +01:00
Nassim Jahnke f55696a605 Bump version to 4.2.2-SNAPSHOT 2022-03-09 17:28:57 +01:00
Nassim Jahnke f361bd66ea 4.2.1 Release
Fix 1.18.2 client respawn on legacy servers
2022-02-28 16:01:41 +01:00
Nassim Jahnke 3dfb96dec9 4.2.0 Release 2022-02-24 09:22:47 +01:00
Nassim Jahnke 82ada0bcd8 Add new default command parser 2022-02-23 18:15:39 +01:00
Nassim Jahnke 28bd50a105 Fix legacy component text wrapping
Fixes #2821
2022-02-22 10:10:51 +01:00
Nassim Jahnke 46bd5814e3 Fix mutated dimension registry on old servers 2022-02-19 10:14:15 +01:00
Nassim Jahnke 4e9cddac8f 1.18.2 pre1 2022-02-18 17:49:45 +01:00
Nassim Jahnke a85c5578c1 22w07a 2022-02-16 18:40:50 +01:00
Nassim Jahnke 130ab70550 Fix registry on respawn 2022-02-09 19:57:54 +01:00
Nassim Jahnke ee27cbdd22 22w06a 2022-02-09 19:15:35 +01:00
Nassim Jahnke bd0d238f23 22w05a 2022-02-02 11:42:18 +01:00
Nassim Jahnke 3a5ac6f037 Merge branch 'master' into dev 2022-01-30 18:24:05 +01:00
Nassim Jahnke 8db0f3ac6e Fix uninjection from empty pipeline
Closes #2788
2022-01-30 18:21:28 +01:00
Nassim Jahnke 60eda447b4 22w03a 2022-01-19 18:05:36 +01:00
Nassim Jahnke d5f2388723 Add Item#copy 2022-01-11 17:10:31 +01:00
Nassim Jahnke d5a568b3fc Update copyright header 2022-01-09 22:36:07 +01:00
Nassim Jahnke 2704d70c1f Update Sponge module to API v8 2022-01-09 18:30:51 +01:00
Konicai 2a1e82ac6d Initial update to api-8 2022-01-09 16:17:41 +01:00
Nassim Jahnke 755a69e912 Update shadow 2022-01-05 10:03:07 +01:00
RK_01 101a4f63de Fixed 1.9.2 -> 1.9.3 block entity translation (#2784) 2022-01-03 11:05:15 +01:00
Nassim Jahnke 84bdaa79e2 Map walls to low variant in 1.15->1.16 2021-12-22 17:32:25 +01:00
Nassim Jahnke c3b6f5ce64 Update Gradle wrapper to 7.3.2 2021-12-22 17:31:30 +01:00
Nassim Jahnke 06a7260173 Fill dirt block tag to fix flower place animation 2021-12-20 10:53:11 +01:00
Nassim Jahnke 54236f718f Update shadow 2021-12-15 08:59:34 +01:00
Nassim Jahnke 2143e38d27 Don't make the client resize palettes on >8 bits 2021-12-08 21:31:53 +01:00
Nassim Jahnke 7d7651bc39 Update ProtocolVersion name for 1.18.1 2021-12-08 16:37:10 +01:00
RK_01 64c11b1f8f Fixed 1.9 -> 1.8 potion metadata packet order (#2765) 2021-12-08 12:49:13 +01:00
Myles a1a0926c4b Back to snapshot 2021-12-03 18:11:51 +00:00
Myles aade94a48f 4.1.1 release 2021-12-03 18:02:58 +00:00
Nassim Jahnke edebe64cf8 Fix handling of invalid biomes in 1.17->1.18 2021-12-03 13:33:52 +01:00
Nassim Jahnke ae4f837091 Fix double effect register 2021-12-02 20:17:24 +01:00
Lucas 5e6d87c8fd Map smoke directions from 1.13 to 1.13.1 (#2745) 2021-12-02 17:04:48 +01:00
Nassim Jahnke 20e9723d21 Update Gradle, particles finally work everywhere™️
Fixes #2746
2021-12-02 10:54:32 +01:00
Nassim Jahnke 54724ac540 Fix 1.18 block entity warnings on <1.12 servers 2021-12-01 19:54:43 +01:00
Nassim Jahnke a9c848e32e Cleanup palette type 2021-12-01 17:50:23 +01:00
Nassim Jahnke 02f9e87233 Fix invisible chests for 1.18 clients on very old servers
Fixes #2744
2021-12-01 17:50:09 +01:00
Nassim Jahnke 22d546edc0 Bump version to 4.1.1-SNAPSHOT 2021-12-01 15:37:39 +01:00
Nassim Jahnke f464e8e287 4.1.0 Release 2021-11-29 21:17:20 +01:00
Nassim Jahnke bd5217acb4 Merge remote-tracking branch 'origin/master' into dev 2021-11-28 16:09:21 +01:00
RK_01 e0cf62825b Fixed 1.9.3 -> 1.9.1 chunk translation (#2740) 2021-11-28 16:08:02 +01:00
Nassim Jahnke 9ce356aff4 another one 2021-11-26 17:15:10 +01:00
Nassim Jahnke 60fa54dddc 1.18-rc2 2021-11-26 10:53:58 +01:00
Nassim Jahnke 99b457965b 1.18-rc1 2021-11-25 16:09:34 +01:00
Nassim Jahnke 1d1a330ef1 1.18 pre8 2021-11-24 16:41:42 +01:00
Nassim Jahnke 4e9910c20e 1.18-pre7 2021-11-23 18:09:09 +01:00
Nassim Jahnke 82f2958ac6 1.18-pre6 2021-11-22 18:41:49 +01:00
Nassim Jahnke 1afa441571 Fix possible NPE in 1.13 component rewriting 2021-11-21 21:02:06 +01:00
Nassim Jahnke d159047dc0 Add more debugging options 2021-11-21 11:43:55 +01:00
Nassim Jahnke 3a529d00ce Fix update light passthrough 2021-11-19 21:35:21 +01:00
Nassim Jahnke b14b2b86e8 1.18-pre5 2021-11-19 17:27:43 +01:00
Nassim Jahnke 9ab4319771 *this is wrong intensifies* 2021-11-19 10:20:30 +01:00
Nassim Jahnke 8de7a4c828 Improve ceillog2 method 2021-11-19 10:06:45 +01:00
Nassim Jahnke 782d7a2172 this is wrong 2021-11-18 11:38:31 +01:00
Nassim Jahnke 2e5f3e4d66 this is wrong 2021-11-18 11:32:53 +01:00
Nassim Jahnke 6a00bf099e Cache 1.17.1 light by default, add config option 2021-11-18 11:23:46 +01:00
Nassim Jahnke bc11bd4caf Set mappings default values to -1 2021-11-17 19:52:06 +01:00
Nassim Jahnke c133552d04 1.18-pre4 2021-11-17 19:28:44 +01:00
Nassim Jahnke 2065a83fa1 Update biomes highest bits 2021-11-17 18:02:54 +01:00
Nassim Jahnke 30ce0eaa45 1.18-pre3 2021-11-17 17:43:17 +01:00
Nassim Jahnke 8be1fc9340 Move MetaTypes methods up into abstract class 2021-11-17 11:13:14 +01:00
Nassim Jahnke 6a8aa497b0 1.18-pre2 2021-11-16 13:28:53 +01:00
Nassim Jahnke 390155e03b Make Mappings extendable 2021-11-16 13:15:27 +01:00
Nassim Jahnke 3051ddb6c0 Better Mappings builders
Allows for mappings between json arrays and objects without a billion different constructors, also now uses the proper size for 1.18 chunks
2021-11-15 21:49:02 +01:00
Nassim Jahnke 25d74632c2 Update Bungee version warning 2021-11-15 11:00:18 +01:00
Nassim Jahnke 2b77427d0b Remove unused 1.18 code 2021-11-14 09:45:25 +01:00
_tomcraft dfc77b6f84 Update BungeeCord support (#2731)
fixes #2730
2021-11-14 09:44:33 +01:00
_tomcraft 6bc7f911c3 Fix bed rewriting and fix inconsistencies in item rewrite (#2729) 2021-11-14 09:37:03 +01:00
Nassim Jahnke 718614f81f 1.18 Pre-1 2021-11-11 10:06:59 +01:00
Nassim Jahnke 8e1f3bb086 Update Gradle to 7.3, adventure to 4.9.3 2021-11-11 10:05:58 +01:00
Nassim Jahnke 3a87eb463a Fix 1.18 spawner entity 2021-11-10 17:31:52 +01:00
Nassim Jahnke a49c395486 Make changes in particles easier to handle 2021-11-10 11:35:44 +01:00
Nassim Jahnke ad7f782a1a Fix InformativeException NPE 2021-11-08 12:09:08 +01:00
Nassim Jahnke 3aa84b5a5a Fix particle 1.18 meta type 2021-11-06 15:19:24 +01:00
Nassim Jahnke 52457ea749 Fix unquoted string being parsed as double 2021-11-05 18:19:14 +01:00
Nassim Jahnke 8104b96b8c Fix premature snbt numeric parsing 2021-11-04 19:43:48 +01:00
Nassim Jahnke a7835650bf Make model customization type with previous handlers 2021-11-03 19:16:03 +01:00
Nassim Jahnke d326dadb5d 21w44a 2021-11-03 19:14:33 +01:00
Nassim Jahnke d9307dad0c Merge remote-tracking branch 'origin/master' into dev 2021-11-03 10:53:16 +01:00
RK_01 752735159c Fixed credits screen not showing on 1.8 servers (#2724) 2021-11-02 19:01:29 +01:00
Nassim Jahnke 7cc6eb2b66 Fix accidental float/double NaN parsing in snbt 2021-11-02 15:09:40 +01:00
Nassim Jahnke 0a19057606 Merge remote-tracking branch 'origin/master' into dev 2021-10-30 15:56:39 +02:00
RK_01 a49d73c4c6 Abstract 1.8 metadata type (#2720) 2021-10-30 15:56:24 +02:00
Nassim Jahnke 82ded0299c Merge remote-tracking branch 'origin/master' into dev 2021-10-29 17:57:47 +02:00
Nassim Jahnke ab7cd4955b Metadata type should be written as var int 2021-10-29 17:57:23 +02:00
Nassim Jahnke 95493f3bbe Minor optimization 2021-10-29 17:47:38 +02:00
Nassim Jahnke a8c6f6b783 21w43a 2021-10-27 18:43:09 +02:00
Nassim Jahnke 516f746061 Handle barrier/light particles in entity meta 2021-10-25 09:52:54 +02:00
Nassim Jahnke d8d65ea989 Merge remote-tracking branch 'origin/master' into dev 2021-10-23 09:58:22 +02:00
Nassim Jahnke d80735e248 Read player digging action as var int
Does not matter for small numbers, but properly reflects Vanilla's reading/writing type
2021-10-23 09:58:11 +02:00
Redned ff5ad2385c Fix recipe book glitch on <1.16.2 servers (#2715) 2021-10-23 09:30:03 +02:00
Nassim Jahnke 2f28b25af3 Add block marker id to ParticleMappings 2021-10-20 18:51:53 +02:00
Nassim Jahnke 02bf9501a9 Handle item and particle meta 2021-10-20 18:48:07 +02:00
Nassim Jahnke a6292988d5 21w42a
Screw entity meta particles
2021-10-20 17:58:50 +02:00
Nassim Jahnke 431f773b77 Merge remote-tracking branch 'origin/master' into dev 2021-10-20 13:52:34 +02:00
Nassim Jahnke bd2bd1cf32 Cancel global entity packet if not lightning 2021-10-20 13:51:49 +02:00
Nassim Jahnke f5d92bf74f Merge remote-tracking branch 'origin/master' into dev 2021-10-19 09:16:06 +02:00
Nassim Jahnke dbe8b6551a Readd flare
Issues were addressed in 2.0.0
2021-10-19 09:10:17 +02:00
Nassim Jahnke 027e132749 Merge remote-tracking branch 'origin/master' into dev 2021-10-16 13:26:06 +02:00
Nassim Jahnke 7e3a157fcf Revert flare usage for now
Caused some issues I have no time to investigate at the moment, but worrying enough to warrant a temporary removal
Closes ViaVersion/ViaBackwards#402
2021-10-16 13:25:56 +02:00
Nassim Jahnke 9cd1ebf576 21w41a 2021-10-13 18:05:52 +02:00
Nassim Jahnke 03f929163c Merge remote-tracking branch 'origin/master' into dev 2021-10-11 21:04:29 +02:00
Nassim Jahnke e7e1ee7a2b Update shadow 2021-10-11 21:03:18 +02:00
_tomcraft 3f229c4cb9 Minor improvements (#2709) 2021-10-11 21:00:32 +02:00
Gero b2e0fdeaf8 Don't cancel chunks with missing light data (#2711) 2021-10-09 14:08:07 +02:00
Nassim Jahnke 0b541befbc Merge remote-tracking branch 'origin/master' into dev 2021-10-08 17:29:16 +02:00
Nassim Jahnke fd9346d4da Use validated channel in getNewPluginChannelId
Fixes #2707
2021-10-08 17:29:05 +02:00
Nassim JahnkeandGerrygames e744214ad6 Fix biome palette writing
Co-authored-by: Gerrygames <gecam59@gmail.com>
2021-10-08 13:17:07 +02:00
Nassim Jahnke 3feff8e751 Fix remove in ChunkLightStorage 2021-10-08 10:05:50 +02:00
Nassim Jahnke a2acd261d8 Merge remote-tracking branch 'origin/master' into dev 2021-10-08 09:37:32 +02:00
Nassim Jahnke 36b8884d92 Fix leftover FU load factors 2021-10-08 09:37:04 +02:00
Nassim Jahnke c15d7b8882 Don't forget id comments 2021-10-07 16:46:10 +02:00
Nassim Jahnke 9f33a09e87 21w40a 2021-10-07 16:44:43 +02:00
Nassim Jahnke cc78180a6c Merge remote-tracking branch 'origin/master' into dev 2021-10-07 12:27:21 +02:00
Connor Hartley e5338688bb Replace use of concurrenthashmap in entity tracker and block storage (#2705) 2021-10-07 12:26:14 +02:00
Nassim Jahnke b19ec959b3 Merge remote-tracking branch 'origin/master' into dev 2021-10-05 14:21:31 +02:00
MrMicky 8b4a57985b Remove usage of sun.misc.Unsafe in BungeeViaInjector (#2698) 2021-10-05 14:20:18 +02:00
Nassim Jahnke 7fb4e4a095 Change GH actions dist to adoptium 2021-10-05 14:10:04 +02:00
Nassim Jahnke 1bc4fc211d Merge remote-tracking branch 'origin/master' into dev 2021-10-03 20:15:19 +02:00
Nassim Jahnke 0a4d08886d Update adventure 2021-10-03 20:14:12 +02:00
creeper123123321 0f5fa620d1 Translatable ender dragon/wither text (#2702) 2021-10-03 16:23:41 +02:00
Gero a0f26f1ca3 Fix channel name validation in 1.13 to 1.12.2 protocol (#2701)
Closes #2187
2021-10-03 12:12:49 +02:00
MrMicky e64a0fb62e Prevent kick when signing empty book (#2700) 2021-10-03 10:11:34 +02:00
Nassim Jahnke 69409d71d1 Run handitem cache every tick 2021-10-02 16:38:20 +02:00
Nassim Jahnke 68c63d20ed Fix reading of explicit int array entries
See https://github.com/KyoriPowered/adventure/pull/460
2021-10-02 11:27:18 +02:00
Nassim Jahnke 2afa3fd9de Merge remote-tracking branch 'origin/master' into dev 2021-10-01 22:46:37 +02:00
Myles 0bcaf3e422 Merge pull request #2695 from ViaVersion/legacy-injector-cleanup
Cleanup Bukkit/Sponge injectors
2021-10-01 15:38:03 +01:00
Nassim Jahnke 6e5992c168 Add docs to abstract LegacyViaInjector methods 2021-10-01 16:33:18 +02:00
Gero 02122f8ce6 Fix #2532 2021-10-01 15:35:04 +02:00
_tomcraft 39f7f70a32 Cancel arm animation if in an open inventory for 1.16+ (#2687) 2021-10-01 12:38:49 +02:00
Nassim Jahnke 427b0a68d0 Cleanup Bukkit/Sponge injectors 2021-10-01 12:17:55 +02:00
Nassim Jahnke 50f3a05fa5 21w39a (probably) 2021-09-29 20:16:31 +02:00
Nassim JahnkeandRK_01 a306c222d4 More NBTTagTest test cases
Co-authored-by: RK_01 <50594595+raphimc@users.noreply.github.com>
2021-09-25 15:43:55 +02:00
Nassim Jahnke 5bfee3339a Merge remote-tracking branch 'origin/master' into dev 2021-09-25 14:57:41 +02:00
Nassim Jahnke 2b9df69627 Fix trailing comma again, fix 'possiblyNumeric' DoubleTag parsing 2021-09-25 14:57:14 +02:00
Nassim Jahnke 4f1e92f309 Merge remote-tracking branch 'origin/master' into dev 2021-09-25 13:18:59 +02:00
Nassim Jahnke 88165088a9 Update adventure nbt i/o 2021-09-25 13:15:26 +02:00
Nassim Jahnke e38f76b8bc Definitely did not forget to update mappings 2021-09-24 14:39:38 +02:00
Nassim Jahnke 1f63fc7de1 21w38a 2021-09-23 17:23:14 +02:00
Nassim Jahnke 763a88fe97 Merge remote-tracking branch 'origin/master' into dev 2021-09-22 11:16:35 +02:00
Nassim Jahnke 12e2be40e8 Remove some old todos, don't send empty 1.14->1.15 meta packet 2021-09-22 11:15:36 +02:00
Nassim Jahnke 22379eda6f Add todo 2021-09-22 10:16:42 +02:00
Nassim Jahnke 4485af577d Merge remote-tracking branch 'origin/master' into dev 2021-09-21 11:02:40 +02:00
Nassim Jahnke 0fcfd78b62 Add more user friendly 'block-versions' option 2021-09-20 15:15:25 +02:00
Nassim Jahnke 4940ed66c1 Don't warn on superfluous bytes
Should be looked into, but not now™️
2021-09-16 18:17:44 +02:00
Nassim Jahnke 73093c0ff2 Read/write palette based on block/biome size variables 2021-09-16 18:12:33 +02:00
Nassim Jahnke c5e27b89af Don't read remaining bytes in 1.18 chunk type 2021-09-16 17:01:58 +02:00
Nassim Jahnke 111cd2fd46 Biome palettes entries can have 1 bit 2021-09-16 15:47:28 +02:00
Nassim Jahnke 5a90c8374c Fix named sound packets and old block entities 2021-09-16 15:41:14 +02:00
Nassim Jahnke 9ffa737a4d Implement BlockEntity sectionX/Z methods 2021-09-16 14:19:45 +02:00
Nassim Jahnke c565f2c9c7 Cleanup Palette interface and read/write 2021-09-16 13:03:31 +02:00
Nassim Jahnke eaa18f569a Write linear palette as map palette for now 2021-09-16 12:17:21 +02:00
Nassim Jahnke bfe6389377 Write biomes to palette 2021-09-16 11:35:05 +02:00
Nassim Jahnke f72412484a Map block entity ids, only biomes and something else left 2021-09-16 00:26:23 +02:00
Nassim Jahnke b4301adb3b WIP 21w37a 2021-09-15 23:00:14 +02:00
Levertion d67269c9fe Add support for setting a custom world name (#2672) 2021-09-15 10:52:11 +02:00
Nassim Jahnke c264e639d6 Clear entity data on world change in world tracker 2021-09-14 17:35:27 +02:00
Nassim Jahnke 32a84f24ef Nicer getters in Pair and Triple 2021-09-14 11:13:39 +02:00
Nassim Jahnke 68e4146f3b Deprecate cancelClientbound/Serverbound with new id parameter 2021-09-05 14:02:33 +02:00
Nassim Jahnke f4f7215a6a Fix disabled packet limiter check 2021-09-02 17:33:09 +02:00
Nassim Jahnke a0b19872f8 Disable VV packet limiter on 1.17.1+ Paper 2021-09-01 15:25:24 +02:00
Nassim Jahnke f2147179c2 Small fixes, add majorVersion method, nicer getter names in some classes
None of the deprecated methods will be removed anytime soon.
2021-08-28 22:15:28 +02:00
RK_01 e7a0b4cf04 Improve 1.8 -> 1.9 chunk translation and fix #2065 (#2669) 2021-08-28 10:02:27 +02:00
Nassim Jahnke 533572e8cd Add CREATE_FOG BossFlag 2021-08-27 19:29:07 +02:00
creeper123123321 257eea5b04 try to fix GoLilyPad servers (#2667)
Closes ViaVersion/ViaFabric#21
2021-08-25 14:55:43 +02:00
Jo0001 47af0d634f Fix typo in comment/javadocs (#2609) 2021-08-25 12:49:57 +02:00
kennytv 5e11d9d51f Update Gradle to 7.2 2021-08-17 13:37:51 +02:00
kennytv 7ffcff7a7b Fix 1.15->1.16 wolf anger 2021-08-14 10:37:21 +02:00
kennytv 9ee548b967 Fix 1.17 clients writing empty books
Fixes #2658
2021-08-11 15:11:56 +02:00
kennytv c9142223fd Gitignores don't have to be .gitignore'd 2021-08-02 17:59:12 +02:00
kennytv 2094397bca Allow bypassing of packet type restriction in Protocol, amend packet creator 2021-08-01 12:05:04 +02:00
kennytv b81109f512 Semi force packet types in PacketWrapper at creation and transformation 2021-07-31 15:08:45 +02:00
kennytv 874dbafe26 More packet sending API
Allows for easy packet sending from a specific version to or from any client version supported by Via.
For example, you can send packets in the 1.17.1 format to both client and server, and it will be transformed accordingly if executed on another server version or sent to a different client version.
2021-07-30 12:26:15 +02:00
kennytv 46ca469a4a Add author tag to constructed book nbt
Fixes #2640
2021-07-27 11:58:24 +02:00
Pierre Maurice Schwang 8fb51bf3b7 Update bug_report.yml (#2636) 2021-07-25 09:51:04 +02:00
creeper123123321 9874a9053a it's 2021 and we should use UTF 8 (#2633) 2021-07-23 21:31:25 +02:00
kennytv db87774426 Fix ProtocolSupport compat on 1.17
Fixes #2632

Thank you md_5, very cool
2021-07-23 10:15:59 +02:00
creeper123123321 d14db9396b Fix idle ticking in proxies (#2631) 2021-07-20 18:57:53 +02:00
kennytv d7966567e7 Lowercase gang 2021-07-07 20:43:27 +02:00
KennyTV b4f8024eef Fix 1.15->1.16 and 1.16.1->1.16.2 dropped items
Fixes #2610
2021-07-07 10:06:15 +02:00
KennyTV e70f230f39 Bump version to 4.0.2-SNAPSHOT 2021-07-07 09:59:49 +02:00
KennyTV b28f743306 4.0.1 Release 2021-07-06 10:31:03 +02:00
KennyTV 9f97a09942 1.17.1-rc2 2021-07-05 14:52:13 +02:00
KennyTV 4f7e655613 1.17.1-rc1 2021-07-01 19:58:34 +02:00
KennyTV a7d94c2f8f 1.17.1-pre3 2021-06-30 18:19:19 +02:00
KennyTV c2172821fd Merge remote-tracking branch 'origin/master' into dev 2021-06-29 18:12:36 +02:00
KennyTV 24393d4ef4 1.17.1-pre2 2021-06-29 18:11:51 +02:00
KennyTV 622ea91648 Ignore bad 1.8 wither meta
Fixes #2570
2021-06-22 11:28:09 +02:00
KennyTV aed1a63a77 Merge remote-tracking branch 'origin/master' into dev 2021-06-21 14:58:38 +02:00
LemonCaramel 14cd568e46 Add Resource pack prompt message option (1.17+) (#2544) 2021-06-21 14:55:49 +02:00
KennyTV 44d836e2e7 Clear entity trackers on server switch
Fixes #5930
2021-06-21 14:33:23 +02:00
_tomcraft f9af6947f7 Improve arm-swing cancel by resetting cursor item (#2528) 2021-06-20 22:50:37 +02:00
_tomcraft 8e1da82793 Use a more fork-proof approach to enable Paper block place patch (#2561) 2021-06-20 22:49:59 +02:00
KennyTV 860aca974b Read unsigned byte in set slot 2021-06-20 16:16:08 +02:00
KennyTV 6a66d7653f Fix writable book id 2021-06-20 16:16:07 +02:00
KennyTV d32a4541a9 1.17.1-pre1 2021-06-20 16:16:07 +02:00
KennyTV 26719169ee Fix 1.8 special inventory tracking 2021-06-20 16:15:48 +02:00
KennyTV eae145543e Fix 1.8 set slot write type
Fixes #2558
2021-06-19 15:35:43 +02:00
KennyTV 48f1300908 Read set slot inv id as unsigned byte for consistency 2021-06-18 16:59:34 +02:00
KennyTV 5cdaabeaec Handle particle id change in 1.16 metadata
Fixes #2551
2021-06-17 11:55:22 +02:00
KennyTV 40f87e9472 Update Gradle wrapper to 7.1 2021-06-16 09:12:23 +02:00
KennyTV 7f385d4762 Create concurrent hashmap with weak values with Guava
This could use Guava's Cache, but that's just the MapMaker but more
2021-06-15 09:59:23 +02:00
KennyTV 389c5adaa3 Half revert back to storing uuids in CommonBoss
Fixes #2547
2021-06-14 22:47:13 +02:00
KennyTV 7a82ded94b Fix Velocity compatibility (requires Velocity 3.0.0)
This finally removes the hacky reorder fix on Velocity; it added a few more events that could benefit us, but this is the most important right now.
2021-06-14 21:09:47 +02:00
Myles 86278e837a Fix 1.17 BungeeCord support 2021-06-14 19:46:25 +01:00
KennyTV 34a0499152 Update bug_report.yml 2021-06-14 10:59:01 +02:00
Myles 68ccc6634d Spigot 1.17 compatibility 2021-06-11 20:19:06 +01:00
Jo0001 317af7ebc5 Use the correct content-type header (#2527) 2021-06-10 22:15:14 +02:00
KennyTV 206368b777 Fix 1.12->1.13 entity tracking
Fixes #2526
2021-06-10 22:10:22 +02:00
KennyTV 204a81b0ea Add 1.17 to legacy api package ProtocolVersion 2021-06-10 10:50:07 +02:00
KennyTV b940ecab9c Fix meta warning 2021-06-10 08:42:52 +02:00
KennyTV 15cbc96697 Shorten metadata error message 2021-06-09 18:59:48 +02:00
KennyTV b5e5b46f77 Update adventure to 4.8.0 release 2021-06-08 19:07:09 +02:00
KennyTV 42b6a1378c Bump to 4.0.1-SNAPSHOT 2021-06-08 19:06:08 +02:00
KennyTV 4074352a53 4.0.0 Release 🚀 2021-06-07 16:32:07 +02:00
KennyTV f909b55a84 1.17-rc2 2021-06-07 14:28:41 +02:00
KennyTV 593aa7564a Put the other filled 1.17 tags into the diff file 2021-06-07 09:58:52 +02:00
KennyTV 24efb48004 Add method to load extra tags from diff files 2021-06-06 17:17:51 +02:00
KennyTV 38b3f40f7d Add Java version warning
We will update the required Java version at some point, the only question is when.
2021-06-06 11:55:40 +02:00
KennyTV d89f916546 Cleanup 1.17 entity rewriter, fix DataItem amount check 2021-06-06 10:08:15 +02:00
KennyTV 62278f287c Update gson, junit, and checker-qual 2021-06-05 17:17:29 +02:00
KennyTV 72be978f8e Update issue template 2021-06-05 17:16:51 +02:00
creeper123123321 666f3d6c92 Explain "left-handed-handling" option (#2512) 2021-06-05 17:12:55 +02:00
KennyTV 8e7606ea1b 1.17-rc1 2021-06-04 16:00:38 +02:00
KennyTV 2b8c5082ed Make Item an interface, more OOP for the ItemRewriter 2021-06-04 12:15:14 +02:00
KennyTV 05f9fc1ddc 1.17-pre5 2021-06-03 20:22:48 +02:00
KennyTV fc1450fe38 Slightly more OOP, move registerPackets out of Protocol constructor
registerPackets being called within the constructor made it impossible to create instance objects then used in registerPackets (vs. having to then create the objects in registerPackets).
2021-06-03 17:28:02 +02:00
KennyTV e1072a8dc7 Fix docs 2021-06-03 10:45:58 +02:00
KennyTV 3290d4ae24 Expose lateBind field in ViaVersionPlugin 2021-06-03 10:40:25 +02:00
KennyTV b2855c2cd4 F 2021-06-02 23:22:09 +02:00
KennyTV fec777b349 Don't wrap direct type mappers 2021-06-02 23:22:00 +02:00
KennyTV 7b1f9c199a Produce less overhead in packet handler registering
Instead of creating a void type reader for every single PacketHandler registered, this just directly uses the consumer-like PacketHandler.

The distinction between ValueCreator and the normal PacketHandler was unnecessary given you could also just read something in a ValueCreator instance, effectively just being a consumer of a PacketWrapper instance.
2021-06-02 22:00:20 +02:00
KennyTV a8b3444ff5 1.17-pre4 2021-06-02 18:44:47 +02:00
KennyTV 6839334c1a Fix confirmation id encoding, remove old send methods 2021-06-02 12:44:49 +02:00
KennyTV d7e3aa7143 Whoops 2021-06-01 23:28:32 +02:00
KennyTV 48436e7caf Go through the rest of the send usages 2021-06-01 23:27:33 +02:00
KennyTV eaa58affd1 Minor changes 2021-06-01 22:52:05 +02:00
KennyTV 57cf1803f3 Fix 1.9 block entity data send 2021-06-01 19:36:25 +02:00
KennyTV 104fa4e29f Optimize protocol path finding
Not perfect, but better. This prevents the path checks from exponentially increasing (if it weren't for the maxProtocolPathSize fail safe).

By default, a path will never go to a protocol version that puts it farther from the desired server protocol version, even if a path existed.
Otherwise as well as previously, *all* possible paths will be checked until a fitting one is found.

Negative examples if the new boolean is set to true:
    A possible path from 3 to 5 in order of 3->10->5 will be dismissed.
    A possible path from 5 to 3 in order of 5->0->3 will be dismissed.

Negative examples if set to false:
    While searching for a path from 3 to 5, 3->2->1 could be checked first before 3->4->5 is found.
    While searching for a path from 5 to 3, 5->6->7 could be checked first before 5->4->3 is found.

Assuming custom platforms like Bedrock protocol use the normal registering methods, they will have to change the boolean to false to revert to previous behavior (tho still somewhat better optimized).
2021-06-01 18:54:36 +02:00
KennyTV 4011aee280 1.17-pre3 2021-06-01 18:10:53 +02:00
KennyTV 37fd69fa86 Make packet send methods use the current thread by default
Defaulting to submitting to the netty event loop caused issues more often than not - this also removes the `currentThread` flag and instead provides new scheduleSend methods so it is always obvious whether the packet is sent immediately.
2021-06-01 10:13:49 +02:00
KennyTV 3fb125592b Send entity destroy on current thread 2021-05-31 20:45:56 +02:00
KennyTV 7925fd2d8f Fix shulker meta handling 2021-05-31 20:17:43 +02:00
KennyTV 199324ee9d 1.17-pre2 2021-05-31 18:21:31 +02:00
KennyTV d5cac99b5f Reorder Type instances 2021-05-31 11:51:21 +02:00
KennyTV 3618914ce9 Add method to get Protocol by supported versions, some cleanup 2021-05-29 22:21:29 +02:00
KennyTV ff140c421a Add/change comments 2021-05-29 11:50:07 +02:00
RK_01 016b8f1dbc Correct ClientboundPackets1_9_3 packetid comments (#2503) 2021-05-29 09:34:24 +02:00
KennyTV 0d31054903 Fix view distance update packet in 1.13->1.14
The client world is initialized during the join packet, but the view distance packet was created during/before the join handling.
Fixes #2502
2021-05-28 10:02:26 +02:00
KennyTV 8beedffea2 Fix project root build/libs dir not being cleaned
The base plugin is usually applied by the java plugin, but since that has been moved into the platforms, cleaning was no longer applied to the root dir (created and filled by the universal submodule).
2021-05-27 23:56:31 +02:00
RK_01 4ef862e06d Correct packet id comment (#2501) 2021-05-27 15:42:51 +02:00
KennyTV 53642e9a3c 1.17-pre1 2021-05-27 15:36:53 +02:00
KennyTV fd9dab8aa1 Replace inventory ack by using 1.17 ping packets 2021-05-26 21:36:20 +02:00
KennyTV 703978e227 Don't require UserConnection holding class in stored objects 2021-05-26 21:35:28 +02:00
KennyTV 7195319eb5 Update adventure 2021-05-26 16:37:29 +02:00
KennyTV 2d0a597f74 Make Metadata fully type safe, remove "Discontinued" meta types
The Discontinued entry was a special edge case that could lead to a Metadata type returning null. Instead, just directly use null in the 1.8->1.9 code where it is checked against. Also renamed the Meta1_17Types entries to be in uppercase and properly represent their value type.
2021-05-26 16:36:47 +02:00
KennyTV bc89f57088 Slightly improve metadata iteration, remove redundant MetaHandlerEvent index
Lazily create the event if needed and share it with other filters when handling a metadata entry. Lastly, only add the additionally created meta once after the filter list, not once per filter.
2021-05-26 09:00:49 +02:00
KennyTV 57769c5671 Make metadata (almost) fail-safe
This could mean life and death, see
`new Metadata(17, MetaType1_14.Float, event.meta()).value()`
vs.
`new Metadata(17, MetaType1_14.Float, event.meta().value())`
2021-05-25 16:27:55 +02:00
LemonCaramel a6b4b16fd3 Add Missing Translation Mapping (#2484) 2021-05-25 16:27:19 +02:00
KennyTV 3a1e364d4a Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.

ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.

ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.

This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).

All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-25 15:37:07 +02:00
Jason 03638028cd Make proper sources jar (#2495) 2021-05-25 09:44:57 +02:00
jmp d5f56784e2 Silence doclint 2021-05-25 09:07:06 +02:00
jmp cbf71e2289 Only add javadoc jar to common and api 2021-05-25 09:07:06 +02:00
jmp e2d9e44be3 Build script improvements 2021-05-25 09:07:06 +02:00
KennyTV 2d2a5fa79c Fill "needs tool" tags
Fixes #2493
2021-05-24 09:21:32 +02:00
RK_01 605331963d Fix typo in DumpSubCmd (#2492) 2021-05-23 19:42:01 +02:00
KennyTV 15a5d51248 Don't cast ChannelInitializer type to SocketChannel 2021-05-22 19:41:07 +02:00
KennyTV 8bcd8fd995 Add apiVersion to ViaAPI, some jd 2021-05-22 19:39:26 +02:00
Kamillaova 9484526d39 Fix README build command (gradlew) (#2489) 2021-05-22 13:37:53 +02:00
KennyTV ab1cc791b7 Fix enchantment parsing or lvl integers 2021-05-21 09:17:40 +02:00
KennyTV 1fe76dbb77 Add more jd to Chunk, ChunkSection, and ChunkSectionLight 2021-05-20 19:23:29 +02:00
KennyTV cf2adab728 Make ChunkSection an interface, don't allocate light arrays if not needed 2021-05-20 18:32:28 +02:00
KennyTV 04fedd2892 Add comments 2021-05-20 16:56:39 +02:00
KennyTV c172091944 21w20a 2021-05-19 18:54:38 +02:00
creeper123123321 16ba5aa4f9 Run some optipng (#2482) 2021-05-18 20:46:35 +02:00
KennyTV 5fa2c788e0 Add missing mineable tag entries
Fixes #2481
2021-05-18 17:07:57 +02:00
creeper123123321 c5a338137e Update fabric.mod.json (#2480) 2021-05-18 13:49:58 +02:00
KennyTV 01d79e2681 Fix non-full chunk sending to 1.17 clients 2021-05-17 17:31:42 +02:00
KennyTV 576682ef9f Handle invalid uuid int array
Closes #2475
2021-05-15 16:42:38 +02:00
KennyTV 54b0345017 Fix PS compatibility on Java 8 💩 2021-05-15 10:11:19 +02:00
KennyTV 4f9f3254be Fix PS compatibility on Java 16 2021-05-15 09:28:18 +02:00
KennyTV 1538ff5201 Expand unsupported software checks 2021-05-14 16:59:12 +02:00
creeper123123321 f17fb833a0 add internal getInputBuffer() (#2472) 2021-05-14 11:19:02 +02:00
KennyTV 84c064fc11 Fix legacy hover deserialization, add snapshot suffix to version 2021-05-14 10:59:43 +02:00
KennyTV 7b5b79f510 Update Gradle to 7.0.1 2021-05-12 16:00:42 +02:00
KennyTV 2588c6ecc8 21w19a (probably) 2021-05-12 15:19:33 +02:00
KennyTV 2df57bc37c Fix 1.14->1.15 meta ordering issue
Closes #2467
2021-05-10 13:27:12 +02:00
KennyTV efeaef3e4e Update shadow plugin 2021-05-09 10:25:57 +02:00
KennyTV cb7a7254a6 Make UnsupportedSoftware hold a list of class names 2021-05-08 10:05:43 +02:00
KennyTV fe3f247eb1 21w18a 2021-05-05 18:28:39 +02:00
Juan Cruz Linsalata 096415cf8e Don't inject if inactive (#2461) 2021-05-02 15:52:07 +02:00
KennyTV af0cf1d3f2 Rename PacketType methods
Just in case a packet with some magic id is going to be added, since the enum ordinal and name methods cannot be overridden
2021-05-02 11:14:38 +02:00
KennyTV d183d76c47 Remove platform bulk chunk transformers 2021-05-02 10:12:37 +02:00
KennyTV 44e928d53c Update copyright scopes 2021-04-30 19:05:07 +02:00
KennyTV 89127cad8a If possible, user Paper internal injection method 2021-04-29 23:32:13 +02:00
KennyTV ab93e0877c Rename platform task implementations 2021-04-29 17:46:29 +02:00
KennyTV 96b5051c75 Use primitive long in task methods 2021-04-29 17:31:16 +02:00
KennyTV 9e59ef4c4a Hold the rest of the primitive Type instances under their actual class
This brings no improvement now, but if primitive read/write methods for manual calls were implemented later, a signature break will have been prevented by this (aka breaking it now)
2021-04-28 21:12:19 +02:00
KennyTV 00746833ac ProtocolInfo is not a StoredObject
You can't actually call UserConnection#get with ProtocolInfo.class since the ProtocolInfo interface is not a StoredObject
2021-04-28 18:57:08 +02:00
KennyTV 8e15b6d42b 21w17a 2021-04-28 17:40:57 +02:00
KennyTV cad358322d Rename outgoing->clientbound, incoming->serverbound
Via can both be used on servers and clients, making a direction like "incoming" ambiguous
2021-04-28 16:30:34 +02:00
KennyTV a2b3906c9e Move bossbar to new legacy package, since it only works on <1.9
The newly created LegacyViaAPI is safe to use, but should hold methods that cannot be universally used on every version
2021-04-28 11:10:16 +02:00
KennyTV cadb5ec64c Rename abstract Protocol to AbstractProtocol
This prevents confusion around the previously equally named interface and abstract class
2021-04-27 18:21:51 +02:00
KennyTV 95e20677fd Clean up ProtocolPipeline
The filter functionality isn't something that's likely to be used again, so move out its usage and only check on <1.9 servers
2021-04-27 15:59:06 +02:00
KennyTV f1c8d271b1 Reformat imports
The package rename wasn't done through refactoring but through simple replaces to not make git choke on diffs
2021-04-27 13:42:36 +02:00
KennyTV 318c49cf30 More interfaces, keep ProtocolRegistry.SERVER_PROTOCOL legacy api 2021-04-27 13:25:18 +02:00
KennyTV d4bc31d11e Always create ProtocolInfo, store mappings as int[] 2021-04-27 10:29:30 +02:00
KennyTV 30d122e7fa Create some fancy interfaces 2021-04-26 23:01:55 +02:00
KennyTV 49d386063d Add ProtocolVersion to legacy api 2021-04-26 21:45:27 +02:00
KennyTV deec4b521e Move some packages and classes around 2021-04-26 21:27:59 +02:00
KennyTV dbf6a110f2 Keep wrapping Via, ViaAPI, and Bossbar API in api-legacy module 2021-04-26 20:55:24 +02:00
KennyTV a25a5634de Change package/imports in classes and build configs 2021-04-26 20:52:34 +02:00
KennyTV a3b1ce817e Repackage to com.viaversion
This process will be split into multiple commits for git not to choke on.
2021-04-26 20:46:30 +02:00
KennyTV c02047aaf8 Change group id to com.viaversion 2021-04-24 20:54:46 +02:00
Juan Cruz Linsalata f18e2b3875 Cancel Bungee packet encoding when closed (#2448) 2021-04-24 18:30:08 +02:00
KennyTV ad0842c107 Bump version to 4.0.0, remove ProtocolRegistry
The bump was overdue given the breakages that have happened
2021-04-23 22:48:08 +02:00
KennyTV 2b19a98809 21w16a 2021-04-21 19:40:51 +02:00
KennyTV d40ce9fc4a Minor optimizations in pipeline filling 2021-04-21 11:58:19 +02:00
KennyTV 144c24c276 Move packet tracking methods out of UserConnectionn 2021-04-20 13:24:10 +02:00
Mariell Hoversholm 2c884dc241 Feat (Bungee): Use only unsafe field modifications (#2440) 2021-04-17 09:59:24 +02:00
KennyTV d0882cf02c Update GsonUtil, more javadoc 2021-04-16 23:05:31 +02:00
RK_01 cfec0cc25f Improve 1.9->1.8 block place translation (and fix some bugs) (#2437) 2021-04-16 08:45:33 +02:00
KennyTVandjmp d3a3e366b1 Fix publishing
Co-authored-by: jmp <jasonpenilla2@me.com>
2021-04-15 11:07:40 +02:00
MrMicky f1eef0294f Fix Java 16 compatibility on Bukkit/Sponge 1.8 (#2438) 2021-04-15 08:43:05 +02:00
KennyTV 4df70de312 Add note on required jdk version for compilation 2021-04-14 20:43:30 +02:00
KennyTV 898521de9a 21w15a 2021-04-14 17:38:06 +02:00
Jason 87d54f1103 Clean up build scripts using new Gradle features (#2436)
* Make use of `TYPESAFE_PROJECT_ACCESSORS` and `VERSION_CATALOGS` Gradle feature previews to clean up build scripts

* Bump setup-java action to v2, specify AdoptOpenJDK distribution
2021-04-14 14:16:48 +02:00
KennyTV c7e5b4a297 Update to Gradle 7.0 2021-04-13 12:37:29 +02:00
Mariell Hoversholm 458279d111 Fix (Bungee): Java 16 compatibility (#2433)
This has been tested on the following:
 - AdoptOpenJDK Java 1.8.0_282
 - GraalVM CE 21.0.0 OpenJDK 11.0.10
 - AdoptOpenJDK Java 15.0.2
 - AdoptOpenJDK Java 16 (also tested with BungeeCord b1556)
 - Amazon Corretto OpenJDK 16.0.0.36.1

... with Waterfall b406 on Linux 5.10.28.
2021-04-13 11:42:32 +02:00
KennyTV 7300a69817 Use Paper method to get server protocol version if possible 2021-04-12 20:11:13 +02:00
LabyStudio 76e739e4f0 fix ghost shield issue and delayed interaction when switching to another item (#2432) 2021-04-12 16:56:53 +02:00
KennyTV 0ee80dc41f Don't throw an exception on hover parse failure 2021-04-11 13:35:53 +02:00
KennyTV 4473f863c6 Update ComponentRewriter 2021-04-10 17:03:43 +02:00
creeper123123321 9f380a7598 Handle minecart block data (#2424) 2021-04-09 17:09:30 +02:00
KennyTV 3c7d481a39 Fix namespaced 1.12->1.13 sound conversion 2021-04-09 14:56:44 +02:00
KennyTV b23c01c44b Javadoc additions 2021-04-08 21:44:45 +02:00
KennyTV 00b8289c61 Handle new entity pose from 21w13a 2021-04-07 17:27:51 +02:00
KennyTV e9fa5b49ca 21w14a 2021-04-07 16:55:22 +02:00
KennyTV ef8cb05703 Update build badge in readme 2021-04-06 19:02:05 +02:00
LabyStudio e83686d6fc Implement showShieldWhenSwordInHand option (#2417) 2021-04-05 18:53:57 +02:00
KennyTV 26bbc92f94 Warn about potentially unstable plugins/server software 2021-04-03 17:01:57 +02:00
MrMicky 9ccd8bff33 Fix error with shit-click on offhand slot on 1.8 servers (#2419) 2021-04-03 09:09:00 +02:00
KennyTV 29d6b55592 Fix ChunkSection nullability annotations 2021-04-02 18:29:51 +02:00
KennyTV 1251d43709 Fix invalid enchantment parsing
Fixes #2418
2021-04-02 18:22:18 +02:00
KennyTV 070c7f5808 Move to checker qual nullability annotations 2021-04-02 14:15:30 +02:00
KennyTV d79bd00f58 Minor log changes 2021-04-02 10:21:31 +02:00
creeper123123321 df7a644479 Add ShortByteArrayType, minor PacketWrapper changes (#2413) 2021-04-01 20:17:17 +02:00
R0bbyYT 956492bca6 Add option to fix delayed shield blocking (#2415) 2021-04-01 20:03:13 +02:00
creeper123123321 1d311284fd GitHub workflow (#2163) 2021-03-31 21:53:10 +02:00
KennyTV b251170c22 Add goat entity type 2021-03-31 20:40:02 +02:00
KennyTV ab376dc562 21w13a 2021-03-31 19:18:16 +02:00
KennyTV fd9442b077 Minor jd changes in ViaAPI, fix typo 2021-03-30 22:10:57 +02:00
KennyTV a63f2ab6fe Improve server version API 2021-03-26 12:51:38 +01:00
KennyTV d918fd27b6 Reduce boxing in protocol path getting
More of its implementation should probably be cleaned up later
2021-03-25 22:34:30 +01:00
KennyTV 63356207a3 ProtocolRegistry -> ProtocolManager interface 2021-03-24 15:30:03 +01:00
KennyTV 210cae70fd Add MIT copyright headers to the api module 2021-03-24 14:02:38 +01:00
KennyTV 0ab2c626aa Split parts of common into api; We are now GPL, api is MIT
This does not affect any previous states of this project; only future modifications as well as the project as a whole will be under the GNU General Public License from now on. The newly introduced api directory, partly split from common, is an exception to this, still being licensed under the MIT license.

See the README for details.
2021-03-24 14:02:37 +01:00
KennyTV b8072aad86 Merge remote-tracking branch 'origin/master' into dev
# Conflicts:
#	.github/ISSUE_TEMPLATE/config.yml
2021-03-22 15:39:34 +01:00
KennyTV 00b4c9b1f8 Add feature request template 2021-03-22 15:30:33 +01:00
KennyTV 2f45de2f6a Small changes to the issue form 2021-03-22 14:42:05 +01:00
KennyTV f60c0165e3 Issue forms, anyone? 2021-03-22 14:36:47 +01:00
KennyTV bfcfb4340e Add missing doc 2021-03-22 13:47:40 +01:00
KennyTV 9b4d50b214 Tidy up concurrent mapping loading 2021-03-21 20:25:52 +01:00
KennyTV bdeb5acae9 Fix license bundling 2021-03-21 20:07:32 +01:00
KennyTV 81b9f1b4cd 21w11a 2021-03-17 17:01:58 +01:00
KennyTV 0552863f28 Update adventure 2021-03-15 20:59:46 +01:00
KennyTV 0986e174a2 Fix drag desync 2021-03-15 14:50:58 +01:00
KennyTV b589561932 More primitive tag calls 2021-03-15 10:43:09 +01:00
KennyTV 388eb73782 Update nbt usage 2021-03-15 10:43:09 +01:00
KennyTV 2f7de53e9b Merge remote-tracking branch 'origin/master' into dev 2021-03-13 15:34:10 +01:00
KennyTV f7afe84982 21w10a (kind of) 2021-03-10 23:18:13 +01:00
LemonCaramel ea014656bc Add "forced-use-1_17-resource-pack" option (#2390) 2021-03-08 12:30:23 +01:00
LemonCaramel 72de597544 Fix Explosion Mapping (#2389) 2021-03-08 08:28:03 +01:00
KennyTV d7c8f3a594 Update Sponge repository url 2021-03-07 12:26:17 +01:00
LemonCaramel 6cc761e3b2 Title Packet fix (#2387) 2021-03-07 10:03:05 +01:00
Joseph Burton 2723302f56 Update bug_report.md 2021-03-06 18:34:34 +01:00
KennyTV 6497cca8bd Update adventure 2021-03-04 17:02:43 +01:00
KennyTV ec188db247 Shade relocated adventure without breaking native platform usage 2021-03-04 16:11:09 +01:00
KennyTV b84bc7668a Fixes 2021-03-04 16:11:09 +01:00
KennyTV cf8d11d530 Let's go on an <insert title card> 2021-03-04 16:11:09 +01:00
RK_01 7f8052c3cd Fix handling of unknown container ids (#2384) 2021-03-04 15:05:27 +01:00
KennyTV 08763a92ab Add 1.17 to table 2021-03-02 14:14:28 +01:00
LemonCaramel 6e9e757294 Fix ExceptionInInitializerError (#2372) 2021-02-28 00:42:37 +01:00
KennyTV 5e227cb4a5 Fix Bungee Chat relocation
Fixes #2371
2021-02-27 10:21:39 +01:00
RK_01 3c73d70f63 Fix handling of animation 3 in 1.8->1.9 (#2358) 2021-02-26 14:45:55 +01:00
KennyTV 9fbadc0ad5 Keep white background of version chart 2021-02-26 10:51:49 +01:00
KennyTV 6b7818e6f1 21w08b 2021-02-25 15:59:48 +01:00
KennyTV 16208b2a7f Update README 2021-02-25 10:21:11 +01:00
KennyTV a0351b8168 Update version 2021-02-25 09:20:31 +01:00
KennyTV 35ac41e1fa Fix subproject version/name 2021-02-25 09:19:18 +01:00
Jason 46a01cb0f0 Fix publishing (#2364) 2021-02-25 09:19:18 +01:00
Myles e437c656c5 Revert "Try /everything"
This reverts commit 902081b22b3b6c7a4ac56c7ec68fa76f917267bb.
2021-02-25 09:19:18 +01:00
KennyTV f5b8937a70 Try /everything 2021-02-25 09:19:17 +01:00
Myles 8e069812e0 Set maven authentication to basic 2021-02-25 09:19:17 +01:00
jmp b6bee8f4cc Configure artifacts for publication 2021-02-25 09:19:17 +01:00
KennyTV aaaa97f781 Fix local publishing 2021-02-25 09:19:17 +01:00
KennyTV 5b0d98f639 Remove test publishing 2021-02-25 09:19:16 +01:00
KennyTV 68985141f1 Try local publishing 2021-02-25 09:19:16 +01:00
KennyTV a48f717396 Add publish url 2021-02-25 09:19:16 +01:00
KennyTV a7a00e9f67 Update version 2021-02-25 09:19:16 +01:00
KennyTV c719b98ab3 Don't spam compiler warnings 2021-02-25 09:19:15 +01:00
KennyTV c059e57771 Move javassist to Bukkit moduke 2021-02-25 09:19:15 +01:00
KennyTV 5fde8c25a3 Change universal jar name 2021-02-25 09:19:15 +01:00
jmp 02f1ab1752 Uppercase jar names 2021-02-25 09:19:14 +01:00
jmp 024c36c584 Switch to indra, attempt to fix shading and universal jar 2021-02-25 09:19:14 +01:00
KennyTV ef6c347194 *cries in elephant* 2021-02-25 09:19:14 +01:00
KennyTV c0dabfe097 *cries in elephant* 2021-02-25 09:18:51 +01:00
KennyTV 0a41d36220 21w08a (aka the great splittening) 2021-02-24 23:38:28 +01:00
KennyTV 37004d8c4f 21w07a 2021-02-17 18:55:43 +01:00
KennyTV 01277d147e Deduplicate more entitytype code 2021-02-16 12:24:35 +01:00
KennyTV 1da0b38849 Merge remote-tracking branch 'origin/master' into dev 2021-02-16 12:21:32 +01:00
KennyTV 84f8e019c8 Fix 1.9to1.9.1 protocol registration 2021-02-15 20:02:31 +01:00
KennyTV 64b7e74d80 Cleanup modern entity types 2021-02-14 17:24:20 +01:00
creeper123123321 a141f871a9 ProtocolVersion.toString() space (#2343) 2021-02-13 13:21:02 +01:00
KennyTV 69609d536b Use chunk section length for fallback biome array 2021-02-11 21:45:36 +01:00
KennyTV b21de03710 Read byte in player position 2021-02-11 19:54:00 +01:00
KennyTV e7b489f66e This is actually 21w06a 2021-02-11 09:30:30 +01:00
KennyTV 7493c8d7b7 Add setSections to Chunk 2021-02-11 00:00:02 +01:00
KennyTV 4ff98256f6 21w06a 2021-02-10 19:09:33 +01:00
Myles d1a0d629df Merge branch 'master' into dev 2021-02-09 16:32:44 +00:00
Myles 50bfc86706 Revert "The bytebuf doesn't need to be rewritten"
This reverts commit ac877d0b1a.
2021-02-09 16:32:31 +00:00
Myles 76c83da382 Merge branch 'master' into dev 2021-02-09 10:54:34 +00:00
Myles f04a748e54 Ignore NBT with hanging comma, fixes #2319 2021-02-09 10:54:04 +00:00
Myles d39193400f Ignore NBT with hanging comma, fixes #2319 2021-02-09 10:50:11 +00:00
Myles 628979f923 Merge branch 'master' into dev 2021-02-09 10:36:54 +00:00
Myles 24b4cd8dbd Merge branch 'reduce-decode-rewriting' 2021-02-09 10:36:13 +00:00
Myles 727c575a1c Run QuickMove on next tick to improve likeliness of success (fixes #2044)
Since it is 5 ticks later, the inventory may be closed
2021-02-09 10:35:13 +00:00
Myles ac877d0b1a The bytebuf doesn't need to be rewritten 2021-02-06 15:29:36 +00:00
Myles 37d57af6ec Change ResourceLeakDetector to PARANOID for displayleaks 2021-02-06 15:26:21 +00:00
KennyTV e09c3b0159 Merge remote-tracking branch 'origin/master' into dev 2021-02-06 15:38:06 +01:00
Myles 22793dbac4 Re-add a semicolon
🥇
2021-02-06 14:30:18 +00:00
Myles 1998eca6c8 Merge pull request #2322 from creeper123123321/passbytebuf
Allow bytebuf passthrough on encode
2021-02-06 14:25:42 +00:00
creeper123123321 100ae1c680 Update SpongeEncodeHandler.java 2021-02-06 11:18:51 -03:00
creeper123123321 6941b48038 fixed pending #2291 changes 2021-02-06 10:21:34 -03:00
KennyTV 59c9018250 Call command argument handler with unmapped name 2021-02-05 13:04:57 +01:00
RK_01 bdfaf9a621 Remap declare command parser types in 1.14 -> 1.13.2 (#2316) 2021-02-05 12:18:28 +01:00
KennyTV 54488341bf Add abstract declare commands handler 2021-02-05 11:41:21 +01:00
KennyTV 59e05e3096 21w05b 2021-02-04 19:11:24 +01:00
KennyTV 554fbb49c5 21w05a 2021-02-03 19:30:28 +01:00
Jo0001 7faf4cf81a Change error message (#2286) 2021-02-01 14:51:03 +01:00
KennyTV ee2959ac5d Handle shulker meta change 2021-01-21 11:37:31 +01:00
KennyTV e679a0c2b0 Fix dust particle writing
The double/float inconsistency was fixed in 21w03a, yay
2021-01-21 09:26:56 +01:00
KennyTV 14bfb8d147 Fix glow squid entity id 2021-01-20 18:51:07 +01:00
KennyTV 3a9dd5c86d Add setBitmask to Chunk 2021-01-20 18:24:43 +01:00
KennyTV c8c54786fc 21w03a 2021-01-20 17:59:34 +01:00
KennyTV 4cc8a3f092 Return -1 in getPlayerVersion if the player is not connected 2021-01-17 13:59:26 +01:00
KennyTV 2beed20f1b Update 1.16.4/5 protocol name 2021-01-17 13:55:19 +01:00
Thibaut Gautier 91319402f3 Fixed encoding not properly working with other packet reading libraries
Injecting a message to byte encoder beforehand would break outbound packets in ViaVersion. This solution is a good fix which won't impact anything.
2021-01-17 13:12:18 +01:00
RK_01 ee147a4b37 Replace some hardcoded chunk section values (#2274) 2021-01-05 09:42:32 +01:00
KennyTV 127cae80bd Fix 1.17 entity tracking
Fixes #2250
2020-12-17 12:38:51 +01:00
KennyTV 55a2a0a779 Fix disconnect on respawn packet send
Closes #2251
2020-12-17 11:52:15 +01:00
KennyTV ed4d0bc134 Add methods to handle new tags format 2020-12-17 11:51:51 +01:00
KennyTV 6298eb42c5 Make TagRewriter.TagData public 2020-12-16 19:54:02 +01:00
KennyTV 823ac0e173 Add RegistryType#getByKey 2020-12-16 19:50:49 +01:00
KennyTV 6622b7dcff 20w51a 2020-12-16 18:57:16 +01:00
KennyTV 4858d75439 Change the outdated server message 2020-12-15 11:38:41 +01:00
KennyTV 4355f8987f Merge branch 'master' into dev
# Conflicts:
#	bukkit-legacy/pom.xml
#	bukkit/pom.xml
#	bungee/pom.xml
#	common/pom.xml
#	fabric/pom.xml
#	jar/pom.xml
#	pom.xml
#	sponge-legacy/pom.xml
#	sponge/pom.xml
#	velocity/pom.xml
2020-12-15 11:16:57 +01:00
KennyTV f35c48bed2 Merge branch 'master' into dev 2020-12-09 21:39:13 +01:00
KennyTV 459e3e68b8 Dust particle rgb values are now written as doubles 2020-12-09 12:41:26 +01:00
KennyTV 72205a5414 Whoops 2020-12-09 11:47:59 +01:00
KennyTV e7ad3970cc Complete vibration particle reading 2020-12-09 11:47:40 +01:00
KennyTV 4714a3f03a Merge branch 'master' into dev 2020-12-09 11:31:51 +01:00
KennyTV 5954c16f62 New particle meta type 2020-12-09 11:29:07 +01:00
KennyTV a4d1ac3b95 Add getSpawnParticleHandler method to ItemRewriter 2020-12-09 11:03:40 +01:00
KennyTV 52b95eab28 Merge remote-tracking branch 'origin/master' into dev 2020-12-09 09:17:37 +01:00
KennyTV 7858b998ca Reduce chance of quick move task while disabling
Closes #2226
2020-12-08 12:42:13 +01:00
creeper123123321 d75420a35b Use ArrayDeque, less ram for PacketWrapper.readableObjects (#2218) 2020-12-07 11:50:52 +01:00
KennyTV 137680ed9f Use generic y section count in 1.17 chunk reading 2020-12-03 11:53:05 +01:00
KennyTV e56ff898eb Use integer for y coordinate in Position 2020-12-03 11:14:46 +01:00
KennyTV 3aa35395f4 Fix tag processing in older versions, small refactor 2020-12-03 11:14:35 +01:00
KennyTV ff91dd7082 Finish 20w49a 2020-12-02 22:31:02 +01:00
KennyTV 8a11b577eb Current WIP 20w49a 2020-12-02 21:57:32 +01:00
_tomcraft 6882678bc4 Reduce useless List operations (#2214) 2020-11-29 21:31:18 +01:00
KennyTV 4555c5dbf3 Use FU map in FakeTileEntity 2020-11-29 16:40:40 +01:00
KennyTV 4cc0d2c1a2 Merge remote-tracking branch 'origin/master' into dev 2020-11-29 16:39:06 +01:00
KennyTV c671a6deed 20w48a (probably) 2020-11-25 17:15:43 +01:00
KennyTV e128f6a7ed Merge branch 'master' into dev 2020-11-23 15:22:44 +01:00
KennyTV 7a6e45008b Fix entity item meta 2020-11-14 22:21:36 +01:00
KennyTV ba776e5f88 Handle metadata and map data changes
Mapdata might be bork tho™️
2020-11-12 21:34:12 +01:00
KennyTV 67fda72bdd 20w46a 2020-11-11 19:13:31 +01:00
KennyTV 721c52e3f5 Fix multi block change reading 2020-11-11 16:54:19 +01:00
KennyTV 424e855d72 Uncache biome data on world change, process multi block change 2020-11-11 16:54:19 +01:00
KennyTV 88a1a42625 Finish update
Still unsure whether we also have to store block entity data and if/which respawn conditions have to be checked for biome uncaching
2020-11-11 16:54:18 +01:00
KennyTV 0d3f729679 20w45a
Missing: Diff mappings
2020-11-11 16:54:18 +01:00
1293 changed files with 75224 additions and 161741 deletions

No files matched your search

-31
View File
@@ -1,31 +0,0 @@
---
name: Bug report
about: Create a bug report so we can fix it
---
**Describe the bug, provide any errors**
A clear and concise description of what the bug is. If present, can you paste the error to https://paste.gg/?
**How can we reproduce it?**
Steps to reproduce the behavior:
1. Login on 1.12'
2. Click on '....'
3. The '....' is displayed wrong
**Expected behaviour**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**ViaVersion Dump**
- Type /viaversion dump, and put the link here.
**Additional server info**
Do you use a proxy (eg. BungeeCord)? What software do you use and what plugins?
**Checklist**
- [ ] I have included a Viaversion dump
- [ ] If applicable, I have included a paste (not a screenshot) of the error
- [ ] I have tried a build from https://ci.viaversion.com/ and the issue still persists
+92
View File
@@ -0,0 +1,92 @@
name: Bug Report
description: Report a bug or console error
labels: [Unconfirmed]
body:
- type: markdown
attributes:
value: |
**Before reporting a bug, please see if using master/dev builds from https://ci.viaversion.com/ fixes your issue.**
Whenever you see fit, you can upload images or videos to any of the text fields.
- type: input
attributes:
label: "`/viaversion dump` Output"
description: |
Run `/viaversion dump` in the console or in the chat, then copy and paste the given link here.
placeholder: |
https://dump.viaversion.com/...
validations:
required: true
- type: textarea
attributes:
label: Console Error
description: |
If you encounter warnings/errors in your console, **paste them with https://paste.gg/ and put the paste link here**.
If the error is small/less than 10 lines, you may put it directly into this field.
value: |
```
Put the paste.gg link or text here.
```
placeholder: Please do not remove the grave accents; simply replace the line of text in the middle.
validations:
required: false
- type: textarea
attributes:
label: Bug Description
description: |
Describe the unexpected behavior.
If you want to attach screenshots, use the comment field at the bottom of the page.
placeholder: |
Example: "Placing signs on 1.13.2 causes text to disappear."
validations:
required: true
- type: textarea
attributes:
label: Steps to Reproduce
description: |
List the steps on how we can reproduce the issue. Make sure we can easily understand what you mean with each step.
placeholder: |
Example:
1. Login with a 1.13.2 client
2. Place a sign
3. The sign text is displayed wrong
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: |
Describe what exactly you expected to happen.
placeholder: |
Example: "Placed sign text should not disappear."
validations:
required: true
- type: textarea
attributes:
label: Additional Server Info
description: |
Do you use a proxy (e.g. BungeeCord)? What software do you use and what plugins?
placeholder: |
Example: "I also use BungeeCord with the following plugins: x, y, z"
validations:
required: false
- type: checkboxes
attributes:
label: Checklist
description: Make sure you have followed each of the steps outlined here.
options:
- label: Via plugins are only running on **EITHER** the backend servers (e.g. Paper) **OR** the proxy (e.g. BungeeCord), **not on both**.
required: true
- label: I have included a ViaVersion dump.
required: true
- label: If applicable, I have included a paste (**not a screenshot**) of the error.
required: true
- label: I have tried the latest build(s) from https://ci.viaversion.com/ and the issue still persists.
required: true
+7
View File
@@ -1 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Dev builds
url: https://ci.viaversion.com/
about: Before reporting a bug, please check if using master/dev builds from our ci fixes your issue.
- name: ViaVersion Discord
url: https://discord.gg/viaversion
about: For smaller issues or questions, you can also join our Discord server.
-17
View File
@@ -1,17 +0,0 @@
---
name: Feature request
about: Suggest an idea for ViaVersion
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Which versions is this for?**
Does the feature apply to any specific versions? If so put them here.
@@ -0,0 +1,38 @@
name: Feature Request
description: Suggest a feature to be added
labels: [Feature Request]
body:
- type: textarea
attributes:
label: Problem Description
description: |
Describe the issue you are facing or why you need the feature to be added.
placeholder: |
I am always frustrated with...
validations:
required: true
- type: textarea
attributes:
label: Solution Description
description: |
Describe the solution you would like to see.
validations:
required: true
- type: textarea
attributes:
label: Alternatives
description: |
Describe alternatives you have considered.
validations:
required: false
- type: textarea
attributes:
label: Additional Info
description: |
Does the feature apply to any specific version or environment?
validations:
required: false
+24
View File
@@ -0,0 +1,24 @@
name: Java CI with Gradle
on: [push, pull_request]
jobs:
build:
# Only run on PRs if the source branch is on a different repo. We do not need to run everything twice.
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 11
check-latest: true
- name: Build with Gradle
run: ./gradlew build
+27
View File
@@ -0,0 +1,27 @@
name: Publish to Hangar and Modrinth
on:
push:
branches:
- master
- dev
jobs:
publish:
if: github.repository_owner == 'ViaVersion'
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
check-latest: true
- name: Publish
env:
HANGAR_TOKEN: ${{ secrets.HANGAR_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: ./gradlew build modrinth publishAllPublicationsToHangar --stacktrace
+4 -5
View File
@@ -18,6 +18,8 @@ hs_err_pid*
# Ignore IDEA directory
.idea/*
!.idea/copyright/*
!.idea/scopes/*
# Include the project's dictionary
!.idea/dictionaries/
@@ -106,8 +108,5 @@ nbactions.xml
nb-configuration.xml
.nb-gradle/
### Git ###
# Don't exclude the .gitignore itself
!.gitignore
### MacOS ###
.DS_Store
+11
View File
@@ -0,0 +1,11 @@
<component name="CopyrightManager">
<settings>
<module2copyright>
<element module="ViaVersion-API" copyright="viaversion-mit" />
<element module="ViaVersion" copyright="viaversion-gpl" />
</module2copyright>
<LanguageOptions name="__TEMPLATE__">
<option name="addBlankAfter" value="false" />
</LanguageOptions>
</settings>
</component>
+6
View File
@@ -0,0 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion&#10;Copyright (C) &amp;#36;originalComment.match(&quot;Copyright \(C\) (\d+)&quot;, 1, &quot;-&quot;)&amp;#36;today.year ViaVersion and contributors&#10;&#10;This program is free software: you can redistribute it and/or modify&#10;it under the terms of the GNU General Public License as published by&#10;the Free Software Foundation, either version 3 of the License, or&#10;(at your option) any later version.&#10;&#10;This program is distributed in the hope that it will be useful,&#10;but WITHOUT ANY WARRANTY; without even the implied warranty of&#10;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the&#10;GNU General Public License for more details.&#10;&#10;You should have received a copy of the GNU General Public License&#10;along with this program. If not, see &lt;http://www.gnu.org/licenses/&gt;." />
<option name="myName" value="viaversion-gpl" />
</copyright>
</component>
+6
View File
@@ -0,0 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion&#10;Copyright (C) &amp;#36;originalComment.match(&quot;Copyright \(C\) (\d+)&quot;, 1, &quot;-&quot;)&amp;#36;today.year ViaVersion and contributors&#10;&#10;Permission is hereby granted, free of charge, to any person obtaining a copy&#10;of this software and associated documentation files (the &quot;Software&quot;), to deal&#10;in the Software without restriction, including without limitation the rights&#10;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&#10;furnished to do so, subject to the following conditions:&#10;&#10;The above copyright notice and this permission notice shall be included in all&#10;copies or substantial portions of the Software.&#10;&#10;THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR&#10;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,&#10;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE&#10;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER&#10;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,&#10;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE&#10;SOFTWARE." />
<option name="myName" value="viaversion-mit" />
</copyright>
</component>
+3
View File
@@ -0,0 +1,3 @@
<component name="DependencyValidationManager">
<scope name="ViaVersion" pattern="com.viaversion.viaversion..*&amp;&amp;!src[viaversion-parent.viaversion-api*]:*..*" />
</component>
+3
View File
@@ -0,0 +1,3 @@
<component name="DependencyValidationManager">
<scope name="ViaVersion-API" pattern="src[viaversion-parent.viaversion-api*]:*..*&amp;&amp;!src[viaversion-parent.viaversion-api.main]:com.viaversion.viaversion.api.minecraft.nbt.*" />
</component>
-15
View File
@@ -1,15 +0,0 @@
sudo: false
language: java
jdk:
- openjdk11
cache:
directories:
- '$HOME/.m2/repository'
script:
- mvn dependency:purge-local-repository -DactTransitively=false -DreResolve=false
- mvn clean install -B -U
install: true
+670 -17
View File
@@ -1,21 +1,674 @@
MIT License
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (c) 2020
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Preamble
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+76 -29
View File
@@ -1,52 +1,99 @@
# ViaVersion - Spigot, Sponge, BungeeCord, Velocity
# ViaVersion
[![Latest Release](https://img.shields.io/github/v/release/ViaVersion/ViaVersion)](https://viaversion.com)
[![Build Status](https://travis-ci.com/ViaVersion/ViaVersion.svg?branch=master)](https://travis-ci.com/ViaVersion/ViaVersion)
[![Build Status](https://github.com/ViaVersion/ViaVersion/actions/workflows/gradle.yml/badge.svg?branch=master)](https://github.com/ViaVersion/ViaVersion/actions)
[![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://viaversion.com/discord)
**Allows the connection of higher client versions to lower server versions**
**Allows the connection of higher client versions to lower server versions -
it works on any platform you can think of.**
The base ViaVersion jar runs on Paper, Velocity, Bungee, and Sponge. We also have projects integrating ViaVersion to run
on Fabric, Forge, or as a standalone proxy to join from basically any client version on any server version from the
past decade. **See [HERE](https://github.com/ViaVersion) for an overview of the different Via\* projects.**
Supported Versions:
![Table (https://i.imgur.com/0u20Y2u.png)](https://i.imgur.com/0u20Y2u.png)
On Paper you may also use ProtocolSupport, but ensure you have the right build for your server version.
![Table (https://i.imgur.com/sTrVnC2.png)](https://i.imgur.com/sTrVnC2.png)
**User Docs:** https://docs.viaversion.com/display/VIAVERSION/
Sources:
Releases/Dev Builds
--------
**wiki.vg** (Used for various information, we also contribute back)
You can find official releases in the following places:
**Burger** (See [PAaaS](https://github.com/Matsv/Paaas))
- **Hangar (for our plugins)**: https://hangar.papermc.io/ViaVersion/ViaVersion
- **Modrinth (for our mods)**: https://modrinth.com/mod/viaversion
- **GitHub**: https://github.com/ViaVersion/ViaVersion/releases
**OpenNBT** (used for slot rewriting)
Releases / Dev Builds:
--------
You can find official releases here:
https://www.spigotmc.org/resources/viaversion.19254/history
Dev builds for **all** of our projects are on our Jenkins server:
- **Jenkins**: https://ci.viaversion.com
ViaVersion as a Dependency
----------
You can find official dev builds here:
**Jenkins:** https://ci.viaversion.com
**JavaDocs:** https://jd.viaversion.com
**Maven Repo:** https://repo.viaversion.com
**Maven:**
License:
```xml
<repository>
<id>viaversion-repo</id>
<url>https://repo.viaversion.com</url>
</repository>
```
```xml
<dependency>
<groupId>com.viaversion</groupId>
<artifactId>viaversion-api</artifactId>
<version>[4.0.0,5.0.0)</version>
<scope>provided</scope>
</dependency>
```
**Gradle:**
```kotlin
repositories {
maven("https://repo.viaversion.com")
}
dependencies {
compileOnly("com.viaversion:viaversion-api:VERSION") // Replace the version
}
```
If you need access to the existing protocol or platform implementations, use the parent artifact `viaversion`.
Please note the [differences in licensing](#license).
Building
--------
After cloning this repository, build the project with Gradle by running `./gradlew build` and take the created jar out
of the `build/libs` directory.
Mapping Files
--------------
Mapping files are generated and managed in our [Mappings repository](https://github.com/ViaVersion/Mappings).
Resources
--------
MIT License, see LICENSE for more details.
- **[Via Mappings Generator](https://github.com/ViaVersion/Mappings)**
- **[Mojang mappings](https://minecraft.wiki/w/Obfuscation_map)** (Thank you, Mojang, very cool)
- **[wiki.vg](https://wiki.vg)** (Used for historic information regarding packet structure, we also contribute back)
- **[Burger](https://github.com/Pokechu22/Burger)** (See [PAaaS](https://github.com/Matsv/Paaas))
License
--------
The entirety of the [API directory](api) (including the legacy API directory) is licensed under the MIT License;
see [licenses/MIT.md](licenses/MIT.md) for
details.
Special thanks to all our [Contributors](https://github.com/ViaVersion/ViaVersion/graphs/contributors)
Everything else, unless explicitly stated otherwise, is licensed under the GNU General Public License v3, including the
end-product as a whole; see [licenses/GPL.md](licenses/GPL.md) for details.
Special thanks to all our [Contributors](https://github.com/ViaVersion/ViaVersion/graphs/contributors).
+25
View File
@@ -0,0 +1,25 @@
plugins {
id("com.github.johnrengelman.shadow")
}
// Shade and relocate adventure in an extra module, so that common/the rest can directly depend on a
// relocated adventure without breaking native platform's adventure usage with project wide relocation
tasks {
shadowJar {
relocate("net.kyori", "com.viaversion.viaversion.libs.kyori")
}
build {
dependsOn(shadowJar)
}
}
dependencies {
api(libs.bundles.adventure) {
exclude("org.checkerframework")
exclude("net.kyori", "adventure-api")
exclude("net.kyori", "adventure-bom")
exclude("com.google.code.gson", "gson")
}
}
publishShadowJar()
+3
View File
@@ -0,0 +1,3 @@
dependencies {
compileOnly(projects.viaversionApi)
}
@@ -0,0 +1,101 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api;
import io.netty.buffer.ByteBuf;
import java.util.SortedSet;
import java.util.UUID;
import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle;
/**
* @deprecated may be removed at some point, use {@link com.viaversion.viaversion.api.Via}
*/
@Deprecated
public class Via<T> implements ViaAPI<T> {
private static final ViaAPI INSTANCE = new Via();
private Via() {
}
@Deprecated
public static ViaAPI getAPI() {
return INSTANCE;
}
@Override
public int getPlayerVersion(T player) {
return com.viaversion.viaversion.api.Via.getAPI().getPlayerVersion(player);
}
@Override
public int getPlayerVersion(UUID uuid) {
return com.viaversion.viaversion.api.Via.getAPI().getPlayerVersion(uuid);
}
@Override
public boolean isInjected(UUID playerUUID) {
return com.viaversion.viaversion.api.Via.getAPI().isInjected(playerUUID);
}
@Override
public String getVersion() {
return com.viaversion.viaversion.api.Via.getAPI().getVersion();
}
@Override
public void sendRawPacket(T player, ByteBuf packet) {
com.viaversion.viaversion.api.Via.getAPI().sendRawPacket(player, packet);
}
@Override
public void sendRawPacket(UUID uuid, ByteBuf packet) {
com.viaversion.viaversion.api.Via.getAPI().sendRawPacket(uuid, packet);
}
@Override
public BossBar createBossBar(String title, BossColor color, BossStyle style) {
return new BossBar(com.viaversion.viaversion.api.Via.getAPI().legacyAPI().createLegacyBossBar(title,
com.viaversion.viaversion.api.legacy.bossbar.BossColor.values()[color.ordinal()],
com.viaversion.viaversion.api.legacy.bossbar.BossStyle.values()[style.ordinal()]));
}
@Override
public BossBar createBossBar(String title, float health, BossColor color, BossStyle style) {
return new BossBar(com.viaversion.viaversion.api.Via.getAPI().legacyAPI().createLegacyBossBar(title, health,
com.viaversion.viaversion.api.legacy.bossbar.BossColor.values()[color.ordinal()],
com.viaversion.viaversion.api.legacy.bossbar.BossStyle.values()[style.ordinal()]));
}
@Override
public SortedSet<Integer> getSupportedVersions() {
return com.viaversion.viaversion.api.Via.getAPI().getSupportedVersions();
}
@Override
public SortedSet<Integer> getFullSupportedVersions() {
return com.viaversion.viaversion.api.Via.getAPI().getFullSupportedVersions();
}
}
@@ -0,0 +1,62 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api;
import com.viaversion.viaversion.api.Via;
import io.netty.buffer.ByteBuf;
import java.util.SortedSet;
import java.util.UUID;
import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle;
/**
* @deprecated may be removed at some point, use {@link Via#getAPI()}
*/
@Deprecated
public interface ViaAPI<T> {
int getPlayerVersion(T player);
int getPlayerVersion(UUID uuid);
default boolean isPorted(UUID playerUUID) {
return isInjected(playerUUID);
}
boolean isInjected(UUID playerUUID);
String getVersion();
void sendRawPacket(T player, ByteBuf packet);
void sendRawPacket(UUID uuid, ByteBuf packet);
BossBar createBossBar(String title, BossColor color, BossStyle style);
BossBar createBossBar(String title, float health, BossColor color, BossStyle style);
SortedSet<Integer> getSupportedVersions();
SortedSet<Integer> getFullSupportedVersions();
}
@@ -0,0 +1,133 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.boss;
import java.util.Set;
import java.util.UUID;
@Deprecated
public class BossBar<T> {
private final com.viaversion.viaversion.api.legacy.bossbar.BossBar bossBar;
public BossBar(com.viaversion.viaversion.api.legacy.bossbar.BossBar bossBar) {
this.bossBar = bossBar;
}
public String getTitle() {
return bossBar.getTitle();
}
public BossBar setTitle(String title) {
bossBar.setTitle(title);
return this;
}
public float getHealth() {
return bossBar.getHealth();
}
public BossBar setHealth(float health) {
bossBar.setHealth(health);
return this;
}
public BossColor getColor() {
return BossColor.values()[bossBar.getColor().ordinal()];
}
public BossBar setColor(BossColor color) {
bossBar.setColor(com.viaversion.viaversion.api.legacy.bossbar.BossColor.values()[color.ordinal()]);
return this;
}
public BossStyle getStyle() {
return BossStyle.values()[bossBar.getStyle().ordinal()];
}
public BossBar setStyle(BossStyle style) {
bossBar.setStyle(com.viaversion.viaversion.api.legacy.bossbar.BossStyle.values()[style.ordinal()]);
return this;
}
@Deprecated
public BossBar addPlayer(T player) {
return this;
}
public BossBar addPlayer(UUID player) {
bossBar.addPlayer(player);
return this;
}
@Deprecated
public BossBar addPlayers(T... players) {
return this;
}
@Deprecated
public BossBar removePlayer(T player) {
return this;
}
public BossBar removePlayer(UUID uuid) {
bossBar.removePlayer(uuid);
return this;
}
public BossBar addFlag(BossFlag flag) {
bossBar.addFlag(com.viaversion.viaversion.api.legacy.bossbar.BossFlag.values()[flag.ordinal()]);
return this;
}
public BossBar removeFlag(BossFlag flag) {
bossBar.removeFlag(com.viaversion.viaversion.api.legacy.bossbar.BossFlag.values()[flag.ordinal()]);
return this;
}
public boolean hasFlag(BossFlag flag) {
return bossBar.hasFlag(com.viaversion.viaversion.api.legacy.bossbar.BossFlag.values()[flag.ordinal()]);
}
public Set<UUID> getPlayers() {
return bossBar.getPlayers();
}
public BossBar show() {
bossBar.show();
return this;
}
public BossBar hide() {
bossBar.hide();
return this;
}
public boolean isVisible() {
return bossBar.isVisible();
}
public UUID getId() {
return bossBar.getId();
}
}
@@ -0,0 +1,45 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.boss;
@Deprecated
public enum BossColor {
PINK(0),
BLUE(1),
RED(2),
GREEN(3),
YELLOW(4),
PURPLE(5),
WHITE(6);
private final int id;
BossColor(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
@@ -0,0 +1,40 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.boss;
@Deprecated
public enum BossFlag {
DARKEN_SKY(1),
PLAY_BOSS_MUSIC(2);
private final int id;
BossFlag(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
@@ -0,0 +1,43 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.boss;
@Deprecated
public enum BossStyle {
SOLID(0),
SEGMENTED_6(1),
SEGMENTED_10(2),
SEGMENTED_12(3),
SEGMENTED_20(4);
private final int id;
BossStyle(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
@@ -0,0 +1,33 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.protocol;
/**
* @deprecated may be removed at some point, use {@link com.viaversion.viaversion.api.protocol.ProtocolManager}
*/
@Deprecated
public class ProtocolRegistry {
@Deprecated
public static int SERVER_PROTOCOL = -1;
}
@@ -1,22 +1,47 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package us.myles.ViaVersion.api.protocol;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.version.VersionRange;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* @deprecated will no longer be updated and may be removed at some point, use {@link com.viaversion.viaversion.api.protocol.version.ProtocolVersion}
*/
@Deprecated
public class ProtocolVersion {
private static final Int2ObjectMap<ProtocolVersion> versions = new Int2ObjectOpenHashMap<>();
private static final List<ProtocolVersion> versionList = new ArrayList<>();
// Before the Netty rewrite
public static final ProtocolVersion v1_4_6 = register(51, "1.4.6/7", new VersionRange("1.4", 6, 7));
public static final ProtocolVersion v1_5_1 = register(60, "1.5.1");
public static final ProtocolVersion v1_5_2 = register(61, "1.5.2");
@@ -24,7 +49,6 @@ public class ProtocolVersion {
public static final ProtocolVersion v_1_6_2 = register(74, "1.6.2");
public static final ProtocolVersion v_1_6_3 = register(77, "1.6.3");
public static final ProtocolVersion v_1_6_4 = register(78, "1.6.4");
// After the Netty rewrite
public static final ProtocolVersion v1_7_1 = register(4, "1.7-1.7.5", new VersionRange("1.7", 0, 5));
public static final ProtocolVersion v1_7_6 = register(5, "1.7.6-1.7.10", new VersionRange("1.7", 6, 10));
public static final ProtocolVersion v1_8 = register(47, "1.8.x");
@@ -53,7 +77,18 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_16_1 = register(736, "1.16.1");
public static final ProtocolVersion v1_16_2 = register(751, "1.16.2");
public static final ProtocolVersion v1_16_3 = register(753, "1.16.3");
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4");
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4/5", new VersionRange("1.16", 4, 5));
public static final ProtocolVersion v1_17 = register(755, "1.17");
public static final ProtocolVersion v1_17_1 = register(756, "1.17.1");
public static final ProtocolVersion v1_18 = register(757, "1.18/1.18.1", new VersionRange("1.18", 0, 1));
public static final ProtocolVersion v1_18_2 = register(758, "1.18.2");
public static final ProtocolVersion v1_19 = register(759, "1.19");
public static final ProtocolVersion v1_19_1 = register(760, "1.19.1/2", new VersionRange("1.19", 1, 2));
public static final ProtocolVersion v1_19_3 = register(761, "1.19.3");
public static final ProtocolVersion v1_19_4 = register(762, "1.19.4");
public static final ProtocolVersion v1_20 = register(763, "1.20/1.20.1", new VersionRange("1.20", 0, 1));
public static final ProtocolVersion v1_20_2 = register(764, "1.20.2");
public static final ProtocolVersion v1_20_3 = register(765, "1.20.3");
public static final ProtocolVersion unknown = register(-1, "UNKNOWN");
public static ProtocolVersion register(int version, String name) {
@@ -82,8 +117,7 @@ public class ProtocolVersion {
return versions.containsKey(id);
}
@NotNull
public static ProtocolVersion getProtocol(int id) {
public static @NonNull ProtocolVersion getProtocol(int id) {
ProtocolVersion protocolVersion = versions.get(id);
if (protocolVersion != null) {
return protocolVersion;
@@ -100,8 +134,7 @@ public class ProtocolVersion {
return Collections.unmodifiableList(new ArrayList<>(versions.values()));
}
@Nullable
public static ProtocolVersion getClosest(String protocol) {
public static @Nullable ProtocolVersion getClosest(String protocol) {
for (ProtocolVersion version : versions.values()) {
String name = version.getName();
if (name.equals(protocol)) {
@@ -141,76 +174,49 @@ public class ProtocolVersion {
Preconditions.checkArgument(!versionWildcard || versionRange == null, "A version cannot be a wildcard and a range at the same time!");
if (versionRange != null) {
includedVersions = new HashSet<>();
for (int i = versionRange.getRangeFrom(); i <= versionRange.getRangeTo(); i++) {
includedVersions = new LinkedHashSet<>();
for (int i = versionRange.rangeFrom(); i <= versionRange.rangeTo(); i++) {
if (i == 0) {
includedVersions.add(versionRange.getBaseVersion()); // Keep both the base version and with ".0" appended
includedVersions.add(versionRange.baseVersion()); // Keep both the base version and with ".0" appended
}
includedVersions.add(versionRange.getBaseVersion() + "." + i);
includedVersions.add(versionRange.baseVersion() + "." + i);
}
} else {
includedVersions = Collections.singleton(name);
}
}
/**
* @return release version
*/
public int getVersion() {
return version;
}
/**
* @return snapshot protocol version without the snapshot indicator bit
* @throws IllegalArgumentException if the version if not a snapshot version
* @see #isSnapshot()
*/
public int getSnapshotVersion() {
Preconditions.checkArgument(isSnapshot());
return snapshotVersion;
}
/**
* @return snapshot protocol version with the snapshot indicator bit
* @throws IllegalArgumentException if the version if not a snapshot version
* @see #isSnapshot()
*/
public int getFullSnapshotVersion() {
Preconditions.checkArgument(isSnapshot());
return (1 << 30) | snapshotVersion; // Bit indicating snapshot versions
}
/**
* @return release version if release, snapshot version (with the snapshot indicator bit) if snapshot
*/
public int getOriginalVersion() {
return snapshotVersion == -1 ? version : ((1 << 30) | snapshotVersion);
}
/**
* @return true if the protocol includes a range of versions (but not an entire major version range), for example 1.7-1.7.5
* @see #getIncludedVersions()
*/
public boolean isKnown() {
return version != -1;
}
public boolean isRange() {
return includedVersions.size() != 1;
}
/**
* Returns an immutable set of all included versions if the protocol is a version range.
* If the protocol only includes a single Minecraft version or the entire major version as a wildcard ({@link #isVersionWildcard()}),
* the set will only contain the string given in {@link #getName()}.
*
* @return immutable set of all included versions if the protocol is a version range
* @see #isRange()
*/
public Set<String> getIncludedVersions() {
return Collections.unmodifiableSet(includedVersions);
}
/**
* @return true if the protocol includes an entire major version range (for example 1.8.x)
*/
public boolean isVersionWildcard() {
return versionWildcard;
}
@@ -223,11 +229,6 @@ public class ProtocolVersion {
return snapshotVersion != -1;
}
/**
* @return release version
* @deprecated ambiguous, see {@link #getOriginalVersion()}, {@link #getVersion()}, and {@link #getSnapshotVersion()}
*/
@Deprecated
public int getId() {
return version;
}
@@ -248,6 +249,6 @@ public class ProtocolVersion {
@Override
public String toString() {
return String.format("%s(%d)", this.name, this.version);
return String.format("%s (%d)", this.name, this.version);
}
}
+37
View File
@@ -0,0 +1,37 @@
plugins {
id("net.kyori.blossom")
id("org.jetbrains.gradle.plugin.idea-ext")
}
sourceSets {
main {
blossom {
javaSources {
property("version", project.version.toString())
property("impl_version", "git-ViaVersion-${project.version}:${rootProject.latestCommitHash()}")
}
}
}
}
dependencies {
api(projects.adventure) {
targetConfiguration = "shadow"
}
api(libs.fastutil)
api(libs.flare)
api(libs.flareFastutil)
api(libs.vianbt)
api(libs.gson)
compileOnlyApi(libs.snakeYaml)
compileOnlyApi(libs.netty)
compileOnlyApi(libs.guava)
compileOnlyApi(libs.checkerQual)
}
java {
withJavadocJar()
}
publishShadowJar()
@@ -0,0 +1,44 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.util;
import com.viaversion.viaversion.api.platform.ViaPlatform;
public final class VersionInfo {
/**
* Plugin version.
*
* @see ViaPlatform#getPluginVersion()
*/
public static final String VERSION = "{{ version }}";
private static final String IMPLEMENTATION_VERSION = "{{ impl_version }}";
public static String getVersion() {
return VERSION;
}
public static String getImplementationVersion() {
return IMPLEMENTATION_VERSION;
}
}
@@ -0,0 +1,87 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
import com.viaversion.viaversion.api.platform.ViaPlatform;
import com.viaversion.viaversion.api.platform.ViaServerProxyPlatform;
public final class Via {
private static ViaManager manager;
/**
* Returns the API associated with the current platform.
*
* @return API instance
* @throws IllegalArgumentException if the platform has not loaded yet
*/
public static ViaAPI getAPI() {
return manager().getPlatform().getApi();
}
/**
* Returns the ViaManager with methods beyond the simple API {@link ViaAPI} provides.
*
* @return manager to interact with various Via parts
* @throws IllegalArgumentException if the platform has not loaded yet
*/
public static ViaManager getManager() {
return manager();
}
/**
* Returns the config associated with the current platform.
*
* @return config instance
* @throws IllegalArgumentException if the platform has not loaded yet
*/
public static ViaVersionConfig getConfig() {
return manager().getPlatform().getConf();
}
public static ViaPlatform getPlatform() {
return manager().getPlatform();
}
public static ViaServerProxyPlatform<?> proxyPlatform() {
Preconditions.checkArgument(manager().getPlatform() instanceof ViaServerProxyPlatform, "Platform is not proxying Minecraft servers!");
return (ViaServerProxyPlatform<?>) manager().getPlatform();
}
/**
* Register the ViaManager associated with the platform.
*
* @param viaManager The ViaManager
* @throws IllegalArgumentException if the manager has already been set
*/
public static void init(ViaManager viaManager) {
Preconditions.checkArgument(manager == null, "ViaManager is already set");
Via.manager = viaManager;
}
private static ViaManager manager() {
Preconditions.checkArgument(manager != null, "ViaVersion has not loaded the platform yet");
return manager;
}
}
@@ -0,0 +1,159 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api;
import com.viaversion.viaversion.api.connection.ConnectionManager;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.legacy.LegacyViaAPI;
import com.viaversion.viaversion.api.platform.ViaPlatform;
import com.viaversion.viaversion.api.protocol.ProtocolManager;
import com.viaversion.viaversion.api.protocol.version.ServerProtocolVersion;
import io.netty.buffer.ByteBuf;
import java.util.SortedSet;
import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* General api point. For more specialized api methods, see {@link Via#getManager()}.
*
* @param <T> player type for the specific platform
* @see ViaManager
* @see ProtocolManager
* @see ConnectionManager
* @see ViaPlatform
*/
public interface ViaAPI<T> {
/**
* Returns the <b>major version</b> matching {@link #getVersion()}.
* It is highly advised to check against the major version and to disable/not initiate
* any hooks into ViaVersion if given and expected versions do not match.
*
* @return major plugin version
* @since 4.0.2
*/
default int majorVersion() {
return 4;
}
/**
* Returns an <b>internally based API version</b> incremented with meaningful API changes.
* This includes breaking changes to existing API and larger additions.
*
* @return API version incremented with meaningful API changes
*/
default int apiVersion() {
return 22;
}
/**
* Returns the server's protocol version info.
*
* @return the server's protocol version info
*/
ServerProtocolVersion getServerVersion();
/**
* Returns the protocol version of a player.
* This will also retrieve the version from ProtocolSupport if it's being used.
*
* @param player the platform's player object, e.g. Bukkit this is Player
* @return protocol version, for example (47=1.8-1.8.8, 107=1.9, 108=1.9.1), or -1 if no longer connected
*/
int getPlayerVersion(T player);
/**
* Returns the protocol version of a player.
*
* @param uuid UUID of a player
* @return protocol version, for example (47=1.8-1.8.8, 107=1.9, 108=1.9.1), or -1 if not connected
*/
int getPlayerVersion(UUID uuid);
/**
* Returns whether Via injected into this player connection.
*
* @param uuid uuid of the player
* @return whether Via has a cached a UserConnection for this player
*/
boolean isInjected(UUID uuid);
/**
* Returns the Via injected UserConnection if present.
*
* @param uuid uuid of the player
* @return user connection if present
*/
@Nullable UserConnection getConnection(UUID uuid);
/**
* Returns the version of the plugin.
*
* @return plugin version
*/
String getVersion();
/**
* Sends a raw packet to the player.
*
* @param player the platform's player object, e.g. for Bukkit this is Player
* @param packet the packet; you need a VarInt id, then the packet contents
* @throws IllegalArgumentException if the player is not injected by Via
*/
void sendRawPacket(T player, ByteBuf packet);
/**
* Sends a raw packet to the player.
*
* @param uuid the uuid from the player to send packet
* @param packet the packet; you need a VarInt id, then the packet contents
* @throws IllegalArgumentException if the player is not injected by Via
*/
void sendRawPacket(UUID uuid, ByteBuf packet);
/**
* Returns the supported protocol versions.
* This method removes any blocked protocol versions.
*
* @return a sorted set of protocol versions
* @see #getFullSupportedVersions() for a full list
*/
SortedSet<Integer> getSupportedVersions();
/**
* Returns the supported protocol versions, including blocked protocols.
*
* @return a sorted set of protocol versions
*/
SortedSet<Integer> getFullSupportedVersions();
/**
* Returns legacy api only applicable on/to legacy versions.
* <p>
* These methods are safe to use and are unlikely to be removed,
* but it is important to be aware of their limited use.
*
* @return legacy api only applicable on/to legacy versions
*/
LegacyViaAPI<T> legacyAPI();
}
@@ -0,0 +1,150 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api;
import com.viaversion.viaversion.api.command.ViaVersionCommand;
import com.viaversion.viaversion.api.configuration.ConfigurationProvider;
import com.viaversion.viaversion.api.connection.ConnectionManager;
import com.viaversion.viaversion.api.debug.DebugHandler;
import com.viaversion.viaversion.api.platform.ViaInjector;
import com.viaversion.viaversion.api.platform.ViaPlatform;
import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
import com.viaversion.viaversion.api.protocol.ProtocolManager;
import com.viaversion.viaversion.api.scheduler.Scheduler;
import java.util.Set;
public interface ViaManager {
/**
* Returns the protocol manager for registering/getting protocols and their mapping data loading.
*
* @return protocol manager
*/
ProtocolManager getProtocolManager();
/**
* Returns platform for handling platform specific configuration, tasks, and plugin data.
*
* @return platform
*/
ViaPlatform<?> getPlatform();
/**
* Returns the userconnection manager for handling clients connected to the server.
*
* @return userconnection manager
*/
ConnectionManager getConnectionManager();
/**
* Returns the manager for Via providers.
*
* @return provider manager
*/
ViaProviders getProviders();
/**
* Returns the injector for injecting netty handlers and initially getting the server protocol version.
*
* @return injector
*/
ViaInjector getInjector();
/**
* Returns the command handler for managing ViaVersion subcommands.
*
* @return command handler
*/
ViaVersionCommand getCommandHandler();
/**
* Returns the platform loader responsible for registering listeners, providers and such.
*
* @return platform loader
*/
ViaPlatformLoader getLoader();
/**
* Returns the async task scheduler.
*
* @return async task scheduler
*/
Scheduler getScheduler();
/**
* Returns the configuration provider.
*
* @return the configuration provider
*/
ConfigurationProvider getConfigurationProvider();
/**
* If debug is enabled, packets and other otherwise suppressed warnings will be logged.
*
* @return true if enabled
*/
default boolean isDebug() {
return debugHandler().enabled();
}
/**
* Sets the debug mode. If enabled, packets and other otherwise suppressed warnings will be logged.
*
* @param debug whether debug should be enabled
*/
@Deprecated
default void setDebug(boolean debug) {
debugHandler().setEnabled(debug);
}
/**
* Returns the debug handler.
*
* @return debug handler
*/
DebugHandler debugHandler();
/**
* Returns a mutable set of self-added subplatform version strings.
* This set is expanded by the subplatform itself (e.g. ViaBackwards), and may not contain all running ones.
*
* @return mutable set of subplatform versions
*/
Set<String> getSubPlatforms();
/**
* Adds a runnable to be executed when ViaVersion has finished its init before the full server load.
*
* @param runnable runnable to be executed
*/
void addEnableListener(Runnable runnable);
/**
* Returns whether the manager has been initialized (and protocols have been loaded).
*
* @return whether the manager has been initialized
*/
boolean isInitialized();
}
@@ -0,0 +1,56 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.command;
import java.util.UUID;
public interface ViaCommandSender {
/**
* Check if the sender has a permission.
*
* @param permission Permission string e.g. viaversion.admin
* @return True if the sender has the permission
*/
boolean hasPermission(String permission);
/**
* Send a message to the sender
*
* @param msg The message to send
*/
void sendMessage(String msg);
/**
* Get the senders UUID.
*
* @return The senders UUID
*/
UUID getUUID();
/**
* Get the senders name.
*
* @return The senders name
*/
String getName();
}
@@ -0,0 +1,104 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.command;
import com.viaversion.viaversion.util.ChatColorUtil;
import java.util.Collections;
import java.util.List;
public abstract class ViaSubCommand {
/**
* Subcommand name
*
* @return The commands name
*/
public abstract String name();
/**
* subcommand description, this'll show in /viaversion list
*
* @return The commands description
*/
public abstract String description();
/**
* Usage example:
* "playerversion [name]"
*
* @return The commands usage
*/
public String usage() {
return name();
}
/**
* Permission, null for everyone
*
* @return The permission required to use the commands
*/
public String permission() {
return "viaversion.admin." + name();
}
/**
* Gets triggered on execution
*
* @param sender Command sender
* @param args Arguments
* @return commands executed succesfully if false, show usage
*/
public abstract boolean execute(ViaCommandSender sender, String[] args);
/**
* Yay, possibility to implement tab-completion
*
* @param sender Command sender
* @param args args
* @return tab complete possibilities
*/
public List<String> onTabComplete(ViaCommandSender sender, String[] args) {
return Collections.emptyList();
}
/**
* Replaces color codes in a string.
*
* @param s string to replace
* @return output String
*/
public static String color(String s) {
return ChatColorUtil.translateAlternateColorCodes(s);
}
/**
* Send a color coded string with replacements to a user.
*
* @param sender target to send the message to
* @param message message
* @param args objects to replace
*/
public static void sendMessage(ViaCommandSender sender, String message, Object... args) {
sender.sendMessage(color(args == null ? message : String.format(message, args)));
}
}
@@ -0,0 +1,72 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.command;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface ViaVersionCommand {
/**
* Register your own subcommand inside ViaVersion
*
* @param command Your own SubCommand instance to handle it.
* @throws Exception throws an exception when the subcommand already exists or if it's not valid, example: spacee
*/
void registerSubCommand(ViaSubCommand command);
/**
* Check if a subcommand is registered.
*
* @param name Subcommand name
* @return true if it exists
*/
boolean hasSubCommand(String name);
/**
* Get subcommand instance by name
*
* @param name subcommand name
* @return ViaSubCommand instance
*/
@Nullable ViaSubCommand getSubCommand(String name);
/**
* Executed when the Command sender executes the commands
*
* @param sender Sender object
* @param args arguments provided
* @return was successful
*/
boolean onCommand(ViaCommandSender sender, String[] args);
/**
* Executed when the Command sender tab-completes
*
* @param sender Sender object
* @param args arguments provided
* @return was successful
*/
List<String> onTabComplete(ViaCommandSender sender, String[] args);
void showHelp(ViaCommandSender sender);
}
@@ -0,0 +1,53 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.configuration;
import java.util.Map;
public interface Config {
/**
* Reloads the config
*/
void reload();
/**
* Saves the config
*/
void save();
/**
* Sets the specified path to the given value.
*
* @param path Path of the object to set.
* @param value New value to set the path to
*/
void set(String path, Object value);
/**
* Get all the configuration values
*
* @return Map with key-values
*/
Map<String, Object> getValues();
}
@@ -0,0 +1,47 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.configuration;
import java.util.Collection;
public interface ConfigurationProvider {
/**
* Registers a config to be saved or reloaded when {@link #reloadConfigs()} is called.
*
* @param config the config to register
*/
void register(Config config);
/**
* Returns all registered configs.
*
* @return unmodifiable collection of all registered configs
*/
Collection<Config> configs();
/**
* Reloads the configuration files.
*/
void reloadConfigs();
}
@@ -1,8 +1,36 @@
package us.myles.ViaVersion.api;
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.configuration;
import com.google.gson.JsonElement;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
import com.viaversion.viaversion.api.protocol.version.BlockedProtocolVersions;
import it.unimi.dsi.fastutil.ints.IntSet;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface ViaVersionConfig {
public interface ViaVersionConfig extends Config {
/**
* Get if the plugin should check for updates
@@ -54,6 +82,25 @@ public interface ViaVersionConfig {
*/
boolean isShieldBlocking();
/**
* Whether the player can block with the shield without a delay.
* <p>
* This option requires {@link #isShowShieldWhenSwordInHand()} to be disabled
*
* @return {@code true} if non-delayed shield blocking is enabled.
*/
boolean isNoDelayShieldBlocking();
/**
* Puts the shield into the second hand when holding a sword.
* The shield will disappear when switching to another item.
* <p>
* This option requires {@link #isShieldBlocking()} to be enabled
*
* @return {@code true} if the shield should appear when holding a sword
*/
boolean isShowShieldWhenSwordInHand();
/**
* Get if armor stand positions are fixed so holograms show up at the correct height in 1.9 &amp; 1.10
*
@@ -79,7 +126,7 @@ public interface ViaVersionConfig {
* Get if the boss bars for 1.9 &amp; 1.10 clients are being stopped from flickering
* This will keep all boss bars on 100% (not recommended)
*
* @return true if boss bar anti flickering is enabled
* @return true if boss bar anti-flickering is enabled
*/
boolean isBossbarAntiflicker();
@@ -139,13 +186,6 @@ public interface ViaVersionConfig {
*/
String getMaxWarningsKickMessage();
/**
* Is anti-xray enabled?
*
* @return A boolean
*/
boolean isAntiXRay();
/**
* Send supported versions in the status response packet
*
@@ -188,6 +228,13 @@ public interface ViaVersionConfig {
*/
int getPistonReplacementId();
/**
* Fix 1.9+ clients not rendering the far away chunks
*
* @return true to fix chunk borders
*/
boolean isChunkBorderFix();
/**
* Force json transform
*
@@ -209,6 +256,8 @@ public interface ViaVersionConfig {
*/
boolean is1_13TeamColourFix();
boolean shouldRegisterUserConnectionOnJoin();
/**
* Should we fix shift quick move action for 1.12 clients
*
@@ -216,12 +265,23 @@ public interface ViaVersionConfig {
*/
boolean is1_12QuickMoveActionFix();
/**
* API to check for blocked protocol versions.
*
* @return blocked protocol versions
*/
BlockedProtocolVersions blockedProtocolVersions();
/**
* Get the blocked protocols
*
* @return An Integer list
* @deprecated use {@link #blockedProtocolVersions()}
*/
IntSet getBlockedProtocols();
@Deprecated/*(forRemoval = true)*/
default IntSet getBlockedProtocols() {
return blockedProtocolVersions().singleBlockedVersions();
}
/**
* Get the custom disconnect message
@@ -324,7 +384,7 @@ public interface ViaVersionConfig {
boolean isTruncate1_14Books();
/**
* Handles left handed info by using unused bit 7 on Client Settings packet
* Handles left-handed info by using unused bit 7 on Client Settings packet
*
* @return true if enabled
*/
@@ -366,4 +426,41 @@ public interface ViaVersionConfig {
* @return true if enabled
*/
boolean isIgnoreLong1_16ChannelNames();
/**
* Force 1.17+ client to accept the server resource pack.
*
* @return true if enabled
*/
boolean isForcedUse1_17ResourcePack();
/**
* Get the message that is sent when a user displays a resource pack prompt.
*
* @return cached serialized component
*/
JsonElement get1_17ResourcePackPrompt();
/***
* Get the world names that should be returned for each Vanilla dimension.
* Note that this can be overridden per-user by using {@link UserConnection#put(StorableObject)} with
* a custom instance of {@link WorldIdentifiers} for the user's {@link UserConnection}.
*
* @return the global map from vanilla dimensions to world name
*/
WorldIdentifiers get1_16WorldNamesMap();
/**
* Caches light until chunks are unloaded to allow subsequent chunk update packets as opposed to instantly uncaching when the first chunk data is sent.
*
* @return true if enabled
*/
boolean cache1_17Light();
/**
* Force-update 1.19.4+ player's inventory when they try to swap armor in a pre-occupied slot.
*
* @return true if enabled
*/
boolean isArmorToggleFix();
}
@@ -0,0 +1,103 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.connection;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Handles injected UserConnections
*/
public interface ConnectionManager {
/**
* Returns if Via injected into this player connection.
*
* @param playerId player uuid
* @return true if the player is handled by Via
*/
boolean isClientConnected(UUID playerId);
/**
* Frontend connections will have the UUID stored. Override this if your platform isn't always frontend.
* UUIDs can't be duplicate between frontend connections.
*
* @return true if the user is a frontend connection
*/
default boolean isFrontEnd(UserConnection connection) {
return !connection.isClientSide();
}
/**
* Returns the frontend UserConnection from the player connected to this proxy server
* Returns null when there isn't a server or connection was not found
* When ViaVersion is reloaded, this method may not return some players.
* May not return ProtocolSupport players.
* <p>
* Note that connections are removed as soon as their channel is closed,
* so avoid using this method during player quits for example.
*
* @return frontend UserConnection of the player connected to this proxy server
*/
@Nullable UserConnection getConnectedClient(UUID clientIdentifier);
/**
* Returns the UUID from the frontend connection to this proxy server
* Returns null when there isn't a server or this connection isn't frontend, or it doesn't have an id
* When ViaVersion is reloaded, this method may not return some players.
* May not return ProtocolSupport players.
* <p>
* Note that connections are removed as soon as their channel is closed,
* so avoid using this method during player quits for example.
*
* @return UUID of the frontend connection to this proxy server
*/
@Nullable UUID getConnectedClientId(UserConnection connection);
/**
* Returns all UserConnections which are registered
* May contain duplicated UUIDs on multiple ProtocolInfo.
* May contain frontend, backend and/or client-sided connections.
* When ViaVersion is reloaded, this method may not return some players.
* May not contain ProtocolSupport players.
*
* @return connected UserConnections
*/
Set<UserConnection> getConnections();
/**
* Returns a map containing the UUIDs and frontend UserConnections from players connected to this proxy server
* Returns empty list when there isn't a server
* When ViaVersion is reloaded, this method may not return some players.
* May not contain ProtocolSupport players.
*
* @return map containing the UUIDs and frontend UserConnections from players connected to this proxy server
*/
Map<UUID, UserConnection> getConnectedClients();
void onLoginSuccess(UserConnection connection);
void onDisconnect(UserConnection connection);
}
@@ -0,0 +1,151 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.connection;
import com.viaversion.viaversion.api.protocol.ProtocolPipeline;
import com.viaversion.viaversion.api.protocol.packet.Direction;
import com.viaversion.viaversion.api.protocol.packet.State;
import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface ProtocolInfo {
/**
* Returns the protocol state the user is currently in.
*
* @return protocol state
* @deprecated server and client can be in different states, use {@link #getClientState()} or {@link #getServerState()}
*/
@Deprecated/*(forRemoval = true)*/
default State getState() {
return this.getServerState();
}
/**
* Returns the protocol state the client is currently in.
*
* @return the client protocol state
*/
State getClientState();
/**
* Returns the protocol state the server is currently in.
*
* @return the server protocol state
*/
State getServerState();
/**
* Returns the protocol state for the given direction.
*
* @param direction protocol direction
* @return state for the given direction
*/
default State getState(final Direction direction) {
// Return the state the packet is coming from
return direction == Direction.CLIENTBOUND ? this.getServerState() : this.getClientState();
}
/**
* Sets both client and server state.
*
* @param state the new protocol state
* @see #setClientState(State)
* @see #setServerState(State)
*/
default void setState(final State state) {
this.setClientState(state);
this.setServerState(state);
}
/**
* Sets the client protocol state.
*
* @param clientState the new client protocol state
*/
void setClientState(State clientState);
/**
* Sets the server protocol state.
*
* @param serverState the new server protocol state
*/
void setServerState(State serverState);
/**
* Returns the user's protocol version, or -1 if not set.
* This is set during the {@link State#HANDSHAKE} state.
*
* @return protocol version, or -1 if not set
*/
int getProtocolVersion();
void setProtocolVersion(int protocolVersion);
/**
* Returns the server protocol version the user is connected to, or -1 if not set.
* This is set during the {@link State#HANDSHAKE} state.
*
* @return server protocol version, or -1 if not set
*/
int getServerProtocolVersion();
void setServerProtocolVersion(int serverProtocolVersion);
/**
* Returns the username associated with this connection.
* This is set once the connection enters the {@link State#PLAY} state.
*
* @return username, set when entering the {@link State#PLAY} state
*/
@Nullable String getUsername();
void setUsername(String username);
/**
* Returns the uuid associated with this connection.
* This is set once the connection enters the {@link State#PLAY} state.
*
* @return uuid, set when entering the {@link State#PLAY} state
*/
@Nullable UUID getUuid();
void setUuid(UUID uuid);
/**
* Returns the user's pipeline.
*
* @return protocol pipeline
*/
ProtocolPipeline getPipeline();
void setPipeline(ProtocolPipeline pipeline);
/**
* Returns the user connection this info represents.
*
* @return user connection
*/
@Deprecated/*(forRemoval = true)*/
UserConnection getUser();
}
@@ -0,0 +1,44 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.connection;
/**
* Dummy interface used to explicitly identify objects storable in user connections.
*
* @see UserConnection#get(Class)
* @see UserConnection#put(StorableObject)
*/
public interface StorableObject {
/**
* Returns whether the object should be uncached on a server switch.
*
* @return whether the object should be uncached on a server switch
*/
default boolean clearOnServerSwitch() {
return true;
}
default void onRemove() {
}
}
@@ -0,0 +1,35 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.connection;
public abstract class StoredObject implements StorableObject {
private final UserConnection user;
protected StoredObject(UserConnection user) {
this.user = user;
}
public UserConnection getUser() {
return user;
}
}
@@ -0,0 +1,339 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.connection;
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.PacketTracker;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.exception.CancelException;
import com.viaversion.viaversion.exception.InformativeException;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
import java.util.function.Function;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface UserConnection {
/**
* Get an object from the storage.
*
* @param objectClass The class of the object to get
* @param <T> The type of the class you want to get.
* @return The requested object
*/
@Nullable <T extends StorableObject> T get(Class<T> objectClass);
/**
* Check if the storage has an object.
*
* @param objectClass The object class to check
* @return True if the object is in the storage
*/
boolean has(Class<? extends StorableObject> objectClass);
/**
* Removes and returns an object from the storage.
*
* @param objectClass class of the object to get
* @param <T> type of the class you want to get
* @return removed storable object if present
*/
@Nullable <T extends StorableObject> T remove(Class<T> objectClass);
/**
* Put an object into the stored objects based on class.
*
* @param object The object to store.
*/
void put(StorableObject object);
/**
* Returns a collection of entity trackers currently registered.
*
* @return collection of entity trackers currently registered
*/
Collection<EntityTracker> getEntityTrackers();
/**
* Returns the entity tracker by the given protocol class if present.
*
* @param protocolClass protocol class
* @param <T> entity tracker type
* @return entity tracker if present
*/
@Nullable <T extends EntityTracker> T getEntityTracker(Class<? extends Protocol> protocolClass);
/**
* Adds an entity tracker to the user connection.
* Does not override existing entity trackers.
*
* @param protocolClass protocol class
* @param tracker entity tracker
*/
void addEntityTracker(Class<? extends Protocol> protocolClass, EntityTracker tracker);
/**
* Clear stored objects and entity trackers.
*/
default void clearStoredObjects() {
clearStoredObjects(false);
}
/**
* Clear stored objects and entity trackers.
* If cleared for a proxy server switch, some stored objects and tracker data will be retained.
*
* @param isServerSwitch whether the clear is due to a server switch
*/
void clearStoredObjects(boolean isServerSwitch);
/**
* Sends a raw packet to the connection on the current thread.
*
* @param packet raw packet to send
*/
void sendRawPacket(ByteBuf packet);
/**
* Send a raw packet to the player, submitted to the netty event loop.
*
* @param packet raw packet to send
*/
void scheduleSendRawPacket(ByteBuf packet);
/**
* Send a raw packet to the player with returning the future.
*
* @param packet The raw packet to send
* @return ChannelFuture of the packet being sent
*/
ChannelFuture sendRawPacketFuture(ByteBuf packet);
/**
* Returns the user's packet tracker used for the inbuilt packet-limiter.
*
* @return packet tracker
*/
PacketTracker getPacketTracker();
/**
* Disconnect a connection.
*
* @param reason The reason to use, not used if player is not active.
*/
void disconnect(String reason);
/**
* Sends a raw packet to the server on the current thread.
*
* @param packet raw packet to be sent
*/
void sendRawPacketToServer(ByteBuf packet);
/**
* Sends a raw packet to the server, submitted to the netty event loop.
*
* @param packet raw packet to be sent
*/
void scheduleSendRawPacketToServer(ByteBuf packet);
/**
* Monitors serverbound packets and returns whether a packet can/should be processed.
*
* @return false if this packet should be cancelled
*/
boolean checkServerboundPacket();
/**
* Monitors clientbound packets and returns whether a packet can/should be processed.
*
* @return false if this packet should be cancelled
*/
boolean checkClientboundPacket();
/**
* @see #checkClientboundPacket()
* @see #checkServerboundPacket()
*/
default boolean checkIncomingPacket() {
return isClientSide() ? checkClientboundPacket() : checkServerboundPacket();
}
/**
* @see #checkClientboundPacket()
* @see #checkServerboundPacket()
*/
default boolean checkOutgoingPacket() {
return isClientSide() ? checkServerboundPacket() : checkClientboundPacket();
}
/**
* Checks if packets needs transforming.
*
* @return whether packets should be passed through
*/
boolean shouldTransformPacket();
/**
* Transforms the clientbound packet contained in ByteBuf.
*
* @param buf ByteBuf with packet id and packet contents
* @param cancelSupplier function called with original CancelException for generating the Exception when the packet is cancelled
* @throws CancelException if the packet should be cancelled
* @throws InformativeException if packet transforming failed
* @throws Exception if any other processing outside of transforming fails
*/
void transformClientbound(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception;
/**
* Transforms the serverbound packet contained in ByteBuf.
*
* @param buf ByteBuf with packet id and packet contents
* @param cancelSupplier Function called with original CancelException for generating the Exception used when
* packet is cancelled
* @throws CancelException if the packet should be cancelled
* @throws InformativeException if packet transforming failed
* @throws Exception if any other processing outside of transforming fails
*/
void transformServerbound(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception;
/**
* Transforms the packet depending on whether the connection is clientside or not.
*
* @see #transformClientbound(ByteBuf, Function)
* @see #transformServerbound(ByteBuf, Function)
*/
default void transformOutgoing(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception {
if (isClientSide()) {
transformServerbound(buf, cancelSupplier);
} else {
transformClientbound(buf, cancelSupplier);
}
}
/**
* Transforms the packet depending on whether the connection is clientside or not.
*
* @see #transformClientbound(ByteBuf, Function)
* @see #transformServerbound(ByteBuf, Function)
*/
default void transformIncoming(ByteBuf buf, Function<Throwable, Exception> cancelSupplier) throws Exception {
if (isClientSide()) {
transformClientbound(buf, cancelSupplier);
} else {
transformServerbound(buf, cancelSupplier);
}
}
/**
* Returns the internal id incremented for each new connection.
*
* @return internal id
*/
long getId();
/**
* Returns the netty channel if present.
*
* @return netty channel if present
*/
@Nullable Channel getChannel();
/**
* Returns info containing the current protocol state and userdata.
*
* @return info containing the current protocol state and userdata
*/
ProtocolInfo getProtocolInfo();
/**
* Returns a map of stored objects.
*
* @return map of stored objects
* @see #has(Class)
* @see #get(Class)
* @see #put(StorableObject)
*/
Map<Class<?>, StorableObject> getStoredObjects();
/**
* Returns whether the connection has protocols other than the base protocol applied.
*
* @return whether the connection is active
*/
boolean isActive();
void setActive(boolean active);
/**
* Returns whether the connection is pending a disconnect, initiated through {@link #disconnect(String)}.
*
* @return whether the connection is pending a disconnect
*/
boolean isPendingDisconnect();
void setPendingDisconnect(boolean pendingDisconnect);
/**
* Returns whether this is a client-side connection.
* This is a mod integrated into the client itself, or for example a backend Velocity connection.
*
* @return whether this is a client-side connection
*/
boolean isClientSide();
/**
* Returns whether {@link ViaVersionConfig#blockedProtocolVersions()} should be checked for this connection.
*
* @return whether blocked protocols should be applied
*/
boolean shouldApplyBlockProtocol();
/**
* Returns whether the packet limiter applies to this user.
*
* @return whether the packet limiter applies to this user
*/
boolean isPacketLimiterEnabled();
/**
* Sets the status of the packet limiter.
*
* @param packetLimiterEnabled whether the packet limiter should be enabled
*/
void setPacketLimiterEnabled(boolean packetLimiterEnabled);
/**
* Returns a newly generated uuid that will let a packet be passed through without
* transformig its contents if used together with {@link PacketWrapper#PASSTHROUGH_ID}.
*
* @return generated passthrough token
*/
UUID generatePassthroughToken();
}
@@ -0,0 +1,42 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
public interface BiMappings extends Mappings {
/**
* Returns the inverse of the bimappings.
*
* @return inverse of the bimappings
*/
@Override
BiMappings inverse();
static BiMappings of(final Mappings mappings) {
return of(mappings, mappings.inverse());
}
static BiMappings of(final Mappings mappings, final Mappings inverse) {
return new BiMappingsBase(mappings, inverse);
}
}
@@ -0,0 +1,65 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
public class BiMappingsBase implements BiMappings {
protected final Mappings mappings;
private final BiMappingsBase inverse;
protected BiMappingsBase(final Mappings mappings, final Mappings inverse) {
this.mappings = mappings;
this.inverse = new BiMappingsBase(inverse, this);
}
private BiMappingsBase(final Mappings mappings, final BiMappingsBase inverse) {
this.mappings = mappings;
this.inverse = inverse;
}
@Override
public int getNewId(final int id) {
return mappings.getNewId(id);
}
@Override
public void setNewId(final int id, final int mappedId) {
mappings.setNewId(id, mappedId);
inverse.mappings.setNewId(mappedId, id);
}
@Override
public int size() {
return mappings.size();
}
@Override
public int mappedSize() {
return mappings.mappedSize();
}
@Override
public BiMappings inverse() {
return this.inverse;
}
}
@@ -0,0 +1,79 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Mappings containing the full string identifier mappings.
*/
public interface FullMappings extends Mappings {
@Deprecated
default Mappings mappings() {
return this;
}
/**
* Returns the unmapped integer id for the given identifier, or -1 if not found.
*
* @param identifier unmapped string identifier
* @return unmapped int id, or -1 if not found
*/
int id(String identifier);
/**
* Returns the mapped integer id for the given mapped identifier, or -1 if not found.
*
* @param mappedIdentifier mapped string identifier
* @return mapped int id, or -1 if not found
*/
int mappedId(String mappedIdentifier);
/**
* Returns the unmapped string identifier for the given mapped id.
*
* @param id unmapped id
* @return unmapped string identifier
*/
String identifier(int id);
/**
* Returns the mapped string identifier for the given mapped id.
*
* @param mappedId mapped id
* @return mapped string identifier
*/
String mappedIdentifier(int mappedId);
/**
* Returns the mapped string identifier for the given unmapped identifier.
*
* @param identifier unmapped identifier
* @return mapped string identifier, or null if not found
*/
@Nullable String mappedIdentifier(String identifier);
@Override
FullMappings inverse();
}
@@ -0,0 +1,126 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import com.viaversion.viaversion.util.Key;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public class FullMappingsBase implements FullMappings {
private static final String[] EMPTY_ARRAY = new String[0];
private final Object2IntMap<String> stringToId;
private final Object2IntMap<String> mappedStringToId;
private final String[] idToString;
private final String[] mappedIdToString;
private final Mappings mappings;
public FullMappingsBase(final List<String> unmappedIdentifiers, final List<String> mappedIdentifiers, final Mappings mappings) {
this.mappings = mappings;
this.stringToId = toInverseMap(unmappedIdentifiers);
this.mappedStringToId = toInverseMap(mappedIdentifiers);
this.idToString = unmappedIdentifiers.toArray(EMPTY_ARRAY);
this.mappedIdToString = mappedIdentifiers.toArray(EMPTY_ARRAY);
}
private FullMappingsBase(final Object2IntMap<String> stringToId, final Object2IntMap<String> mappedStringToId, final String[] idToString, final String[] mappedIdToString, final Mappings mappings) {
this.stringToId = stringToId;
this.mappedStringToId = mappedStringToId;
this.idToString = idToString;
this.mappedIdToString = mappedIdToString;
this.mappings = mappings;
}
@Override
public Mappings mappings() {
return mappings;
}
@Override
public int id(final String identifier) {
return stringToId.getInt(Key.stripMinecraftNamespace(identifier));
}
@Override
public int mappedId(final String mappedIdentifier) {
return mappedStringToId.getInt(Key.stripMinecraftNamespace(mappedIdentifier));
}
@Override
public String identifier(final int id) {
final String identifier = idToString[id];
return Key.namespaced(identifier);
}
@Override
public String mappedIdentifier(final int mappedId) {
final String identifier = mappedIdToString[mappedId];
return Key.namespaced(identifier);
}
@Override
public @Nullable String mappedIdentifier(final String identifier) {
final int id = id(identifier);
if (id == -1) {
return null;
}
final int mappedId = mappings.getNewId(id);
return mappedId != -1 ? mappedIdentifier(mappedId) : null;
}
@Override
public int getNewId(int id) {
return mappings.getNewId(id);
}
@Override
public void setNewId(int id, int mappedId) {
mappings.setNewId(id, mappedId);
}
@Override
public int size() {
return mappings.size();
}
@Override
public int mappedSize() {
return mappings.mappedSize();
}
@Override
public FullMappings inverse() {
return new FullMappingsBase(mappedStringToId, stringToId, mappedIdToString, idToString, mappings.inverse());
}
private static Object2IntMap<String> toInverseMap(final List<String> list) {
final Object2IntMap<String> map = new Object2IntOpenHashMap<>(list.size());
map.defaultReturnValue(-1);
for (int i = 0; i < list.size(); i++) {
map.put(list.get(i), i);
}
return map;
}
}
@@ -0,0 +1,59 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
public class IdentityMappings implements Mappings {
private final int size;
private final int mappedSize;
public IdentityMappings(final int size, final int mappedSize) {
this.size = size;
this.mappedSize = mappedSize;
}
@Override
public int getNewId(final int id) {
return id >= 0 && id < size ? id : -1;
}
@Override
public void setNewId(final int id, final int mappedId) {
throw new UnsupportedOperationException();
}
@Override
public int size() {
return size;
}
@Override
public int mappedSize() {
return mappedSize;
}
@Override
public Mappings inverse() {
return new IdentityMappings(mappedSize, size);
}
}
@@ -0,0 +1,71 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import com.viaversion.viaversion.util.Int2IntBiMap;
public class Int2IntMapBiMappings implements BiMappings {
private final Int2IntBiMap mappings;
private final Int2IntMapBiMappings inverse;
protected Int2IntMapBiMappings(final Int2IntBiMap mappings) {
this.mappings = mappings;
this.inverse = new Int2IntMapBiMappings(mappings.inverse(), this);
mappings.defaultReturnValue(-1);
}
private Int2IntMapBiMappings(final Int2IntBiMap mappings, final Int2IntMapBiMappings inverse) {
this.mappings = mappings;
this.inverse = inverse;
}
public static Int2IntMapBiMappings of(final Int2IntBiMap mappings) {
return new Int2IntMapBiMappings(mappings);
}
@Override
public int getNewId(final int id) {
return mappings.get(id);
}
@Override
public void setNewId(final int id, final int mappedId) {
mappings.put(id, mappedId);
}
@Override
public int size() {
return mappings.size();
}
@Override
public int mappedSize() {
return mappings.inverse().size();
}
@Override
public BiMappings inverse() {
return this.inverse;
}
}
@@ -0,0 +1,77 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
public class Int2IntMapMappings implements Mappings {
private final Int2IntMap mappings;
private final int mappedIds;
protected Int2IntMapMappings(final Int2IntMap mappings, final int mappedIds) {
this.mappings = mappings;
this.mappedIds = mappedIds;
mappings.defaultReturnValue(-1);
}
public static Int2IntMapMappings of(final Int2IntMap mappings, final int mappedIds) {
return new Int2IntMapMappings(mappings, mappedIds);
}
public static Int2IntMapMappings of() {
return new Int2IntMapMappings(new Int2IntOpenHashMap(), -1);
}
@Override
public int getNewId(final int id) {
return mappings.get(id);
}
@Override
public void setNewId(final int id, final int mappedId) {
mappings.put(id, mappedId);
}
@Override
public int size() {
return mappings.size();
}
@Override
public int mappedSize() {
return mappedIds;
}
@Override
public Mappings inverse() {
final Int2IntMap inverse = new Int2IntOpenHashMap();
inverse.defaultReturnValue(-1);
for (final Int2IntMap.Entry entry : mappings.int2IntEntrySet()) {
if (entry.getIntValue() != -1) {
inverse.putIfAbsent(entry.getIntValue(), entry.getIntKey());
}
}
return of(inverse, size());
}
}
@@ -0,0 +1,81 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import java.util.Arrays;
public class IntArrayMappings implements Mappings {
private final int[] mappings;
private final int mappedIds;
protected IntArrayMappings(final int[] mappings, final int mappedIds) {
this.mappings = mappings;
this.mappedIds = mappedIds;
}
public static IntArrayMappings of(final int[] mappings, final int mappedIds) {
return new IntArrayMappings(mappings, mappedIds);
}
@Deprecated
public static Builder<IntArrayMappings> builder() {
return Mappings.builder(IntArrayMappings::new);
}
@Override
public int getNewId(int id) {
return id >= 0 && id < mappings.length ? mappings[id] : -1;
}
@Override
public void setNewId(int id, int mappedId) {
mappings[id] = mappedId;
}
@Override
public int size() {
return mappings.length;
}
@Override
public int mappedSize() {
return mappedIds;
}
@Override
public Mappings inverse() {
final int[] inverse = new int[mappedIds];
Arrays.fill(inverse, -1);
for (int id = 0; id < mappings.length; id++) {
final int mappedId = mappings[id];
if (mappedId != -1 && inverse[mappedId] == -1) {
inverse[mappedId] = id;
}
}
return of(inverse, mappings.length);
}
public int[] raw() {
return mappings;
}
}
@@ -0,0 +1,113 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.TagData;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface MappingData {
/**
* Loads the mapping data.
*/
void load();
/**
* Returns the mapped block state id, or -1 if unmapped.
*
* @param id unmapped block state id
* @return mapped block state id, or -1 if unmapped
* @throws NullPointerException if this mappingdata does not hold block state mappings
*/
int getNewBlockStateId(int id);
/**
* Returns the mapped block id, or -1 if unmapped.
*
* @param id unmapped block id
* @return mapped block id, or -1 if unmapped
* @throws NullPointerException if this mappingdata does not hold block mappings
*/
int getNewBlockId(int id);
/**
* Returns the mapped item id, or -1 if unmapped.
*
* @param id unmapped item id
* @return mapped item id, or -1 if unmapped
* @throws NullPointerException if this mappingdata does not hold item mappings
*/
int getNewItemId(int id);
/**
* Returns the backwards mapped item id, or -1 if unmapped.
*
* @param id mapped item id
* @return backwards mapped item id, or -1 if unmapped
* @throws NullPointerException if this mappingdata does not hold item mappings
*/
int getOldItemId(int id);
/**
* Returns the mapped particle id, or -1 if unmapped.
*
* @param id unmapped particle id
* @return mapped particle id, or -1 if unmapped
* @throws NullPointerException if this mappingdata does not hold particle mappings
*/
int getNewParticleId(int id);
/**
* Returns a list of tags to send if present.
*
* @param type registry tag type
* @return list of tags to send if present, else null
*/
@Nullable List<TagData> getTags(RegistryType type);
@Nullable BiMappings getItemMappings();
@Nullable ParticleMappings getParticleMappings();
@Nullable Mappings getBlockMappings();
@Nullable Mappings getBlockEntityMappings();
@Nullable Mappings getBlockStateMappings();
@Nullable Mappings getSoundMappings();
@Nullable Mappings getStatisticsMappings();
@Nullable Mappings getMenuMappings();
@Nullable Mappings getEnchantmentMappings();
@Nullable FullMappings getEntityMappings();
@Nullable FullMappings getArgumentTypeMappings();
@Nullable Mappings getPaintingMappings();
}
@@ -0,0 +1,256 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.TagData;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.checkerframework.checker.nullness.qual.Nullable;
public class MappingDataBase implements MappingData {
protected final String unmappedVersion;
protected final String mappedVersion;
protected BiMappings itemMappings;
protected FullMappings argumentTypeMappings;
protected FullMappings entityMappings;
protected ParticleMappings particleMappings;
protected Mappings blockMappings;
protected Mappings blockStateMappings;
protected Mappings blockEntityMappings;
protected Mappings soundMappings;
protected Mappings statisticsMappings;
protected Mappings enchantmentMappings;
protected Mappings paintingMappings;
protected Mappings menuMappings;
protected Map<RegistryType, List<TagData>> tags;
public MappingDataBase(final String unmappedVersion, final String mappedVersion) {
this.unmappedVersion = unmappedVersion;
this.mappedVersion = mappedVersion;
}
@Override
public void load() {
if (Via.getManager().isDebug()) {
getLogger().info("Loading " + unmappedVersion + " -> " + mappedVersion + " mappings...");
}
final CompoundTag data = readNBTFile("mappings-" + unmappedVersion + "to" + mappedVersion + ".nbt");
blockMappings = loadMappings(data, "blocks");
blockStateMappings = loadMappings(data, "blockstates");
blockEntityMappings = loadMappings(data, "blockentities");
soundMappings = loadMappings(data, "sounds");
statisticsMappings = loadMappings(data, "statistics");
menuMappings = loadMappings(data, "menus");
enchantmentMappings = loadMappings(data, "enchantments");
paintingMappings = loadMappings(data, "paintings");
itemMappings = loadBiMappings(data, "items");
final CompoundTag unmappedIdentifierData = MappingDataLoader.loadNBT("identifiers-" + unmappedVersion + ".nbt", true);
final CompoundTag mappedIdentifierData = MappingDataLoader.loadNBT("identifiers-" + mappedVersion + ".nbt", true);
if (unmappedIdentifierData != null && mappedIdentifierData != null) {
entityMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "entities");
argumentTypeMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "argumenttypes");
final ListTag unmappedParticles = unmappedIdentifierData.get("particles");
final ListTag mappedParticles = mappedIdentifierData.get("particles");
if (unmappedParticles != null && mappedParticles != null) {
Mappings particleMappings = loadMappings(data, "particles");
if (particleMappings == null) {
particleMappings = new IdentityMappings(unmappedParticles.size(), mappedParticles.size());
}
final List<String> identifiers = unmappedParticles.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList());
final List<String> mappedIdentifiers = mappedParticles.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList());
this.particleMappings = new ParticleMappings(identifiers, mappedIdentifiers, particleMappings);
}
}
final CompoundTag tagsTag = data.get("tags");
if (tagsTag != null) {
this.tags = new EnumMap<>(RegistryType.class);
loadTags(RegistryType.ITEM, tagsTag);
loadTags(RegistryType.BLOCK, tagsTag);
}
loadExtras(data);
}
protected @Nullable CompoundTag readNBTFile(final String name) {
return MappingDataLoader.loadNBT(name);
}
protected @Nullable Mappings loadMappings(final CompoundTag data, final String key) {
return MappingDataLoader.loadMappings(data, key);
}
protected @Nullable FullMappings loadFullMappings(final CompoundTag data, final CompoundTag unmappedIdentifiers, final CompoundTag mappedIdentifiers, final String key) {
return MappingDataLoader.loadFullMappings(data, unmappedIdentifiers, mappedIdentifiers, key);
}
protected @Nullable BiMappings loadBiMappings(final CompoundTag data, final String key) {
final Mappings mappings = loadMappings(data, key);
return mappings != null ? BiMappings.of(mappings) : null;
}
private void loadTags(final RegistryType type, final CompoundTag data) {
final CompoundTag tag = data.get(type.resourceLocation());
if (tag == null) {
return;
}
final List<TagData> tagsList = new ArrayList<>(tags.size());
for (final Map.Entry<String, Tag> entry : tag.entrySet()) {
final IntArrayTag entries = (IntArrayTag) entry.getValue();
tagsList.add(new TagData(entry.getKey(), entries.getValue()));
}
this.tags.put(type, tagsList);
}
@Override
public int getNewBlockStateId(final int id) {
return checkValidity(id, blockStateMappings.getNewId(id), "blockstate");
}
@Override
public int getNewBlockId(final int id) {
return checkValidity(id, blockMappings.getNewId(id), "block");
}
@Override
public int getNewItemId(final int id) {
return checkValidity(id, itemMappings.getNewId(id), "item");
}
@Override
public int getOldItemId(final int id) {
return itemMappings.inverse().getNewIdOrDefault(id, 1);
}
@Override
public int getNewParticleId(final int id) {
return checkValidity(id, particleMappings.getNewId(id), "particles");
}
@Override
public @Nullable List<TagData> getTags(final RegistryType type) {
return tags != null ? tags.get(type) : null;
}
@Override
public @Nullable BiMappings getItemMappings() {
return itemMappings;
}
@Override
public @Nullable ParticleMappings getParticleMappings() {
return particleMappings;
}
@Override
public @Nullable Mappings getBlockMappings() {
return blockMappings;
}
@Override
public @Nullable Mappings getBlockEntityMappings() {
return blockEntityMappings;
}
@Override
public @Nullable Mappings getBlockStateMappings() {
return blockStateMappings;
}
@Override
public @Nullable Mappings getSoundMappings() {
return soundMappings;
}
@Override
public @Nullable Mappings getStatisticsMappings() {
return statisticsMappings;
}
@Override
public @Nullable Mappings getMenuMappings() {
return menuMappings;
}
@Override
public @Nullable Mappings getEnchantmentMappings() {
return enchantmentMappings;
}
@Override
public @Nullable FullMappings getEntityMappings() {
return entityMappings;
}
@Override
public @Nullable FullMappings getArgumentTypeMappings() {
return argumentTypeMappings;
}
@Override
public @Nullable Mappings getPaintingMappings() {
return paintingMappings;
}
protected Logger getLogger() {
return Via.getPlatform().getLogger();
}
/**
* Returns the given mapped id if valid, else 0 with a warning logged to the console.
*
* @param id unmapped id
* @param mappedId mapped id
* @param type mapping type (e.g. "item")
* @return the given mapped id if valid, else 0
*/
protected int checkValidity(final int id, final int mappedId, final String type) {
if (mappedId == -1) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
getLogger().warning(String.format("Missing %s %s for %s %s %d", mappedVersion, type, unmappedVersion, type, id));
}
return 0;
}
return mappedId;
}
protected void loadExtras(final CompoundTag data) {
}
}
@@ -0,0 +1,352 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import com.github.steveice10.opennbt.NBTIO;
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.google.common.annotations.Beta;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonIOException;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.util.GsonUtil;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import org.checkerframework.checker.nullness.qual.Nullable;
public final class MappingDataLoader {
private static final byte DIRECT_ID = 0;
private static final byte SHIFTS_ID = 1;
private static final byte CHANGES_ID = 2;
private static final byte IDENTITY_ID = 3;
private static final Map<String, CompoundTag> MAPPINGS_CACHE = new HashMap<>();
private static boolean cacheValid = true;
@Deprecated/*(forRemoval = true)*/
public static void enableMappingsCache() {
// Always enabled
}
public static void clearCache() {
MAPPINGS_CACHE.clear();
cacheValid = false;
}
/**
* Loads the file from the plugin folder if present, else from the bundled resources.
*
* @return loaded json object, or null if not found or invalid
*/
public static @Nullable JsonObject loadFromDataDir(final String name) {
final File file = new File(Via.getPlatform().getDataFolder(), name);
if (!file.exists()) {
return loadData(name);
}
// Load the file from the platform's directory if present
try (final FileReader reader = new FileReader(file)) {
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
} catch (final JsonSyntaxException e) {
// Users might mess up the format, so let's catch the syntax error
Via.getPlatform().getLogger().warning(name + " is badly formatted!");
throw new RuntimeException(e);
} catch (final IOException | JsonIOException e) {
throw new RuntimeException(e);
}
}
/**
* Loads the file from the bundled resources.
*
* @return loaded json object from bundled resources if present
*/
public static @Nullable JsonObject loadData(final String name) {
final InputStream stream = getResource(name);
if (stream == null) {
return null;
}
try (final InputStreamReader reader = new InputStreamReader(stream)) {
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
public static @Nullable CompoundTag loadNBT(final String name, final boolean cache) {
if (!cacheValid) {
return loadNBTFromFile(name);
}
CompoundTag data = MAPPINGS_CACHE.get(name);
if (data != null) {
return data;
}
data = loadNBTFromFile(name);
if (cache && data != null) {
MAPPINGS_CACHE.put(name, data);
}
return data;
}
public static @Nullable CompoundTag loadNBT(final String name) {
return loadNBT(name, false);
}
private static @Nullable CompoundTag loadNBTFromFile(final String name) {
final InputStream resource = getResource(name);
if (resource == null) {
return null;
}
try (final InputStream stream = resource) {
return NBTIO.readTag(stream);
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
public static @Nullable Mappings loadMappings(final CompoundTag mappingsTag, final String key) {
return loadMappings(mappingsTag, key, size -> {
final int[] array = new int[size];
Arrays.fill(array, -1);
return array;
}, (array, id, mappedId) -> array[id] = mappedId, IntArrayMappings::of);
}
@Beta
public static <M extends Mappings, V> @Nullable Mappings loadMappings(
final CompoundTag mappingsTag,
final String key,
final MappingHolderSupplier<V> holderSupplier,
final AddConsumer<V> addConsumer,
final MappingsSupplier<M, V> mappingsSupplier
) {
final CompoundTag tag = mappingsTag.get(key);
if (tag == null) {
return null;
}
final ByteTag serializationStragetyTag = tag.get("id");
final IntTag mappedSizeTag = tag.get("mappedSize");
final byte strategy = serializationStragetyTag.asByte();
final V mappings;
if (strategy == DIRECT_ID) {
final IntArrayTag valuesTag = tag.get("val");
return IntArrayMappings.of(valuesTag.getValue(), mappedSizeTag.asInt());
} else if (strategy == SHIFTS_ID) {
final IntArrayTag shiftsAtTag = tag.get("at");
final IntArrayTag shiftsTag = tag.get("to");
final IntTag sizeTag = tag.get("size");
final int[] shiftsAt = shiftsAtTag.getValue();
final int[] shiftsTo = shiftsTag.getValue();
final int size = sizeTag.asInt();
mappings = holderSupplier.get(size);
// Handle values until first shift
if (shiftsAt[0] != 0) {
final int to = shiftsAt[0];
for (int id = 0; id < to; id++) {
addConsumer.addTo(mappings, id, id);
}
}
// Handle shifts
for (int i = 0; i < shiftsAt.length; i++) {
final int from = shiftsAt[i];
final int to = i == shiftsAt.length - 1 ? size : shiftsAt[i + 1];
int mappedId = shiftsTo[i];
for (int id = from; id < to; id++) {
addConsumer.addTo(mappings, id, mappedId++);
}
}
} else if (strategy == CHANGES_ID) {
final IntArrayTag changesAtTag = tag.get("at");
final IntArrayTag valuesTag = tag.get("val");
final IntTag sizeTag = tag.get("size");
final boolean fillBetween = tag.get("nofill") == null;
final int[] changesAt = changesAtTag.getValue();
final int[] values = valuesTag.getValue();
mappings = holderSupplier.get(sizeTag.asInt());
for (int i = 0; i < changesAt.length; i++) {
final int id = changesAt[i];
if (fillBetween) {
// Fill from after the last change to before this change with unchanged ids
final int previousId = i != 0 ? changesAt[i - 1] + 1 : 0;
for (int identity = previousId; identity < id; identity++) {
addConsumer.addTo(mappings, identity, identity);
}
}
// Assign the changed value
addConsumer.addTo(mappings, id, values[i]);
}
} else if (strategy == IDENTITY_ID) {
final IntTag sizeTag = tag.get("size");
return new IdentityMappings(sizeTag.asInt(), mappedSizeTag.asInt());
} else {
throw new IllegalArgumentException("Unknown serialization strategy: " + strategy);
}
return mappingsSupplier.create(mappings, mappedSizeTag.asInt());
}
public static FullMappings loadFullMappings(final CompoundTag mappingsTag, final CompoundTag unmappedIdentifiers, final CompoundTag mappedIdentifiers, final String key) {
final ListTag unmappedElements = unmappedIdentifiers.get(key);
final ListTag mappedElements = mappedIdentifiers.get(key);
if (unmappedElements == null || mappedElements == null) {
return null;
}
Mappings mappings = loadMappings(mappingsTag, key);
if (mappings == null) {
mappings = new IdentityMappings(unmappedElements.size(), mappedElements.size());
}
return new FullMappingsBase(
unmappedElements.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList()),
mappedElements.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList()),
mappings
);
}
@Deprecated
public static void mapIdentifiers(final int[] output, final JsonObject unmappedIdentifiers, final JsonObject mappedIdentifiers, @Nullable final JsonObject diffIdentifiers, final boolean warnOnMissing) {
final Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(mappedIdentifiers);
for (final Map.Entry<String, JsonElement> entry : unmappedIdentifiers.entrySet()) {
final int id = Integer.parseInt(entry.getKey());
final int mappedId = mapIdentifierEntry(id, entry.getValue().getAsString(), newIdentifierMap, diffIdentifiers, warnOnMissing);
if (mappedId != -1) {
output[id] = mappedId;
}
}
}
private static int mapIdentifierEntry(final int id, final String val, final Object2IntMap<String> mappedIdentifiers, @Nullable final JsonObject diffIdentifiers, final boolean warnOnMissing) {
int mappedId = mappedIdentifiers.getInt(val);
if (mappedId == -1) {
// Search in diff mappings
if (diffIdentifiers != null) {
JsonElement diffElement = diffIdentifiers.get(val);
if (diffElement != null || (diffElement = diffIdentifiers.get(Integer.toString(id))) != null) {
final String mappedName = diffElement.getAsString();
if (mappedName.isEmpty()) {
return -1; // "empty" remaps without warnings
}
mappedId = mappedIdentifiers.getInt(mappedName);
}
}
if (mappedId == -1) {
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + val + " :( ");
}
return -1;
}
}
return mappedId;
}
@Deprecated
public static void mapIdentifiers(final int[] output, final JsonArray unmappedIdentifiers, final JsonArray mappedIdentifiers, @Nullable final JsonObject diffIdentifiers, final boolean warnOnMissing) {
final Object2IntMap<String> newIdentifierMap = MappingDataLoader.arrayToMap(mappedIdentifiers);
for (int id = 0; id < unmappedIdentifiers.size(); id++) {
final JsonElement unmappedIdentifier = unmappedIdentifiers.get(id);
final int mappedId = mapIdentifierEntry(id, unmappedIdentifier.getAsString(), newIdentifierMap, diffIdentifiers, warnOnMissing);
if (mappedId != -1) {
output[id] = mappedId;
}
}
}
/**
* Returns a map of the object entries hashed by their id value.
*
* @param object json object
* @return map with indexes hashed by their id value
*/
public static Object2IntMap<String> indexedObjectToMap(final JsonObject object) {
final Object2IntMap<String> map = new Object2IntOpenHashMap<>(object.size(), .99F);
map.defaultReturnValue(-1);
for (final Map.Entry<String, JsonElement> entry : object.entrySet()) {
map.put(entry.getValue().getAsString(), Integer.parseInt(entry.getKey()));
}
return map;
}
/**
* Returns a map of the array entries hashed by their id value.
*
* @param array json array
* @return map with indexes hashed by their id value
*/
public static Object2IntMap<String> arrayToMap(final JsonArray array) {
final Object2IntMap<String> map = new Object2IntOpenHashMap<>(array.size(), .99F);
map.defaultReturnValue(-1);
for (int i = 0; i < array.size(); i++) {
map.put(array.get(i).getAsString(), i);
}
return map;
}
public static @Nullable InputStream getResource(final String name) {
return MappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
}
@FunctionalInterface
public interface AddConsumer<T> {
void addTo(T holder, int id, int mappedId);
}
@FunctionalInterface
public interface MappingHolderSupplier<T> {
T get(int expectedSize);
}
@FunctionalInterface
public interface MappingsSupplier<T extends Mappings, V> {
T create(V mappings, int mappedSize);
}
}
@@ -0,0 +1,211 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Arrays;
public interface Mappings {
/**
* Returns the mapped id from the given id, or -1 if invalid/out of bounds.
*
* @param id unmapped id
* @return mapped id, or -1 if invalid/out of bounds
*/
int getNewId(int id);
/**
* Returns the mapped id from the given id, or the given default if unmapped/invalid.
*
* @param id unmapped id
* @param def fallback return value
* @return mapped id, or def if invalid/out of bounds
*/
default int getNewIdOrDefault(int id, int def) {
final int mappedId = getNewId(id);
return mappedId != -1 ? mappedId : def;
}
/**
* Returns whether the id has a mapping.
*
* @param id unmapped id
* @return whether the id has a mapped id
*/
default boolean contains(int id) {
return getNewId(id) != -1;
}
/**
* Manually maps a specific id.
*
* @param id unmapped id
* @param mappedId mapped id
* @throws IndexOutOfBoundsException if the unmapped id is invalid
*/
void setNewId(int id, int mappedId);
/**
* Returns amount of unmapped entries, being the size of the mapping.
*
* @return amount of unmapped entries
*/
int size();
/**
* Returns the amount of new ids total, even if it does not have a direct mapping.
* Returns -1 if unknown.
*
* @return amount of new ids, or -1 if unknown
*/
int mappedSize();
/**
* Mappings with keys and values swapped.
*
* @return mappings with keys and values swapped
*/
Mappings inverse();
static <T extends Mappings> Builder<T> builder(final MappingsSupplier<T> supplier) {
return new Builder<>(supplier);
}
@FunctionalInterface
interface MappingsSupplier<T extends Mappings> {
T supply(int[] mappings, int mappedIds);
}
@Deprecated
class Builder<T extends Mappings> {
protected final MappingsSupplier<T> supplier;
protected JsonElement unmapped;
protected JsonElement mapped;
protected JsonObject diffMappings;
protected int mappedSize = -1;
protected int size = -1;
protected boolean warnOnMissing = true;
protected Builder(final MappingsSupplier<T> supplier) {
this.supplier = supplier;
}
/**
* Sets a custom entry size different to the size of the unmapped collection.
*
* @param size custom entry size
* @return self
*/
public Builder<T> customEntrySize(final int size) {
this.size = size;
return this;
}
/**
* Sets a custom entry mapped ids count different to the size of the mapped collection.
*
* @param size custom mapped id count
* @return self
*/
public Builder<T> customMappedSize(final int size) {
this.mappedSize = size;
return this;
}
/**
* Sets whether warnings should be logged for missing mapped ids.
*
* @param warnOnMissing whether warnings should be logged for missing mapped ids
* @return self
*/
public Builder<T> warnOnMissing(final boolean warnOnMissing) {
this.warnOnMissing = warnOnMissing;
return this;
}
public Builder<T> unmapped(final JsonArray unmappedArray) {
this.unmapped = unmappedArray;
return this;
}
public Builder<T> unmapped(final JsonObject unmappedObject) {
this.unmapped = unmappedObject;
return this;
}
public Builder<T> mapped(final JsonArray mappedArray) {
this.mapped = mappedArray;
return this;
}
public Builder<T> mapped(final JsonObject mappedObject) {
this.mapped = mappedObject;
return this;
}
public Builder<T> diffMappings(final JsonObject diffMappings) {
this.diffMappings = diffMappings;
return this;
}
public T build() {
final int size = this.size != -1 ? this.size : size(unmapped);
final int mappedSize = this.mappedSize != -1 ? this.mappedSize : size(mapped);
final int[] mappings = new int[size];
Arrays.fill(mappings, -1);
// Do conversion if one is an array and the other an object, otherwise directly map
if (unmapped.isJsonArray()) {
if (mapped.isJsonObject()) {
MappingDataLoader.mapIdentifiers(mappings, toJsonObject(unmapped.getAsJsonArray()), mapped.getAsJsonObject(), diffMappings, warnOnMissing);
} else {
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonArray(), mapped.getAsJsonArray(), diffMappings, warnOnMissing);
}
} else if (mapped.isJsonArray()) {
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonObject(), toJsonObject(mapped.getAsJsonArray()), diffMappings, warnOnMissing);
} else {
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonObject(), mapped.getAsJsonObject(), diffMappings, warnOnMissing);
}
return supplier.supply(mappings, mappedSize);
}
protected int size(final JsonElement element) {
return element.isJsonObject() ? element.getAsJsonObject().size() : element.getAsJsonArray().size();
}
protected JsonObject toJsonObject(final JsonArray array) {
final JsonObject object = new JsonObject();
for (int i = 0; i < array.size(); i++) {
final JsonElement element = array.get(i);
object.add(Integer.toString(i), element);
}
return object;
}
}
}
@@ -0,0 +1,73 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import java.util.List;
public class ParticleMappings extends FullMappingsBase {
private final IntList itemParticleIds = new IntArrayList(4);
private final IntList blockParticleIds = new IntArrayList(4);
public ParticleMappings(final List<String> unmappedIdentifiers, final List<String> mappedIdentifiers, final Mappings mappings) {
super(unmappedIdentifiers, mappedIdentifiers, mappings);
addBlockParticle("block");
addBlockParticle("falling_dust");
addBlockParticle("block_marker");
addItemParticle("item");
}
public boolean addItemParticle(final String identifier) {
final int id = id(identifier);
return id != -1 && itemParticleIds.add(id);
}
public boolean addBlockParticle(final String identifier) {
final int id = id(identifier);
return id != -1 && blockParticleIds.add(id);
}
public boolean isBlockParticle(final int id) {
return blockParticleIds.contains(id);
}
public boolean isItemParticle(final int id) {
return itemParticleIds.contains(id);
}
@Deprecated/*(forRemoval = true)*/
public int getBlockId() {
return id("block");
}
@Deprecated/*(forRemoval = true)*/
public int getFallingDustId() {
return id("falling_dust");
}
@Deprecated/*(forRemoval = true)*/
public int getItemId() {
return id("item");
}
}
@@ -0,0 +1,28 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data.entity;
public interface ClientEntityIdChangeListener {
void setClientEntityId(int entityId);
}
@@ -0,0 +1,30 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data.entity;
public interface DimensionData {
int minY();
int height();
}
@@ -0,0 +1,177 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data.entity;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface EntityTracker {
/**
* User connection the tracker belongs to.
*
* @return user connection
*/
UserConnection user();
/**
* Tracks an entity.
*
* @param id entity id
* @param type entity type
*/
void addEntity(int id, EntityType type);
/**
* Returns whether the entity is currently tracked.
*
* @param id entity id
* @return whether the entity is tracked
*/
boolean hasEntity(int id);
/**
* Returns the tracked entity for the given entity id if present.
*
* @param entityId entity id
* @return tracked entity if tracked
*/
@Nullable TrackedEntity entity(int entityId);
/**
* Entity type of the entity if tracked.
* This returning null does not necessarily mean no entity by the id exists.
*
* @param id entity id
* @return entity type of the entity if tracked
*/
@Nullable EntityType entityType(int id);
/**
* Untracks an entity.
*
* @param id entity id
*/
void removeEntity(int id);
/**
* Clears stored entity types and data.
*/
void clearEntities();
/**
* Returns the stored entity data if an entity with the id is tracked, else null.
* If no data has been initialized yet, it will be done and returned by this method.
*
* @param id entity id
* @return stored entity data if an entity with the id is tracked, else null
* @throws IllegalArgumentException if entity data storage has not been enabled via the implementation
*/
@Nullable StoredEntityData entityData(int id);
/**
* Returns stored entity data if it has previously been initialized by {@link #entityData(int)}, else null.
*
* @param id entity id
* @return stored entity data if it has previously been initialized by {@link #entityData(int)}
* @throws IllegalArgumentException if entity data storage has not been enabled via the implementation
*/
@Nullable StoredEntityData entityDataIfPresent(int id);
/**
* Returns the client entity id or -1 if unset.
*
* @return client entity id or -1 if unset
*/
int clientEntityId();
/**
* Sets the client entity id.
*
* @param clientEntityId client entity id
*/
void setClientEntityId(int clientEntityId);
/**
* Returns the current world section height (block height / 16).
* This is always 16 for sub 1.17 worlds.
*
* @return current world section height
*/
int currentWorldSectionHeight();
/**
* Sets the current world section height.
*
* @param currentWorldSectionHeight world section height
*/
void setCurrentWorldSectionHeight(int currentWorldSectionHeight);
/**
* Returns the minimum y of the current player world.
*
* @return minimum y of the current world
*/
int currentMinY();
/**
* Sets the minimum y of the current player world.
*
* @param currentMinY minimum y of the current world
*/
void setCurrentMinY(int currentMinY);
/**
* Returns the name of the world the player is currently in.
*
* @return world name of the current world
*/
@Nullable String currentWorld();
/**
* Sets the name of the world the player is currently in.
*
* @param currentWorld name of the current world
*/
void setCurrentWorld(String currentWorld);
int biomesSent();
void setBiomesSent(int biomesSent);
EntityType playerType();
@Nullable DimensionData dimensionData(String dimension);
void setDimensions(Map<String, DimensionData> dimensions);
/**
* Adds the client player entity to the tracker.
* If the client entity has not been set yet, this will return false.
*
* @return whether the client has been tracked
*/
boolean trackClientEntity();
}
@@ -0,0 +1,69 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data.entity;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface StoredEntityData {
/**
* Returns the entity type of the stored entity.
*
* @return entity type
*/
EntityType type();
/**
* Checks if the storage contains an object of the given type.
*
* @param objectClass object class to check
* @return whether an object of the given type is in the storage
*/
boolean has(Class<?> objectClass);
/**
* Returns an object from the storage if present.
*
* @param objectClass class of the object to get
* @param <T> object type
* @return object if present
*/
@Nullable <T> T get(Class<T> objectClass);
/**
* Removes and returns an object from the storage if present.
*
* @param objectClass class of the object to remove
* @param <T> object type
* @return removed object if present
*/
@Nullable <T> T remove(Class<T> objectClass);
/**
* Stores an object based on its class.
*
* @param object object to store
*/
void put(Object object);
}
@@ -0,0 +1,58 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data.entity;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
public interface TrackedEntity {
/**
* Returns the type of the stored entity.
*
* @return type of the entity
*/
EntityType entityType();
/**
* Object to hold arbitrary additional data.
*
* @return entity data
*/
StoredEntityData data();
/**
* Returns whether the stored entity currently has any additional data.
*
* @return whether the stored entity currently has additional data
*/
boolean hasData();
/**
* Returns whether metadata has already been sent at least once for this entity.
*
* @return whether metadata has already been sent at least once for this entity
*/
boolean hasSentMetadata();
void sentMetadata(boolean sentMetadata);
}
@@ -0,0 +1,105 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.debug;
import com.google.common.annotations.Beta;
import com.viaversion.viaversion.api.protocol.packet.Direction;
import com.viaversion.viaversion.api.protocol.packet.PacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
@Beta
public interface DebugHandler {
/**
* Returns whether debug mode is enabled.
*
* @return whether debug mode is enabled
*/
boolean enabled();
/**
* Sets debug mode.
*
* @param enabled whether debug should be enabled
*/
void setEnabled(boolean enabled);
/**
* Adds a packet type name to the list of packet types to log.
*
* @param packetTypeName packet type name
*/
void addPacketTypeNameToLog(String packetTypeName);
/**
* Adds a packet id to the list of packet types to log.
* Packets will be checked on each protocol transformer, so this is best used on single protocol pipes.
*
* @param packetType packet type
*/
void addPacketTypeToLog(PacketType packetType);
/**
* Removes a packet type name from the list of packet types to log.
*
* @param packetTypeName packet type name
*/
boolean removePacketTypeNameToLog(String packetTypeName);
/**
* Resets packet type filters.
*/
void clearPacketTypesToLog();
/**
* Returns whether packets should be logged after being transformed.
* Set to true by default.
*
* @return whether packets should be logged after being transformed
*/
boolean logPostPacketTransform();
/**
* Sets whether packets should be logged after being transformed.
*
* @param logPostPacketTransform whether packets should be logged after being transformed
*/
void setLogPostPacketTransform(boolean logPostPacketTransform);
/**
* Returns whether the given packet should be logged.
* If no specific packet type has been added, all packet types will be logged.
*
* @param wrapper packet wrapper
* @param direction packet direction
* @return whether the packet should be logged
*/
boolean shouldLog(PacketWrapper wrapper, Direction direction);
default void enableAndLogIds(final PacketType... packetTypes) {
setEnabled(true);
for (final PacketType packetType : packetTypes) {
addPacketTypeToLog(packetType);
}
}
}
@@ -0,0 +1,58 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.legacy;
import com.viaversion.viaversion.api.legacy.bossbar.BossBar;
import com.viaversion.viaversion.api.legacy.bossbar.BossColor;
import com.viaversion.viaversion.api.legacy.bossbar.BossStyle;
/**
* API only applicable on or to legacy versions of Minecraft.
*
* @param <T> player type
*/
public interface LegacyViaAPI<T> {
/**
* Creates a new bossbar instance. This only works on pre 1.9 servers for 1.9+ clients.
*
* @param title title
* @param health health, between 0 and 1 (inclusive)
* @param color color
* @param style style
* @return new bossbar instance
*/
BossBar createLegacyBossBar(String title, float health, BossColor color, BossStyle style);
/**
* Creates a new bossbar instance with full health. This only works on pre 1.9 servers for 1.9+ clients.
*
* @param title title
* @param color color
* @param style style
* @return new bossbar instance
*/
default BossBar createLegacyBossBar(String title, BossColor color, BossStyle style) {
return createLegacyBossBar(title, 1F, color, style);
}
}
@@ -1,19 +1,39 @@
package us.myles.ViaVersion.api.boss;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.legacy.bossbar;
import com.viaversion.viaversion.api.connection.UserConnection;
import java.util.Set;
import java.util.UUID;
public abstract class BossBar<T> {
public interface BossBar {
/**
* Get the current title
*
* @return the title
*/
public abstract String getTitle();
String getTitle();
/**
* Change the title
@@ -21,14 +41,14 @@ public abstract class BossBar<T> {
* @param title Title can be in either JSON or just text
* @return The BossBar object
*/
public abstract BossBar setTitle(String title);
BossBar setTitle(String title);
/**
* Get the health
*
* @return float between 0F - 1F
*/
public abstract float getHealth();
float getHealth();
/**
* Change the health
@@ -36,29 +56,29 @@ public abstract class BossBar<T> {
* @param health this float has to be between 0F - 1F
* @return The BossBar object
*/
public abstract BossBar setHealth(float health);
BossBar setHealth(float health);
/**
* Get the bossbar color
*
* @return The colour
*/
public abstract BossColor getColor();
BossColor getColor();
/**
* Yay colors!
* Yay, colors!
*
* @param color Whatever color you want!
* @return The BossBar object
*/
public abstract BossBar setColor(BossColor color);
BossBar setColor(BossColor color);
/**
* Get the bosbar style
*
* @return BossStyle
*/
public abstract BossStyle getStyle();
BossStyle getStyle();
/**
* Change the bosbar style
@@ -66,19 +86,7 @@ public abstract class BossBar<T> {
* @param style BossStyle
* @return The BossBar object
*/
public abstract BossBar setStyle(BossStyle style);
/**
* Show the bossbar to a player.
*
* @param player The player
* @return The BossBar object
* @deprecated Deprecated use UUID's instead of Player objects {@link #addPlayer(UUID)}
*/
@Deprecated
public BossBar addPlayer(T player) {
throw new UnsupportedOperationException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
BossBar setStyle(BossStyle style);
/**
* Show the bossbar to a player (uuid). This only works for frontend connections. Use #addConnection(UserConnection) for other types.
@@ -86,7 +94,7 @@ public abstract class BossBar<T> {
* @param player uuid of the player
* @return The BossBar object
*/
public abstract BossBar addPlayer(UUID player);
BossBar addPlayer(UUID player);
/**
* Show the bossbar to a player connection.
@@ -94,31 +102,7 @@ public abstract class BossBar<T> {
* @param conn UserConnection of the connection
* @return The BossBar object
*/
public abstract BossBar addConnection(UserConnection conn);
/**
* add multiple players
*
* @param players list of players
* @return The BossBar object
* @deprecated Deprecated use UUID's instead of Player objects {@link #addPlayer(UUID)}
*/
@Deprecated
public BossBar addPlayers(T... players) {
throw new UnsupportedOperationException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
/**
* Remove the bossbar from a player
*
* @param player The player
* @return The BossBar object
* @deprecated Deprecated use UUID's instead of Player objects {@link #removePlayer(UUID)}
*/
@Deprecated
public BossBar removePlayer(T player) {
throw new UnsupportedOperationException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
BossBar addConnection(UserConnection conn);
/**
* Removes the bossbar from a player. This only works for frontend connections. For others types, use #removeConnection(UserConnection)
@@ -126,7 +110,7 @@ public abstract class BossBar<T> {
* @param uuid The players UUID
* @return The BossBar object
*/
public abstract BossBar removePlayer(UUID uuid);
BossBar removePlayer(UUID uuid);
/**
* Removes the bossbar from a player connection.
@@ -134,7 +118,7 @@ public abstract class BossBar<T> {
* @param conn The UserConnection
* @return The BossBar object
*/
public abstract BossBar removeConnection(UserConnection conn);
BossBar removeConnection(UserConnection conn);
/**
* Add flags
@@ -142,7 +126,7 @@ public abstract class BossBar<T> {
* @param flag The flag to add
* @return The BossBar object
*/
public abstract BossBar addFlag(BossFlag flag);
BossBar addFlag(BossFlag flag);
/**
* Remove flags.
@@ -150,53 +134,53 @@ public abstract class BossBar<T> {
* @param flag The flag to remove
* @return The BossBar object
*/
public abstract BossBar removeFlag(BossFlag flag);
BossBar removeFlag(BossFlag flag);
/**
* @param flag The flag to check against
* @return True if it has the flag
*/
public abstract boolean hasFlag(BossFlag flag);
boolean hasFlag(BossFlag flag);
/**
* Get players. Only returns UUIDs which are front-end. For all connections, use #getConnections()
*
* @return UUIDS from players (sorry I lied)
*/
public abstract Set<UUID> getPlayers();
Set<UUID> getPlayers();
/**
* Get UserConnections.
*
* @return UserConnection from players
*/
public abstract Set<UserConnection> getConnections();
Set<UserConnection> getConnections();
/**
* Show the bossbar to everyone (In the getPlayer set)
*
* @return The BossBar object
*/
public abstract BossBar show();
BossBar show();
/**
* Hide the bossbar from everyone (In the getPlayer set)
*
* @return The BossBar object
*/
public abstract BossBar hide();
BossBar hide();
/**
* Is it visible?
*
* @return visibility changable with show() and hide()
*/
public abstract boolean isVisible();
boolean isVisible();
/**
* Get the UUID of this bossbar
*
* @return Unique Id for this bossbar
*/
public abstract UUID getId();
UUID getId();
}
@@ -0,0 +1,44 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.legacy.bossbar;
public enum BossColor {
PINK(0),
BLUE(1),
RED(2),
GREEN(3),
YELLOW(4),
PURPLE(5),
WHITE(6);
private final int id;
BossColor(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
@@ -0,0 +1,40 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.legacy.bossbar;
public enum BossFlag {
DARKEN_SKY(1),
PLAY_BOSS_MUSIC(2),
CREATE_FOG(4);
private final int id;
BossFlag(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
@@ -0,0 +1,42 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.legacy.bossbar;
public enum BossStyle {
SOLID(0),
SEGMENTED_6(1),
SEGMENTED_10(2),
SEGMENTED_12(3),
SEGMENTED_20(4);
private final int id;
BossStyle(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
@@ -0,0 +1,68 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public interface BlockChangeRecord {
/**
* Returns the relative x coordinate within the chunk section.
*
* @return relative x coordinate within the chunk section
*/
byte getSectionX();
/**
* Returns the relative y coordinate within the chunk section.
*
* @return relative y coordinate within the chunk section
*/
byte getSectionY();
/**
* Returns the relative z coordinate within the chunk section.
*
* @return relative z coordinate within the chunk section
*/
byte getSectionZ();
/**
* Returns the absolute y coordinate based on the given chunk section y.
*
* @param chunkSectionY chunk section
* @return absolute y coordinate
*/
short getY(int chunkSectionY);
/**
* Returns the absolute y coordinate - only works for sub 1.16 protocols.
*
* @return absolute y coordinate
*/
default short getY() {
return getY(-1);
}
int getBlockId();
void setBlockId(int blockId);
}
@@ -0,0 +1,72 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import com.google.common.base.Preconditions;
public class BlockChangeRecord1_16_2 implements BlockChangeRecord {
private final byte sectionX;
private final byte sectionY;
private final byte sectionZ;
private int blockId;
public BlockChangeRecord1_16_2(byte sectionX, byte sectionY, byte sectionZ, int blockId) {
this.sectionX = sectionX;
this.sectionY = sectionY;
this.sectionZ = sectionZ;
this.blockId = blockId;
}
public BlockChangeRecord1_16_2(int sectionX, int sectionY, int sectionZ, int blockId) {
this((byte) sectionX, (byte) sectionY, (byte) sectionZ, blockId);
}
@Override
public byte getSectionX() {
return sectionX;
}
@Override
public byte getSectionY() {
return sectionY;
}
@Override
public byte getSectionZ() {
return sectionZ;
}
@Override
public short getY(int chunkSectionY) {
Preconditions.checkArgument(chunkSectionY >= 0, "Invalid chunkSectionY: " + chunkSectionY);
return (short) ((chunkSectionY << 4) + sectionY);
}
public int getBlockId() {
return blockId;
}
public void setBlockId(int blockId) {
this.blockId = blockId;
}
}
@@ -0,0 +1,76 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public class BlockChangeRecord1_8 implements BlockChangeRecord {
private final byte sectionX;
private final short y;
private final byte sectionZ;
private int blockId;
public BlockChangeRecord1_8(byte sectionX, short y, byte sectionZ, int blockId) {
this.sectionX = sectionX;
this.y = y;
this.sectionZ = sectionZ;
this.blockId = blockId;
}
public BlockChangeRecord1_8(int sectionX, int y, int sectionZ, int blockId) {
this((byte) sectionX, (short) y, (byte) sectionZ, blockId);
}
/**
* @return x coordinate within the chunk section
*/
public byte getSectionX() {
return sectionX;
}
@Override
public byte getSectionY() {
return (byte) (y & 0xF);
}
/**
* @return y coordinate
*/
@Override
public short getY(int chunkSectionY) {
return y;
}
/**
* @return z coordinate within the chunk section
*/
public byte getSectionZ() {
return sectionZ;
}
public int getBlockId() {
return blockId;
}
public void setBlockId(int blockId) {
this.blockId = blockId;
}
}
@@ -0,0 +1,104 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import java.util.EnumMap;
import java.util.Map;
public enum BlockFace {
NORTH((byte) 0, (byte) 0, (byte) -1, EnumAxis.Z),
SOUTH((byte) 0, (byte) 0, (byte) 1, EnumAxis.Z),
EAST((byte) 1, (byte) 0, (byte) 0, EnumAxis.X),
WEST((byte) -1, (byte) 0, (byte) 0, EnumAxis.X),
TOP((byte) 0, (byte) 1, (byte) 0, EnumAxis.Y),
BOTTOM((byte) 0, (byte) -1, (byte) 0, EnumAxis.Y);
public static final BlockFace[] HORIZONTAL = {NORTH, SOUTH, EAST, WEST};
private static final Map<BlockFace, BlockFace> opposites = new EnumMap<>(BlockFace.class);
static {
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
opposites.put(BlockFace.SOUTH, BlockFace.NORTH);
opposites.put(BlockFace.EAST, BlockFace.WEST);
opposites.put(BlockFace.WEST, BlockFace.EAST);
opposites.put(BlockFace.TOP, BlockFace.BOTTOM);
opposites.put(BlockFace.BOTTOM, BlockFace.TOP);
}
private final byte modX;
private final byte modY;
private final byte modZ;
private final EnumAxis axis;
BlockFace(byte modX, byte modY, byte modZ, EnumAxis axis) {
this.modX = modX;
this.modY = modY;
this.modZ = modZ;
this.axis = axis;
}
public BlockFace opposite() {
return opposites.get(this);
}
public byte modX() {
return modX;
}
public byte modY() {
return modY;
}
public byte modZ() {
return modZ;
}
public EnumAxis axis() {
return axis;
}
@Deprecated/*(forRemoval = true)*/
public byte getModX() {
return modX;
}
@Deprecated/*(forRemoval = true)*/
public byte getModY() {
return modY;
}
@Deprecated/*(forRemoval = true)*/
public byte getModZ() {
return modZ;
}
@Deprecated/*(forRemoval = true)*/
public EnumAxis getAxis() {
return axis;
}
public enum EnumAxis {
X, Y, Z
}
}
@@ -0,0 +1,53 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.connection.UserConnection;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Stored up until 1.14 to be used in chunk sending.
*/
public class ClientWorld implements StorableObject {
private Environment environment;
@Deprecated/*(forRemoval = true)*/
public ClientWorld(final UserConnection connection) {
}
public ClientWorld() {
}
public ClientWorld(final Environment environment) {
this.environment = environment;
}
public @Nullable Environment getEnvironment() {
return environment;
}
public void setEnvironment(final int environmentId) {
this.environment = Environment.getEnvironmentById(environmentId);
}
}
@@ -0,0 +1,57 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public enum Environment {
NORMAL(0),
NETHER(-1),
END(1);
private final int id;
Environment(int id) {
this.id = id;
}
public int id() {
return id;
}
@Deprecated/*(forRemoval = true)*/
public int getId() {
return id;
}
public static Environment getEnvironmentById(int id) {
switch (id) {
default:
case -1:
return NETHER;
case 0:
return NORMAL;
case 1:
return END;
}
}
}
@@ -0,0 +1,62 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public class EulerAngle {
private final float x;
private final float y;
private final float z;
public EulerAngle(final float x, final float y, final float z) {
this.x = x;
this.y = y;
this.z = z;
}
public float x() {
return x;
}
public float y() {
return y;
}
public float z() {
return z;
}
@Deprecated/*(forRemoval = true)*/
public float getX() {
return x;
}
@Deprecated/*(forRemoval = true)*/
public float getY() {
return y;
}
@Deprecated/*(forRemoval = true)*/
public float getZ() {
return z;
}
}
@@ -0,0 +1,66 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public final class GlobalPosition extends Position {
private final String dimension;
public GlobalPosition(final String dimension, final int x, final int y, final int z) {
super(x, y, z);
this.dimension = dimension;
}
public String dimension() {
return dimension;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final GlobalPosition position = (GlobalPosition) o;
if (x != position.x) return false;
if (y != position.y) return false;
if (z != position.z) return false;
return dimension.equals(position.dimension);
}
@Override
public int hashCode() {
int result = dimension.hashCode();
result = 31 * result + x;
result = 31 * result + y;
result = 31 * result + z;
return result;
}
@Override
public String toString() {
return "GlobalPosition{" +
"dimension='" + dimension + '\'' +
", x=" + x +
", y=" + y +
", z=" + z +
'}';
}
}
@@ -0,0 +1,106 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
public final class Particle {
private final List<ParticleData<?>> arguments = new ArrayList<>(4);
private int id;
public Particle(final int id) {
this.id = id;
}
public int getId() {
return id;
}
public void setId(final int id) {
this.id = id;
}
public <T> ParticleData<T> getArgument(final int index) {
//noinspection unchecked
return (ParticleData<T>) arguments.get(index);
}
public <T> ParticleData<T> removeArgument(final int index) {
//noinspection unchecked
return (ParticleData<T>) arguments.remove(index);
}
public List<ParticleData<?>> getArguments() {
return arguments;
}
public <T> void add(final Type<T> type, final T value) {
arguments.add(new ParticleData<>(type, value));
}
public <T> void add(final int index, final Type<T> type, final T value) {
arguments.add(index, new ParticleData<>(type, value));
}
public static final class ParticleData<T> {
private final Type<T> type;
private T value;
public ParticleData(final Type<T> type, final T value) {
this.type = type;
this.value = value;
}
public Type<T> getType() {
return type;
}
public T getValue() {
return value;
}
public void setValue(final T value) {
this.value = value;
}
public void write(final ByteBuf buf) throws Exception {
type.write(buf, value);
}
public void write(final PacketWrapper wrapper) {
wrapper.write(type, value);
}
@Override
public String toString() {
return "ParticleData{" +
"type=" + type +
", value=" + value +
'}';
}
}
}
@@ -0,0 +1,43 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import java.util.UUID;
public final class PlayerMessageSignature {
private final UUID uuid;
private final byte[] signatureBytes;
public PlayerMessageSignature(final UUID uuid, final byte[] signatureBytes) {
this.uuid = uuid;
this.signatureBytes = signatureBytes;
}
public UUID uuid() {
return uuid;
}
public byte[] signatureBytes() {
return signatureBytes;
}
}
@@ -0,0 +1,107 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public class Position {
protected final int x;
protected final int y;
protected final int z;
public Position(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
// @Deprecated/*(forRemoval=true)*/ Just leave this unchecked
public Position(int x, short y, int z) {
this(x, (int) y, z);
}
@Deprecated/*(forRemoval=true)*/
public Position(Position toCopy) {
this(toCopy.x(), toCopy.y(), toCopy.z());
}
public Position getRelative(BlockFace face) {
return new Position(x + face.modX(), (short) (y + face.modY()), z + face.modZ());
}
public int x() {
return x;
}
public int y() {
return y;
}
public int z() {
return z;
}
public GlobalPosition withDimension(String dimension) {
return new GlobalPosition(dimension, x, y, z);
}
@Deprecated/*(forRemoval=true)*/
public int getX() {
return x;
}
@Deprecated/*(forRemoval=true)*/
public int getY() {
return y;
}
@Deprecated/*(forRemoval=true)*/
public int getZ() {
return z;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Position position = (Position) o;
if (x != position.x) return false;
if (y != position.y) return false;
return z == position.z;
}
@Override
public int hashCode() {
int result = x;
result = 31 * result + y;
result = 31 * result + z;
return result;
}
@Override
public String toString() {
return "Position{" +
"x=" + x +
", y=" + y +
", z=" + z +
'}';
}
}
@@ -0,0 +1,47 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public class Position3d {
private final double x;
private final double y;
private final double z;
public Position3d(final double x, final double y, final double z) {
this.x = x;
this.y = y;
this.z = z;
}
public double x() {
return x;
}
public double y() {
return y;
}
public double z() {
return z;
}
}
@@ -0,0 +1,47 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public final class ProfileKey {
private final long expiresAt;
private final byte[] publicKey;
private final byte[] keySignature;
public ProfileKey(final long expiresAt, final byte[] publicKey, final byte[] keySignature) {
this.expiresAt = expiresAt;
this.publicKey = publicKey;
this.keySignature = keySignature;
}
public long expiresAt() {
return expiresAt;
}
public byte[] publicKey() {
return publicKey;
}
public byte[] keySignature() {
return keySignature;
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public final class Quaternion {
private final float x;
private final float y;
private final float z;
private final float w;
public Quaternion(final float x, final float y, final float z, final float w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
public float x() {
return x;
}
public float y() {
return y;
}
public float z() {
return z;
}
public float w() {
return w;
}
@Override
public String toString() {
return "Quaternion{" +
"x=" + x +
", y=" + y +
", z=" + z +
", w=" + w +
'}';
}
}
@@ -0,0 +1,68 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import java.util.HashMap;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.Nullable;
public enum RegistryType {
BLOCK("block"),
ITEM("item"),
FLUID("fluid"),
ENTITY("entity_type"),
GAME_EVENT("game_event");
private static final Map<String, RegistryType> MAP = new HashMap<>();
private static final RegistryType[] VALUES = values();
static {
for (RegistryType type : getValues()) {
MAP.put(type.resourceLocation, type);
}
}
public static RegistryType[] getValues() {
return VALUES;
}
public static @Nullable RegistryType getByKey(String resourceKey) {
return MAP.get(resourceKey);
}
private final String resourceLocation;
RegistryType(final String resourceLocation) {
this.resourceLocation = resourceLocation;
}
@Deprecated/*(forRemoval = true)*/
public String getResourceLocation() {
return resourceLocation;
}
public String resourceLocation() {
return resourceLocation;
}
}
@@ -0,0 +1,41 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public final class TagData {
private final String identifier;
private final int[] entries;
public TagData(final String identifier, final int[] entries) {
this.identifier = identifier;
this.entries = entries;
}
public String identifier() {
return identifier;
}
public int[] entries() {
return entries;
}
}
@@ -0,0 +1,77 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public class Vector {
private int blockX;
private int blockY;
private int blockZ;
public Vector(int blockX, int blockY, int blockZ) {
this.blockX = blockX;
this.blockY = blockY;
this.blockZ = blockZ;
}
public int blockX() {
return blockX;
}
public int blockY() {
return blockY;
}
public int blockZ() {
return blockZ;
}
@Deprecated/*(forRemoval=true)*/
public int getBlockX() {
return blockX;
}
@Deprecated/*(forRemoval=true)*/
public int getBlockY() {
return blockY;
}
@Deprecated/*(forRemoval=true)*/
public int getBlockZ() {
return blockZ;
}
@Deprecated/*(forRemoval=true)*/
public void setBlockX(int blockX) {
this.blockX = blockX;
}
@Deprecated/*(forRemoval=true)*/
public void setBlockY(int blockY) {
this.blockY = blockY;
}
@Deprecated/*(forRemoval=true)*/
public void setBlockZ(int blockZ) {
this.blockZ = blockZ;
}
}
@@ -0,0 +1,47 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public final class Vector3f {
private final float x;
private final float y;
private final float z;
public Vector3f(final float x, final float y, final float z) {
this.x = x;
this.y = y;
this.z = z;
}
public float x() {
return x;
}
public float y() {
return y;
}
public float z() {
return z;
}
}
@@ -0,0 +1,62 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public class VillagerData {
private final int type;
private final int profession;
private final int level;
public VillagerData(final int type, final int profession, final int level) {
this.type = type;
this.profession = profession;
this.level = level;
}
public int type() {
return type;
}
public int profession() {
return profession;
}
public int level() {
return level;
}
@Deprecated/*(forRemoval=true)*/
public int getType() {
return type;
}
@Deprecated/*(forRemoval=true)*/
public int getProfession() {
return profession;
}
@Deprecated/*(forRemoval=true)*/
public int getLevel() {
return level;
}
}
@@ -0,0 +1,57 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.viaversion.api.connection.StorableObject;
public class WorldIdentifiers implements StorableObject {
public static final String OVERWORLD_DEFAULT = "minecraft:overworld";
public static final String NETHER_DEFAULT = "minecraft:the_nether";
public static final String END_DEFAULT = "minecraft:the_end";
private final String overworld;
private final String nether;
private final String end;
public WorldIdentifiers(String overworld) {
this(overworld, NETHER_DEFAULT, END_DEFAULT);
}
public WorldIdentifiers(String overworld, String nether, String end) {
this.overworld = overworld;
this.nether = nether;
this.end = end;
}
public String overworld() {
return this.overworld;
}
public String nether() {
return this.nether;
}
public String end() {
return this.end;
}
}
@@ -0,0 +1,51 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.blockentity;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface BlockEntity {
static byte pack(int sectionX, int sectionZ) {
return (byte) (((sectionX) & 15) << 4 | (sectionZ & 15));
}
default byte sectionX() {
return (byte) ((packedXZ() >> 4) & 15);
}
default byte sectionZ() {
return (byte) (packedXZ() & 15);
}
byte packedXZ();
short y();
int typeId();
@Nullable CompoundTag tag();
BlockEntity withTypeId(int typeId);
}
@@ -0,0 +1,64 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.blockentity;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
public final class BlockEntityImpl implements BlockEntity {
private final byte packedXZ;
private final short y;
private final int typeId;
private final CompoundTag tag;
public BlockEntityImpl(final byte packedXZ, final short y, final int typeId, final CompoundTag tag) {
this.packedXZ = packedXZ;
this.y = y;
this.typeId = typeId;
this.tag = tag;
}
@Override
public byte packedXZ() {
return packedXZ;
}
@Override
public short y() {
return y;
}
@Override
public int typeId() {
return typeId;
}
@Override
public CompoundTag tag() {
return tag;
}
@Override
public BlockEntity withTypeId(int typeId) {
return new BlockEntityImpl(packedXZ, y, typeId, tag);
}
}
@@ -0,0 +1,155 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
import java.util.BitSet;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
//TODO Move methods from distinctly different versions to different objects/interfaces
public class BaseChunk implements Chunk {
protected final int x;
protected final int z;
protected final boolean fullChunk;
protected boolean ignoreOldLightData;
protected BitSet chunkSectionBitSet;
protected int bitmask;
protected ChunkSection[] sections;
protected int[] biomeData;
protected CompoundTag heightMap;
protected final List<CompoundTag> blockEntities;
public BaseChunk(int x, int z, boolean fullChunk, boolean ignoreOldLightData, @Nullable BitSet chunkSectionBitSet,
ChunkSection[] sections, int @Nullable [] biomeData, @Nullable CompoundTag heightMap, List<CompoundTag> blockEntities) {
this.x = x;
this.z = z;
this.fullChunk = fullChunk;
this.ignoreOldLightData = ignoreOldLightData;
this.chunkSectionBitSet = chunkSectionBitSet;
this.sections = sections;
this.biomeData = biomeData;
this.heightMap = heightMap;
this.blockEntities = blockEntities;
}
public BaseChunk(int x, int z, boolean fullChunk, boolean ignoreOldLightData, int bitmask, ChunkSection[] sections, int[] biomeData, CompoundTag heightMap, List<CompoundTag> blockEntities) {
this(x, z, fullChunk, ignoreOldLightData, null, sections, biomeData, heightMap, blockEntities);
this.bitmask = bitmask;
}
public BaseChunk(int x, int z, boolean fullChunk, boolean ignoreOldLightData, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
this(x, z, fullChunk, ignoreOldLightData, bitmask, sections, biomeData, null, blockEntities);
}
@Override
public boolean isBiomeData() {
return biomeData != null;
}
@Override
public int getX() {
return x;
}
@Override
public int getZ() {
return z;
}
@Override
public boolean isFullChunk() {
return fullChunk;
}
@Override
public boolean isIgnoreOldLightData() {
return ignoreOldLightData;
}
@Override
public void setIgnoreOldLightData(boolean ignoreOldLightData) {
this.ignoreOldLightData = ignoreOldLightData;
}
@Override
public int getBitmask() {
return bitmask;
}
@Override
public void setBitmask(int bitmask) {
this.bitmask = bitmask;
}
@Override
public @Nullable BitSet getChunkMask() {
return chunkSectionBitSet;
}
@Override
public void setChunkMask(BitSet chunkSectionMask) {
this.chunkSectionBitSet = chunkSectionMask;
}
@Override
public ChunkSection[] getSections() {
return sections;
}
@Override
public void setSections(ChunkSection[] sections) {
this.sections = sections;
}
@Override
public int @Nullable [] getBiomeData() {
return biomeData;
}
@Override
public void setBiomeData(int @Nullable [] biomeData) {
this.biomeData = biomeData;
}
@Override
public @Nullable CompoundTag getHeightMap() {
return heightMap;
}
@Override
public void setHeightMap(final CompoundTag heightMap) {
this.heightMap = heightMap;
}
@Override
public List<CompoundTag> getBlockEntities() {
return blockEntities;
}
@Override
public List<BlockEntity> blockEntities() {
throw new UnsupportedOperationException();
}
}
@@ -0,0 +1,126 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
import java.util.BitSet;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
// TODO specialized sub interfaces
public interface Chunk {
/**
* Returns the chunk x coordinate.
*
* @return chunk x coordinate
*/
int getX();
/**
* Returns the chunk z coordinate.
*
* @return chunk z coordinate
*/
int getZ();
/**
* Returns whether this chunk holds biome data, always true for 1.17+ chunks.
*
* @return true if this chunk holds biome data
*/
boolean isBiomeData();
/**
* Returns whether this is a full chunk, always true for 1.17+ chunks.
*
* @return true if this is a full chunk
*/
boolean isFullChunk();
boolean isIgnoreOldLightData();
void setIgnoreOldLightData(boolean ignoreOldLightData);
/**
* Returns the chunk section bit mask for chunks &lt; 1.17.
*
* @return chunk section bit mask for chunks &lt; 1.17
* @see #getChunkMask()
*/
int getBitmask();
void setBitmask(int bitmask);
/**
* Returns the chunk section bit mask, only non-null for 1.17+ chunks.
*
* @return chunk section bit mask, only non-null for 1.17+ chunks
* @see #getBitmask()
*/
@Nullable BitSet getChunkMask();
void setChunkMask(BitSet chunkSectionMask);
/**
* Returns an array of nullable chunk section entries.
*
* @return array of nullable chunk sections
*/
@Nullable ChunkSection[] getSections();
void setSections(ChunkSection[] sections);
/**
* Returns the chunk's raw biome data. The format the biomes are stored may vary.
*
* @return raw biome data
*/
int @Nullable [] getBiomeData();
void setBiomeData(int @Nullable [] biomeData);
/**
* Returns a compoundtag containing the chunk's heightmaps if present.
*
* @return compoundtag containing heightmaps if present
*/
@Nullable CompoundTag getHeightMap();
void setHeightMap(@Nullable CompoundTag heightMap);
/**
* Returns a list of block entities.
*
* @return list of block entities
*/
List<CompoundTag> getBlockEntities();
/**
* Returns a list of block entities.
*
* @return list of block entities
*/
List<BlockEntity> blockEntities();
}
@@ -0,0 +1,135 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
import java.util.BitSet;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public class Chunk1_18 implements Chunk {
protected final int x;
protected final int z;
protected ChunkSection[] sections;
protected CompoundTag heightMap;
protected final List<BlockEntity> blockEntities;
public Chunk1_18(int x, int z, ChunkSection[] sections, CompoundTag heightMap, List<BlockEntity> blockEntities) {
this.x = x;
this.z = z;
this.sections = sections;
this.heightMap = heightMap;
this.blockEntities = blockEntities;
}
@Override
public boolean isBiomeData() {
return false;
}
@Override
public int getX() {
return x;
}
@Override
public int getZ() {
return z;
}
@Override
public boolean isFullChunk() {
return true;
}
@Override
public boolean isIgnoreOldLightData() {
return false;
}
@Override
public void setIgnoreOldLightData(boolean ignoreOldLightData) {
throw new UnsupportedOperationException();
}
@Override
public int getBitmask() {
return -1;
}
@Override
public void setBitmask(int bitmask) {
throw new UnsupportedOperationException();
}
@Override
public @Nullable BitSet getChunkMask() {
return null;
}
@Override
public void setChunkMask(BitSet chunkSectionMask) {
throw new UnsupportedOperationException();
}
@Override
public ChunkSection[] getSections() {
return sections;
}
@Override
public void setSections(ChunkSection[] sections) {
this.sections = sections;
}
@Override
public int @Nullable [] getBiomeData() {
return null;
}
@Override
public void setBiomeData(int @Nullable [] biomeData) {
throw new UnsupportedOperationException();
}
@Override
public @Nullable CompoundTag getHeightMap() {
return heightMap;
}
@Override
public void setHeightMap(final CompoundTag heightMap) {
this.heightMap = heightMap;
}
@Override
public List<CompoundTag> getBlockEntities() {
throw new UnsupportedOperationException();
}
@Override
public List<BlockEntity> blockEntities() {
return blockEntities;
}
}
@@ -0,0 +1,175 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface ChunkSection {
/**
* Size (dimensions) of blocks in a chunks section.
*/
int SIZE = 16 * 16 * 16; // width * depth * height
/**
* Size (dimensions) of biomes in a chunks section.
*/
int BIOME_SIZE = 4 * 4 * 4;
static int index(int x, int y, int z) {
return y << 8 | z << 4 | x;
}
static int xFromIndex(int idx) {
return idx & 0xF;
}
static int yFromIndex(int idx) {
return idx >> 8 & 0xF;
}
static int zFromIndex(int idx) {
return idx >> 4 & 0xF;
}
@Deprecated/*(forRemoval = true)*/
default int getFlatBlock(int idx) {
return palette(PaletteType.BLOCKS).idAt(idx);
}
@Deprecated/*(forRemoval = true)*/
default int getFlatBlock(int x, int y, int z) {
return getFlatBlock(index(x, y, z));
}
@Deprecated/*(forRemoval = true)*/
default void setFlatBlock(int idx, int id) {
palette(PaletteType.BLOCKS).setIdAt(idx, id);
}
@Deprecated/*(forRemoval = true)*/
default void setFlatBlock(int x, int y, int z, int id) {
setFlatBlock(index(x, y, z), id);
}
@Deprecated/*(forRemoval = true)*/
default int getBlockWithoutData(int x, int y, int z) {
return getFlatBlock(x, y, z) >> 4;
}
@Deprecated/*(forRemoval = true)*/
default int getBlockData(int x, int y, int z) {
return getFlatBlock(x, y, z) & 0xF;
}
@Deprecated/*(forRemoval = true)*/
default void setBlockWithData(int x, int y, int z, int type, int data) {
setFlatBlock(index(x, y, z), type << 4 | (data & 0xF));
}
@Deprecated/*(forRemoval = true)*/
default void setBlockWithData(int idx, int type, int data) {
setFlatBlock(idx, type << 4 | (data & 0xF));
}
@Deprecated/*(forRemoval = true)*/
default void setPaletteIndex(int idx, int index) {
palette(PaletteType.BLOCKS).setPaletteIndexAt(idx, index);
}
@Deprecated/*(forRemoval = true)*/
default int getPaletteIndex(int idx) {
return palette(PaletteType.BLOCKS).paletteIndexAt(idx);
}
@Deprecated/*(forRemoval = true)*/
default int getPaletteSize() {
return palette(PaletteType.BLOCKS).size();
}
@Deprecated/*(forRemoval = true)*/
default int getPaletteEntry(int index) {
return palette(PaletteType.BLOCKS).idByIndex(index);
}
@Deprecated/*(forRemoval = true)*/
default void setPaletteEntry(int index, int id) {
palette(PaletteType.BLOCKS).setIdByIndex(index, id);
}
@Deprecated/*(forRemoval = true)*/
default void replacePaletteEntry(int oldId, int newId) {
palette(PaletteType.BLOCKS).replaceId(oldId, newId);
}
@Deprecated/*(forRemoval = true)*/
default void addPaletteEntry(int id) {
palette(PaletteType.BLOCKS).addId(id);
}
@Deprecated/*(forRemoval = true)*/
default void clearPalette() {
palette(PaletteType.BLOCKS).clear();
}
/**
* Returns the number of non-air blocks in this section.
*
* @return non-air blocks in this section
*/
int getNonAirBlocksCount();
void setNonAirBlocksCount(int nonAirBlocksCount);
/**
* Returns whether this section holds light data.
* Only true for &lt; 1.14 chunks.
*
* @return whether this section holds light data
*/
default boolean hasLight() {
return getLight() != null;
}
/**
* Returns the light of the chunk section.
* Only present for &lt; 1.14 chunks, otherwise sent separately.
*
* @return chunk section light if present
*/
@Nullable ChunkSectionLight getLight();
void setLight(@Nullable ChunkSectionLight light);
/**
* Returns the palette of the given type if present.
*
* @param type type of the palette
* @return palette
*/
@Nullable DataPalette palette(PaletteType type);
void addPalette(PaletteType type, DataPalette blockPalette);
void removePalette(PaletteType type);
}
@@ -0,0 +1,85 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import java.util.EnumMap;
import org.checkerframework.checker.nullness.qual.Nullable;
public class ChunkSectionImpl implements ChunkSection {
private final EnumMap<PaletteType, DataPalette> palettes = new EnumMap<>(PaletteType.class);
private ChunkSectionLight light;
private int nonAirBlocksCount;
public ChunkSectionImpl() {
}
public ChunkSectionImpl(final boolean holdsLight) {
addPalette(PaletteType.BLOCKS, new DataPaletteImpl(ChunkSection.SIZE));
if (holdsLight) {
this.light = new ChunkSectionLightImpl();
}
}
public ChunkSectionImpl(final boolean holdsLight, final int expectedPaletteLength) {
addPalette(PaletteType.BLOCKS, new DataPaletteImpl(ChunkSection.SIZE, expectedPaletteLength));
if (holdsLight) {
this.light = new ChunkSectionLightImpl();
}
}
@Override
public int getNonAirBlocksCount() {
return nonAirBlocksCount;
}
@Override
public void setNonAirBlocksCount(final int nonAirBlocksCount) {
this.nonAirBlocksCount = nonAirBlocksCount;
}
@Override
public @Nullable ChunkSectionLight getLight() {
return light;
}
@Override
public void setLight(@Nullable final ChunkSectionLight light) {
this.light = light;
}
@Override
public DataPalette palette(final PaletteType type) {
return palettes.get(type);
}
@Override
public void addPalette(final PaletteType type, final DataPalette palette) {
palettes.put(type, palette);
}
@Override
public void removePalette(final PaletteType type) {
palettes.remove(type);
}
}
@@ -0,0 +1,113 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface ChunkSectionLight {
/**
* Length of the sky and block light nibble arrays.
*/
int LIGHT_LENGTH = 16 * 16 * 16 / 2; // Dimensions / 2 (nibble bit count)
/**
* Returns whether the section has sky light.
*
* @return true if skylight is present
*/
boolean hasSkyLight();
/**
* Returns whether the section has block light.
* This returns true unless specifically set to null.
*
* @return true if skylight is present
*/
boolean hasBlockLight();
/**
* Returns the nibblearray's raw sky light byte array if present.
*
* @return the nibblearray's raw sky light byte array if present
* @see #hasSkyLight()
*/
byte @Nullable [] getSkyLight();
/**
* Returns the nibblearray's raw block light byte array if present.
*
* @return the nibblearray's raw block light byte array if present
* @see #hasBlockLight()
*/
byte @Nullable [] getBlockLight();
/**
* Set the sky light array.
*
* @param data raw sky light data
*/
void setSkyLight(byte[] data);
/**
* Set the block light array.
*
* @param data raw block light data
*/
void setBlockLight(byte[] data);
/**
* Returns the sky light nibblearray.
*
* @return sky light nibblearray
* @see #hasSkyLight()
*/
@Nullable NibbleArray getSkyLightNibbleArray();
/**
* Returns the block light nibblearray.
*
* @return block light nibblearray
* @see #hasBlockLight()
*/
@Nullable NibbleArray getBlockLightNibbleArray();
void readSkyLight(ByteBuf input);
void readBlockLight(ByteBuf input);
/**
* Write the sky light to a buffer.
*
* @param output buffer to write to
*/
void writeSkyLight(ByteBuf output);
/**
* Write the block light to a buffer.
*
* @param output buffer to write to
*/
void writeBlockLight(ByteBuf output);
}
@@ -0,0 +1,118 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
public class ChunkSectionLightImpl implements ChunkSectionLight {
private NibbleArray blockLight;
private NibbleArray skyLight;
public ChunkSectionLightImpl() {
// Block light is always written
this.blockLight = new NibbleArray(ChunkSection.SIZE);
}
@Override
public void setBlockLight(byte[] data) {
if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH);
if (this.blockLight == null) {
this.blockLight = new NibbleArray(data);
} else {
this.blockLight.setHandle(data);
}
}
@Override
public void setSkyLight(byte[] data) {
if (data == null) {
this.skyLight = null;
return;
}
if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH);
if (this.skyLight == null) {
this.skyLight = new NibbleArray(data);
} else {
this.skyLight.setHandle(data);
}
}
@Override
public byte @Nullable [] getBlockLight() {
return blockLight == null ? null : blockLight.getHandle();
}
@Override
public @Nullable NibbleArray getBlockLightNibbleArray() {
return blockLight;
}
@Override
public byte @Nullable [] getSkyLight() {
return skyLight == null ? null : skyLight.getHandle();
}
@Override
public @Nullable NibbleArray getSkyLightNibbleArray() {
return skyLight;
}
@Override
public void readBlockLight(ByteBuf input) {
if (this.blockLight == null) {
this.blockLight = new NibbleArray(LIGHT_LENGTH * 2);
}
input.readBytes(this.blockLight.getHandle());
}
@Override
public void readSkyLight(ByteBuf input) {
if (this.skyLight == null) {
this.skyLight = new NibbleArray(LIGHT_LENGTH * 2);
}
input.readBytes(this.skyLight.getHandle());
}
@Override
public void writeBlockLight(ByteBuf output) {
output.writeBytes(blockLight.getHandle());
}
@Override
public void writeSkyLight(ByteBuf output) {
output.writeBytes(skyLight.getHandle());
}
@Override
public boolean hasSkyLight() {
return skyLight != null;
}
@Override
public boolean hasBlockLight() {
return blockLight != null;
}
}
@@ -0,0 +1,137 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
public interface DataPalette {
/**
* Returns the packet section index of the given coordinates.
*
* @param x x
* @param y y
* @param z z
* @return packed section index of the given coordinates
*/
int index(final int x, final int y, final int z);
/**
* Returns the value of the given chunk coordinate.
*
* @param sectionCoordinate section index within the section
* @return section state of the given index
*/
int idAt(int sectionCoordinate);
/**
* Returns the value of the section coordinate.
*
* @param sectionX section x
* @param sectionY section y
* @param sectionZ section z
* @return id of the given section coordinate
*/
default int idAt(final int sectionX, final int sectionY, final int sectionZ) {
return idAt(index(sectionX, sectionY, sectionZ));
}
/**
* Set a value in the chunk section.
* This method does not update non-air blocks count.
*
* @param sectionCoordinate section index within the section
* @param id id value
*/
void setIdAt(int sectionCoordinate, int id);
/**
* Set a value in the chunk section.
* This method does not update non-air blocks count.
*
* @param sectionX section x
* @param sectionY section y
* @param sectionZ section z
* @param id id value
*/
default void setIdAt(final int sectionX, final int sectionY, final int sectionZ, final int id) {
setIdAt(index(sectionX, sectionY, sectionZ), id);
}
/**
* Returns the id assigned to the given palette index.
*
* @param index palette index
* @return id assigned to the given palette index
*/
int idByIndex(int index);
/**
* Assigns an id assigned to the given palette index.
*
* @param index palette index
* @param id id value
*/
void setIdByIndex(int index, int id);
/**
* Returns the palette index of the given section index.
*
* @param packedCoordinate section index
* @return palette index of the given section index
*/
int paletteIndexAt(int packedCoordinate);
/**
* Sets the index of the given section coordinate.
*
* @param sectionCoordinate section index
* @param index palette index
*/
void setPaletteIndexAt(int sectionCoordinate, int index);
/**
* Adds a new id to the palette.
*
* @param id id value
*/
void addId(int id);
/**
* Replaces an id in the palette.
*
* @param oldId old id
* @param newId new id
*/
void replaceId(int oldId, int newId);
/**
* Returns the size of the palette.
*
* @return palette size
*/
int size();
/**
* Clears the palette.
*/
void clear();
}
@@ -0,0 +1,210 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
public final class DataPaletteImpl implements DataPalette {
private static final int DEFAULT_INITIAL_SIZE = 16;
private final IntList palette;
private final Int2IntMap inversePalette;
private final int sizeBits;
private ChunkData values;
public DataPaletteImpl(final int valuesLength) {
this(valuesLength, DEFAULT_INITIAL_SIZE);
}
public DataPaletteImpl(final int valuesLength, final int initialSize) {
values = new EmptyChunkData(valuesLength);
sizeBits = Integer.numberOfTrailingZeros(valuesLength) / 3;
// Pre-size the palette array/map
palette = new IntArrayList(initialSize);
// To get an initial table size of initialSize, need to scale it down by load factor.
inversePalette = new Int2IntOpenHashMap((int) (initialSize * Int2IntOpenHashMap.DEFAULT_LOAD_FACTOR));
inversePalette.defaultReturnValue(-1);
}
@Override
public int index(final int x, final int y, final int z) {
return (y << this.sizeBits | z) << this.sizeBits | x;
}
@Override
public int idAt(final int sectionCoordinate) {
final int index = values.get(sectionCoordinate);
return palette.getInt(index);
}
@Override
public void setIdAt(final int sectionCoordinate, final int id) {
int index = inversePalette.get(id);
if (index == -1) {
index = palette.size();
palette.add(id);
inversePalette.put(id, index);
}
values.set(sectionCoordinate, index);
}
@Override
public int paletteIndexAt(final int packedCoordinate) {
return values.get(packedCoordinate);
}
@Override
public void setPaletteIndexAt(final int sectionCoordinate, final int index) {
values.set(sectionCoordinate, index);
}
@Override
public int size() {
return palette.size();
}
@Override
public int idByIndex(final int index) {
return palette.getInt(index);
}
@Override
public void setIdByIndex(final int index, final int id) {
final int oldId = palette.set(index, id);
if (oldId == id) return;
inversePalette.put(id, index);
if (inversePalette.get(oldId) == index) {
inversePalette.remove(oldId);
for (int i = 0; i < palette.size(); i++) {
if (palette.getInt(i) == oldId) {
inversePalette.put(oldId, i);
break;
}
}
}
}
@Override
public void replaceId(final int oldId, final int newId) {
final int index = inversePalette.remove(oldId);
if (index == -1) return;
inversePalette.put(newId, index);
for (int i = 0; i < palette.size(); i++) {
if (palette.getInt(i) == oldId) {
palette.set(i, newId);
}
}
}
@Override
public void addId(final int id) {
inversePalette.put(id, palette.size());
palette.add(id);
}
@Override
public void clear() {
palette.clear();
inversePalette.clear();
}
interface ChunkData {
int get(int idx);
void set(int idx, int val);
}
private class EmptyChunkData implements ChunkData {
private final int size;
public EmptyChunkData(int size) {
this.size = size;
}
@Override
public int get(int idx) {
return 0;
}
@Override
public void set(int idx, int val) {
if (val != 0) {
values = new ByteChunkData(size);
values.set(idx, val);
}
}
}
private class ByteChunkData implements ChunkData {
private final byte[] data;
public ByteChunkData(int size) {
this.data = new byte[size];
}
@Override
public int get(int idx) {
return data[idx] & 0xFF;
}
@Override
public void set(int idx, int val) {
// Overflowed size of byte (over 256 different materials), go up to short
if (val > 0xFF) {
values = new ShortChunkData(data);
values.set(idx, val);
return;
}
data[idx] = (byte) val;
}
}
private static class ShortChunkData implements ChunkData {
private final short[] data;
public ShortChunkData(byte[] data) {
this.data = new short[data.length];
for (int i = 0; i < data.length; i++) {
this.data[i] = (short) (data[i] & 0xFF);
}
}
@Override
public int get(int idx) {
return data[idx];
}
@Override
public void set(int idx, int val) {
data[idx] = (short) val;
}
}
}
@@ -1,4 +1,26 @@
package us.myles.ViaVersion.api.minecraft.chunks;
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import java.util.Arrays;
@@ -0,0 +1,44 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
public enum PaletteType {
BLOCKS(ChunkSection.SIZE, 8),
BIOMES(ChunkSection.BIOME_SIZE, 3);
private final int size;
private final int highestBitsPerValue;
PaletteType(final int size, final int highestBitsPerValue) {
this.size = size;
this.highestBitsPerValue = highestBitsPerValue;
}
public int size() {
return size;
}
public int highestBitsPerValue() {
return highestBitsPerValue;
}
}
@@ -0,0 +1,99 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface EntityType {
/**
* Returns the entity id.
*
* @return entity id
* @throws IllegalStateException if ids have not been loaded yet
*/
int getId();
/**
* Returns the parent entity type if present.
*
* @return parent entity type if present
*/
@Nullable EntityType getParent();
/**
* Returns the entity type name, not necessarily matching the Vanilla type name.
*
* @return entity type name
*/
String name();
/**
* Returns the entity's Vanilla identifier.
*
* @return entity identifier
* @throws IllegalArgumentException if {@link #isAbstractType()} returns true
*/
String identifier();
/**
* Returns whether the type does not represent an actual entity, e.g. animal or monster.
*
* @return whether the type does not represent an actual entity
*/
boolean isAbstractType();
@Deprecated/*(forRemoval = true)*/
default boolean is(EntityType... types) {
for (EntityType type : types) {
if (this == type) {
return true;
}
}
return false;
}
default boolean is(EntityType type) {
return this == type;
}
/**
* Returns whether the current type is equal to the given type, or has it as a parent type.
*
* @param type entity type to check against
* @return true if the current type is equal to the given type, or has it as a parent type
*/
default boolean isOrHasParent(EntityType type) {
EntityType parent = this;
do {
if (parent == type) {
return true;
}
parent = parent.getParent();
} while (parent != null);
return false;
}
}
Loaded 100 of 1293 files, more files were not shown because too many files have changed in this diff. Show more