Compare commits

..
279 Commits
Author SHA1 Message Date
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
836 changed files with 17738 additions and 209692 deletions

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ body:
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 video to any of the textfields.
Whenever you see fit, you can upload images or videos to any of the text fields.
- type: input
attributes:
+7 -11
View File
@@ -1,6 +1,3 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Java CI with Gradle
on: [push, pull_request]
@@ -10,19 +7,18 @@ jobs:
# 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-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
- 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@v2
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 11
check-latest: true
- name: Build with Gradle
run: ./gradlew build
- uses: actions/upload-artifact@v2
with:
name: artifact
path: build/libs
+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
+1 -1
View File
@@ -1,6 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion&#10;Copyright (C) 2016-2022 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="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>
+1 -1
View File
@@ -1,6 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion&#10;Copyright (C) 2016-2022 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="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>
+51 -31
View File
@@ -1,44 +1,41 @@
# ViaVersion - Spigot, Sponge, BungeeCord, Velocity
# ViaVersion
[![Latest Release](https://img.shields.io/github/v/release/ViaVersion/ViaVersion)](https://viaversion.com)
[![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/aSjHvQk.png)](https://i.imgur.com/aSjHvQk.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](https://wiki.vg)** (Used for information regarding packet structure, we also contribute back)
You can find official releases in the following places:
**[Burger](https://github.com/Pokechu22/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](https://github.com/ViaVersion/OpenNBT)**
Dev builds for **all** of our projects are on our Jenkins server:
- **Jenkins**: https://ci.viaversion.com
Releases / Dev Builds:
--------
You can find official releases here:
https://www.spigotmc.org/resources/viaversion.19254/history
ViaVersion as a Dependency
----------
You can find official dev builds here:
**Jenkins:** https://ci.viaversion.com
**JavaDocs:** https://jd.viaversion.com
**Maven Repository:**
**Maven:**
```xml
<repository>
<id>viaversion-repo</id>
@@ -46,34 +43,57 @@ You can find official dev builds here:
</repository>
```
**API-artifact:**
```xml
<dependency>
<groupId>com.viaversion</groupId>
<artifactId>viaversion-api</artifactId>
<version>LATEST</version>
<version>[4.0.0,5.0.0)</version>
<scope>provided</scope>
</dependency>
```
Replace the version depending on your needs.
**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:
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.
After cloning this repository, build the project with Gradle by running `./gradlew build` and take the created jar out
of the `build/libs` directory.
License:
Mapping Files
--------------
Mapping files are generated and managed in our [Mappings repository](https://github.com/ViaVersion/Mappings).
Resources
--------
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
- **[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.
Everything else, unless explicitly stated otherwise, is licensed under the GNU General Public License, including the end
product as a whole; see [licenses/GPL.md](licenses/GPL.md) for details.
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).
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -23,13 +23,12 @@
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;
import java.util.SortedSet;
import java.util.UUID;
/**
* @deprecated may be removed at some point, use {@link com.viaversion.viaversion.api.Via}
*/
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -24,13 +24,12 @@ 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;
import java.util.SortedSet;
import java.util.UUID;
/**
* @deprecated may be removed at some point, use {@link Via#getAPI()}
*/
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -26,14 +26,13 @@ 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.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.ArrayList;
import java.util.Collections;
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}
@@ -84,7 +83,11 @@ public class ProtocolVersion {
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");
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 unknown = register(-1, "UNKNOWN");
public static ProtocolVersion register(int version, String name) {
+10 -3
View File
@@ -1,11 +1,18 @@
plugins {
id("net.kyori.blossom")
id("org.jetbrains.gradle.plugin.idea-ext")
id("via.shadow-conventions")
}
blossom {
replaceToken("\$VERSION", project.version)
replaceToken("\$IMPL_VERSION", "git-ViaVersion-${project.version}:${rootProject.latestCommitHash()}")
sourceSets {
main {
blossom {
javaSources {
property("version", project.version.toString())
property("impl_version", "git-ViaVersion-${project.version}:${rootProject.latestCommitHash()}")
}
}
}
}
dependencies {
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -31,5 +31,14 @@ public final class VersionInfo {
*
* @see ViaPlatform#getPluginVersion()
*/
public static final String VERSION = "$VERSION";
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;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -29,10 +29,9 @@ 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 org.checkerframework.checker.nullness.qual.Nullable;
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()}.
@@ -64,7 +63,7 @@ public interface ViaAPI<T> {
* @return API version incremented with meaningful API changes
*/
default int apiVersion() {
return 15;
return 20;
}
/**
@@ -136,7 +135,7 @@ public interface ViaAPI<T> {
* Returns the supported protocol versions.
* This method removes any blocked protocol versions.
*
* @return a list of protocol versions
* @return a sorted set of protocol versions
* @see #getFullSupportedVersions() for a full list
*/
SortedSet<Integer> getSupportedVersions();
@@ -144,7 +143,7 @@ public interface ViaAPI<T> {
/**
* Returns the supported protocol versions, including blocked protocols.
*
* @return a list of protocol versions
* @return a sorted set of protocol versions
*/
SortedSet<Integer> getFullSupportedVersions();
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -30,7 +30,7 @@ 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 {
@@ -84,12 +84,18 @@ public interface ViaManager {
*/
ViaPlatformLoader getLoader();
/**
* Returns the async task scheduler.
*
* @return async task scheduler
*/
Scheduler getScheduler();
/**
* If debug is enabled, packets and other otherwise suppressed warnings will be logged.
*
* @return true if enabled
*/
@Deprecated
default boolean isDebug() {
return debugHandler().enabled();
}
@@ -125,4 +131,11 @@ public interface ViaManager {
* @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();
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -23,7 +23,6 @@
package com.viaversion.viaversion.api.command;
import com.viaversion.viaversion.util.ChatColorUtil;
import java.util.Collections;
import java.util.List;
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -22,9 +22,8 @@
*/
package com.viaversion.viaversion.api.command;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface ViaVersionCommand {
/**
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -186,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
*
@@ -263,6 +256,8 @@ public interface ViaVersionConfig {
*/
boolean is1_13TeamColourFix();
boolean shouldRegisterUserConnectionOnJoin();
/**
* Should we fix shift quick move action for 1.12 clients
*
@@ -458,4 +453,6 @@ public interface ViaVersionConfig {
boolean cache1_17Light();
@Nullable String chatTypeFormat(String translationKey);
boolean isArmorToggleFix();
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -22,11 +22,10 @@
*/
package com.viaversion.viaversion.api.connection;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Handles injected UserConnections
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -23,10 +23,10 @@
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 org.checkerframework.checker.nullness.qual.Nullable;
import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface ProtocolInfo {
@@ -34,10 +34,63 @@ 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()}
*/
State getState();
@Deprecated/*(forRemoval = true)*/
default State getState() {
return this.getServerState();
}
void setState(State state);
/**
* 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.
@@ -93,5 +146,6 @@ public interface ProtocolInfo {
*
* @return user connection
*/
@Deprecated/*(forRemoval = true)*/
UserConnection getUser();
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -38,4 +38,7 @@ public interface StorableObject {
default boolean clearOnServerSwitch() {
return true;
}
default void onRemove() {
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -32,12 +32,11 @@ import com.viaversion.viaversion.exception.InformativeException;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import org.checkerframework.checker.nullness.qual.Nullable;
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 {
@@ -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;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -27,9 +27,12 @@ import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Mappings containing the full string identifier mappings.
*/
public interface FullMappings {
public interface FullMappings extends Mappings {
Mappings mappings();
@Deprecated
default Mappings mappings() {
return this;
}
/**
* Returns the unmapped integer id for the given identifier, or -1 if not found.
@@ -70,4 +73,7 @@ public interface FullMappings {
* @return mapped string identifier, or null if not found
*/
@Nullable String mappedIdentifier(String identifier);
@Override
FullMappings inverse();
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -22,33 +22,34 @@
*/
package com.viaversion.viaversion.api.data;
import com.google.gson.JsonArray;
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 JsonArray oldMappings, final JsonArray newMappings, final Mappings mappings) {
public FullMappingsBase(final List<String> unmappedIdentifiers, final List<String> mappedIdentifiers, final Mappings mappings) {
this.mappings = mappings;
stringToId = MappingDataLoader.arrayToMap(oldMappings);
mappedStringToId = MappingDataLoader.arrayToMap(newMappings);
stringToId.defaultReturnValue(-1);
mappedStringToId.defaultReturnValue(-1);
this.stringToId = toInverseMap(unmappedIdentifiers);
this.mappedStringToId = toInverseMap(mappedIdentifiers);
this.idToString = unmappedIdentifiers.toArray(EMPTY_ARRAY);
this.mappedIdToString = mappedIdentifiers.toArray(EMPTY_ARRAY);
}
idToString = new String[oldMappings.size()];
for (int i = 0; i < oldMappings.size(); i++) {
idToString[i] = oldMappings.get(i).getAsString();
}
mappedIdToString = new String[newMappings.size()];
for (int i = 0; i < newMappings.size(); i++) {
mappedIdToString[i] = newMappings.get(i).getAsString();
}
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
@@ -58,22 +59,24 @@ public class FullMappingsBase implements FullMappings {
@Override
public int id(final String identifier) {
return stringToId.getInt(identifier);
return stringToId.getInt(Key.stripMinecraftNamespace(identifier));
}
@Override
public int mappedId(final String mappedIdentifier) {
return mappedStringToId.getInt(mappedIdentifier);
return mappedStringToId.getInt(Key.stripMinecraftNamespace(mappedIdentifier));
}
@Override
public String identifier(final int id) {
return idToString[id];
final String identifier = idToString[id];
return Key.namespaced(identifier);
}
@Override
public String mappedIdentifier(final int mappedId) {
return mappedIdToString[mappedId];
final String identifier = mappedIdToString[mappedId];
return Key.namespaced(identifier);
}
@Override
@@ -86,4 +89,38 @@ public class FullMappingsBase implements FullMappings {
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;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -40,7 +40,6 @@ public class Int2IntMapMappings implements Mappings {
}
public static Int2IntMapMappings of() {
return new Int2IntMapMappings(new Int2IntOpenHashMap(), -1);
}
@@ -50,8 +49,8 @@ public class Int2IntMapMappings implements Mappings {
}
@Override
public void setNewId(final int id, final int newId) {
mappings.put(id, newId);
public void setNewId(final int id, final int mappedId) {
mappings.put(id, mappedId);
}
@Override
@@ -63,4 +62,16 @@ public class Int2IntMapMappings implements Mappings {
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());
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -22,106 +22,39 @@
*/
package com.viaversion.viaversion.api.data;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Arrays;
public class IntArrayMappings implements Mappings {
private final int[] oldToNew;
private final int[] mappings;
private final int mappedIds;
protected IntArrayMappings(final int[] oldToNew, final int mappedIds) {
this.oldToNew = oldToNew;
protected IntArrayMappings(final int[] mappings, final int mappedIds) {
this.mappings = mappings;
this.mappedIds = mappedIds;
}
public static IntArrayMappings of(final int[] oldToNew, final int mappedIds) {
return new IntArrayMappings(oldToNew, 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);
}
@Deprecated/*(forRemoval = true)*/
public IntArrayMappings(int[] oldToNew) {
this(oldToNew, -1);
}
@Deprecated/*(forRemoval = true)*/
public IntArrayMappings(int size, JsonObject oldMapping, JsonObject newMapping, @Nullable JsonObject diffMapping) {
oldToNew = new int[size];
Arrays.fill(oldToNew, -1);
this.mappedIds = newMapping.size();
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping);
}
@Deprecated/*(forRemoval = true)*/
public IntArrayMappings(JsonObject oldMapping, JsonObject newMapping, @Nullable JsonObject diffMapping) {
this(oldMapping.entrySet().size(), oldMapping, newMapping, diffMapping);
}
@Deprecated/*(forRemoval = true)*/
public IntArrayMappings(int size, JsonObject oldMapping, JsonObject newMapping) {
oldToNew = new int[size];
Arrays.fill(oldToNew, -1);
mappedIds = -1;
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping);
}
@Deprecated/*(forRemoval = true)*/
public IntArrayMappings(JsonObject oldMapping, JsonObject newMapping) {
this(oldMapping.entrySet().size(), oldMapping, newMapping);
}
@Deprecated/*(forRemoval = true)*/
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping, boolean warnOnMissing) {
oldToNew = new int[size];
Arrays.fill(oldToNew, -1);
mappedIds = -1;
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping, warnOnMissing);
}
@Deprecated/*(forRemoval = true)*/
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
this(size, oldMapping, newMapping, null, warnOnMissing);
}
@Deprecated/*(forRemoval = true)*/
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
this(oldMapping.size(), oldMapping, newMapping, warnOnMissing);
}
@Deprecated/*(forRemoval = true)*/
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping) {
this(size, oldMapping, newMapping, true);
}
@Deprecated/*(forRemoval = true)*/
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping) {
this(oldMapping.size(), oldMapping, newMapping, diffMapping, true);
}
@Deprecated/*(forRemoval = true)*/
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping) {
this(oldMapping.size(), oldMapping, newMapping, true);
}
@Override
public int getNewId(int id) {
return id >= 0 && id < oldToNew.length ? oldToNew[id] : -1;
return id >= 0 && id < mappings.length ? mappings[id] : -1;
}
@Override
public void setNewId(int id, int newId) {
oldToNew[id] = newId;
public void setNewId(int id, int mappedId) {
mappings[id] = mappedId;
}
@Override
public int size() {
return oldToNew.length;
return mappings.length;
}
@Override
@@ -129,7 +62,20 @@ public class IntArrayMappings implements Mappings {
return mappedIds;
}
public int[] getOldToNew() {
return oldToNew;
@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;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -24,10 +24,8 @@ package com.viaversion.viaversion.api.data;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.TagData;
import com.viaversion.viaversion.util.Int2IntBiMap;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface MappingData {
@@ -89,7 +87,7 @@ public interface MappingData {
*/
@Nullable List<TagData> getTags(RegistryType type);
@Nullable Int2IntBiMap getItemMappings();
@Nullable BiMappings getItemMappings();
@Nullable ParticleMappings getParticleMappings();
@@ -103,6 +101,8 @@ public interface MappingData {
@Nullable Mappings getStatisticsMappings();
@Nullable Mappings getMenuMappings();
@Nullable Mappings getEnchantmentMappings();
@Nullable FullMappings getEntityMappings();
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -22,28 +22,26 @@
*/
package com.viaversion.viaversion.api.data;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
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 com.viaversion.viaversion.util.Int2IntBiHashMap;
import com.viaversion.viaversion.util.Int2IntBiMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import org.checkerframework.checker.nullness.qual.Nullable;
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 oldVersion;
protected final String newVersion;
protected final boolean hasDiffFile;
protected Int2IntBiMap itemMappings;
protected final String unmappedVersion;
protected final String mappedVersion;
protected BiMappings itemMappings;
protected FullMappings argumentTypeMappings;
protected FullMappings entityMappings;
protected ParticleMappings particleMappings;
@@ -54,124 +52,125 @@ public class MappingDataBase implements MappingData {
protected Mappings statisticsMappings;
protected Mappings enchantmentMappings;
protected Mappings paintingMappings;
protected Mappings menuMappings;
protected Map<RegistryType, List<TagData>> tags;
protected boolean loadItems = true;
public MappingDataBase(String oldVersion, String newVersion) {
this(oldVersion, newVersion, false);
}
public MappingDataBase(String oldVersion, String newVersion, boolean hasDiffFile) {
this.oldVersion = oldVersion;
this.newVersion = newVersion;
this.hasDiffFile = hasDiffFile;
public MappingDataBase(final String unmappedVersion, final String mappedVersion) {
this.unmappedVersion = unmappedVersion;
this.mappedVersion = mappedVersion;
}
@Override
public void load() {
getLogger().info("Loading " + oldVersion + " -> " + newVersion + " mappings...");
JsonObject diffmapping = hasDiffFile ? loadDiffFile() : null;
JsonObject oldMappings = MappingDataLoader.loadData("mapping-" + oldVersion + ".json", true);
JsonObject newMappings = MappingDataLoader.loadData("mapping-" + newVersion + ".json", true);
blockMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blocks");
blockStateMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blockstates");
blockEntityMappings = loadFromArray(oldMappings, newMappings, diffmapping, "blockentities");
soundMappings = loadFromArray(oldMappings, newMappings, diffmapping, "sounds");
statisticsMappings = loadFromArray(oldMappings, newMappings, diffmapping, "statistics");
enchantmentMappings = loadFromArray(oldMappings, newMappings, diffmapping, "enchantments");
paintingMappings = loadFromArray(oldMappings, newMappings, diffmapping, "paintings");
entityMappings = loadFullMappings(oldMappings, newMappings, diffmapping, "entities");
argumentTypeMappings = loadFullMappings(oldMappings, newMappings, diffmapping, "argumenttypes");
Mappings particles = loadFromArray(oldMappings, newMappings, diffmapping, "particles");
if (particles != null) {
particleMappings = new ParticleMappings(oldMappings.getAsJsonArray("particles"), newMappings.getAsJsonArray("particles"), particles);
if (Via.getManager().isDebug()) {
getLogger().info("Loading " + unmappedVersion + " -> " + mappedVersion + " mappings...");
}
if (loadItems && newMappings.has("items")) {
itemMappings = new Int2IntBiHashMap();
itemMappings.defaultReturnValue(-1);
MappingDataLoader.mapIdentifiers(itemMappings, oldMappings.getAsJsonObject("items"), newMappings.getAsJsonObject("items"),
diffmapping != null ? diffmapping.getAsJsonObject("items") : null, true);
}
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");
if (diffmapping != null && diffmapping.has("tags")) {
this.tags = new EnumMap<>(RegistryType.class);
JsonObject tags = diffmapping.getAsJsonObject("tags");
if (tags.has(RegistryType.ITEM.resourceLocation())) {
loadTags(RegistryType.ITEM, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("items")));
}
if (tags.has(RegistryType.BLOCK.resourceLocation())) {
loadTags(RegistryType.BLOCK, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("blocks")));
}
}
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");
loadExtras(oldMappings, newMappings, diffmapping);
}
protected FullMappings loadFullMappings(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
Mappings mappings = loadFromArray(oldMappings, newMappings, diffMappings, key);
return mappings != null ? new FullMappingsBase(oldMappings.getAsJsonArray(key), newMappings.getAsJsonArray(key), mappings) : null;
}
private void loadTags(RegistryType type, JsonObject object, Object2IntMap<String> typeMapping) {
JsonObject tags = object.getAsJsonObject(type.resourceLocation());
List<TagData> tagsList = new ArrayList<>(tags.size());
for (Map.Entry<String, JsonElement> entry : tags.entrySet()) {
JsonArray array = entry.getValue().getAsJsonArray();
int[] entries = new int[array.size()];
int i = 0;
for (JsonElement element : array) {
String stringId = element.getAsString();
if (!typeMapping.containsKey(stringId) && !typeMapping.containsKey(stringId = stringId.replace("minecraft:", ""))) { // aaa
getLogger().warning(type + " Tags contains invalid type identifier " + stringId + " in tag " + entry.getKey());
continue;
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());
}
entries[i++] = typeMapping.getInt(stringId);
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);
}
tagsList.add(new TagData(entry.getKey(), entries));
}
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(int id) {
public int getNewBlockStateId(final int id) {
return checkValidity(id, blockStateMappings.getNewId(id), "blockstate");
}
@Override
public int getNewBlockId(int id) {
public int getNewBlockId(final int id) {
return checkValidity(id, blockMappings.getNewId(id), "block");
}
@Override
public int getNewItemId(int id) {
return checkValidity(id, itemMappings.get(id), "item");
public int getNewItemId(final int id) {
return checkValidity(id, itemMappings.getNewId(id), "item");
}
@Override
public int getOldItemId(int id) {
int oldId = itemMappings.inverse().get(id);
// Remap new items to stone
return oldId != -1 ? oldId : 1;
public int getOldItemId(final int id) {
return itemMappings.inverse().getNewIdOrDefault(id, 1);
}
@Override
public int getNewParticleId(int id) {
return checkValidity(id, particleMappings.mappings().getNewId(id), "particles");
public int getNewParticleId(final int id) {
return checkValidity(id, particleMappings.getNewId(id), "particles");
}
@Override
public @Nullable List<TagData> getTags(RegistryType type) {
public @Nullable List<TagData> getTags(final RegistryType type) {
return tags != null ? tags.get(type) : null;
}
@Override
public @Nullable Int2IntBiMap getItemMappings() {
public @Nullable BiMappings getItemMappings() {
return itemMappings;
}
@@ -205,6 +204,11 @@ public class MappingDataBase implements MappingData {
return statisticsMappings;
}
@Override
public @Nullable Mappings getMenuMappings() {
return menuMappings;
}
@Override
public @Nullable Mappings getEnchantmentMappings() {
return enchantmentMappings;
@@ -225,26 +229,6 @@ public class MappingDataBase implements MappingData {
return paintingMappings;
}
protected @Nullable Mappings loadFromArray(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
return IntArrayMappings.builder().unmapped(oldMappings.getAsJsonArray(key))
.mapped(newMappings.getAsJsonArray(key)).diffMappings(diff).build();
}
protected @Nullable Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
return IntArrayMappings.builder().unmapped(oldMappings.getAsJsonObject(key))
.mapped(newMappings.getAsJsonObject(key)).diffMappings(diff).build();
}
protected @Nullable JsonObject loadDiffFile() {
return MappingDataLoader.loadData("mappingdiff-" + oldVersion + "to" + newVersion + ".json");
}
protected Logger getLogger() {
return Via.getPlatform().getLogger();
}
@@ -257,21 +241,16 @@ public class MappingDataBase implements MappingData {
* @param type mapping type (e.g. "item")
* @return the given mapped id if valid, else 0
*/
protected int checkValidity(int id, int mappedId, String type) {
protected int checkValidity(final int id, final int mappedId, final String type) {
if (mappedId == -1) {
getLogger().warning(String.format("Missing %s %s for %s %s %d", newVersion, type, oldVersion, type, id));
if (!Via.getConfig().isSuppressConversionWarnings()) {
getLogger().warning(String.format("Missing %s %s for %s %s %d", mappedVersion, type, unmappedVersion, type, id));
}
return 0;
}
return mappedId;
}
/**
* To be overridden.
*
* @param oldMappings old mappings
* @param newMappings new mappings
* @param diffMappings diff mappings if present
*/
protected void loadExtras(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings) {
protected void loadExtras(final CompoundTag data) {
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -22,6 +22,13 @@
*/
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;
@@ -29,46 +36,36 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.util.GsonUtil;
import com.viaversion.viaversion.util.Int2IntBiMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import org.checkerframework.checker.nullness.qual.Nullable;
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.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import org.checkerframework.checker.nullness.qual.Nullable;
public class MappingDataLoader {
public final class MappingDataLoader {
private static final Map<String, JsonObject> MAPPINGS_CACHE = new ConcurrentHashMap<>();
private static boolean cacheJsonMappings;
/**
* Returns true if a selected number of mappings should be cached.
* If enabled, cleanup should be done after the cache is no longer needed.
*
* @return true if mappings should be cached
*/
public static boolean isCacheJsonMappings() {
return cacheJsonMappings;
}
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() {
cacheJsonMappings = true;
// Always enabled
}
/**
* Returns the cached mappings. Cleared after ViaVersion has been fully loaded.
*
* @return cached mapping file json objects
* @see #isCacheJsonMappings()
*/
public static Map<String, JsonObject> getMappingsCache() {
return MAPPINGS_CACHE;
public static void clearCache() {
MAPPINGS_CACHE.clear();
cacheValid = false;
}
/**
@@ -76,143 +73,228 @@ public class MappingDataLoader {
*
* @return loaded json object, or null if not found or invalid
*/
public static @Nullable JsonObject loadFromDataDir(String name) {
File file = new File(Via.getPlatform().getDataFolder(), name);
if (!file.exists()) return loadData(name);
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 (FileReader reader = new FileReader(file)) {
try (final FileReader reader = new FileReader(file)) {
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
} catch (JsonSyntaxException e) {
} 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!");
e.printStackTrace();
} catch (IOException | JsonIOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (final IOException | JsonIOException e) {
throw new RuntimeException(e);
}
return null;
}
/**
* Loads the file from the bundled resources. Uses the cache if enabled.
* Loads the file from the bundled resources.
*
* @return loaded json object from bundled resources if present
*/
public static @Nullable JsonObject loadData(String name) {
return loadData(name, false);
}
/**
* Loads the file from the bundled resources. Uses the cache if enabled.
*
* @param cacheIfEnabled whether loaded files should be cached
* @return loaded json object from bundled resources if present
*/
public static @Nullable JsonObject loadData(String name, boolean cacheIfEnabled) {
if (cacheJsonMappings) {
JsonObject cached = MAPPINGS_CACHE.get(name);
if (cached != null) {
return cached;
}
public static @Nullable JsonObject loadData(final String name) {
final InputStream stream = getResource(name);
if (stream == null) {
return null;
}
InputStream stream = getResource(name);
if (stream == null) return null;
InputStreamReader reader = new InputStreamReader(stream);
try {
JsonObject object = GsonUtil.getGson().fromJson(reader, JsonObject.class);
if (cacheIfEnabled && cacheJsonMappings) {
MAPPINGS_CACHE.put(name, object);
}
return object;
} finally {
try {
reader.close();
} catch (IOException ignored) {
// Ignored
}
try (final InputStreamReader reader = new InputStreamReader(stream)) {
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
public static void mapIdentifiers(Int2IntBiMap output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
int value = mapIdentifierEntry(entry, newIdentifierMap, diffIdentifiers, warnOnMissing);
if (value != -1) {
output.put(Integer.parseInt(entry.getKey()), value);
}
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);
}
}
@Deprecated/*(forRemoval = true)*/
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
mapIdentifiers(output, oldIdentifiers, newIdentifiers, null);
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);
}
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
int value = mapIdentifierEntry(entry, newIdentifierMap, diffIdentifiers, warnOnMissing);
if (value != -1) {
output[Integer.parseInt(entry.getKey())] = value;
}
@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;
}
}
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers) {
mapIdentifiers(output, oldIdentifiers, newIdentifiers, diffIdentifiers, true);
}
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);
private static int mapIdentifierEntry(Map.Entry<String, JsonElement> entry, Object2IntMap<String> newIdentifierMap, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
int value = newIdentifierMap.getInt(entry.getValue().getAsString());
if (value == -1) {
// Search in diff mappings
if (diffIdentifiers != null) {
JsonElement diffElement = diffIdentifiers.get(entry.getKey());
if (diffElement != null) {
value = newIdentifierMap.getInt(diffElement.getAsString());
// 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);
}
}
if (value == -1) {
// 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 " + entry.getValue() + " :( ");
Via.getPlatform().getLogger().warning("No key for " + val + " :( ");
}
return -1;
}
}
return value;
return mappedId;
}
@Deprecated/*(forRemoval = true)*/
public static void mapIdentifiers(int[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, boolean warnOnMissing) {
mapIdentifiers(output, oldIdentifiers, newIdentifiers, null, warnOnMissing);
}
public static void mapIdentifiers(int[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
Object2IntMap<String> newIdentifierMap = MappingDataLoader.arrayToMap(newIdentifiers);
for (int i = 0; i < oldIdentifiers.size(); i++) {
JsonElement oldIdentifier = oldIdentifiers.get(i);
int mappedId = newIdentifierMap.getInt(oldIdentifier.getAsString());
if (mappedId == -1) {
// Search in diff mappings
if (diffIdentifiers != null) {
JsonElement diffElement = diffIdentifiers.get(oldIdentifier.getAsString());
if (diffElement != null) {
String mappedName = diffElement.getAsString();
if (mappedName.isEmpty()) continue; // "empty" remaps
mappedId = newIdentifierMap.getInt(mappedName);
}
}
if (mappedId == -1) {
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + oldIdentifier + " :( ");
}
continue;
}
@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;
}
output[i] = mappedId;
}
}
@@ -222,10 +304,10 @@ public class MappingDataLoader {
* @param object json object
* @return map with indexes hashed by their id value
*/
public static Object2IntMap<String> indexedObjectToMap(JsonObject object) {
Object2IntMap<String> map = new Object2IntOpenHashMap<>(object.size(), .99F);
public static Object2IntMap<String> indexedObjectToMap(final JsonObject object) {
final Object2IntMap<String> map = new Object2IntOpenHashMap<>(object.size(), .99F);
map.defaultReturnValue(-1);
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
for (final Map.Entry<String, JsonElement> entry : object.entrySet()) {
map.put(entry.getValue().getAsString(), Integer.parseInt(entry.getKey()));
}
return map;
@@ -237,8 +319,8 @@ public class MappingDataLoader {
* @param array json array
* @return map with indexes hashed by their id value
*/
public static Object2IntMap<String> arrayToMap(JsonArray array) {
Object2IntMap<String> map = new Object2IntOpenHashMap<>(array.size(), .99F);
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);
@@ -246,7 +328,25 @@ public class MappingDataLoader {
return map;
}
public static @Nullable InputStream getResource(String name) {
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);
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -25,7 +25,6 @@ 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 {
@@ -43,7 +42,7 @@ public interface Mappings {
*
* @param id unmapped id
* @param def fallback return value
* @return mapped id, or -1 if invalid/out of bounds
* @return mapped id, or def if invalid/out of bounds
*/
default int getNewIdOrDefault(int id, int def) {
final int mappedId = getNewId(id);
@@ -63,11 +62,11 @@ public interface Mappings {
/**
* Manually maps a specific id.
*
* @param id unmapped id
* @param newId mapped id
* @param id unmapped id
* @param mappedId mapped id
* @throws IndexOutOfBoundsException if the unmapped id is invalid
*/
void setNewId(int id, int newId);
void setNewId(int id, int mappedId);
/**
* Returns amount of unmapped entries, being the size of the mapping.
@@ -84,8 +83,15 @@ public interface Mappings {
*/
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);
return new Builder<>(supplier);
}
@FunctionalInterface
@@ -94,6 +100,7 @@ public interface Mappings {
T supply(int[] mappings, int mappedIds);
}
@Deprecated
class Builder<T extends Mappings> {
protected final MappingsSupplier<T> supplier;
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -22,16 +22,16 @@
*/
package com.viaversion.viaversion.api.data;
import com.google.gson.JsonArray;
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(2);
private final IntList itemParticleIds = new IntArrayList(4);
private final IntList blockParticleIds = new IntArrayList(4);
public ParticleMappings(JsonArray oldMappings, JsonArray newMappings, Mappings mappings) {
super(oldMappings, newMappings, mappings);
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");
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -24,9 +24,8 @@ package com.viaversion.viaversion.api.data.entity;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface EntityTracker {
@@ -53,6 +52,14 @@ public interface EntityTracker {
*/
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.
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -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);
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -23,7 +23,6 @@
package com.viaversion.viaversion.api.legacy.bossbar;
import com.viaversion.viaversion.api.connection.UserConnection;
import java.util.Set;
import java.util.UUID;
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -54,10 +54,10 @@ public interface BlockChangeRecord {
short getY(int chunkSectionY);
/**
* Returns the absolute y coordinate - only works for sub 1.16 protocols.
*
* @return absolute y coordinate
* @deprecated 1.16+ stores the relative y coordinate
*/
@Deprecated
default short getY() {
return getY(-1);
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -22,7 +22,7 @@
*/
package com.viaversion.viaversion.api.minecraft;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Map;
public enum BlockFace {
@@ -33,9 +33,9 @@ public enum BlockFace {
TOP((byte) 0, (byte) 1, (byte) 0, EnumAxis.Y),
BOTTOM((byte) 0, (byte) -1, (byte) 0, EnumAxis.Y);
public static final BlockFace[] HORIZONTAL = new BlockFace[]{NORTH, SOUTH, EAST, WEST};
public static final BlockFace[] HORIZONTAL = {NORTH, SOUTH, EAST, WEST};
private static final Map<BlockFace, BlockFace> opposites = new HashMap<>();
private static final Map<BlockFace, BlockFace> opposites = new EnumMap<>(BlockFace.class);
static {
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -33,7 +33,7 @@ public class Position {
this.z = z;
}
@Deprecated/*(forRemoval=true)*/
// @Deprecated/*(forRemoval=true)*/ Just leave this unchecked
public Position(int x, short y, int z) {
this(x, (int) y, z);
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -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 +
'}';
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -22,10 +22,9 @@
*/
package com.viaversion.viaversion.api.minecraft;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.HashMap;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.Nullable;
public enum RegistryType {
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -26,7 +26,7 @@ public final class TagData {
private final String identifier;
private final int[] entries;
public TagData(String identifier, int[] entries) {
public TagData(final String identifier, final int[] entries) {
this.identifier = identifier;
this.entries = entries;
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -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;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -27,6 +27,10 @@ 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);
}
@@ -42,4 +46,6 @@ public interface BlockEntity {
int typeId();
@Nullable CompoundTag tag();
BlockEntity withTypeId(int typeId);
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -56,4 +56,9 @@ public final class BlockEntityImpl implements BlockEntity {
public CompoundTag tag() {
return tag;
}
@Override
public BlockEntity withTypeId(int typeId) {
return new BlockEntityImpl(packedXZ, y, typeId, tag);
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -24,10 +24,9 @@ package com.viaversion.viaversion.api.minecraft.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
import org.checkerframework.checker.nullness.qual.Nullable;
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 {
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -24,10 +24,9 @@ package com.viaversion.viaversion.api.minecraft.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.BitSet;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
// TODO specialized sub interfaces
public interface Chunk {
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -24,10 +24,9 @@ package com.viaversion.viaversion.api.minecraft.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
import org.checkerframework.checker.nullness.qual.Nullable;
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;
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -40,6 +40,18 @@ public interface ChunkSection {
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);
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -22,9 +22,8 @@
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.EnumMap;
import org.checkerframework.checker.nullness.qual.Nullable;
public class ChunkSectionImpl implements ChunkSection {
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -47,6 +47,11 @@ public class ChunkSectionLightImpl implements ChunkSectionLight {
@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);
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -29,21 +29,24 @@ 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[] values;
private final int sizeBits;
private ChunkData values;
public DataPaletteImpl(final int valuesLength) {
this(valuesLength, 8);
this(valuesLength, DEFAULT_INITIAL_SIZE);
}
public DataPaletteImpl(final int valuesLength, final int expectedPaletteLength) {
this.values = new int[valuesLength];
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(expectedPaletteLength);
inversePalette = new Int2IntOpenHashMap(expectedPaletteLength);
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);
}
@@ -54,7 +57,7 @@ public final class DataPaletteImpl implements DataPalette {
@Override
public int idAt(final int sectionCoordinate) {
final int index = values[sectionCoordinate];
final int index = values.get(sectionCoordinate);
return palette.getInt(index);
}
@@ -67,17 +70,17 @@ public final class DataPaletteImpl implements DataPalette {
inversePalette.put(id, index);
}
values[sectionCoordinate] = index;
values.set(sectionCoordinate, index);
}
@Override
public int paletteIndexAt(final int packedCoordinate) {
return values[packedCoordinate];
return values.get(packedCoordinate);
}
@Override
public void setPaletteIndexAt(final int sectionCoordinate, final int index) {
values[sectionCoordinate] = index;
values.set(sectionCoordinate, index);
}
@Override
@@ -131,4 +134,77 @@ public final class DataPaletteImpl implements DataPalette {
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,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -23,7 +23,6 @@
package com.viaversion.viaversion.api.minecraft.entities;
import com.viaversion.viaversion.api.Via;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -23,7 +23,6 @@
package com.viaversion.viaversion.api.minecraft.entities;
import com.viaversion.viaversion.api.Via;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -24,7 +24,6 @@
package com.viaversion.viaversion.api.minecraft.entities;
import com.viaversion.viaversion.api.Via;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -23,7 +23,6 @@
package com.viaversion.viaversion.api.minecraft.entities;
import com.viaversion.viaversion.api.Via;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -25,9 +25,8 @@ package com.viaversion.viaversion.api.minecraft.entities;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Locale;
import org.checkerframework.checker.nullness.qual.Nullable;
public enum Entity1_19Types implements EntityType {
@@ -0,0 +1,274 @@
/*
* 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 com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil;
import java.util.Locale;
import org.checkerframework.checker.nullness.qual.Nullable;
public enum Entity1_19_3Types implements EntityType {
ENTITY(null, null),
AREA_EFFECT_CLOUD(ENTITY),
END_CRYSTAL(ENTITY),
EVOKER_FANGS(ENTITY),
EXPERIENCE_ORB(ENTITY),
EYE_OF_ENDER(ENTITY),
FALLING_BLOCK(ENTITY),
FIREWORK_ROCKET(ENTITY),
ITEM(ENTITY),
LLAMA_SPIT(ENTITY),
TNT(ENTITY),
SHULKER_BULLET(ENTITY),
FISHING_BOBBER(ENTITY),
LIVINGENTITY(ENTITY, null),
ARMOR_STAND(LIVINGENTITY),
MARKER(ENTITY),
PLAYER(LIVINGENTITY),
ABSTRACT_INSENTIENT(LIVINGENTITY, null),
ENDER_DRAGON(ABSTRACT_INSENTIENT),
BEE(ABSTRACT_INSENTIENT),
ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null),
ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null),
VILLAGER(ABSTRACT_AGEABLE),
WANDERING_TRADER(ABSTRACT_AGEABLE),
// Animals
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
AXOLOTL(ABSTRACT_ANIMAL),
DOLPHIN(ABSTRACT_INSENTIENT),
CHICKEN(ABSTRACT_ANIMAL),
COW(ABSTRACT_ANIMAL),
MOOSHROOM(COW),
PANDA(ABSTRACT_INSENTIENT),
PIG(ABSTRACT_ANIMAL),
POLAR_BEAR(ABSTRACT_ANIMAL),
RABBIT(ABSTRACT_ANIMAL),
SHEEP(ABSTRACT_ANIMAL),
TURTLE(ABSTRACT_ANIMAL),
FOX(ABSTRACT_ANIMAL),
FROG(ABSTRACT_ANIMAL),
GOAT(ABSTRACT_ANIMAL),
ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null),
CAT(ABSTRACT_TAMEABLE_ANIMAL),
OCELOT(ABSTRACT_TAMEABLE_ANIMAL),
WOLF(ABSTRACT_TAMEABLE_ANIMAL),
ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null),
PARROT(ABSTRACT_PARROT),
// Horses
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
CHESTED_HORSE(ABSTRACT_HORSE, null),
DONKEY(CHESTED_HORSE),
MULE(CHESTED_HORSE),
LLAMA(CHESTED_HORSE),
TRADER_LLAMA(CHESTED_HORSE),
HORSE(ABSTRACT_HORSE),
SKELETON_HORSE(ABSTRACT_HORSE),
ZOMBIE_HORSE(ABSTRACT_HORSE),
CAMEL(ABSTRACT_HORSE),
// Golem
ABSTRACT_GOLEM(ABSTRACT_CREATURE, null),
SNOW_GOLEM(ABSTRACT_GOLEM),
IRON_GOLEM(ABSTRACT_GOLEM),
SHULKER(ABSTRACT_GOLEM),
// Fish
ABSTRACT_FISHES(ABSTRACT_CREATURE, null),
COD(ABSTRACT_FISHES),
PUFFERFISH(ABSTRACT_FISHES),
SALMON(ABSTRACT_FISHES),
TROPICAL_FISH(ABSTRACT_FISHES),
// Monsters
ABSTRACT_MONSTER(ABSTRACT_CREATURE, null),
BLAZE(ABSTRACT_MONSTER),
CREEPER(ABSTRACT_MONSTER),
ENDERMITE(ABSTRACT_MONSTER),
ENDERMAN(ABSTRACT_MONSTER),
GIANT(ABSTRACT_MONSTER),
SILVERFISH(ABSTRACT_MONSTER),
VEX(ABSTRACT_MONSTER),
WITCH(ABSTRACT_MONSTER),
WITHER(ABSTRACT_MONSTER),
RAVAGER(ABSTRACT_MONSTER),
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
PIGLIN(ABSTRACT_PIGLIN),
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
HOGLIN(ABSTRACT_ANIMAL),
STRIDER(ABSTRACT_ANIMAL),
TADPOLE(ABSTRACT_FISHES),
ZOGLIN(ABSTRACT_MONSTER),
WARDEN(ABSTRACT_MONSTER),
// Illagers
ABSTRACT_ILLAGER_BASE(ABSTRACT_MONSTER, null),
ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null),
EVOKER(ABSTRACT_EVO_ILLU_ILLAGER),
ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER),
VINDICATOR(ABSTRACT_ILLAGER_BASE),
PILLAGER(ABSTRACT_ILLAGER_BASE),
// Skeletons
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
SKELETON(ABSTRACT_SKELETON),
STRAY(ABSTRACT_SKELETON),
WITHER_SKELETON(ABSTRACT_SKELETON),
// Guardians
GUARDIAN(ABSTRACT_MONSTER),
ELDER_GUARDIAN(GUARDIAN),
// Spiders
SPIDER(ABSTRACT_MONSTER),
CAVE_SPIDER(SPIDER),
// Zombies
ZOMBIE(ABSTRACT_MONSTER),
DROWNED(ZOMBIE),
HUSK(ZOMBIE),
ZOMBIFIED_PIGLIN(ZOMBIE),
ZOMBIE_VILLAGER(ZOMBIE),
// Flying entities
ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null),
GHAST(ABSTRACT_FLYING),
PHANTOM(ABSTRACT_FLYING),
ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null),
BAT(ABSTRACT_AMBIENT),
ALLAY(ABSTRACT_CREATURE),
ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null),
SQUID(ABSTRACT_WATERMOB),
GLOW_SQUID(SQUID),
// Slimes
SLIME(ABSTRACT_INSENTIENT),
MAGMA_CUBE(SLIME),
// Hangable objects
ABSTRACT_HANGING(ENTITY, null),
LEASH_KNOT(ABSTRACT_HANGING),
ITEM_FRAME(ABSTRACT_HANGING),
GLOW_ITEM_FRAME(ITEM_FRAME),
PAINTING(ABSTRACT_HANGING),
ABSTRACT_LIGHTNING(ENTITY, null),
LIGHTNING_BOLT(ABSTRACT_LIGHTNING),
// Arrows
ABSTRACT_ARROW(ENTITY, null),
ARROW(ABSTRACT_ARROW),
SPECTRAL_ARROW(ABSTRACT_ARROW),
TRIDENT(ABSTRACT_ARROW),
// Fireballs
ABSTRACT_FIREBALL(ENTITY, null),
DRAGON_FIREBALL(ABSTRACT_FIREBALL),
FIREBALL(ABSTRACT_FIREBALL),
SMALL_FIREBALL(ABSTRACT_FIREBALL),
WITHER_SKULL(ABSTRACT_FIREBALL),
// Projectiles
PROJECTILE_ABSTRACT(ENTITY, null),
SNOWBALL(PROJECTILE_ABSTRACT),
ENDER_PEARL(PROJECTILE_ABSTRACT),
EGG(PROJECTILE_ABSTRACT),
POTION(PROJECTILE_ABSTRACT),
EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT),
// Vehicles
MINECART_ABSTRACT(ENTITY, null),
CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null),
CHEST_MINECART(CHESTED_MINECART_ABSTRACT),
HOPPER_MINECART(CHESTED_MINECART_ABSTRACT),
MINECART(MINECART_ABSTRACT),
FURNACE_MINECART(MINECART_ABSTRACT),
COMMAND_BLOCK_MINECART(MINECART_ABSTRACT),
TNT_MINECART(MINECART_ABSTRACT),
SPAWNER_MINECART(MINECART_ABSTRACT),
BOAT(ENTITY),
CHEST_BOAT(BOAT);
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
private final EntityType parent;
private final String identifier;
private int id = -1;
Entity1_19_3Types(final EntityType parent) {
this.parent = parent;
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT);
}
Entity1_19_3Types(final EntityType parent, @Nullable final String identifier) {
this.parent = parent;
this.identifier = identifier;
}
@Override
public int getId() {
if (id == -1) {
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
}
return id;
}
@Override
public String identifier() {
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
return identifier;
}
@Override
public @Nullable EntityType getParent() {
return parent;
}
@Override
public boolean isAbstractType() {
return identifier == null;
}
public static EntityType getTypeFromId(final int typeId) {
return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY);
}
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id);
}
}
@@ -0,0 +1,281 @@
/*
* 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 com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil;
import java.util.Locale;
import org.checkerframework.checker.nullness.qual.Nullable;
public enum Entity1_19_4Types implements EntityType {
ENTITY(null, null),
AREA_EFFECT_CLOUD(ENTITY),
END_CRYSTAL(ENTITY),
EVOKER_FANGS(ENTITY),
EXPERIENCE_ORB(ENTITY),
EYE_OF_ENDER(ENTITY),
FALLING_BLOCK(ENTITY),
FIREWORK_ROCKET(ENTITY),
ITEM(ENTITY),
LLAMA_SPIT(ENTITY),
TNT(ENTITY),
SHULKER_BULLET(ENTITY),
FISHING_BOBBER(ENTITY),
LIVINGENTITY(ENTITY, null),
ARMOR_STAND(LIVINGENTITY),
MARKER(ENTITY),
PLAYER(LIVINGENTITY),
DISPLAY(ENTITY, null),
BLOCK_DISPLAY(DISPLAY),
ITEM_DISPLAY(DISPLAY),
TEXT_DISPLAY(DISPLAY),
INTERACTION(ENTITY),
ABSTRACT_INSENTIENT(LIVINGENTITY, null),
ENDER_DRAGON(ABSTRACT_INSENTIENT),
BEE(ABSTRACT_INSENTIENT),
ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null),
ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null),
VILLAGER(ABSTRACT_AGEABLE),
WANDERING_TRADER(ABSTRACT_AGEABLE),
// Animals
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
AXOLOTL(ABSTRACT_ANIMAL),
DOLPHIN(ABSTRACT_INSENTIENT),
CHICKEN(ABSTRACT_ANIMAL),
COW(ABSTRACT_ANIMAL),
MOOSHROOM(COW),
PANDA(ABSTRACT_INSENTIENT),
PIG(ABSTRACT_ANIMAL),
POLAR_BEAR(ABSTRACT_ANIMAL),
RABBIT(ABSTRACT_ANIMAL),
SHEEP(ABSTRACT_ANIMAL),
TURTLE(ABSTRACT_ANIMAL),
FOX(ABSTRACT_ANIMAL),
FROG(ABSTRACT_ANIMAL),
GOAT(ABSTRACT_ANIMAL),
SNIFFER(ABSTRACT_ANIMAL),
ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null),
CAT(ABSTRACT_TAMEABLE_ANIMAL),
OCELOT(ABSTRACT_TAMEABLE_ANIMAL),
WOLF(ABSTRACT_TAMEABLE_ANIMAL),
ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null),
PARROT(ABSTRACT_PARROT),
// Horses
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
CHESTED_HORSE(ABSTRACT_HORSE, null),
DONKEY(CHESTED_HORSE),
MULE(CHESTED_HORSE),
LLAMA(CHESTED_HORSE),
TRADER_LLAMA(CHESTED_HORSE),
HORSE(ABSTRACT_HORSE),
SKELETON_HORSE(ABSTRACT_HORSE),
ZOMBIE_HORSE(ABSTRACT_HORSE),
CAMEL(ABSTRACT_HORSE),
// Golem
ABSTRACT_GOLEM(ABSTRACT_CREATURE, null),
SNOW_GOLEM(ABSTRACT_GOLEM),
IRON_GOLEM(ABSTRACT_GOLEM),
SHULKER(ABSTRACT_GOLEM),
// Fish
ABSTRACT_FISHES(ABSTRACT_CREATURE, null),
COD(ABSTRACT_FISHES),
PUFFERFISH(ABSTRACT_FISHES),
SALMON(ABSTRACT_FISHES),
TROPICAL_FISH(ABSTRACT_FISHES),
// Monsters
ABSTRACT_MONSTER(ABSTRACT_CREATURE, null),
BLAZE(ABSTRACT_MONSTER),
CREEPER(ABSTRACT_MONSTER),
ENDERMITE(ABSTRACT_MONSTER),
ENDERMAN(ABSTRACT_MONSTER),
GIANT(ABSTRACT_MONSTER),
SILVERFISH(ABSTRACT_MONSTER),
VEX(ABSTRACT_MONSTER),
WITCH(ABSTRACT_MONSTER),
WITHER(ABSTRACT_MONSTER),
RAVAGER(ABSTRACT_MONSTER),
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
PIGLIN(ABSTRACT_PIGLIN),
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
HOGLIN(ABSTRACT_ANIMAL),
STRIDER(ABSTRACT_ANIMAL),
TADPOLE(ABSTRACT_FISHES),
ZOGLIN(ABSTRACT_MONSTER),
WARDEN(ABSTRACT_MONSTER),
// Illagers
ABSTRACT_ILLAGER_BASE(ABSTRACT_MONSTER, null),
ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null),
EVOKER(ABSTRACT_EVO_ILLU_ILLAGER),
ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER),
VINDICATOR(ABSTRACT_ILLAGER_BASE),
PILLAGER(ABSTRACT_ILLAGER_BASE),
// Skeletons
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
SKELETON(ABSTRACT_SKELETON),
STRAY(ABSTRACT_SKELETON),
WITHER_SKELETON(ABSTRACT_SKELETON),
// Guardians
GUARDIAN(ABSTRACT_MONSTER),
ELDER_GUARDIAN(GUARDIAN),
// Spiders
SPIDER(ABSTRACT_MONSTER),
CAVE_SPIDER(SPIDER),
// Zombies
ZOMBIE(ABSTRACT_MONSTER),
DROWNED(ZOMBIE),
HUSK(ZOMBIE),
ZOMBIFIED_PIGLIN(ZOMBIE),
ZOMBIE_VILLAGER(ZOMBIE),
// Flying entities
ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null),
GHAST(ABSTRACT_FLYING),
PHANTOM(ABSTRACT_FLYING),
ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null),
BAT(ABSTRACT_AMBIENT),
ALLAY(ABSTRACT_CREATURE),
ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null),
SQUID(ABSTRACT_WATERMOB),
GLOW_SQUID(SQUID),
// Slimes
SLIME(ABSTRACT_INSENTIENT),
MAGMA_CUBE(SLIME),
// Hangable objects
ABSTRACT_HANGING(ENTITY, null),
LEASH_KNOT(ABSTRACT_HANGING),
ITEM_FRAME(ABSTRACT_HANGING),
GLOW_ITEM_FRAME(ITEM_FRAME),
PAINTING(ABSTRACT_HANGING),
ABSTRACT_LIGHTNING(ENTITY, null),
LIGHTNING_BOLT(ABSTRACT_LIGHTNING),
// Arrows
ABSTRACT_ARROW(ENTITY, null),
ARROW(ABSTRACT_ARROW),
SPECTRAL_ARROW(ABSTRACT_ARROW),
TRIDENT(ABSTRACT_ARROW),
// Fireballs
ABSTRACT_FIREBALL(ENTITY, null),
DRAGON_FIREBALL(ABSTRACT_FIREBALL),
FIREBALL(ABSTRACT_FIREBALL),
SMALL_FIREBALL(ABSTRACT_FIREBALL),
WITHER_SKULL(ABSTRACT_FIREBALL),
// Projectiles
PROJECTILE_ABSTRACT(ENTITY, null),
SNOWBALL(PROJECTILE_ABSTRACT),
ENDER_PEARL(PROJECTILE_ABSTRACT),
EGG(PROJECTILE_ABSTRACT),
POTION(PROJECTILE_ABSTRACT),
EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT),
// Vehicles
MINECART_ABSTRACT(ENTITY, null),
CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null),
CHEST_MINECART(CHESTED_MINECART_ABSTRACT),
HOPPER_MINECART(CHESTED_MINECART_ABSTRACT),
MINECART(MINECART_ABSTRACT),
FURNACE_MINECART(MINECART_ABSTRACT),
COMMAND_BLOCK_MINECART(MINECART_ABSTRACT),
TNT_MINECART(MINECART_ABSTRACT),
SPAWNER_MINECART(MINECART_ABSTRACT),
BOAT(ENTITY),
CHEST_BOAT(BOAT);
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
private final EntityType parent;
private final String identifier;
private int id = -1;
Entity1_19_4Types(final EntityType parent) {
this.parent = parent;
this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT);
}
Entity1_19_4Types(final EntityType parent, @Nullable final String identifier) {
this.parent = parent;
this.identifier = identifier;
}
@Override
public int getId() {
if (id == -1) {
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
}
return id;
}
@Override
public String identifier() {
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
return identifier;
}
@Override
public @Nullable EntityType getParent() {
return parent;
}
@Override
public boolean isAbstractType() {
return identifier == null;
}
public static EntityType getTypeFromId(final int typeId) {
return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY);
}
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id);
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
@@ -24,9 +24,8 @@ package com.viaversion.viaversion.api.minecraft.item;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.google.gson.annotations.SerializedName;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Objects;
import org.checkerframework.checker.nullness.qual.Nullable;
public class DataItem implements Item {
@SerializedName(value = "identifier", alternate = "id")
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
* 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
Loaded 100 of 836 files, more files were not shown because too many files have changed in this diff. Show more