Compare commits

...
1321 Commits
Author SHA1 Message Date
Nassim Jahnke 132cf1d6e1 5.0.0 Release 2024-06-16 14:02:32 +02:00
Nassim Jahnke 5f57041413 Fix item data handling order 2024-06-16 11:05:50 +02:00
Nassim Jahnke f91a25cba7 Make sure we have block mappings before trying to apply them 2024-06-16 10:22:37 +02:00
Nassim Jahnke 547041cb62 Merge branch 'refs/heads/dev' into preview 2024-06-15 16:11:26 +02:00
Pantera (Mad_Daniel) b7af3b7d8e Fix player head in 1.20.2->1.20 (#786) 2024-06-15 15:10:20 +02:00
Nassim Jahnke bb927b31f7 Some fixups
Informative commit message I know
2024-06-14 00:58:32 +02:00
EnZaXD eceda8ac58 Add remaining item array type in BlockItemPacketRewriter1_13 (#784) 2024-06-13 18:42:17 +02:00
Nassim Jahnke 65d829065a Read proper sound event type in 1.20.5->1.20.3 2024-06-13 18:33:43 +02:00
Nassim Jahnke 0b38dc18a5 Remove snapshot from version 2024-06-12 18:10:36 +02:00
Nassim Jahnke 4b58f6d154 1.21-rc1 2024-06-12 18:08:23 +02:00
Nassim Jahnke 6d8fee053d 1.21-pre3 2024-06-12 18:08:23 +02:00
Nassim Jahnke 335415efd7 1.21-pre2 2024-06-12 18:08:23 +02:00
Nassim Jahnke 59f7ce339e Remove jukebox_playable 2024-06-12 18:08:22 +02:00
Nassim Jahnke a9b9c48b26 Handle item changes in show item text components 2024-06-12 18:08:22 +02:00
Nassim Jahnke 8fb814ef11 Handle chat and horse container changes 2024-06-12 18:08:22 +02:00
Nassim Jahnke 9873f279a4 Bump version 2024-06-12 18:08:22 +02:00
Nassim Jahnke ab1467dba5 Handle jukebox song level event 2024-06-12 18:08:21 +02:00
Nassim Jahnke 3749a5d5da Update data component ids 2024-06-12 18:08:21 +02:00
Nassim Jahnke 6f8da18f65 24w21b, mostly 2024-06-12 18:08:21 +02:00
Nassim Jahnke 1a24ce6d87 24w20a 2024-06-12 18:08:21 +02:00
Nassim Jahnke e9d142e2ec Rebase onto 5.0.0 2024-06-12 18:08:20 +02:00
Nassim Jahnke 218b2abe45 24w19a 2024-06-12 18:08:20 +02:00
Nassim Jahnke 263790e9f6 24w18a 2024-06-12 18:08:20 +02:00
EnZaXD 094bfe34c6 Use trade list rewriter functions (#782) 2024-06-11 15:10:22 +02:00
Nassim Jahnke bfbc086f44 Revert "Send registry data before finish configuration in 1.20.5->1.20.3 (#778)"
This reverts commit e93e30c235.
2024-06-08 20:09:10 +02:00
EnZaXD 7bd43e0234 Use TagRewriter#registerGeneric in 1.20.3->1.20.2 (#779) 2024-06-07 18:38:29 +02:00
EnZaXD e93e30c235 Send registry data before finish configuration in 1.20.5->1.20.3 (#778) 2024-06-07 18:19:49 +02:00
Nassim Jahnke 2f5fbd93ea Make items in 1.20.5+ non null 2024-06-07 13:52:45 +02:00
EnZaXD f86fdd1eb4 Update VV API usage (#776) 2024-06-06 11:09:39 +02:00
Nassim Jahnke 993608b4b4 Also apply MC-68487 workaround to items 2024-06-06 10:56:43 +02:00
EnZaXD a786152dfc Handle UPDATE_LISTED state in 1.19.3->1.19.1 (#775) 2024-06-05 09:24:47 +02:00
EnZaXD 89caecef4f Ignore errors in 1.14->1.13.2 lore tag conversion (#773) 2024-06-04 12:42:43 +02:00
EnZaXD 6058763489 Don't publish extra modules (#772) 2024-06-03 20:31:54 +02:00
EnZaXD 8a675923d1 Emulate recovery compass using lodestone compass in 1.19->1.18.2 (#770) 2024-06-03 09:49:39 +02:00
EnZaXD 3370383481 Add firework flight length fix from VV (#769) 2024-06-02 09:04:17 +02:00
Nassim Jahnke 449ddd1de7 Update Gradle wrapper 2024-06-01 17:10:40 +02:00
Nassim Jahnke 9efc2e630f Update publication metadata 2024-05-30 22:37:44 +02:00
Nassim Jahnke 5849bf06e6 Move Bungee and Sponge modules to separate plugins 2024-05-30 22:21:49 +02:00
EnZaXD 1c45e41934 Fix horse/llama's armor/carpet not visible in 1.20.5->.3 (#765) 2024-05-30 15:47:06 +02:00
Nassim Jahnke bc3d6b952f Resend damageable item on cancelled block break in 1.11->1.10
The client assumes durability changes, so we have to resend the item
2024-05-30 15:42:07 +02:00
EnZaXD b53c0aeb9b Handle block state particles when identifier is used in 1.20.5->.3 (#764) 2024-05-30 10:45:02 +02:00
EnZaXD 3511ba3c67 [ci skip] Replace GitHub link to hangar/viaversion.com sub link (#766) 2024-05-30 10:43:20 +02:00
EnZaXD 1bf5f7408b Add missing translation mappings and component rewriter (#761) 2024-05-28 10:52:08 +02:00
EnZaXD 9e63243003 Make TranslatableRewriter usable in other projects as well (#762) 2024-05-27 19:37:57 +02:00
RK_01 98fad11060 Update Via API usage (#760) 2024-05-27 13:35:14 +02:00
Nassim Jahnke fe4986b042 Fix sniffer entity data removal
Fixes #757
2024-05-22 10:11:09 +02:00
Nassim Jahnke 0618037a0e Rename Position 2024-05-21 13:12:18 +02:00
Nassim Jahnke d7f550fc4f Remove empty item tags
Fixes #752
2024-05-21 11:20:55 +02:00
Nassim Jahnke a9ed655d95 Add extra slot to horse inventories
Fixes #754
2024-05-21 10:36:02 +02:00
EnZaXD 6e75026681 Add config option to suppress emulation warnings (#751) 2024-05-19 09:27:22 +02:00
EnZaXD f9890db702 Use legacy chunk rewriter functions (#750) 2024-05-15 17:27:43 +02:00
EnZaXD dd4ab8082e Update data class names to indicate target version (#749) 2024-05-15 11:16:50 +02:00
EnZaXD f949fd658a [ci skip] Add J17 note to README as well (#748) 2024-05-14 22:20:07 +02:00
EnZaXD 8f92d55747 Update Via API usage (#747) 2024-05-14 20:48:49 +02:00
EnZaXD 4d6c6a2da1 Fix wrong Protocol1_8To1_9#STRING_TO_JSON usages in 1.12->1.11.1 (#746) 2024-05-14 20:48:19 +02:00
Nassim Jahnke 903a49b96a Apply IJ code reformat 2024-05-14 20:48:17 +02:00
FlorianMichael b85046f11d Rework logging inside protocols and rewriters 2024-05-14 20:48:07 +02:00
FlorianMichael 264cce865b Rename data, protocol and mapping classes
Syncs names with https://github.com/ViaVersion/ViaVersion/commit/a2b7fc82e2bc3a30823812da3c4d478f467a5411
2024-05-14 20:47:58 +02:00
FlorianMichael c27f720316 Update Via API usage
Question to EntityPacketRewriter1_16_2: is it intended that the LOGIN handler doesn't copy the written dimensions tag or was that just forgotten?
2024-05-14 20:47:43 +02:00
Nassim Jahnke a946632e8b Lots of renames 2024-05-14 20:47:40 +02:00
Nassim Jahnke 5e7371d39b Start working on 5.0.0 2024-05-11 15:01:36 +02:00
EnZaXD abb1803aaf Cache dimensions without namespace in 1.19->1.18.2 (#744) 2024-05-10 21:47:45 +02:00
Nassim Jahnke e45a95c6ec Bump version to 4.10.3-SNAPSHOT 2024-05-10 21:47:35 +02:00
Nassim Jahnke 17bda0fc29 4.10.2 Release 2024-05-10 13:24:40 +02:00
EnZaXD 1a22b371cd Handle bad heightmaps in 1.17->1.16.4 (#743) 2024-05-09 21:56:14 +02:00
EnZaXD 6292c5a5a5 Use backup tag remove method when rewriting trade list (#742) 2024-05-09 20:55:31 +02:00
Nassim Jahnke 6b616d8b07 Fixup banner handling 2024-05-09 19:44:03 +02:00
Nassim Jahnke fd43ca56d7 Properly write properties 2024-05-09 18:04:13 +02:00
Nassim Jahnke 91193cf602 Handle player head block entities
Fixes #741
2024-05-09 17:22:31 +02:00
EnZaXD 1680f9985d [ci skip] Use login/status packet enums in older protocols (#740) 2024-05-09 09:25:17 +02:00
EnZaXD e8602adf5b Fix red nether brick name in 1.11->1.10 (#739) 2024-05-07 19:35:18 +02:00
EnZaXD 7f0982e59c Fix item mappings with explicit data (0) (#738) 2024-05-07 18:54:38 +02:00
Nassim Jahnke 072b59060c Don't write null criteria for unknown advancements 2024-05-07 17:07:13 +02:00
EnZaXD 633b4b393b Remove alpha channel from particle colors in 1.20.5->.3 (#737) 2024-05-06 09:50:33 +02:00
Nassim Jahnke 34101ea8b8 4.10.1 Release
Definitely the first time I made this commit
2024-05-05 16:53:56 +02:00
Nassim Jahnke 093328db11 Handle missing mappings 2024-05-05 16:53:36 +02:00
Nassim Jahnke 5bd8786737 Update entity mapping usage 2024-05-05 12:22:17 +02:00
EnZaXD fedda03062 Use TagUtil#removeNamespaced in 1.19.4->.3 (#735) 2024-05-02 16:07:22 +02:00
EnZaXD 99f6356230 Make chat_types handling in 1.19 protocols optional (#733) 2024-05-02 15:59:51 +02:00
EnZaXD 9b8e65c59d Implement handleTranslate() for tags in TranslatableRewriter (#734) 2024-05-02 15:28:40 +02:00
Nassim JahnkeandKrakenied bd2eb42374 Add advancement criteria if possible in 1.20.2->1.20
Fixes #616

Co-authored-by: Krakenied <Krakenied1@gmail.com>
2024-05-01 11:31:03 +02:00
Nassim Jahnke e9db3f040f Check both namespaced and implicit key when replacing registries 2024-05-01 10:35:48 +02:00
Nassim Jahnke ce0e01abec Auto: Update copyright headers 2024-04-30 22:29:02 +02:00
Nassim Jahnke 025603027e Remove default components from trade list 2024-04-30 22:29:02 +02:00
EnZaXD 67ae00faeb Add support for different mapping types with same id (#731) 2024-04-30 18:29:45 +02:00
Nassim Jahnke 325e3f92ed Remove 1.19.4 registries without namespace as well 2024-04-29 23:12:37 +02:00
Nassim Jahnke 42897030f7 Fix entity effect reading below 1.20.2
Fixes #3811
2024-04-28 11:39:43 +02:00
Nassim Jahnke ddeaf921be Register listeners a tick later
Because 1.8 has task registration order reverse???
Fixes #730
2024-04-28 11:35:51 +02:00
Nassim Jahnke 06c30c2838 Add paperweight-mappings-namespace attribute 2024-04-28 03:52:25 +02:00
Gero bf7ed14506 Fix remapping of 1.20.5 CLICK_WINDOW_BUTTON 2024-04-27 21:31:49 +02:00
Gero c4d0c7ab8f Bump to 4.10.1-SNAPSHOT 2024-04-27 21:31:41 +02:00
Nassim Jahnke f1f337af27 Bump VV dependency 2024-04-26 15:25:19 +02:00
Nassim Jahnke e37fea42d4 4.10.0 Release 2024-04-26 15:15:57 +02:00
FlorianMichael 78a667c5b9 Add constructors to LegacyBlockItemRewriter to define item types 2024-04-26 15:15:24 +02:00
Nassim Jahnke 27dd2e39bd Merge branch 'refs/heads/dev' into preview
# Conflicts:
#	common/src/main/java/com/viaversion/viabackwards/api/data/BackwardsMappings.java
2024-04-26 14:32:00 +02:00
Nassim Jahnke b3115ea71d Fix some namespace parsing issues 2024-04-26 13:31:14 +02:00
Nassim Jahnke be742fc493 Fix 1.20.3->1.20.2 cloud particle handling 2024-04-26 13:19:09 +02:00
EnZaXD 100febf575 Rework legacy item/block mappings format (#728) 2024-04-26 09:18:42 +02:00
Nassim Jahnke cddf30b60f Read normal byte array type for cookie packet 2024-04-25 19:11:19 +02:00
EnZaXD c4c15fb047 Add EntityRewriterBase#getDisplayVisibilityMetaValue (#725) 2024-04-23 22:18:58 +02:00
EnZaXD ab11527c86 Reuse existing logger getter in BackwardsMappings (#726) 2024-04-23 22:18:45 +02:00
Nassim Jahnke 1d3a444fe0 Update version 2024-04-23 17:02:21 +02:00
Nassim Jahnke 82bb374edc Update version references 2024-04-23 11:26:31 +02:00
Nassim Jahnke a4147a24f1 Merge branch 'refs/heads/dev' into preview 2024-04-23 11:00:24 +02:00
EnZaXD 87f2a6ba7b Add mob spawn rewriter function for pre 1.11 (#724) 2024-04-23 10:45:12 +02:00
EnZaXD 948c615622 Replace LegacyEntityRewriter#getObjectTypeFromId with existing method (#723) 2024-04-22 23:30:15 +02:00
Nassim Jahnke 0996fc9270 Merge branch 'refs/heads/dev' into preview
# Conflicts:
#	common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java
#	common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java
2024-04-21 23:43:33 +02:00
Nassim Jahnke 0cd46fdac9 Also to component rewriter methods 2024-04-21 23:37:00 +02:00
Nassim Jahnke 2a4bfb936f Add UserConnection param to item rewriter methods 2024-04-21 22:48:56 +02:00
Nassim Jahnke 3b9b3ab257 Use getFullItemMappings 2024-04-21 20:50:04 +02:00
FlorianMichael e52210a674 Update mappings 2024-04-21 10:11:17 +02:00
Nassim Jahnke 11286b2162 Fall back to keys without namespace in registry data 2024-04-20 12:13:06 +02:00
Gero 471d4acf20 Add missing dust_color_transition data remapping (changed in 24w03a) 2024-04-19 16:54:52 +02:00
Gero e5fff8fabc 1.20.5-rc2 2024-04-19 16:54:10 +02:00
Nassim Jahnke 23955e5385 Update particle format in biome registry data 2024-04-18 19:16:42 +02:00
Nassim Jahnke bf635cc6c5 1.20.5-rc1 2024-04-18 16:30:58 +02:00
Nassim Jahnke 5a49413dbc Merge branch 'refs/heads/dev' into preview 2024-04-18 16:26:20 +02:00
Nassim Jahnke c64e9acf35 Override getTagRewriter methods 2024-04-18 16:26:03 +02:00
Nassim Jahnke 00f773d150 Merge branch 'refs/heads/master' into dev 2024-04-18 16:19:39 +02:00
EnZaXD 1ac504afb9 Use correct constructor in MappedLegacyBlockItem (#721) 2024-04-17 08:46:48 +02:00
EnZaXD 09eda34051 Use VVs IdAndData class for block id conversions (#719) 2024-04-16 21:05:45 +02:00
EnZaXD 9cf5f98ed1 Replace incoming/outgoing usages with client/server bound (#720) 2024-04-16 21:00:20 +02:00
Nassim Jahnke 1e8cf198e7 Update missed call 2024-04-15 17:29:22 +02:00
Nassim Jahnke caa28df36d 1.20.5-pre2 2024-04-15 17:17:19 +02:00
Nassim Jahnke d2edf3fbfe 1.20.5-pre1 2024-04-10 17:41:19 +02:00
Nassim Jahnke 68807be880 Track banner patterns 2024-04-09 13:18:40 +02:00
Nassim Jahnke 7d6c330fa3 Handle entity effect particle color 2024-04-08 15:05:01 +02:00
Nassim Jahnke 3ea95a0d78 Update authors 2024-04-07 20:44:24 +02:00
FlorianMichael fe708ba0eb Fix chat command handling 2024-04-07 19:58:44 +02:00
Nassim Jahnke fccd5b3f3b Fix trade list handling 2024-04-07 13:41:51 +02:00
Nassim Jahnke 9f652ad24a Update VV usage 2024-04-06 21:33:41 +02:00
Nassim Jahnke f7dad9b5d7 Add StructuredEnchantmentRewriter, update translation mappings 2024-04-06 21:30:19 +02:00
Nassim Jahnke 1507f788ec 24w14a 2024-04-06 21:28:59 +02:00
Nassim Jahnke 41b04f9902 24w13a 2024-04-06 21:28:59 +02:00
Nassim Jahnke 9beaf71196 Handle new argument types 2024-04-06 21:28:59 +02:00
Nassim Jahnke 0c7aa1d037 Update mappings 2024-04-06 21:28:59 +02:00
Nassim Jahnke 7a7d2f1fa1 Handle lore and name in StructuredItemRewriter 2024-04-06 21:28:56 +02:00
Nassim Jahnke 37711d0079 Set rewritten item in metadata rewriter 2024-04-06 21:28:21 +02:00
Nassim Jahnke e1f2f151c9 24w11a 2024-04-06 21:28:21 +02:00
Nassim Jahnke a453163822 Some 24w10a changes 2024-04-06 21:28:21 +02:00
EnZaXD 1647b18233 Override nbtTagName() correctly (#717) 2024-04-05 20:36:03 +02:00
vadage c7dc80b71b Support config loading from input stream (#718) 2024-04-05 20:32:47 +02:00
EnZaXD 39d3265463 Update VV ItemRewriter API Usage (#716) 2024-04-04 09:48:19 +02:00
Nassim Jahnke 2b953556ec Update VV API usage 2024-04-01 14:20:15 +02:00
EnZaXD 4e5b6fe876 Fix minor inconsistencies in older protocols (#714) 2024-04-01 13:01:07 +02:00
EnZaXD 0e74527342 Update Via API usage (#713) 2024-03-31 15:14:33 +02:00
EnZaXD 75fddd0fb9 Allow platforms to disable dummy enchantment in LegacyEnchantmentRewriter (#710) 2024-03-28 14:32:13 +01:00
EnZaXD 0aacfe3bcb Add item handler methods to LegacyEnchantmentRewriter (#709) 2024-03-28 11:22:34 +01:00
EnZaXD 4547d5c702 Move methods in LegacyBlockItemRewriter and expose handleChunk method (#707) 2024-03-27 20:15:57 +01:00
EnZaXD b438484dc7 Keep original item data in LegacyBlockItemRewriter (#706) 2024-03-27 17:04:50 +01:00
EnZaXD ed52ef21ee Add calculation methods for block id and data (#704) 2024-03-27 16:49:14 +01:00
EnZaXD 9d1a5a05f5 Expose EntityRewriterBase#alwaysShowOriginalMobName (#705) 2024-03-27 16:48:35 +01:00
EnZaXD 4e856ef396 Various API changes to LegacyBlockItemRewriter (#703) 2024-03-27 13:27:19 +01:00
EnZaXD 082cc010b2 Update Via API usage (#702) 2024-03-24 22:10:06 +01:00
EnZaXD 59a621315b Allow platforms to use BackwardsMappingDataLoader (#701) 2024-03-24 12:14:51 +01:00
EnZaXD d8b7e7d9ff Update mapping data loader (#700) 2024-03-24 11:46:08 +01:00
Nassim Jahnke 51561d143c Merge branch 'master' into dev
# Conflicts:
#	.github/workflows/publish.yml
2024-03-22 20:55:44 +01:00
Nassim Jahnke 2ffa852c92 Update build dependencies 2024-03-22 20:48:31 +01:00
Nassim Jahnke ac86d891fe Check if id is present in EnchantmentRewriter
Closes #699
2024-03-17 19:58:05 +01:00
Nassim Jahnke 9d8aa9a232 Update mappings 2024-03-17 16:29:32 +01:00
Nassim Jahnke f3b26c5aa5 Fix 1.20.2->1.20 entity sound reading
Fixes ViaVersion/ViaVersion#3744
2024-03-14 14:41:49 +01:00
Nassim Jahnke d96cef7134 Merge branch 'master' into dev 2024-03-09 13:09:17 +01:00
Nassim Jahnke ced1a65230 Replace some generic CompoundTag get usages 2024-03-09 13:08:36 +01:00
Nassim Jahnke 6ad1dc4195 Merge branch 'master' into dev
# Conflicts:
#	gradle.properties
#	gradle/libs.versions.toml
2024-03-07 13:51:41 +01:00
Nassim Jahnke c6ea04fd33 Update ViaNBT 2024-03-07 13:37:42 +01:00
Nassim Jahnke 79a2881a02 4.9.2 Release 2024-03-05 17:51:04 +01:00
Nassim Jahnke 64e68830bc Create FUNDING.yml 2024-03-04 17:32:32 +01:00
EnZaXD ab742c794f Update description included in platforms (#694) 2024-03-04 17:26:59 +01:00
Nassim Jahnke 39e9d6dd04 Use new SoundEvent type 2024-03-01 14:23:13 +01:00
Nassim Jahnke 445d798a17 Partially implement mapped item handling 2024-02-29 20:30:46 +01:00
Nassim Jahnke 66896d2027 Update version 2024-02-29 14:28:48 +01:00
Nassim Jahnke 05b1a6bacd Start working on 24w09a 2024-02-29 12:41:39 +01:00
EnZaXD bf3834ab21 Tidy up fabric.mod.json file of fabric platform (#695) 2024-02-29 12:25:31 +01:00
EnZaXD 2f60c79ed8 Use equals for legacy custom payload channel handlers (#693) 2024-02-29 12:09:50 +01:00
EnZaXD 5bb3e8a1fc paste.gg -> mclo.gs (#689) 2024-02-21 16:13:12 +01:00
Nassim Jahnke 8f417b6caa Rename methods once again 2024-02-14 19:27:40 +01:00
Nassim Jahnke 96d6c0697e Fix compilation 2024-02-14 18:15:41 +01:00
Nassim Jahnke c112044b5a 24w07a 2024-02-14 17:39:31 +01:00
Nassim Jahnke 45c44c8f7e Update VV usage 2024-02-14 11:13:58 +01:00
Nassim Jahnke 5a3a82a83d Update VV usage 2024-02-13 19:03:56 +01:00
Nassim Jahnke bc03235f42 Merge branch 'master' into dev
# Conflicts:
#	common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java
2024-02-12 11:08:17 +01:00
Nassim Jahnke 073488abcf Update template 2024-02-12 11:03:39 +01:00
Nassim Jahnke b60464296b Small cleanups 2024-02-12 11:02:55 +01:00
Nassim Jahnke 9241213fb5 Replace tag instanceof/unchecked casts with helper methods 2024-02-11 10:42:44 +01:00
Nassim Jahnke e9c3889c82 Add editorconfig 2024-02-11 10:39:06 +01:00
Nassim Jahnke f90861dbce Remap breeze wind charge 2024-02-08 16:19:17 +01:00
Nassim Jahnke 06f07d2b2c 24w06a 2024-02-07 19:07:34 +01:00
Nassim Jahnke fa1c3e1520 24w05b 2024-02-01 17:53:18 +01:00
EnZaXD dca8ecf1db Fix notes color from note block being wrong in 1.13->1.12 (#680)
Closes https://github.com/ViaVersion/ViaBackwards/issues/679
2024-02-01 16:28:40 +01:00
Nassim Jahnke 680d0642c9 Merge branch 'master' into dev
# Conflicts:
#	common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java
2024-01-31 22:58:51 +01:00
Nassim Jahnke 170e5f224f Fix writable book handling in 1.16->1.15 2024-01-31 22:58:11 +01:00
Nassim Jahnke f6def0c97c 24w05a (mostly) 2024-01-31 18:06:46 +01:00
EnZaXD 4375a259dd Fix 1.17.1 -> 1.18 mappings loading (#676)
Closes https://github.com/ViaVersion/ViaBackwards/issues/568
2024-01-29 20:30:59 +01:00
Nassim Jahnke b3b4d0f618 Merge branch 'master' into dev
# Conflicts:
#	common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java
2024-01-29 17:33:42 +01:00
Nassim Jahnke 8fc82cd331 Update book conversion error logging 2024-01-29 17:33:08 +01:00
EnZaXD de21548a8e Clean up more item type usage in ItemRewriter (#675) 2024-01-29 17:29:17 +01:00
Nassim Jahnke 8759f059b7 Ignore errors in book conversion 2024-01-29 10:17:50 +01:00
Nassim Jahnke 1f3555df4a Put books through component conversion in 1.20.3->1.20.2 2024-01-27 21:04:32 +01:00
Nassim Jahnke 9abfdfb8f9 Include config packets in Protocol generic types 2024-01-26 16:23:17 +01:00
Nassim Jahnke 8c2f80a632 Fix missed type removal from last commit 2024-01-26 14:38:55 +01:00
Nassim Jahnke 3e89641448 24w04a 2024-01-24 20:23:29 +01:00
Nassim Jahnke a2ddcae076 Merge branch 'master' into dev
# Conflicts:
#	.github/workflows/gradle.yml
2024-01-24 17:51:31 +01:00
Kichura b40f77fed3 Update JDK to 17, setup-java to v4 (#671) 2024-01-20 21:19:36 +01:00
Nassim Jahnke 8ffbc7047f Add cookie handling, TransferProvider for other platforms 2024-01-20 10:26:56 +01:00
Nassim Jahnke e6814a13a9 24w03b (probably) 2024-01-18 16:34:00 +01:00
Kichura 9fd0df824f Update supported Velocity version to 3.3 (#666) 2024-01-14 10:02:16 +01:00
EnZaXD 6b1f913b91 Fix VV API usage (#664) 2024-01-13 09:54:39 +01:00
Nassim Jahnke de42850dd1 Merge branch 'master' into dev
# Conflicts:
#	template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/EntityPacketRewriter1_99.java
2024-01-12 10:33:40 +01:00
Nassim Jahnke 88df61605b Update VV usage 2024-01-09 20:59:26 +01:00
Nassim Jahnke 6c2d43d7f9 Handle 1.20->1.20.2 tags 2024-01-09 17:19:19 +01:00
Nassim Jahnke 62765d03ce Merge remote-tracking branch 'origin/master' into dev 2024-01-04 17:51:18 +01:00
Nassim Jahnke 2889daed61 Update license header 2024-01-01 12:38:33 +01:00
Nassim Jahnke 651bf052fc Update ViaNBT 2023-12-31 14:04:57 +01:00
Nassim Jahnke 59660a5bdc Merge branch 'master' into dev 2023-12-27 19:48:40 +01:00
Kichura fa18a572c0 Update setup-java to v4, Fix friendly names in CI steps (#660) 2023-12-27 19:47:31 +01:00
Nassim Jahnke 83fa0c613f Update copyright profile 2023-12-27 17:51:16 +01:00
Nassim Jahnke 5334f77d49 Finish up things 2023-12-27 17:30:47 +01:00
Nassim Jahnke 96293e6e66 Start working on mcstructs usage (missing TranslatableRewriter1_16) 2023-12-27 00:24:56 +01:00
Nassim Jahnke 19ec92c261 Merge remote-tracking branch 'origin/master' into dev 2023-12-26 21:51:03 +01:00
Nassim Jahnke 65faeb8574 Fix 1.20.3->1.20.2 configuration resource pack id 2023-12-26 21:49:34 +01:00
Nassim Jahnke 6ad4a29d30 Allow specifying unmapped data in legacy mappings 2023-12-20 12:10:15 +01:00
Nassim Jahnke ba725df33e 23w51b 2023-12-18 19:50:25 +01:00
Nassim Jahnke 4fe53f5ab8 Update the bane of my existence 2023-12-13 22:45:23 +01:00
Nassim Jahnke a390990178 Read correct method type in update score
Fixes #650
2023-12-13 12:04:43 +01:00
Nassim Jahnke e020dd69ef Fix tab complete tooltip reading in old versions
Fixes #648
2023-12-11 11:27:52 +01:00
Nassim Jahnke b09950dc64 Update Via usage 2023-12-10 12:15:35 +01:00
Nassim Jahnke 7b8fd2b061 Fix 1.17->1.16 map data type reading
Fixes #646
2023-12-09 14:59:43 +01:00
Nassim Jahnke 2d57e8c212 Clone tag instead of abusing tag conversion 2023-12-08 21:06:30 +01:00
Camden Cove dcc3824a8c Fix 1.13.1->1.13 item type in some cases (#645) 2023-12-08 12:05:52 +01:00
EnZaXD 2dd19c778b Handle chunk loading game state in 1.20.3 -> 1.20.2 (#643) 2023-12-08 09:37:20 +01:00
Nassim Jahnke e24a170e77 Fix reset score reading 2023-12-07 23:17:55 +01:00
Nassim Jahnke 3a69dda548 Bump version to 4.9.2-SNAPSHOT 2023-12-07 23:17:36 +01:00
Nassim Jahnke 77ecda3977 4.9.1 Release 2023-12-07 11:19:36 +01:00
Nassim Jahnke c44bc88d2d Convert chat type in disguised chat packet 2023-12-07 10:11:18 +01:00
Nassim Jahnke deede5347e Fix 1.13 map data type
Fixes #641
2023-12-07 09:54:30 +01:00
Nassim Jahnke 255536e9d0 Handle tags packet 2023-12-06 09:47:11 +01:00
Nassim Jahnke 8a2c18863c Fix map marker reading 2023-12-05 22:23:48 +01:00
Nassim Jahnke 375bb5a1b9 Bump version to 4.9.1-SNAPSHOT 2023-12-05 22:18:32 +01:00
Nassim Jahnke c739b54403 4.9.0 Release 2023-12-04 10:14:06 +01:00
Nassim Jahnke a0388cf541 Merge branch 'master' into dev 2023-12-04 10:13:46 +01:00
RK_01 3dd6e5043e Change gamemode data type in JOIN_GAME handlers (#639) 2023-12-03 18:35:47 +01:00
Nassim JahnkeandEnZaXD d30766a17a Fix ordering issue in login ack send on the server
Fixes 1.20.2+ Fabric servers with Fabric API

Co-authored-by: EnZaXD <60033407+FlorianMichael@users.noreply.github.com>
2023-11-30 18:39:41 +01:00
Nassim Jahnke f556a29d38 1.20.3-rc1 2023-11-30 17:13:05 +01:00
Nassim Jahnke 8a19fbdead Update translation mappings 2023-11-30 15:54:54 +01:00
Nassim Jahnke d4011f3646 1.20.3-pre3 2023-11-27 17:12:42 +01:00
EnZaXD 2bd687b19d Implemented ViaVersion's SignableCommandArgumentsProvider (#633) 2023-11-26 15:34:55 +01:00
Nassim Jahnke 4f4bff6898 Update mappings 2023-11-21 07:36:29 +01:00
Nassim Jahnke adac67b85c Handle new resource pack actions 2023-11-21 07:13:37 +01:00
Nassim Jahnke 0949ff4ba9 1.20.3-pre1 (maybe) 2023-11-20 19:09:05 +01:00
Nassim Jahnke 8f5683f764 23w46a (mostly) 2023-11-19 16:48:24 +01:00
Drex 995c0bf4c3 Implement keep blocks explosion types (#632) 2023-11-19 16:19:40 +01:00
Nassim Jahnke 0f77acdc9f Remove todos 2023-11-09 18:00:08 +10:00
Nassim Jahnke ac5fbdd7f4 Allow null mapped entity name 2023-11-09 17:58:10 +10:00
Nassim Jahnke fb7cd2d9e3 23w45a 2023-11-09 17:57:28 +10:00
Nassim Jahnke 5284a581b3 Handle new 1.20.2 map markers 2023-11-08 11:55:03 +10:00
Nassim Jahnke 8eca6bf0b2 Improve Gradle setup
Don't build full platform jars to reduce build time
2023-11-06 14:45:30 +10:00
Nassim Jahnke c13a89a29c Update Gradle wrapper 2023-11-05 11:56:20 +10:00
Nassim Jahnke bce716caa4 Don't expect enables features to always be sent
The client defaults to the vanilla registry, so it doesn't need to be sent
2023-11-05 11:50:33 +10:00
Nassim Jahnke 71f08b9e4e Add 1.20.3 translations, fix unlit bulb mappings 2023-10-26 17:44:17 +10:00
Nassim Jahnke 59fc7f6a1a 23w43a 2023-10-26 13:13:23 +10:00
RK_01 232180ee61 Fix identifier handling in old protocols (#624) 2023-10-24 09:55:13 +10:00
EnZaXD cfb97e1abe Mention ViaVersion addon in "Known issues" (#623) 2023-10-24 09:54:30 +10:00
RK_01 48907be813 Implement support for chat signing (#621) 2023-10-22 19:51:00 +10:00
EnZaXD ff87b1dc92 1.13.2 -> 1.14: Change bamboo mapping (#622) 2023-10-22 12:36:21 +10:00
Nassim Jahnke e68ddf42b0 Update VV usage 2023-10-21 13:41:39 +10:00
Nassim Jahnke 8a9d4bd971 Update VV usage 2023-10-20 12:46:29 +10:00
Nassim Jahnke 7f85d074af Update VV usage 2023-10-19 21:31:00 +10:00
Nassim Jahnke 4cd65dd956 23w42a (if the ci manages to find VV) 2023-10-19 11:50:31 +10:00
Nassim Jahnke 719bb11938 Update TranslatableRewriter 2023-10-18 14:56:44 +10:00
Дмитрий e419831e8a Big Dripleaf mappings change (#614) 2023-10-18 11:48:45 +10:00
Kichura d121745a0f Update Fabric dependencies (#605) 2023-10-16 15:17:17 +10:00
Nassim Jahnke 65158455cc Fix early sending of resource pack
Fixes #3476
2023-10-15 18:12:39 +10:00
Nassim Jahnke 0912e33358 Merge pull request #611 from SplotyCode/fix/scoreboatd 2023-10-13 21:20:00 +10:00
David Scandurra 02f595b109 ChatUtil: Append unwritten formatting in prefix mode 2023-10-12 23:03:18 +02:00
Nassim Jahnke f78d166acf 23w41a (probably) 2023-10-12 01:53:44 +10:00
Nassim Jahnke 2e0acf169b Actually track 1.20.2 entities
Fixes #609, #597
2023-10-11 16:43:32 +10:00
EnZaXD aa1f38674d Fix platform loading (#604) 2023-10-08 19:33:00 +10:00
Nassim Jahnke 9e883faa78 Update nbt lib usage 2023-10-08 18:56:56 +10:00
EnZaXD e27930b1d7 Allow platform implementation to define config path (#603) 2023-10-08 17:20:01 +10:00
Nassim Jahnke d46eb8719a Fix it again 2023-10-08 15:26:37 +10:00
EnZaXD d092c98897 Fix ViaBackwards#init previous platform check (#602) 2023-10-08 15:10:35 +10:00
EnZaXD 75680296e8 Updated Via API usage (#601) 2023-10-08 14:51:49 +10:00
EnZaXD 80696a1273 [ci skip] Note smithing table as not usable for <1.19.4 clients (#600) 2023-10-08 02:18:34 +00:00
Nassim Jahnke 54330702b1 23w40a 2023-10-06 22:36:03 +10:00
Nassim Jahnke f923648fe8 4.8.1 Release 2023-10-03 20:58:18 +10:00
Nassim Jahnke 92c160c43a Fix trade list sending
Forgot to remove cancellation from initial configuration testing
Fixes #594
2023-09-28 11:19:36 +10:00
Nassim Jahnke cc7df5a4fc Fix serverbound beacon secondary effect 2023-09-28 09:36:41 +10:00
Nassim Jahnke 8e6727c350 Handle changed custom potion effects tag 2023-09-27 14:58:03 +10:00
Nassim Jahnke e73eeeb434 Update branch check again 2023-09-26 10:48:42 +10:00
Brokkonaut 96650decae Fix packet id of player velocity packets (#593) 2023-09-26 10:47:57 +10:00
Nassim Jahnke 1d35b1cdb2 [ci skip] Fix branch check in publishing 2023-09-26 00:24:36 +10:00
Nassim Jahnke c6711919b1 Add separate client and server state handling 2023-09-25 18:34:03 +10:00
Nassim Jahnke 67f7a66ca5 Fix 1.20.2->1.20 if run on the backend 2023-09-25 10:54:52 +10:00
Nassim Jahnke 4cba8072c4 Fix implementation version 2023-09-24 23:56:29 +10:00
Nassim Jahnke cfbe287361 Bump version to 4.8.1-SNAPSHOT 2023-09-24 23:55:25 +10:00
Nassim Jahnke f254869c66 4.8.0 Release 2023-09-21 10:35:54 +10:00
Nassim Jahnke 57ca5f1bf5 Fix particle handling 2023-09-21 10:35:42 +10:00
Nassim Jahnke b69ebe6657 Send the config ack packet 2023-09-19 13:25:25 +10:00
Nassim Jahnke ea2fac0788 Handle configuration start
TODO: Check whether all the necessary data for the join game packet is always expected by the client or if we need to cache it from the initial login
2023-09-19 13:20:19 +10:00
Nassim Jahnke 2b2384acc1 Remove new trim patterns in 1.20->1.19
Fixes #570
2023-09-15 18:13:12 +10:00
SplotyCode 643c6b18dd Fix scoreboard component coversion (#586) 2023-09-08 12:22:16 +10:00
Nassim Jahnke 80438807cc 1.20.2-pre2 2023-09-08 09:33:31 +10:00
Nassim Jahnke 2f373adad4 [ci skip] Update Blossom 2023-09-06 11:30:10 +10:00
Nassim Jahnke e2546b8471 1.20.2-pre1 2023-09-06 00:59:17 +10:00
Nassim Jahnke 88fd52ac6e [ci skip] Update Gradle wrapper and checkout actions 2023-09-05 21:29:01 +10:00
Nassim Jahnke c13c3f17fc Fix scoreboard objective reading 2023-08-31 11:48:48 +10:00
Nassim Jahnke 3b9354c4f6 23w35a (untested) 2023-08-31 00:53:48 +10:00
Nassim Jahnke 83636ecf51 Fix 1.16->1.15 hover components in books
Fixes #572
2023-08-27 18:52:43 +10:00
Nassim Jahnke 082b61a956 [ci skip] Update Hangar publish plugin 2023-08-26 20:05:17 +10:00
Nassim Jahnke 108e96ec6d Move world data tracker into first join game handler 2023-08-18 01:36:37 +10:00
Nassim Jahnke 6dd5cb20d9 23w33a 2023-08-18 01:32:50 +10:00
EnZaXD 2a2a0d8a72 Adde1.9 protocols from ViaVersion to ViaBackwards (#580) 2023-08-14 11:06:59 +10:00
Nassim Jahnke 9c68b30865 Merge remote-tracking branch 'origin/master' into dev
# Conflicts:
#	.github/workflows/gradle.yml
2023-08-14 10:15:19 +10:00
EnZaXD e0b7426dc9 Remove unused chat-types setting from config.yml (#579) 2023-08-14 10:04:02 +10:00
EnZaXD 43e2b242c4 Fix 1.19.4 -> 1.19.3 precipitation reading (#578) 2023-08-14 10:02:52 +10:00
Nassim Jahnke 567725d996 Update README 2023-08-11 21:36:20 +10:00
Nassim Jahnke 4fa985f131 Also publish dev branch builds to Hangar 2023-08-11 20:34:24 +10:00
Nassim Jahnke 2e8d6bcc9f Include link to commit in autopublished changelog 2023-08-11 16:26:17 +10:00
Nassim Jahnke 95e3446e8c Add mappings for changed block states and sounds 2023-08-11 16:08:10 +10:00
Nassim Jahnke 725e505514 Also handle release versions on publish 2023-08-11 15:54:59 +10:00
Nassim Jahnke c053975535 Finish publish action 2023-08-11 12:16:42 +10:00
Nassim Jahnke 70725d4aaf Add Hangar publishing 2023-08-11 00:26:51 +10:00
Nassim Jahnke 0d147653f3 Fix spawn tracker mapping data check 2023-08-10 17:13:08 +10:00
Nassim Jahnke f4cc9d4730 Fix double register 2023-08-10 17:06:49 +10:00
Nassim Jahnke 406733b13a 23w32a 2023-08-10 16:55:03 +10:00
Nassim Jahnke 9df7debb7e Finish 23w31a 2023-08-06 13:17:31 +10:00
Nassim Jahnke e12d491b53 Start working on 23w31a 2023-08-05 14:12:45 +10:00
Kichura 4d4e739939 Friendly names in CI, Update Blossom. (#562) 2023-07-25 11:08:22 +10:00
Nassim Jahnke 2904ad54c6 Fix non item display rotation 2023-07-24 20:58:30 +10:00
Nassim Jahnke 92e5fe8a9b Update gradle wrapper 2023-07-11 23:34:47 +02:00
Nassim Jahnke bc0cb7702c Properly handle changed item display rotation 2023-07-03 20:16:52 +02:00
Nassim Jahnke 04d75264e0 Add required 1.18(.1) tag
Fixes #558
2023-06-15 10:10:32 +02:00
tahmid-23 4a308f9d81 Fix 1.19.3->1.19.1 entity sound packet (#555) 2023-06-15 09:56:59 +02:00
EnZaXD 4627142700 Emulate "trim_pattern" registry in 1.19.4 -> 1.20 if not present (#557) 2023-06-14 19:04:28 +02:00
Nassim Jahnke 817080b7a6 Extend correct item rewriter
Fixes #551
2023-06-10 10:14:40 +02:00
Nassim Jahnke 8f51ab2f6a Fix display rotation change 2023-06-09 12:28:08 +02:00
Nassim Jahnke 359cdb13eb Bump version to 4.7.1-SNAPSHOT 2023-06-09 12:19:34 +02:00
Nassim Jahnke 63a3908b53 4.7.0 Release 2023-06-07 11:36:14 +02:00
Nassim Jahnke ceb08c1e55 Update VV usage 2023-06-05 09:10:50 +02:00
Nassim Jahnke c468ec714c Handle servers not sending 1.16 expected tags
Fixes #548
2023-05-28 12:15:42 +02:00
Nassim Jahnke 4fb9fdab9b Add statistics handler to 1.19.4->1.19.3 protocol 2023-05-23 16:43:46 +02:00
Nassim Jahnke d271d3d687 1.20-pre3 2023-05-19 14:34:34 +02:00
Nassim Jahnke 9fa7af7c7b Update nbt file 2023-05-10 16:18:43 +02:00
Nassim Jahnke f591593992 1.20-pre1 2023-05-10 15:54:13 +02:00
Nassim Jahnke e74b5d661d 23w18a, maybe 2023-05-03 15:22:21 +02:00
Nassim Jahnke 483920b729 Sanity checks in item rewriting 2023-05-01 11:33:00 +02:00
Nassim Jahnke 73647ee4fb 23w17a 2023-04-26 19:06:30 +02:00
Nassim Jahnke 97f5ec322a 23w16a 2023-04-20 17:28:25 +02:00
Nassim Jahnke da35067e1d Handle optional block state entity meta 2023-04-18 13:39:59 +02:00
Kichura 65c8024ba7 Add ViaBackwards icon to Fabric (#543) 2023-04-15 14:14:40 +02:00
Nassim Jahnke 377f512f95 23w14a 2023-04-05 15:26:33 +02:00
RK_01 b174dd31b4 Fixed max player count value mapping (#541) 2023-03-31 09:40:18 +02:00
Nassim Jahnke 8eaadd0f18 23w13a 2023-03-29 16:34:17 +02:00
Nassim Jahnke ef1b062449 Handle changed sign nbt 2023-03-24 11:36:32 +01:00
Nassim Jahnke c1383baf14 23w12a 2023-03-22 19:41:00 +01:00
Nassim Jahnke 455e862089 Update mapping files 2023-03-20 10:32:27 +01:00
Nassim Jahnke 0d4257f228 Don't override getTranslatableRewriter in 1.13->1.12, 1.14->1.13 protocols
The method is used in item handling and would otherwise mess up the lore
2023-03-20 10:05:46 +01:00
Pantera (Mad_Daniel) 614207aeef Add remaining sound mappings 2023-03-18 18:24:41 +01:00
Nassim Jahnke 1b268ad4ec Use right type for component metadata 2023-03-18 13:56:53 +01:00
Nassim Jahnke 509055307a Handle 1.12 keybind components
Fixes #474
2023-03-18 13:55:16 +01:00
Nassim Jahnke 68e578a04e Handle translatables in 1.13.1 entity display names 2023-03-18 13:16:22 +01:00
Nassim Jahnke a07550363e Handle shifted 1.19.4 boat types 2023-03-18 12:27:46 +01:00
Nassim Jahnke eb6e9e016a Handle translatables in 1.14/1.15 entity display names 2023-03-18 12:23:14 +01:00
Nassim Jahnke 587a5e487f Improve 1.13->1.12 translatable handling 2023-03-18 10:02:23 +01:00
Nassim Jahnke efded25594 4.6.1 Release 2023-03-16 20:45:16 +01:00
Nassim Jahnke 11e71b1307 Fix #3252 2023-03-15 21:20:33 +01:00
riku6460 974b15243a Fix enchantments in 1.12 -> 1.13 (#533) 2023-03-14 20:01:25 +01:00
Nassim Jahnke e14da27093 Bump version to 4.6.1-SNAPSHOT 2023-03-14 20:01:14 +01:00
Nassim Jahnke 94f8cb662b 4.6.0 Release 2023-03-13 10:51:00 +01:00
Nassim Jahnke 777059d652 Change read type of Teams packet display name 2023-03-13 09:54:09 +01:00
Nassim Jahnke fc565f8cd5 Delay version detection when using legacy injector 2023-03-10 14:29:54 +01:00
Nassim Jahnke 4293289468 Support Folia (leaf's region threaded Minecraft server) 2023-03-10 12:19:22 +01:00
Nassim Jahnke f7acb7ce91 Read custom model data from nbt mapping files, merge dir and packed data 2023-03-09 11:29:59 +01:00
Nassim Jahnke 4a62bb2fbc 1.19.4-pre4 2023-03-08 15:50:03 +01:00
Nassim Jahnke 71361be66c Update mapping files 2023-03-06 10:53:41 +01:00
Nassim Jahnke 3cddb712c8 Fix item loading in 1.13.2->1.13, 1.13->1.12 2023-03-05 21:57:47 +01:00
Nassim Jahnke cba4d03ff0 Small cleanup 2023-03-05 21:45:50 +01:00
Nassim Jahnke 2d1f675834 Mapping fixes 2023-03-05 15:21:06 +01:00
Nassim Jahnke b516103a6e Update to new mappings format 2023-03-04 17:25:45 +01:00
Nassim Jahnke 53daf8328c Fix building 2023-03-02 20:13:33 +01:00
Nassim Jahnke 5d0d6f603b Update VV usage 2023-03-02 13:22:16 +01:00
Nassim Jahnke 565944c317 Handle new container id 2023-03-01 16:09:56 +01:00
Nassim Jahnke 708d6bed52 Update Gradle wrapper 2023-03-01 14:59:26 +01:00
Nassim Jahnke 7349781927 Fix item desync when dropping items on 1.17+ servers as 1.13- clients 2023-02-25 22:42:34 +01:00
Nassim Jahnke 5355316a97 I didn't read the changelogs 🛌 2023-02-22 19:09:19 +01:00
Nassim Jahnke aae59658ec 23w08a 2023-02-22 19:05:08 +01:00
Nassim Jahnke 70c21e995c Update GH actions workflow 2023-02-22 16:27:18 +01:00
Nassim Jahnke fa4cfeb7e9 Things 2023-02-20 17:33:53 +01:00
Nassim Jahnke 1b54d10d91 Small refactor 2023-02-20 13:09:19 +01:00
Nassim Jahnke 3c749bd939 Handle translation additions 2023-02-18 10:32:09 +01:00
Nassim Jahnke 9807eece72 And now there's mappings 2023-02-17 23:42:58 +01:00
Nassim Jahnke 8670d8105d 23w07 without mappings 2023-02-16 13:18:18 +01:00
Nassim Jahnke 27d007aa47 Update Gradle wrapper 2023-02-16 13:10:27 +01:00
Nassim Jahnke 82c01c4b2d Greatly reduce the number of inner classes 2023-02-12 12:17:15 +01:00
Nassim Jahnke 8715c243c9 Improve additional metadata handling
Fixes #527
2023-02-10 12:10:49 +01:00
Nassim Jahnke 27dd148c69 23w06a 2023-02-08 19:31:27 +01:00
Nassim Jahnke 15aa25f0d2 Replace some deprecated api usage 2023-02-04 20:16:43 +01:00
Nassim Jahnke f30fdc1feb Ensure correct packet types in rewriters during compile time 2023-02-04 19:05:29 +01:00
Nassim Jahnke a506b21f56 Don't load mappings in 1.19.4 protocol 2023-02-03 12:13:30 +01:00
Nassim Jahnke 1b4dbc1388 Fix comparator directions in 1.13->1.12
Fixes #524
2023-02-02 12:10:50 +01:00
Nassim Jahnke f1be100b30 Catch and remove bad item nbt from hoverevents in 1.16 conversion
Closes #520
2023-02-02 11:40:12 +01:00
Nassim Jahnke 94210e92f1 Read custom_model_data field from item mappings
Closes #525
2023-02-02 10:51:26 +01:00
Nassim Jahnke 4797914556 23w05a 2023-02-01 16:30:59 +01:00
Lobo Metalúrgico dbf103b788 (fix): 1.12.2 issue because of 1.19 goat horn mapping (#523) 2023-01-20 10:06:40 +01:00
Nassim Jahnke 78bce8895a 23w03a 2023-01-18 18:11:59 +01:00
Nassim Jahnke 4eaf01f008 Update copyright header 2023-01-12 12:41:06 +01:00
Nassim Jahnke 4a9acd6b11 Fix missed 1.19.3 pose change
Fixes #509
2022-12-21 10:44:37 +01:00
Nassim Jahnke 02fcf90b8f Bump version to 4.5.2-SNAPSHOT 2022-12-21 10:28:45 +01:00
Nassim Jahnke 01cdc4416c 4.5.1 Release 2022-12-11 14:40:07 +01:00
Nassim Jahnke 7c2845b884 Fix 1.19.3 player info add 2022-12-11 14:27:41 +01:00
Nassim Jahnke 7cbfffaa68 Fix 1.19.3 sound remapping
Fix #505
2022-12-09 13:24:35 +01:00
Nassim Jahnke 0d0719040c Bump version to 4.5.1-SNAPSHOT 2022-12-09 13:17:55 +01:00
Nassim Jahnke 858fcb2b16 Thank you gradle, very cool 2022-12-09 11:19:11 +01:00
Nassim Jahnke dc4c929108 Add missing empty sound remaps
This is definitely definitely still 4.5.0
2022-12-07 13:53:39 +01:00
Nassim Jahnke 0fe3d9410e 1.19.3-rc3
Definitely still 4.5.0 as well
2022-12-06 12:21:56 +01:00
Nassim Jahnke cc9bf7284a 4.5.0 Release 2022-12-05 21:27:43 +01:00
Nassim Jahnke 383281cb9f 1.19.3-rc1 2022-12-01 17:21:37 +01:00
Nassim Jahnke d18825e700 1.19.3-pre3 2022-11-29 17:33:11 +01:00
Nassim Jahnke 2427690b78 22w46a 2022-11-16 18:30:11 +01:00
Nassim Jahnke a4261d6d9e 22w45a 2022-11-09 16:40:14 +01:00
Nassim Jahnke 091a63e45d 22w44a 2022-11-02 19:20:08 +01:00
Nassim Jahnke 9a9c6c4644 22w43a 2022-10-26 18:28:53 +02:00
Nassim Jahnke 808b1fd2f0 Finish mappings 2022-10-22 12:22:55 +02:00
Nassim Jahnke 9d3ee288df Handle chat types 2022-10-22 11:25:45 +02:00
Nassim Jahnke 100901029e Start working on 22w42a 2022-10-20 22:33:28 +02:00
Kichura 5bf8b59e91 Update actions, Gradle 7.5.1. (#500) 2022-10-15 19:20:35 +02:00
Nassim Jahnke c554027108 Change windswept_forest biome mapping 2022-10-09 15:57:31 +02:00
creeper123123321 4d295fbe2c fix #410 (#499) 2022-10-09 15:56:56 +02:00
Nassim Jahnke 40047330b4 4.4.2 Release 2022-08-21 09:42:48 +02:00
Pieter12345 98304168b8 Fix 1.18.2->1.19 CHAT_MESSAGE using static timestamp (#495) 2022-08-21 09:03:58 +02:00
EDX 3695df1e44 Update PlayerPackets1_11.java (#492) 2022-08-15 11:55:09 +02:00
Nassim Jahnke 958f265e18 Add mangrove/deep dark biome mappings 2022-08-08 13:38:23 +02:00
strider 394c944c50 Add 1.19->1.18 sound mappings (#489) 2022-08-05 16:08:18 +02:00
Nassim JahnkeandTisawesomeness d559c7cff1 Here you go, proper 1.19.1->1.19 and 1.19->1.18.2 support
Co-authored-by: Tisawesomeness <tis_dev@protonmail.com>
2022-08-04 16:59:01 +02:00
Gero 3d4f4438a8 Alter velocity modern forwarding version (#487) 2022-08-03 16:17:55 +02:00
Gero 2972fb8422 Bump version to 4.4.2-SNAPSHOT 2022-08-03 12:47:32 +02:00
Nassim Jahnke 817593ee43 4.4.1 Release 2022-07-28 18:54:02 +02:00
Nassim Jahnke 044980c1a8 Simplify component building 2022-07-28 15:00:16 +02:00
Nassim Jahnke 245bd53850 Add missing 1.19.1 chat types to config 2022-07-28 12:33:36 +02:00
Nassim Jahnke b632e4772f Allow 1.19.0 clients on 1.19.1 servers 2022-07-28 11:47:25 +02:00
Nassim Jahnke b336b8a1fc Tongue 2022-07-27 19:09:40 +02:00
Nassim Jahnke 304b21425c 4.4.0 Release 2022-07-26 18:48:10 +02:00
Nassim Jahnke bb17bb3bfd 1.19.1-rc3 2022-07-26 18:47:14 +02:00
Nassim Jahnke 941bb91be8 1.19.1-pre6 2022-07-20 19:35:04 +02:00
Nassim Jahnke fb334c6c14 1.19.1-pre5 2022-07-15 18:42:57 +02:00
Nassim Jahnke 90460ee99f 1.19.1-pre4 2022-07-08 21:07:57 +02:00
Gero 81a737886a Update chat-types-1.19.1.nbt (#470) 2022-07-06 18:18:28 +02:00
Gero 356158a9d4 team_name -> target (#469) 2022-07-06 18:02:22 +02:00
Nassim Jahnke 32bd9378e1 1.19.1-pre3 2022-07-06 17:55:39 +02:00
Nassim Jahnke 317af16975 Merge remote-tracking branch 'origin/master' into dev
# Conflicts:
#	build.gradle.kts
2022-07-02 19:36:24 +02:00
Nassim Jahnke 3826be4f5f 4.3.1 Release 2022-07-02 19:34:07 +02:00
Gero 282afe94cc Interpret translation keys with %s as the raw translation 2022-07-01 15:20:54 +02:00
Nassim Jahnke 9d86b31cb7 Bump version to 4.4.0-SNAPSHOT, update translation mappings
A break and more funky things
2022-07-01 12:40:43 +02:00
Nassim Jahnke 80041606a7 Merge 1.19.1->1.19 and 1.19->1.18.2 protocols 2022-07-01 12:14:10 +02:00
Gero 41e4172136 Fix chat type style 2022-07-01 10:19:54 +02:00
Gero a856658399 Handle 1.19.1 chat types 2022-07-01 10:17:51 +02:00
Nassim Jahnke 7173bbbbce 1.19.1-pre2 (at least an initial pass) 2022-06-30 19:36:43 +02:00
Nassim Jahnke 54507c6175 Merge remote-tracking branch 'origin/master' into dev 2022-06-28 12:26:27 +02:00
Myles 4dd7d384c8 Add feature request label to issue templates 2022-06-27 13:37:20 +01:00
Nassim Jahnke fc751aedf3 1.19.1-pre1 2022-06-21 22:14:47 +02:00
Nassim Jahnke a1da3dc11c Fix writing books
Fixes #2959
2022-06-17 08:38:23 +02:00
Nassim Jahnke 87c37b08e8 Fix 1.18.0/1 client on 1.19 server
Fixes #454
2022-06-16 20:06:10 +02:00
Gero 187b79f4e1 Fix NPE for chat messages before join game (#456) 2022-06-14 10:39:35 +02:00
Gero b84cda54c3 Fully implement chat types (#455) 2022-06-09 20:49:27 +02:00
Nassim Jahnke f474067eb2 Don't forget to clear 2022-06-09 20:13:36 +02:00
Nassim Jahnke 6a700d228d Properly deal with custom chat type registries 2022-06-09 20:07:58 +02:00
Nassim Jahnke f08223d1e9 Fix trade offers 2022-06-08 10:10:12 +02:00
Nassim Jahnke a5e3a6b563 Bump version to 4.3.1-SNAPSHOT 2022-06-08 10:08:21 +02:00
Nassim Jahnke 65afe42d2c 4.3.0 Release 2022-06-05 11:32:43 +02:00
Nassim Jahnke 9da206e280 Add sanity check in 1.13->1.12 enchantment handler
Closes #2908
2022-06-03 18:19:54 +02:00
Nassim Jahnke c2ae3df1db Fix 1.13->1.12 item cooldown
Fixes #450
2022-05-29 15:51:02 +02:00
Nassim Jahnke dc9fe10779 Fix join game reading 2022-05-23 19:32:54 +02:00
Nassim Jahnke 08a583526e 1.19-pre2 2022-05-23 18:17:17 +02:00
Nassim Jahnke 125fa885f6 Dont clear dimension storage on server switch 2022-05-21 10:57:39 +02:00
Nassim Jahnke 4a1eefcf87 1.19-pre1 2022-05-18 21:08:05 +02:00
Nassim Jahnke 68c0a0b333 Handle argument types, update Via usage 2022-05-14 12:32:10 +02:00
Nassim Jahnke fdc73126f7 Timestamp is millis now, fix dimension storage 2022-05-13 10:11:26 +02:00
Nassim Jahnke 1e0c0ebb2d 22w19a (almost, also more dread) 2022-05-12 23:56:24 +02:00
Nassim Jahnke 5bffa2c51c Fix clientbound chat message reading 2022-05-08 12:05:46 +02:00
Nassim Jahnke 34fa4f85db More or less handle new chat type formats 2022-05-05 11:24:19 +02:00
Nassim Jahnke ef0e412d36 22w18a
I hate codecs
2022-05-04 23:18:50 +02:00
Nassim Jahnke 7df02934f3 22w17a (and even more dread) 2022-04-27 22:38:41 +02:00
Nassim Jahnke d64b259b77 Remove painting variant tags 2022-04-20 21:41:38 +02:00
Nassim Jahnke 8850d5c8ff 22w16b (probably, also ignoring a possible race condition) 2022-04-20 21:00:45 +02:00
Nassim Jahnke 15c7106430 22w15a 2022-04-13 18:48:53 +02:00
Nassim Jahnke 56dfc985d2 Add item mappings, rename carpets tag for older versions 2022-04-06 22:53:45 +02:00
Nassim Jahnke dfa778942c 22w14a 2022-04-06 20:37:16 +02:00
Nassim Jahnke bd71833f18 22w13a 2022-03-31 19:00:43 +02:00
Nassim Jahnke c6f25bf33f Merge remote-tracking branch 'origin/master' into dev 2022-03-30 11:08:33 +02:00
Nassim Jahnke fc22d7e6c8 Don't warn for non-horse armor on horses
Closes #448
2022-03-30 11:07:38 +02:00
Nassim Jahnke 22f604cd7e Fix parrot imitate warden key 2022-03-30 11:06:25 +02:00
Nassim Jahnke a85b9e8100 Remove full frog metadata, add translation mappings 2022-03-24 20:10:19 +01:00
Nassim Jahnke 8d380f4278 22w12a 2022-03-24 19:31:11 +01:00
Nassim Jahnke 1486d58813 Comment out entity effect transformer 2022-03-21 10:42:37 +01:00
Nassim Jahnke 9d3de047a0 Merge remote-tracking branch 'origin/master' into dev
# Conflicts:
#	build.gradle.kts
2022-03-18 12:21:34 +01:00
Nassim Jahnke c75e5bd6a7 4.2.1 Release 2022-03-18 12:07:11 +01:00
Quantum64 30a3a4fb89 Prevent 1.16 -> 1.17 cursor desync with dragging (mostly fixes #389) (#445) 2022-03-18 11:01:46 +01:00
Lucas 9fe9cd3a8a Map smoke directions from 1.13.1 to 1.13 (#413) 2022-03-18 10:52:37 +01:00
Nassim Jahnke 12926980e2 Also remove block entities above 255 in chunk data for 1.17->1.16 2022-03-18 10:32:34 +01:00
Nassim Jahnke 31787b5e5b Fix Velocity/Sponge config location 2022-03-18 10:30:55 +01:00
Nassim Jahnke d56921b611 Actually everything from 22w11a 2022-03-16 23:06:58 +01:00
Nassim Jahnke 15a5e6f710 22w11a 2022-03-16 22:52:19 +01:00
Nassim Jahnke 422f2b699b 1.19 Experimental Snapshot 1 2022-03-16 19:08:08 +01:00
Nassim Jahnke eda8abf55c Handle new biomes for <1.16 clients
Fixes #422
2022-03-13 11:29:34 +01:00
Nassim Jahnke 2b955894d3 Update gradle wrapper to 7.4.1 2022-03-09 18:50:30 +01:00
Nassim Jahnke 539c4e696a Fix long scoreboard objective names for <1.18 clients 2022-03-06 15:41:51 +01:00
Nassim Jahnke aa35ace816 Don't send block entities < 0 for 1.16- players
Fixes ViaVersion/ViaVersion#2833
2022-03-01 10:21:22 +01:00
Nassim Jahnke 8ea7686b2c Bump version to 4.2.1-SNAPSHOT 2022-03-01 10:19:31 +01:00
Nassim Jahnke 7dbd620886 4.2.0 Release 2022-02-24 09:44:23 +01:00
Nassim Jahnke 6a1b0e044a 1.18.2-pre3 2022-02-23 18:13:48 +01:00
Nassim Jahnke afe3584b70 1.18.2 pre1 2022-02-18 18:33:34 +01:00
Nassim Jahnke d8096e7f2e Wither skeletons don't need visible names 2022-02-16 19:15:08 +01:00
Nassim Jahnke 121c735073 Fix registry on respawn 2022-02-09 19:58:04 +01:00
Nassim Jahnke 52698423d0 22w06a 2022-02-09 18:57:28 +01:00
Nassim Jahnke bbff706890 Merge branch 'master' into dev 2022-01-26 09:57:29 +01:00
Nassim Jahnke 2a079be7c2 Make custom world height warning actual warning
Closes ViaVersion/ViaVersion#2805
2022-01-23 17:04:30 +01:00
Nassim Jahnke a8e767250a Fix 1.17->1.16 heightmap conversion
Fixes ViaVersion/ViaVersion#2801
2022-01-22 11:52:09 +01:00
creeper123123321 5593dfb8e5 Fix 1.14->1.13 difficulty (#427) 2022-01-20 12:34:10 +01:00
Nassim Jahnke afd072c313 Mmm 2022-01-19 18:14:21 +01:00
Nassim Jahnke d26cac9622 22w03a 2022-01-19 18:13:33 +01:00
Nassim Jahnke 2c341ab7ad Update copyright 2022-01-09 22:40:10 +01:00
Nassim Jahnke 54eaccca0d Update Sponge module to API v8 2022-01-09 18:58:44 +01:00
Nassim Jahnke 0d5661f8a6 Remove bad 1.13->1.12 sound warning, update shadow
Fixes #424
2022-01-03 18:38:01 +01:00
Nassim Jahnke 7a19cb8d04 Update shadow and Gradle wrapper 2021-12-23 11:41:57 +01:00
FrostBird347 9fddf7b176 Update mapping-1.16.2to1.17.json (#417) 2021-12-05 09:40:42 +01:00
Lucas f687dff702 Add missing block entity NBT on 1.18 (#414) 2021-12-04 16:36:46 +01:00
Nassim Jahnke 249280312e Fix advancement translatables
Closes #415
2021-12-04 16:33:30 +01:00
Nassim Jahnke a200975cda Bump version to 4.1.2-SNAPSHOT 2021-12-04 16:21:06 +01:00
Nassim Jahnke 0163bc8c24 4.1.1 Release 2021-12-03 13:36:40 +01:00
Nassim Jahnke a5a789c440 Fix handling of untracked entities
Some simple meta handlers do not go through entity rewriters, suddenly having to deal with invalid metadata because of plugins' bad concurrency handling
Closes #412
2021-12-03 11:00:52 +01:00
Nassim Jahnke 87aed8f3f2 Fix NPE
Fixes ViaVersion/ViaVersion#2751
2021-12-03 08:59:28 +01:00
Nassim Jahnke cadab9e6bb Throw error on unhandled 1.14->1.13 metadata 2021-12-02 12:43:42 +01:00
Nassim Jahnke 13b5545999 Fix vibration and transition particle meta 2021-12-02 11:11:34 +01:00
Nassim Jahnke f4a6c20695 Update Gradle wrapper to 7.3.1 2021-12-02 11:02:55 +01:00
Nassim Jahnke ff583e40fb Fix 1.18 mountain biomes in biome registry 2021-12-01 17:04:05 +01:00
Nassim Jahnke c8b0ca48de Bump version to 4.1.1-SNAPSHOT 2021-12-01 17:03:41 +01:00
Nassim Jahnke 8d35d16575 4.1.0 Release 2021-11-29 21:01:23 +01:00
Nassim Jahnke e70f595f76 Handle translatable changes 2021-11-19 22:09:36 +01:00
Nassim Jahnke 888441b81d Set mappings default values to -1 2021-11-17 19:52:31 +01:00
Nassim Jahnke 71f4012537 Update leftover Via usage 2021-11-17 11:18:46 +01:00
Nassim Jahnke ce6ca4dc0f 1.18-pre2 2021-11-16 19:40:17 +01:00
Nassim Jahnke becba6498e Make mapped entity names configurable 2021-11-13 11:06:59 +01:00
Nassim Jahnke 95bc340b06 Fix play record, remove unused 1.18 code 2021-11-12 13:18:02 +01:00
Nassim Jahnke 1ab93c4021 Update Gradle wrapper to 7.3 2021-11-10 17:47:36 +01:00
Nassim Jahnke b36052465f Fix 1.18 spawner entity/block entity update 2021-11-10 17:34:04 +01:00
Nassim Jahnke 5695726d9a Use new metatypes classes 2021-11-10 17:18:55 +01:00
Nassim Jahnke 025a892daf 21w44a 2021-11-03 19:17:46 +01:00
Nassim Jahnke 74aa5f4598 Merge remote-tracking branch 'origin/master' into dev 2021-10-26 11:09:59 +02:00
Nassim Jahnke db345577a2 Fix 1.13.1->1.13 inventory title regression
Fixes #375
2021-10-26 11:09:42 +02:00
Nassim Jahnke 80f41c8c24 Merge remote-tracking branch 'origin/master' into dev 2021-10-24 16:44:35 +02:00
Nassim Jahnke 169650f17c Remove unnecessary type reading 2021-10-24 16:44:22 +02:00
Nassim Jahnke 4361ebe636 Use correct meta type 2021-10-21 09:12:51 +02:00
Nassim Jahnke 9d52fd6212 21w42a 2021-10-20 19:02:20 +02:00
Nassim Jahnke abb2abe5c9 Update biome palette reading 2021-10-13 21:15:59 +02:00
Nassim Jahnke e9d1d257ea Merge remote-tracking branch 'origin/master' into dev 2021-10-11 21:05:31 +02:00
Nassim Jahnke a721eb4d03 Update shadow 2021-10-11 21:05:21 +02:00
Nassim Jahnke fe644127c1 Merge remote-tracking branch 'origin/master' into dev 2021-10-11 11:06:27 +02:00
Nassim Jahnke 71cc1ca4b5 Ignore invalid enchantment tags
Fixes ViaVersion/ViaVersion#2693
2021-10-11 11:05:50 +02:00
Nassim Jahnke 5df0dacf92 21w40a 2021-10-07 16:56:22 +02:00
Nassim Jahnke 448f452965 Merge remote-tracking branch 'origin/master' into dev
# Conflicts:
#	gradle/libs.versions.toml
2021-10-07 15:33:06 +02:00
Nassim Jahnke 3d6c31c479 Update FU load factor usage 2021-10-07 12:37:07 +02:00
Nassim Jahnke 067c93a63a Cancel null block entity nbt updates 2021-09-25 10:11:43 +02:00
Nassim Jahnke 04a970ef08 21w38a 2021-09-24 14:39:19 +02:00
Nassim Jahnke 3d32cb3adf Map new sounds (to nothing) 2021-09-17 09:41:14 +02:00
Nassim Jahnke 1ef1a861ca Fix block entity ids 2021-09-16 18:31:03 +02:00
Nassim JahnkeandGerrygames deb11bf1a9 21w37a works™️
Co-authored-by: Gerrygames <gecam59@gmail.com>
2021-09-16 18:19:23 +02:00
Nassim Jahnke 87ad6bd2b1 More work on 21w37a 2021-09-16 17:05:19 +02:00
Nassim Jahnke 3054b758df 21w37a (probably) 2021-09-16 14:57:52 +02:00
Nassim Jahnke 5777f4a117 Start working on 1.18 2021-09-14 18:16:12 +02:00
Nassim Jahnke 9615a5aba2 Add todo, map world name in 1.17 packets 2021-09-14 17:37:05 +02:00
Nassim Jahnke 8fff947863 Map powder snow bucket to snow block
Fixes #397
2021-09-07 11:25:04 +02:00
kennytv 68f77cc809 Update Gradle to 7.2 2021-08-17 13:39:55 +02:00
kennytv 4f801b4228 Fix 1.16->1.15 wolf anger
Fixes #392
2021-08-14 10:51:49 +02:00
kennytv 54dc05046f Fix entity id int type 2021-08-11 15:08:01 +02:00
kennytv e05c585b37 Fix 1.14 position tracking of client
Fixes #391
2021-08-11 08:55:42 +02:00
kennytv a03a3a2a8d Fix NPE in 1.16 TranslatableRewriter
Closes ViaVersion/ViaVersion#2655
2021-08-09 09:08:15 +02:00
kennytv e251565837 Don't ignore gitignores 2021-08-09 09:03:54 +02:00
kennytv 455bb546f0 Add option to replace ping packets by using container acks
Closes ViaVersion/ViaVersion#2624
2021-07-17 11:13:01 +02:00
kennytv fa707e5391 Ignore untracked entity meta 2021-07-11 17:35:17 +02:00
kennytv 6f2961a00b Lowercase gang 2021-07-07 20:42:50 +02:00
KennyTV 43ebe3c3e3 Fix 1.17->1.16 and 1.16.2->1.16.1 meta types 2021-07-07 10:15:32 +02:00
KennyTV f8d10be031 Bump version to 4.0.2-SNAPSHOT 2021-07-07 10:08:35 +02:00
KennyTV 3f01f0100c 4.0.1 Release 2021-07-05 18:41:06 +02:00
KennyTV 29d3787de8 Send doubled respawn anyways for < 1.13 clients 💩
Fixes #381 (dirty hotfix)
2021-07-03 10:35:59 +02:00
KennyTV 59df758ceb Fix 1.15->1.14 immediate respawn flag in join game 2021-07-03 10:00:09 +02:00
KennyTV 80360bf27c 1.17.1-rc1 2021-07-01 20:09:34 +02:00
KennyTV 3da7d7513e Merge branch 'master' into dev 2021-06-29 19:21:13 +02:00
KennyTV a654becac8 Limit number of book pages in 1.17->1.17.1 2021-06-29 19:20:05 +02:00
creeper123123321 77a5b2212b update fabric loader (#378) 2021-06-24 12:20:50 +02:00
creeper123123321 7013ed8acf Fix Fabric config dir (#377) 2021-06-24 12:08:40 +02:00
KennyTV 9d41854e22 Hotfix 1.13->1.12 command suggestions
Fixes #368
2021-06-19 11:18:33 +02:00
KennyTV edf9ccca8b Uncache state ids on inventory close 2021-06-18 17:26:32 +02:00
KennyTV d62165bf51 1.17.1-pre1 2021-06-18 17:22:39 +02:00
KennyTV 00bc4a9d6a Read unsigned byte in set slot for consistency 2021-06-18 17:01:50 +02:00
KennyTV 7885babe1e Fix particle id change in 1.16 meta 2021-06-17 12:15:05 +02:00
KennyTV 9a53678838 Remove unnecessary warning 2021-06-17 09:00:38 +02:00
KennyTV 91874ffc3b More bandaid 2021-06-16 13:58:49 +02:00
KennyTV e71c34255b Bandaid fix tile entity error 2021-06-16 13:51:04 +02:00
KennyTV 8e78a14c14 Update Gradle wrapper to 7.1 2021-06-16 09:13:17 +02:00
KennyTV 3b85200641 Sanity check for bad/untracked meta packets
Fixes ViaVersion/ViaVersion#2549
Fixes ViaVersion/ViaVersion#2521
2021-06-15 22:27:56 +02:00
KennyTV 1dc0f72e54 Update bug_report.yml 2021-06-14 10:58:13 +02:00
KennyTV 13d27a6f4d Fix dust color transition and vibration particle id
Fixes #2543
2021-06-14 09:12:37 +02:00
KennyTV 3cec1751c9 Fix 1.17 map data
Fixes #367
2021-06-10 18:34:15 +02:00
KennyTV 80f9dce513 Fix 1.17 special type tracking 2021-06-10 08:47:32 +02:00
SuspiciousActivity cf7c718493 Fix 1.17 ping handler (#365) 2021-06-09 15:14:42 +02:00
KennyTV 0ba20299a3 Bump version to 4.0.1-SNAPSHOT 2021-06-09 15:12:48 +02:00
KennyTV 54a979c641 4.0.0 Release 2021-06-07 19:52:09 +02:00
KennyTV e41d643488 Update VV usage 2021-06-06 17:24:41 +02:00
KennyTV 5281f6e7dd Temp fix the build
It doesn't want to pull the updated SNAPSHOT version for some reason, probably due to the recent build script changes.
2021-06-04 12:33:03 +02:00
KennyTV 7e2775114b Update VV usage 2021-06-04 12:16:08 +02:00
KennyTV cbbc127360 Update translation mappings 2021-06-03 21:34:23 +02:00
KennyTV 83a566d145 Update VV usage 2021-06-03 20:25:20 +02:00
KennyTV 3d3c1a0430 Fix load order with late-bind enabled
Fixes #362
2021-06-03 11:05:51 +02:00
KennyTV 08f6c0b1f1 Update VV usage 2021-06-02 22:05:05 +02:00
KennyTV 4cc3ea0883 Replace some hardcoded packet ids 2021-06-01 23:57:54 +02:00
KennyTV 2876495b62 Fix early achievement send 2021-06-01 20:17:10 +02:00
KennyTV 7d03831ba8 Update VV usage 2021-05-31 23:18:56 +02:00
KennyTV 0514dd2ea5 1.17-pre2 2021-05-31 18:25:57 +02:00
KennyTV f341fc132c Fix ancient client error caused by empty meta for < 1.11
Since modern versions don't immediately send metadata in spawn packets and 1.10 clients and lower have a slight oversight in the meta getting, every mob/player spawn spammed the client console with an error. Even though it is a harmless error, I figured people would like their client console not to get spammed anymore.
2021-05-29 15:01:02 +02:00
KennyTV 27b4933262 Update build scripts 2021-05-29 09:32:55 +02:00
KennyTV fb368a9ebe 1.17-pre1 2021-05-27 15:46:08 +02:00
KennyTV 8adb80b5eb Don't store UserConnection in stored objects unless needed 2021-05-26 21:58:19 +02:00
KennyTV 4a60f0f903 Update VV usage 2021-05-26 15:52:37 +02:00
KennyTV a789e2ff7b Update EntityTracker/meta rewriter 2021-05-25 15:27:16 +02:00
KennyTV 1201c2979b Update VV usage 2021-05-20 18:34:05 +02:00
KennyTV 0e15a98472 21w20a 2021-05-19 18:56:18 +02:00
KennyTV 51d07c1c50 Print bad component on deserialization fail 2021-05-18 09:40:22 +02:00
KennyTV 5f59a57a78 Fix legacy hover conversion
Fixes ViaVersion/ViaVersion#2471
2021-05-14 11:04:45 +02:00
KennyTV 084fc5d327 21w19a, update to Gradle 7.0.1 2021-05-12 16:01:46 +02:00
KennyTV 2194c96883 Handle new map colors
Co-authored-by: Gerrygames <gecam59@gmail.com>
2021-05-11 14:02:12 +02:00
creeper123123321 bd421fcfab CurseForge link (#357) 2021-04-28 22:50:58 +02:00
KennyTV 93e99bc1ef 21w17a 2021-04-28 17:56:29 +02:00
KennyTV 687e1f4f43 Update VV 2021-04-28 13:09:19 +02:00
KennyTV 4ea5a76337 Reformat imports 2021-04-27 20:36:11 +02:00
KennyTV face56dce1 Update VV 2021-04-27 13:25:27 +02:00
KennyTV 24aebfe92a Change imports/package qualifiers 2021-04-26 23:31:29 +02:00
KennyTV 9337ff8958 Move files to com.viaversion package 2021-04-26 23:27:18 +02:00
KennyTV 18e2ef01e7 Update ViaVersion dependency 2021-04-26 23:24:49 +02:00
KennyTV 516be47827 Bump version to 4.0.0 2021-04-23 22:50:35 +02:00
KennyTV 9e62c161b4 Fix publishing 2021-04-15 11:11:04 +02:00
KennyTV d4785f093e 21w15a 2021-04-14 17:46:12 +02:00
KennyTVandjmp fad65e5b81 Update gradle build files
Co-authored-by: jmp <jasonpenilla2@me.com>
2021-04-14 14:19:28 +02:00
KennyTV 49d507dfad Update to Gradle 7.0 2021-04-13 12:40:37 +02:00
KennyTV 75031f66b5 Handle new translations 2021-04-10 16:54:10 +02:00
MrMicky ad48770606 Use commands from Declare Commands packet for tab-completion on 1.12 (#353) 2021-04-10 09:56:55 +02:00
KennyTV f7bd440a96 21w14a 2021-04-07 17:35:57 +02:00
KennyTV b2586cf13b Update readme 2021-04-05 13:38:19 +02:00
MrMicky 7a5e57e1a8 Fix mushrooms blocks on 1.12.2 and below (#351) 2021-04-03 10:15:51 +02:00
MrMicky 0812204f11 Fix colored inventory titles on 1.13 and below (#350) 2021-04-02 20:41:56 +02:00
KennyTV 066fef0513 Move to checker qual nullability annotations 2021-04-02 18:24:13 +02:00
creeper123123321 8d7ed4c16c +x gradlew, gradle workflow (#349) 2021-03-31 22:17:03 +02:00
KennyTV 51b74fd618 21w13a 2021-03-31 20:26:04 +02:00
KennyTV 6403c6480d Fix proxy server switches to equal world names and same the dimension 2021-03-26 14:47:20 +01:00
KennyTV 9dcd95b2c3 Update VV usage 2021-03-26 12:52:55 +01:00
KennyTV 4c7919fe82 Update VV usage 2021-03-24 16:54:07 +01:00
KennyTV df09b9a5ee Change license in fabric.mod.json 2021-03-24 12:32:31 +01:00
KennyTV a5f5185f1d Update README 2021-03-23 20:33:37 +01:00
KennyTV bd6c2e1dcc Slightly amend license header 2021-03-23 11:11:01 +01:00
KennyTV 9352ea54f8 Add form based issue templates
(cherry picked from commit 6600d78a105eeb3ea685f27e5d059cdc0399fa06)
2021-03-22 15:43:44 +01:00
KennyTV e1325311c7 GPL 2021-03-21 10:48:42 +01:00
KennyTV a0bb191e9f 21w11a 2021-03-17 17:44:17 +01:00
KennyTV 44ae5c8c1b Update nbt usage 2021-03-15 11:16:40 +01:00
KennyTV 35ced30047 Minor cleanup 2021-03-13 18:39:15 +01:00
KennyTV f498d59303 Fix explosion packet 2021-03-13 15:34:57 +01:00
KennyTV 62b321b7e9 21w10a 2021-03-11 11:56:18 +01:00
KennyTV 279e0f01ea Fix some (previously) existing issues with name/lore saving, cleanup 2021-03-04 16:09:45 +01:00
KennyTV ea59ab372e Throw away Bungee Chat 2021-03-03 10:12:04 +01:00
KennyTV 70b4e74b52 Add 1.17 to table 2021-03-02 14:21:10 +01:00
KennyTV a8de222bc2 More sanity checks in legacy enchantment handling
Fixes #336
2021-03-01 18:25:31 +01:00
KennyTV 70a10132d0 Fix Bungee Chat relocation 2021-02-27 10:22:28 +01:00
KennyTV 25a2cb2eb9 Fix group id 2021-02-25 23:23:24 +01:00
KennyTV 43a36be834 a/b 2021-02-25 23:21:40 +01:00
KennyTV a33f2d7fae Test Via dependency 2021-02-25 09:27:28 +01:00
KennyTV a349c001fe 21w08a 2021-02-25 00:31:41 +01:00
KennyTV 0fbe2dc432 Actually fix building (I think™️) 2021-02-24 14:50:51 +01:00
KennyTV 0323300acd Update ViaVersion dependency 2021-02-24 14:25:06 +01:00
KennyTV 189936ecd2 Make it build™️ 2021-02-24 14:24:06 +01:00
KennyTV 9a581c534f 21w07a, bandaid building 2021-02-23 12:45:00 +01:00
KennyTV 99e2297d67 Update build scripts 2021-02-23 11:29:18 +01:00
KennyTV 3fc2a3e395 Setup gradle 2021-02-18 14:34:33 +01:00
KennyTV 5c1c7940a3 Fix NPE 2021-02-17 12:24:20 +01:00
KennyTV 15348f659a Fix missing shulker mapping warning
Fixes #320
2021-02-15 12:30:07 +01:00
KennyTV 8dfacde007 Fix named sound remapping 2021-02-14 19:10:37 +01:00
KennyTV 859a79d7da Update entity types usage 2021-02-14 17:27:09 +01:00
KennyTV e27d107ebc Read byte in player position 2021-02-11 19:56:34 +01:00
KennyTV 0ddf718be1 Update readme 2021-02-11 11:51:16 +01:00
KennyTV 6738b2a16b Fix multi block change 2021-02-11 09:45:06 +01:00
KennyTV c75f497c79 This is actually 21w06a 2021-02-11 09:31:12 +01:00
KennyTV 84bb022a31 This should be a 2 2021-02-11 00:36:43 +01:00
KennyTV b48edbde04 Handle world min_y value 2021-02-11 00:30:29 +01:00
KennyTV ab0406ba77 21w06a
Ship it™️ https://i.imgur.com/9R1gYOe.png
2021-02-10 19:37:28 +01:00
RK_01 600c843747 Add CommandRewriters for all protocols (#325) 2021-02-05 15:14:11 +01:00
KennyTV d2bd9679da Remove long array nbt tags for < 1.12 clients
Fixes #322
2021-02-04 22:26:36 +01:00
KennyTV 518aafe617 21w05b
Horrible mappings, but that's unique features/blocks for you
2021-02-04 20:22:40 +01:00
KennyTV 0166d1a3b1 Fix 1.16->1.15 lightning
Closes ViaVersion/ViaVersion#2309
2021-02-01 16:18:03 +01:00
RK_01 0da5b65858 [1.14.4 -> 1.15] Added wolf specific health metadata (#318) 2021-01-27 22:58:35 +01:00
KennyTV e8da5554dc Handle shulker meta index change 2021-01-21 11:42:09 +01:00
KennyTV 8a67061d32 Handle dust particle change 2021-01-21 09:38:50 +01:00
KennyTV 29ec3efa9c 21w03a 2021-01-20 18:52:30 +01:00
KennyTV 4a360bac44 Add sanity check to enchantment nbt check 2021-01-08 09:05:57 +01:00
KennyTV 1c4b27e56c Fix shades lib imports 2020-12-19 23:26:50 +01:00
KennyTV 673239108c *The future* 2020-12-19 21:40:10 +01:00
KennyTV 56b926be40 Minor parameter change 2020-12-17 11:59:28 +01:00
KennyTV 963630db7e 20w51a 2020-12-16 20:32:16 +01:00
KennyTV 54dcb32232 Handle dust particle rgb type change 2020-12-09 12:42:11 +01:00
KennyTV 9e4718abc3 Handle new particles (untested), warn for custom world height 2020-12-09 11:55:56 +01:00
Myles 5e5e32769f Actually update the dimension change comment 2020-12-06 10:49:50 +01:00
Myles c0f88bbf62 Fix comments for dimension handler 2020-12-06 10:49:50 +01:00
Myles ec2f118d80 Dimension Name -> World Name 2020-12-06 10:49:50 +01:00
Myles 2a8c7334a9 Don't send respawn packet twice if the dimension has same name 2020-12-06 10:49:50 +01:00
KennyTV ad4092b8f6 20w49a (almost)
Missing: Translating the 2 new particles with data
2020-12-03 12:55:58 +01:00
KennyTV 92cec1f798 20w48a 2020-11-25 18:06:06 +01:00
KennyTV 56c80fb5c3 20w46a 2020-11-22 09:50:55 +01:00
KennyTV 6e011f9297 Finish mappings except for sounds 2020-11-22 09:50:55 +01:00
KennyTV d11e9d3b77 Start working on 20w45a 2020-11-22 09:50:45 +01:00
KennyTV 0f631eb1d9 Also emulate damage sound when drowning 2020-11-15 14:21:32 +01:00
KennyTV 9fbfcb3851 Make 1.11->1.10, 1.10->1.9 sounds configurable, fix some sound issues
Closes #279
2020-11-15 12:20:04 +01:00
KennyTV a982d8c0f0 Fix named sound conversion warnings
Closes #283
2020-11-04 09:00:32 +01:00
KennyTV 27f7c3e72b Bump version to 3.2.1-SNAPSHOT 2020-11-04 08:54:55 +01:00
KennyTV 819d7f3d39 3.2.0 Release 2020-10-31 09:42:53 +01:00
KennyTV 25404d6c92 Fix fire extinguishing (only on Spigot servers)
Fixes #274
2020-10-21 18:57:54 +02:00
KennyTV b340c7246b Only use serverbound hotbar switch for storage 2020-10-21 12:19:05 +02:00
KennyTV 2669967b49 1.16.4-pre1 2020-10-21 12:19:05 +02:00
KennyTV e945db8cb6 Fix double chat packet register 2020-10-20 12:55:53 +02:00
Gerrygames 9a09e53572 Fix action bar coloring in chat packets (#271) 2020-10-20 12:18:33 +02:00
KennyTV 0c040db6f0 Fix NPE in piston remapper
Fixes ViaVersion/ViaVersion#2137
2020-10-15 19:17:16 +02:00
KennyTV 46c7cab3a4 Set mob name as always visible, add config option
Closes #262
2020-09-23 16:48:34 +02:00
KennyTV 922afc12a5 Configurable particle mappings, map areaeffectcloud data 2020-09-21 11:23:10 +02:00
KennyTV 4817bf7e2b Merge branch 'dev' into master
# Conflicts:
#	all/pom.xml
#	bukkit/pom.xml
#	bungee/pom.xml
#	core/pom.xml
#	fabric/pom.xml
#	pom.xml
#	sponge/pom.xml
#	velocity/pom.xml
2020-09-10 16:33:23 +02:00
KennyTV 2a118acf77 3.1.1 Release, 1.16.3 support 2020-09-09 15:48:26 +02:00
KennyTV 0b93cd0e09 Fix 1.13.1->1.13 statistics 2020-09-09 11:26:09 +02:00
KennyTV b1af6ad721 Make mapping loading considerably faster 2020-09-09 11:00:31 +02:00
KennyTV c6d8a83ac9 Fix piston mapping getting with blockconnections disabled 2020-09-06 09:03:18 +02:00
KennyTV 72a070da3e Fix joins not waiting for mappings to be loaded 2020-09-04 19:36:09 +02:00
KennyTV dbe0f7049e Bump minimum VV version to 3.2.0 2020-09-04 15:27:28 +02:00
KennyTV 91b81ebb24 Readd warnings for missing mappings 2020-09-04 11:06:39 +02:00
KennyTV 897e9545c2 Fix 1.13<->1.12 special case handling 2020-09-03 16:47:35 +02:00
KennyTV 947e5c3e07 Abstract mapping data loading 2020-09-03 15:35:34 +02:00
KennyTV ececd96718 Workaround pre 1.16.2 MC-68487
Fixes #255
2020-09-03 00:17:41 +02:00
KennyTV e9ace2dd6b Fix mapping loading on Sponge
Fixes #257
2020-09-02 10:11:36 +02:00
KennyTV c72f8f766d *Actually* don't cast the ping description 2020-08-24 13:02:16 +02:00
KennyTV 1b89327d84 Don't cast the ping description 2020-08-24 13:01:22 +02:00
KennyTV 8a8c1a33a6 Check if block entity id tag is present 2020-08-20 20:37:02 +02:00
KennyTV 761249d39f Fix 1.16.2 type mapping
Fixes ViaVersion/ViaVersion#2021
2020-08-20 11:16:16 +02:00
DoctorMacc e03da34f55 Don't assume CanPlaceOn tag is ListTag
I guess somewhere in my testing I made a CanPlaceOn tag that was a byte value and the client disconnected on me when I put ViaBackwards on my testing instance. This commit doesn't translate the CanPlaceOn tag if it isn't a ListTag.
2020-08-17 08:58:14 +02:00
KennyTV 03ec04cc8d Process motd description rgb colors
Fixes ViaVersion/ViaVersion#1999
2020-08-16 10:50:22 +02:00
KennyTV f387899dab Fix chain mappings 2020-08-13 17:53:31 +02:00
KennyTV ce49daa300 Rewrite custom stats ids 2020-08-13 13:59:23 +02:00
KennyTV 249a720cee Fix wrong clientpackettype 2020-08-12 22:37:34 +02:00
KennyTV fa59cbcc01 Update VV usage 2020-08-12 22:35:34 +02:00
KennyTV 803c24f4d3 Rewrite item/block/entity ids in statistics 2020-08-12 22:32:19 +02:00
KennyTV 5e19a5af33 Back to snapshot 2020-08-12 16:34:39 +02:00
KennyTV 8911f1eb94 Don't cancel 1.16.2 multi block change packets
Tfw the logic works but you do a stupid, different error for the same packet on two different projects
2020-08-11 21:37:26 +02:00
KennyTV 6f0bd98be2 3.1.0 Release 2020-08-11 08:50:33 +02:00
KennyTV e325a03c0a Fix effects value 2020-08-10 22:03:05 +02:00
KennyTV b9317df859 Use effects data to determine legacy dimension, cleanup ClientWorld usage 2020-08-10 21:21:10 +02:00
KennyTV 11bb1349e9 Compare to correct tag in lore processing 2020-08-10 18:03:46 +02:00
KennyTV 6289e9317d Remove casting in display saving
Fixes #246
2020-08-09 21:59:37 +02:00
KennyTV 2d9d67bcb2 Merge branch 'master' into dev 2020-08-08 09:15:59 +02:00
KennyTV 62fd868130 Update issue template 2020-08-08 09:15:31 +02:00
KennyTV b2b8c48fd0 Eliminate full copying/saving of item tags
This unnecessarily stores a hell of a lot of unneeded data and heavily accumulates the more versions the pipeline goes down to.
2020-08-07 10:07:39 +02:00
KennyTV 9f9d05d3c6 1.16.2-pre3 2020-08-06 20:23:22 +02:00
KennyTV 6e01a0affd 1.16.2-pre2 2020-08-05 18:23:23 +02:00
KennyTV d6d6307550 Map netherite tools and armor to diamond
Addresses #243
2020-08-05 10:41:37 +02:00
KennyTV 1afdf0fb81 Process player info entries with 1.16->1.15 color correction 2020-07-30 15:43:34 +02:00
KennyTV fd529ce967 Properly implement color diff
Semi fixes #239
2020-07-30 15:22:27 +02:00
KennyTV c5ba1864d1 1.16.2-Pre1 2020-07-29 17:27:13 +02:00
KennyTV 831b8ad5ad Don't remove white chatcolor in 1.13->1.12 suffix
Fixes #236
2020-07-26 09:28:06 +02:00
KennyTV 58256b5b64 *moonwalks out* 2020-07-22 21:53:35 +02:00
KennyTV d209e9b768 20w30a, bump version to match VV's 2020-07-22 21:52:48 +02:00
KennyTV 61b1f0d8a4 More reciperewriter cleanup 2020-07-15 11:49:33 +02:00
KennyTV 2748624dde Write default registry for 1.16/1.16.1 clients
Actually processing the monster that is the .2 registry would be unreasonable, and there shouldn't be any reason to keep using those two versions (and not -1.15.2 or +1.16.2)
2020-07-11 22:29:19 +02:00
KennyTV d5b19b8869 Merge branch 'master' into dev 2020-07-09 17:10:45 +02:00
KennyTV 650f89e1ce Don't send air block break particles to sub 1.12 players
Fixes #227
2020-07-09 17:10:31 +02:00
KennyTV 00172ee675 Fix vindicator meta casting
Fixes #226
2020-07-09 14:55:52 +02:00
KennyTV 45aab8f9f2 Map biomes 2020-07-09 14:40:54 +02:00
KennyTV 1e455b0391 20w28a 2020-07-09 13:26:33 +02:00
KennyTV 59cb67da6e Fix empty json in 1.14->1.13 items 2020-07-06 15:06:01 +02:00
KennyTV 6b96e1a8e2 Fix 1.12->1.11 title json null
Fixes #217
2020-07-06 14:57:14 +02:00
KennyTV 5ef94d94e6 Rewrite item nbt attributes 2020-07-02 16:00:17 +02:00
KennyTV a59c384884 Send dummy respawn on same dimension switch 2020-07-02 13:20:49 +02:00
KennyTV 7638d678bb Move RecipeRewriter to VV, cleanup advancements+trade list 2020-07-02 00:26:44 +02:00
KennyTV f3c30130d2 20w27a 2020-07-01 22:32:35 +02:00
KennyTV bb583065f3 Cleanup some tag rewriting 2020-06-30 21:16:19 +02:00
KennyTV f5bb30559d Make map data type read consistent 2020-06-30 17:09:46 +02:00
KennyTV 87afb84a4d Fix server switching to 1.16 servers on Bungee
Fixes #216
2020-06-30 13:56:38 +02:00
KennyTV 07078b21f1 Improve map color rewriter, cc Gerrygames 2020-06-30 13:25:38 +02:00
KennyTV 63d3dcb31b Make this more readable with the base colors 2020-06-30 12:41:09 +02:00
KennyTV 478e663506 Handle new map item colors 2020-06-30 12:33:40 +02:00
KennyTV 6bb8ae1dfc Fix json entity names 2020-06-29 18:28:40 +02:00
KennyTV 2cea70e643 Fix chat meta conversion
Fixes #213
2020-06-29 10:01:27 +02:00
KennyTV 54de77a110 Correct component type in advancements 2020-06-28 11:56:22 +02:00
KennyTV e38cb88640 Fix item particle id
Fixes ViaVersion/ViaVersion#1852
2020-06-28 09:20:01 +02:00
KennyTV 8deeda641a VV now has these methods 2020-06-28 09:11:11 +02:00
KennyTV f75420a642 Fix 1.12 chat reading 2020-06-27 22:08:22 +02:00
KennyTV efd435e908 Update 1.16 translations 2020-06-27 19:27:06 +02:00
KennyTV 875ffb7f2d Use JsonElement for chat components 2020-06-27 17:05:07 +02:00
KennyTV 385ca98125 Fix NPE
Fixes #211
2020-06-25 14:30:05 +02:00
KennyTV c4630039c4 Also handle block entity data nbt 2020-06-25 11:30:45 +02:00
KennyTV cf6df691d2 Bump dependencies 2020-06-25 10:32:05 +02:00
KennyTV 76dfbe030e Version bump to 3.0.2-SNAPSHOT 2020-06-24 14:36:31 +02:00
KennyTV c7a168d3b3 3.0.1 Release 2020-06-24 14:24:29 +02:00
KennyTV b79bf429f7 1.16.1 2020-06-24 14:16:21 +02:00
KennyTV 6e1c482e2d Version graph 2020-06-24 10:43:59 +02:00
KennyTV b506060e48 Fix component length read 2020-06-23 19:20:39 +02:00
KennyTV 8294f6af4f Bump version to 3.0.1-SNAPSHOT 2020-06-23 17:11:40 +02:00
KennyTV b98f208a98 3.0.0 2020-06-23 15:08:10 +02:00
KennyTV bdc79c43eb Remove unmapped piston warning
Remove some wont-fix/unneeded todos
2020-06-19 17:47:43 +02:00
KennyTV f83ac57d8f 1.16 pre7 2020-06-16 19:02:31 +02:00
KennyTV 124f5a5b87 1.16 pre6 2020-06-15 20:12:04 +02:00
KennyTV 4a8a475d55 Properly write interact sneaking boolean 2020-06-12 18:56:30 +02:00
KennyTV 86cf835d53 1.16 pre5 2020-06-12 17:17:35 +02:00
KennyTV 166b4314fd 1.16 pre4 2020-06-11 19:29:56 +02:00
KennyTV 615cd40cae 1.16 pre3 2020-06-10 18:36:00 +02:00
KennyTV 25220621e7 Fix 1.14->1.13 entity id rewriting 2020-06-10 17:32:41 +02:00
KennyTV e3faa0d77d Move to proper FU usage 2020-06-09 08:13:52 +02:00
KennyTV 6de1ba9f30 Move to proper FU usage 2020-06-08 23:59:17 +02:00
KennyTV 79708fe952 Fix 1.14.0-1.14.3 acknowledge player digging kick 2020-06-08 18:03:00 +02:00
KennyTV 16b68f7e3d Use fastutil soft wrappers 2020-06-08 18:03:00 +02:00
KennyTV 71d5aab1b0 Cancel 1.14 bell block action
Fixes #209
2020-06-08 18:01:40 +02:00
KennyTV 3bda6dd503 Remove new statistics 2020-06-08 09:39:10 +02:00
KennyTV 5ff7767353 Use packet type constants for automated channel mapping 2020-06-06 16:15:28 +02:00
KennyTV d334a202e7 1.16-pre1 2020-06-04 23:42:17 +02:00
KennyTV eec16eb5bb Fix nether biome id 2020-06-04 09:32:46 +02:00
KennyTV ee86b109b2 Fix ghost items 2020-06-04 09:30:19 +02:00
KennyTV 004d0d2b23 Some metadata and entity rewriter cleanup 2020-06-03 22:48:48 +02:00
KennyTV cf5e5590ad Remove more unnecessary map lookups 2020-06-03 18:36:22 +02:00
KennyTV 5988ab4c19 Some minor optimizations 2020-06-03 11:20:17 +02:00
KennyTV e25abe57e0 Re-add translatable handler to 1.14 item handling
Reeeee
2020-06-03 08:56:28 +02:00
KennyTV 3d50c36ce3 Remove translatable handler from 1.13/1.14 item handling
Lore and name weren't actually components in those versions
Fixes #207
2020-06-03 08:48:18 +02:00
KennyTV 38ed381094 Handle color for items and entities, handle item translatable components 2020-06-02 12:13:21 +02:00
KennyTV 2698725401 Remove unnecessary override 2020-06-02 11:19:28 +02:00
KennyTV aec46ecd38 Refactor/optimize chat component rewriter 2020-06-02 11:14:26 +02:00
KennyTV c2fb40b4e1 20w22a 2020-05-29 15:20:39 +02:00
KennyTV 8b4733258b Fix show_entity and show_item in 1.16->1.15 2020-05-28 13:29:24 +02:00
KennyTV 4b0e352849 Use correct gamemode type in respawn packet 2020-05-23 12:49:21 +02:00
KennyTV 611dd93bb9 Extend from VV soundrewriter 2020-05-23 11:21:42 +02:00
KennyTV cb8cdf27a4 20w21a 2020-05-20 17:08:15 +02:00
KennyTV f487f13e82 Fix ender pearl sound in 1.11->1.10 2020-05-18 00:28:04 +02:00
KennyTV 13bcce6d30 20w20a 2020-05-13 18:32:10 +02:00
KennyTV a30b48d8e9 Fix stop sound source reading 2020-05-09 15:31:54 +02:00
KennyTV e7ab178449 Fix load ordering issue with VV
Fixes #204
2020-05-09 09:49:26 +02:00
KennyTV 040558e01f Remap smithing inventory to anvil 2020-05-08 09:21:16 +02:00
KennyTV d4a76b0ff5 Minor cleanup 2020-05-04 11:18:48 +02:00
KennyTV 446f46db83 Fix entity rewriting 2020-04-30 17:16:47 +02:00
KennyTV e49c355580 Fix missing channel remap
Fixes #202
2020-04-30 16:26:04 +02:00
KennyTV 8fbcd71e09 Handle soul speed enchant 2020-04-29 21:50:41 +02:00
KennyTV 6e9155ba80 20w18a 2020-04-29 18:19:38 +02:00
KennyTV c2d81e6e9d Map the sound name in stop sound packets 2020-04-28 11:23:56 +02:00
KennyTV 8409f6fb2a Fix show_item count tag 2020-04-27 14:24:52 +02:00
KennyTV 29908523b0 Async mapping loader change 2020-04-25 13:30:26 +02:00
KennyTV 48a69f1411 Add sanity check for implementation version 2020-04-24 11:45:54 +02:00
KennyTV 49daeb33c0 Also process hovered text 2020-04-23 12:37:29 +02:00
KennyTV b1ca8cc2a0 Approximate hex color to chat color, fix show_text hover
TODO: show_entity hover
2020-04-23 12:25:09 +02:00
KennyTV 2b0745dc2c 20w17a 2020-04-22 23:25:57 +02:00
KennyTV 4d701b1c4e Use properly renamed entity type constants 2020-04-22 19:30:41 +02:00
KennyTV 0cb41c970b Load legacy mappings from dir if present 2020-04-19 14:02:52 +02:00
KennyTV 345d78976a Add VB version to dumps 2020-04-17 21:11:36 +02:00
KennyTV 11417fa04e Add sanity check for skullowner tag rewrite
Fixes #199
2020-04-17 20:47:22 +02:00
KennyTV c0668f1ee7 Update 20w16a translation mappings 2020-04-17 09:46:16 +02:00
KennyTV b11c5e27c5 20w16a, fix strider meta 2020-04-15 18:24:13 +02:00
KennyTV 99482b611f Pass VB plugin instance for listener creation 2020-04-14 19:01:19 +02:00
KennyTV 46577b4396 Only send missing entity warning when debug is enabled
Too prominent plugins fail at respecting the tracking range of the player for packet entities, and people have shown not to be able to find the first appearance of the warning with its explanation
2020-04-11 18:57:56 +02:00
KennyTV 6ab2e2f0b2 Fix npe in mapping loading 2020-04-09 16:40:46 +02:00
KennyTV b8dde25f3a 20w15a, minimize diffmappings 2020-04-08 19:40:34 +02:00
KennyTV 32c26a5539 Open book when using lecterns on Bukkit
Fixes #194
2020-04-06 15:24:31 +02:00
KennyTV f263f757de Async mapping data loading 2020-04-05 22:57:32 +02:00
KennyTV ecceac660d 20w14a 2020-04-02 22:27:42 +02:00
KennyTV 910f5d98dc Fix 1.13->1.12.2 enchantment table preview
Fixes #192
2020-03-31 19:13:41 +02:00
KennyTV 1d48bf5086 20w13a 2020-03-25 21:03:09 +01:00
KennyTV 432977614f Fix skull item nbt 2020-03-23 11:13:38 +01:00
KennyTV 60164a7383 Transform tile entity uuid nbt 2020-03-20 21:12:53 +01:00
KennyTV 1b70321018 Fix parrot shoulder tracker 2020-03-19 10:32:55 +01:00
KennyTV 3b24b0dfe1 20w12a 2020-03-18 20:35:56 +01:00
KennyTV 6b73de2510 Fix number casting in 1.13 enchantments 2020-03-16 12:01:21 +01:00
KennyTV 5909103c56 Fix wrong protocol 2020-03-15 23:32:26 +01:00
KennyTV 99884107fc Fix falling block conversion
Fixes #187
2020-03-15 23:31:34 +01:00
KennyTV 8087b42c40 Map named sound packets, some cleanup 2020-03-15 12:09:56 +01:00
KennyTV 2b269a6563 20w11a 2020-03-11 22:55:04 +01:00
KennyTV af88a57983 Fix spawn egg conversion from 1.13->1.12.2, some cleanup 2020-03-05 19:03:09 +01:00
KennyTV 9a5d4197fc 20w10a mappings 2020-03-04 18:49:39 +01:00
KennyTV 126300b388 Map obsidian tear particles 2020-02-27 12:33:15 +01:00
KennyTV 334ae94577 Update translation mappings 2020-02-27 08:24:15 +01:00
KennyTV 1d1c3fdc06 20w09a 2020-02-26 19:29:41 +01:00
KennyTV ace1e6c553 20w07a 2020-02-14 17:00:24 +01:00
KennyTV 9550151de6 Make startup debug more consistent 2020-02-12 13:53:24 +01:00
Jonathan Leitschuh 947ff8e5ac Use HTTPS instead of HTTP to resolve dependencies (#183)
This fixes a security vulnerability in this project where the `pom.xml`
files were configuring Maven to resolve dependencies over HTTP instead of
HTTPS.

Signed-off-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>
2020-02-11 17:35:23 +01:00
KennyTV 2b76a5bc17 Resolve memory leak 2020-02-09 14:13:54 +01:00
KennyTV ba7333184b Partly fix memory leak, remove some unnecessary concurrenthashmap usages
The block entity caching in 1.13->1.12 protocol did not uncache any of the positions/blocks - this at least clears the cache on respawn, but an uncache in the chunkunload is still required to be done
2020-02-09 13:10:06 +01:00
KennyTV d6fe7914e8 More entity rewriter cleanup 2020-02-09 11:48:47 +01:00
KennyTV a4ed18f59b Entity rewriter cleanup 2020-02-07 22:32:24 +01:00
KennyTV 57602f2cee Sound mappings 2020-02-07 16:46:58 +01:00
KennyTV 78d85b7080 Item and particle mappings 2020-02-07 09:35:54 +01:00
KennyTV 91f784f3f3 20w09a (missing: sounds, items) 2020-02-06 12:02:33 +01:00
KennyTV 0f1f9328ae Use VV 1.11 EntityIdRewriter 2020-02-05 20:38:03 +01:00
KennyTV c560373be3 Fix 1.11->1.10 potion splash effect 2020-02-04 14:53:15 +01:00
KennyTV d9e5f650f1 Disable face player fix by default (unlikely to be used too often) 2020-02-03 11:16:08 +01:00
KennyTV 3144c6fb19 Make the tracker warning slightly more aggressive 2020-02-03 11:02:02 +01:00
KennyTV 7296fd58ec Map 1.14 campfire particles 2020-02-02 10:16:31 +01:00
KennyTV 2334f6c5c9 Fix NPE 2020-02-01 12:44:56 +01:00
KennyTV 152b9db80f Actually set legacy block remaps 2020-02-01 12:07:27 +01:00
KennyTV 01121dedf3 Configurable block/item mappings (1.9-1.12), cleanup
Resolves #39
2020-02-01 11:58:02 +01:00
KennyTV 8df3815e82 Give the output jar a nicer name 2020-01-29 16:59:52 +01:00
KennyTV 83ef8572c1 Farewell, lombok!
Also replaced some optionals with simple nullable objects
2020-01-27 19:41:59 +01:00
KennyTV aca265956f Handle 1.14 zombies/skeletons holding up arms 2020-01-27 18:43:03 +01:00
KennyTV 08743513ca Replicate explosion sound on 1.15 servers 2020-01-27 14:20:52 +01:00
KennyTV 7578671fc6 Fix 1.13 item mapping 2020-01-27 09:03:03 +01:00
KennyTV b2df8fc0d9 Custom item mappings (1.12-1.15)
Item mappings as well as their names can now be freely modified in the respective mapping files.
(Todo: 1.9-1.11)
2020-01-26 20:52:08 +01:00
KennyTV b62c8c46e3 Minor optimizations to legacy block rewriting 2020-01-26 15:41:25 +01:00
KennyTV 96b9a023c1 Update readme 2020-01-26 11:48:42 +01:00
KennyTV 4b3f1be599 Add api version to prevent legacy data loading 2020-01-22 12:43:21 +01:00
KennyTV d3bcc9f6c8 Prepare 1.15.2 support (if no protocol changes on release) 2020-01-19 19:14:29 +01:00
KennyTV 4680c0f3d2 Remove 1.12 flyingspeed attribute 2020-01-18 10:29:53 +01:00
KennyTV e809c117c4 Handle translatable messages (1.15->...->1.12) 2020-01-16 23:23:29 +01:00
KennyTV 80ef8a401d Minor change to rewriter register 2020-01-16 17:12:25 +01:00
KennyTV b00ae1b701 Handle 1.13->1.12.2 translatable key changes 2020-01-16 11:09:26 +01:00
KennyTV 8878a18108 Handle 1.13->1.12.2 (general) statistics 2020-01-15 22:53:34 +01:00
KennyTV 9d3bec1aa1 Handle 1.13 areaeffectcloud particle data 2020-01-14 19:43:04 +01:00
KennyTV 1857244eae We need playerteleport for caching, not entityteleport 2020-01-14 14:15:40 +01:00
KennyTV d7f67065be Handle face player packet 2020-01-14 13:51:33 +01:00
KennyTV 8c1923b077 WIP Face player 2020-01-14 13:51:02 +01:00
KennyTV ed67bd888e Fix another 1.14 particle error 2020-01-13 22:43:15 +01:00
KennyTV 95dd94f645 Remap 1.15 particles for areaeffectcloud 2020-01-13 22:29:21 +01:00
KennyTV 71e24d9797 Map new 1.15 particles, fix remap in 1.14 2020-01-13 22:24:44 +01:00
KennyTV d50c26dd55 Fix book edit 2020-01-12 10:18:09 +01:00
KennyTV d3ecce71fa Fix 1.14 lightning tracking
Fixes https://github.com/ViaVersion/ViaRewind/issues/145
2020-01-10 14:59:00 +01:00
KennyTV e40300d0b1 Fix 1.14 particle rewriting
In the used common method, the id rewriting is done after the data handling
2020-01-09 21:59:12 +01:00
KennyTV 884dcbe5b9 Map debug stick 2020-01-07 18:46:19 +01:00
KennyTV 26fab9f1ea Cleanup some block rewriting 2020-01-06 17:59:29 +01:00
KennyTV 07cc5fd7ed Let users move and change block/sound mappings in the data folder 2020-01-06 16:34:39 +01:00
KennyTV b1c4d563b4 Add option to (not) add the 1.13 scoreboard team color 2020-01-02 19:34:31 +01:00
KennyTV 617f1d3876 Add additional info to entity warning in teleport packet 2020-01-02 18:25:43 +01:00
KennyTV 3e01afbe17 Fix skull rotation
Fixes #121
2019-12-30 14:24:44 +01:00
KennyTV b339216533 Remap shulker boxes to droppers (for a full block hitbox) 2019-12-29 12:16:56 +01:00
KennyTV edc4f71403 Fix inventory titles being overriden
Fixes #175
2019-12-25 12:01:04 +01:00
KennyTV 5d8f86e9eb Change immediaterespawn flag on gamestate change 2019-12-24 17:26:41 +01:00
KennyTV de2c3b3719 Store config values for direct access 2019-12-24 09:57:11 +01:00
KennyTV 35f531d051 Instantly respawn sub 1.15 clients if gamerule is set 2019-12-23 22:55:57 +01:00
KennyTV f95b05866c Cleanup and fix CanPlaceOn/CanDestroy nbt tags 2019-12-22 12:40:21 +01:00
KennyTV 12819a63a3 Suppress stored entity warning if disabled in Via config
... pretty sure reports of this occurring are caused by HolographicDisplay, but still investigating ;)
2019-12-18 20:05:52 +01:00
KennyTV 6b8f9d87f2 1.15.1 2019-12-17 18:33:21 +01:00
KennyTV cc93551339 Add more info to missing entity warning in position cache 2019-12-16 20:58:53 +01:00
KennyTV 98eb47c360 Update VV item/position usage 2019-12-14 11:34:57 +01:00
Gerrygames 31b3acdba7 acknowledge player digging 2019-12-11 20:36:47 +01:00
KennyTV 03b7f995f6 Send empty list instead of implicit byte for metadata 2019-12-11 19:11:53 +01:00
KennyTV a642e46eb3 Cleanup outdated VV check 2019-12-11 12:35:55 +01:00
KennyTV a25b002fa8 Fix acknowledge player digging 2019-12-11 11:58:55 +01:00
Nassim 653a38fbba Merge pull request #170 from KennyTV/abstraction
Fix trade list
2019-12-10 20:45:07 +01:00
KennyTV 9177dff34f Fix trade list 2019-12-09 19:29:36 +01:00
Myles 449d45da9b Merge pull request #169 from Gerrygames/abstraction
use isSuppressConversionWarnings
2019-12-09 11:24:18 +00:00
Gerrygames f22b6138b9 use isSuppressConversionWarnings 2019-12-09 12:21:24 +01:00
Myles f959a388c0 Merge pull request #168 from KennyTV/1.15
1.15 (and a lot of other improvements/fixes) 🎉
2019-12-07 17:10:55 +00:00
KennyTV e55ff0130c 1.15 (and a lot of other improvements/fixes) 🎉 2019-12-07 17:14:17 +01:00
KennyTV 3b48aa8076 Merge remote-tracking branch 'upstream/master' into 1.15
# Conflicts:
#	README.md
2019-12-07 17:02:19 +01:00
Nassim 10217f5c5f Merge dev, fixed suffix length check (#165)
* fix falling block data remap (#161)

* Update README.md (#162)

* fix item hover event on 1.11 (#164)

* Fix kick for overly long suffix
2019-11-21 09:24:28 +00:00
Jo0001 2531e9f353 Fix typo in README.md (#163) 2019-10-27 12:32:44 +00:00
ForceUpdate1 5bb87bc059 Update README.md (#162) 2019-10-24 22:39:44 +02:00
Gerrygames 91ca18de3e Merge remote-tracking branch 'mats/dev' into mats_abstraction 2019-10-20 13:48:47 +02:00
Gerrygames e7e315983e fix remaps in wrong direction (#160) 2019-10-20 12:36:58 +01:00
Nassim 0da10a2864 Fix 1.11 enchant remapping, arrow velocity and bed handling (#159)
* Arrow velocity and entity meta error fix

* Fix 1.11 enchant remapping, some minor cleanup
2019-10-13 21:20:52 +01:00
creeper123123321 b21fce2506 Fix typo (#41) (#157) 2019-10-13 17:33:42 +01:00
Nassim 8e032f6499 Cleanup entity tracking/rewrites and item rewrites (#155)
* Cleanup entity tracking and rewrites

* Fix

* Item rewriter cleanup
2019-10-12 10:08:18 +01:00
Nassim 1d12eb0b95 Cleanup entity tracking and rewrites, cleanup 1.14.1->1.14 protocol (#148) 2019-09-24 12:53:25 +01:00
Nassim 6a0e553c96 Use VV entity types (#147) 2019-09-23 12:33:28 +01:00
Nassim f0da0624f7 Fix villager and llama meta rewrites (#146) 2019-09-23 09:00:03 +01:00
Nassim 8e2d640f8c Be able to suppress plugin channel name warnings (#142) 2019-09-13 10:07:51 +01:00
Nassim b879076026 Check if non-full light fix is disabled (#143) 2019-09-13 10:07:32 +01:00
Nassim fdcab0d5a8 (Custom) enchant remap fixes, non full block light fix (#124)
* Fix 1.13 enchant conversion + custom enchants

* Remove redundant check

* More enchant remap fixes, add config option for custom enchant display

* Fix non full blocks "saving" block light
2019-09-09 14:23:09 +01:00
Nassim e6059845aa Remap tridents, fix falling dust and lingering potions (#140)
* Fix falling dust particle for 1.9 clients

* Fix concurrent meta addition / lingering potions
Fixes #125

* Remap trident and trident sounds
2019-09-07 13:49:05 +01:00
Nassim 781ef86af6 Send valid biomes again + remap new ones (#136)
* Remap biomes

* Fix base shulker box remappings, remove unnecessary int/short casting
2019-08-18 08:09:45 +01:00
Gerrygames 3ecf898d0a Fix explosion block desync (#131) 2019-08-14 09:39:12 +01:00
Nassim 1c82d51734 Fix pistonhandler with serverside blockconnections (#130) 2019-08-14 09:38:51 +01:00
ForceUpdate1 b7bd93cfb6 Some improvements 👀 (#126)
* fix particle remaps
fix use bed packets
fix npe in piston handler

* remove todo

* Revert "fix plugin channel remap"

This reverts commit 960197c0

* reformat code

* Comments added
2019-08-04 09:39:43 +01:00
Myles 5a7a8eb334 Merge pull request #119 from ForceUpdate1/dev
Fix plugin channel remap 1.13 -> 1.12 🙌
2019-08-03 09:51:53 +01:00
Myles 0e10b6b54b Merge pull request #127 from ForceUpdate1/particleFix
Fix RGB Particles ✨
2019-08-03 09:51:33 +01:00
Marco 2376dad26a fix rgb particle 2019-08-03 10:43:54 +02:00
Marco 2fc0eac1e2 change to ViaBackwards logger 2019-08-03 00:38:06 +02:00
Marco 04793f41c5 Merge branch 'dev' of https://github.com/ViaVersion/ViaBackwards into dev 2019-08-02 21:59:00 +02:00
Myles e481c45b62 Merge pull request #123 from Gerrygames/dev
fix #122 and wrong byte types in trade list packets
2019-07-26 10:40:05 +01:00
Gerrygames 66b7b461b7 use correct byte type in trade list packets 2019-07-26 10:53:53 +02:00
Gerrygames 751c585469 fix #122 2019-07-22 22:38:12 +02:00
Myles 485c8270fa Merge pull request #116 from KennyTV/dev
New version support, some fixes
2019-07-19 12:07:52 +01:00
KennyTV 24d77278f6 Fix typo 2019-07-19 13:01:10 +02:00
KennyTV d66eb0c56b 1.14.4 support 2019-07-19 12:53:37 +02:00
Foorcee 960197c02e fix plugin channel remap 2019-07-19 08:47:02 +02:00
ForceUpdate1 21a6852593 Merge pull request #6 from ViaVersion/dev
merge upstream
2019-07-11 09:11:50 +02:00
KennyTV c186d13ae5 Fix trade item rewrites 2019-07-06 19:36:50 +02:00
KennyTV 01018fe600 Remap 1.13 piston tile entity 2019-07-05 10:22:38 +02:00
Mats cba2566c21 Merge pull request #114 from KennyTV/dev
Remap 1.14 enchantments
2019-07-03 21:37:31 +02:00
Matsv b9cb23e353 🔧 Fix commandblock rewrite 2019-07-03 16:28:19 +02:00
KennyTV e9ffe66131 Fix 1.14 dummy enchant being lost 1.13 conversion 2019-07-02 19:48:42 +02:00
KennyTV d6a1f06b35 Refactor 1.13 enchantment rewrites 2019-07-02 19:09:16 +02:00
KennyTV d124b2ddfe Fix npe in 1.13 enchant remaps 2019-06-30 11:23:42 +02:00
KennyTV 92e9eab85e Remap 1.14 enchants, show enchantment level in 1.13 remaps 2019-06-30 10:45:16 +02:00
KennyTV 1d9a0773c7 Set version to 3.0.0-SNAPSHOT 2019-06-30 10:44:43 +02:00
Matsv 105e6f23a2 ✨ Rewrite particles 2019-06-29 21:08:24 +02:00
Mats ff1bf45fd2 Merge pull request #109 from ForceUpdate1/1.14
[WIP] Add 1.14.x support, some 1.13.x fixes
2019-06-29 15:12:36 +02:00
KennyTV 21bd518f45 Properly fix recipe book from 1.14.3 2019-06-25 12:34:01 +02:00
KennyTV 167b715048 Fix new recipe type 2019-06-25 09:16:03 +02:00
KennyTV 1c94e0ead2 Fix 2019-06-24 17:28:32 +02:00
KennyTV b4c30dbff3 Update to 1.14.3 2019-06-24 17:24:21 +02:00
creeper123123321 5e1143af4b Use correct fabric.mod.json metadata keys 2019-06-16 10:21:38 -03:00
creeper123123321 ac571df2cd rebased into 1.14 branch 2019-06-16 10:05:06 -03:00
creeper123123321 fd8c89ae17 Don't shade Log4J API 2019-06-16 09:53:03 -03:00
creeper123123321 3acba1b8e2 ViaFabric platform 2019-06-16 09:53:03 -03:00
KennyTV 0c7c7ba05c Fix trident entitytype 2019-06-13 11:45:58 +02:00
Gerrygames 4070efd803 fix wrong light mask 2019-06-12 17:42:11 +02:00
KennyTV 6c27c1e863 whoops 2019-06-09 11:13:42 +02:00
KennyTV dc12f26f05 Let there be light 2019-06-09 11:11:33 +02:00
KennyTV 3f9e66bd7b Fix recipe book data 2019-06-07 14:46:48 +02:00
KennyTV 9849eebda3 Remap 1.14 spawn eggs 2019-06-07 14:40:00 +02:00
KennyTV 8f84efb833 Hotfix untracked entity 2019-06-02 20:17:55 +02:00
KennyTV 0084f764ba Fix block remaps 2019-06-02 00:00:38 +02:00
Marco c2d72214de impl first block id remaps 2019-05-30 15:36:11 +02:00
Marco d64e75d374 inventory name remap 2019-05-30 14:46:31 +02:00
Marco a12b39b67f remap cartography_table inventory 2019-05-30 14:04:50 +02:00
KennyTV 25b5b1ca8c Remap berry bushes to vines 2019-05-29 14:00:33 +02:00
KennyTV afe7c69ec1 1.14.2 2019-05-28 13:11:31 +02:00
KennyTV 955056ae61 Remap bell to goldblock 2019-05-28 13:11:22 +02:00
KennyTV 041796c85d Fix zombie submob metadata 2019-05-27 09:45:57 +02:00
KennyTV f684ed2801 Merge remote-tracking branch 'origin/1.14' into 1.14 2019-05-25 11:49:51 +02:00
KennyTV 92b8a7fd58 Fix bell item remap 2019-05-25 11:49:35 +02:00
Marco dc18190452 fix inventory slot sizes 2019-05-25 11:41:40 +02:00
Marco 4239d75275 fix intentory rewrites furnace, blast furnace, grindstone, smoker 2019-05-25 11:32:40 +02:00
Marco 111ead2719 Merge remote-tracking branch 'origin/1.14' into 1.14
# Conflicts:
#	core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java
2019-05-25 11:04:33 +02:00
Marco f3710c4fcf fix item rewrites at to server 2019-05-25 11:03:51 +02:00
KennyTV fda618d7e8 Finish (?) 1.14 mappings 2019-05-25 10:47:36 +02:00
Marco 89099a6f0d fix item remaps 2019-05-25 01:37:32 +02:00
KennyTV 41d286feb5 1.14 sign item mappings 2019-05-24 15:59:10 +02:00
Foorcee e043ef5f66 Merge remote-tracking branch 'origin/1.14' into 1.14 2019-05-24 13:28:51 +02:00
Foorcee 070661c623 reimpl. item remaps 2019-05-24 13:28:36 +02:00
KennyTV 1d2f9c6d4c A bunch of 1.14 mappings 2019-05-24 13:28:26 +02:00
KennyTV 884113ae3c Set pom version 2019-05-24 12:43:17 +02:00
KennyTV 649d2d1381 Some 1.13 item mappings 2019-05-24 11:20:44 +02:00
Marco Neuhaus a44d18fb87 Merge remote-tracking branch 'origin/1.14' into 1.14 2019-05-23 19:14:38 +02:00
Marco Neuhaus f85ef70366 fix dust particle 2019-05-23 19:14:01 +02:00
KennyTV 8d02b00cc3 Remap mushroom stem item 2019-05-23 13:17:27 +02:00
KennyTV 747943258e Add remaining 1.13 -> 1.12 mappings 2019-05-23 13:00:33 +02:00
KennyTV b20c2cbc3b Fix lever mappings 2019-05-23 11:38:49 +02:00
Marco Neuhaus b466ed9eb8 fix particle rewrites 2019-05-22 23:53:05 +02:00
KennyTV a29e88f535 Make 'em blocks placeable again! 2019-05-22 19:55:19 +02:00
KennyTV 85a5ae44e1 Fix minecarts 2019-05-22 18:35:20 +02:00
KennyTV 3107094faa Turtle egg and sea pickle mappings 2019-05-22 17:24:33 +02:00
KennyTV 885ae3f63b Add trident to EntityType1_13 2019-05-22 16:23:56 +02:00
KennyTV 88cfa40776 Fix painting and xp orb tracker 2019-05-22 15:27:48 +02:00
Marco 1dc4a771a3 fix wandering traders + trades 2019-05-22 11:27:27 +02:00
Marco 24bfa82c0c fix item remaps 2019-05-21 23:35:49 +02:00
Marco 4b0881263b add missing remaps 2019-05-21 23:10:11 +02:00
Gerrygames 3d1aa03abb fix cats and ocelots 2019-05-21 23:06:22 +02:00
Gerrygames 114dbedfb7 fix missing metadata index check 2019-05-21 22:28:28 +02:00
Gerrygames a9ee4ae88b Merge remote-tracking branch 'force/1.14' into 1.14 2019-05-21 22:16:06 +02:00
Gerrygames e4638688f5 fix mapping size 2019-05-21 22:15:56 +02:00
Marco 347da9c309 Merge remote-tracking branch 'origin/1.14' into 1.14 2019-05-21 22:07:50 +02:00
Marco 19d86058f9 add entity remaps 2019-05-21 22:07:43 +02:00
Gerrygames a7126b39dc fix horse armor 2019-05-21 22:05:36 +02:00
Gerrygames dd454d56f3 fix display name 2019-05-21 21:50:57 +02:00
Gerrygames 96b05bcd4f Use logger 2019-05-21 19:43:58 +02:00
Gerrygames 9aa98846d2 fix mappings 2019-05-21 19:16:56 +02:00
Gerrygames 8102506468 a few mappings for 1.14 2019-05-21 18:42:52 +02:00
Gerrygames 05e1fef42c remove pose metadata correctly, add debug 2019-05-21 17:40:26 +02:00
Gerrygames 1911bc55cd further work on 1.14 metadata 📃 2019-05-21 17:19:49 +02:00
Marco 0bb4539d57 first metadata rewriting 2019-05-21 16:33:23 +02:00
Marco Neuhaus 028350de3e fix arrows 2019-05-20 22:08:08 +02:00
Marco Neuhaus 4493f1c3a6 fix spawn object 2019-05-20 21:51:45 +02:00
Marco 2c66e21268 fix more problems 2019-05-19 20:47:05 +02:00
Marco 3706b72855 update 1.13.2 -> 1.14 Packet Ids 2019-05-19 19:15:50 +02:00
Marco cb396c8534 fix 1.14.1 2019-05-19 16:54:27 +02:00
Marco Neuhaus 53d753932f register protocol 2019-05-15 13:47:10 +02:00
Marco Neuhaus e4a54fbade add 1.14.1 support (not tested yet) 2019-05-15 13:44:59 +02:00
ForceUpdate1 13c157d2fc Merge pull request #5 from ViaVersion/1.14
1.14
2019-05-15 13:26:19 +02:00
ForceUpdate1 c9eee58a80 Merge pull request #4 from ViaVersion/dev
Dev
2019-05-15 13:24:07 +02:00
Myles 2584d2934d Merge branch 'master' into dev 2019-05-12 16:08:39 +01:00
Myles 271079370d Merge pull request #108 from creeper123123321/patch-1
Stop shading guava
2019-05-12 16:08:20 +01:00
creeper123123321 15324dd149 Stop shading guava 2019-05-12 11:35:28 -03:00
Myles 6072b9a74e Merge pull request #107 from Gerrygames/1.13
Fix map packet
2019-05-07 12:22:06 +01:00
Gerrygames 9441a1e49e fix map packet 2019-05-07 13:13:15 +02:00
Myles aaaa396f2c Merge pull request #106 from Gerrygames/fix_jukebox
Fix play record rewrites
2019-05-01 22:20:58 +01:00
Marco Neuhaus da67500eaa fix play record rewrites 2019-05-01 14:46:06 +02:00
Myles adc8c56862 Merge branch 'master' into dev 2019-04-23 15:50:05 +01:00
Myles cec91ee159 Fix compiling 2019-04-23 15:49:38 +01:00
Myles 4e36ac59b0 Merge branch 'master' into dev 2019-04-23 13:04:23 +01:00
Myles 608df43225 Use ViaVersion libraries 2019-04-23 13:04:03 +01:00
Myles cc68a6fa4c Merge branch 'master' into dev 2019-04-21 12:13:23 +01:00
Myles 6877304de1 Merge pull request #104 from creeper123123321/master
Set item to null when shift clicking
2019-04-20 23:24:02 +01:00
creeper123123321 bb2e089f27 Set item to null when shift clicking 2019-04-20 18:33:29 -03:00
Myles 2d0db67a29 Merge branch 'master' into dev 2019-04-19 16:29:57 +01:00
Myles 44d71ec538 Merge pull request #97 from creeper123123321/master
Workaround for #48
2019-04-19 11:40:49 +01:00
Myles 86c1a035f6 Merge pull request #102 from creeper123123321/dev
1.13: Fix sound underflow + tag name conflict + when rewriting of item nbt should occur
2019-04-11 15:39:16 +01:00
creeper123123321 77efe57015 fix tag name conflict 2019-03-30 16:33:02 -03:00
creeper123123321 6f20b874c5 fix possible array out of bounds 2019-03-30 15:08:31 -03:00
creeper123123321 1f3ed39eb6 fix toServer 2019-03-30 14:39:45 -03:00
Mats b6e1e7e35b Merge pull request #101 from creeper123123321/1.14
merge dev and add -19w11b suffix
2019-03-16 22:18:40 +01:00
creeper123123321 b8c87cfa2e Fix wrong position remappings 2019-03-16 17:29:23 -03:00
creeper123123321 ebb964dbd5 merge dev and add -19w11b suffix 2019-03-16 14:29:21 -03:00
Matsv 6c49c0b2d3 ✨ Fix paintings 2019-03-16 16:43:46 +01:00
Mats 0eff5ece5f Merge pull request #100 from creeper123123321/dev
[WIP] Snapshot support
2019-03-16 16:33:04 +01:00
Matsv 68aae77877 🐛 Fix recipe book crash 2019-03-16 16:15:49 +01:00
Matsv 6fb9f9adf3 🆘 Hacky way to fix flower pots 2019-03-16 16:03:32 +01:00
Matsv 0497ce198d 🔧 Start working on flower pot special treatment 2019-03-16 15:11:23 +01:00
creeper123123321 91acf71454 fix aoob exception 2019-03-16 09:41:24 -03:00
creeper123123321 1885840768 19w11b 2019-03-16 09:28:33 -03:00
creeper123123321 d99c5f5e60 metadata 2019-03-16 09:28:33 -03:00
creeper123123321 3252d48383 fix npe, remove living bed position 2019-03-16 09:28:32 -03:00
creeper123123321 8e2feeb375 fix 18 serializer error 2019-03-16 09:28:32 -03:00
creeper123123321 912a109c91 trying to rewrite entity data 2019-03-16 09:28:32 -03:00
creeper123123321 de4789822e stonecutting handling - todo opennbt long array 2019-03-16 09:28:32 -03:00
creeper123123321 b2b5ed2ae8 probably bugged 1.14 -> 1.13.2 protocol 2019-03-16 09:28:32 -03:00
Matsv 092057431c 🚀 Bump version for the development branch 2019-03-16 13:00:19 +01:00
Matsv 1130ba6e87 Merge branch 'master' of https://github.com/Matsv/ViaBackwards into dev 2019-03-16 12:04:21 +01:00
creeper123123321 a352822afa shorter workaround 2019-03-07 14:56:00 -03:00
creeper123123321 ce63e5ee62 Revert "Workaround for #48"
This reverts commit df53ce3e1c.
2019-03-07 14:49:54 -03:00
creeper123123321 df53ce3e1c Workaround for #48 2019-03-07 14:38:19 -03:00
Myles 414fdac20a Merge pull request #96 from Gerrygames/1.13_items
add missing wood rewrites
2019-02-19 19:32:51 +00:00
Marco Neuhaus d6c37db4eb add missing wood rewrites 2019-02-18 21:56:38 +01:00
Myles 0c94a85dcc Merge pull request #95 from creeper123123321/master
Do not register new incoming packets
2019-02-16 13:30:05 +00:00
creeper123123321 0fe233c7ed Do not register new incoming packets 2019-02-16 11:21:53 -02:00
Mats b1246b6ffc Merge pull request #94 from Gerrygames/1.13_items
add dummy enchantment for 1.13 enchatments
2019-02-16 10:02:26 +01:00
Mats 1c04ec7c55 Merge pull request #92 from creeper123123321/dev
Better tab-complete
2019-02-16 10:01:44 +01:00
Marco Neuhaus e35f264e89 Merge branch 'dev' of https://github.com/Matsv/ViaBackwards into 1.13_items
# Conflicts:
#	core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java
2019-02-16 00:07:36 +01:00
Marco Neuhaus 02bdaa5ddb Merge branch 'dev' of https://github.com/Gerrygames/ViaBackwards into 1.13_items 2019-02-16 00:03:58 +01:00
Marco Neuhaus cd230b601d add dummy enchantments for 1.13 enchatments 2019-02-16 00:00:05 +01:00
Myles 4574d9d9b8 Merge pull request #93 from Gerrygames/1.13_items
fix enchantments
2019-02-15 22:15:44 +00:00
Marco Neuhaus 934bd4d1db fix enchantments 2019-02-15 23:12:11 +01:00
creeper123123321 66336bca0f ooops 2019-02-15 18:30:48 -02:00
creeper123123321 829857be7c Use boolean + string 2019-02-15 18:24:42 -02:00
creeper123123321 6e5f9e0741 Better tab-complete 2019-02-15 18:03:06 -02:00
Mats 19d2c8fcb9 Merge pull request #91 from creeper123123321/dev
Login plugin request and response
2019-02-03 13:54:59 +01:00
creeper123123321 9e12a199cf Login plugin request and response 2019-02-02 17:19:30 -02:00
Mats c310290bbc Merge pull request #90 from Gerrygames/1.13
fix ConcurrentModificationException
2019-01-30 22:19:01 +01:00
Gerrygames ff68a5182a fix ConcurrentModificationException 2019-01-28 14:45:52 +01:00
Matsv 9b7a4b79f7 📎 Rename 1.13.2 classes 2019-01-27 14:25:27 +01:00
Matsv 58b8f4004b 📎 Rename 1.13.1 classes 2019-01-27 14:16:05 +01:00
Matsv 8477e20725 ♻ Rewrite Entity 1.13.1 the ViaBackwards way & remove incorrect metadata & 1.13 rewrite 2019-01-27 14:06:48 +01:00
Matsv 99ffbc1bfa 🔥 Merge branch 'master' of https://github.com/Matsv/ViaBackwards into dev
# Conflicts:
#	core/src/main/java/nl/matsv/viabackwards/api/ViaBackwardsPlatform.java
2019-01-27 13:06:09 +01:00
Matsv 29f1f3ea7c ✨ Reformat code 2019-01-27 13:01:24 +01:00
Mats ce93f48a55 Merge pull request #75 from creeper123123321/master
Velocity and maybe better version detector
2019-01-27 12:58:45 +01:00
Mats bf7ea31d35 Merge pull request #89 from Gerrygames/dev
remap trading gui 1.13.1 to 1.13
2019-01-27 12:58:08 +01:00
Mats 0965acafd7 Merge pull request #88 from Gerrygames/1.13_items
Add remap for 1.13 Items
2019-01-27 12:57:27 +01:00
Marco Neuhaus 2d53b812ea remove debug messages and fix enchantment rewrite 2019-01-27 12:40:58 +01:00
Gerrygames 316ae1020e remap trading gui 1.131 to 1.13 2019-01-26 19:25:24 +01:00
Marco Neuhaus b15c55fb28 fix rewrite and add pumpkin rewrite 2019-01-26 16:51:39 +01:00
Marco Neuhaus c0dbda5882 Merge branch 'dev' of https://github.com/Matsv/ViaBackwards into 1.13_items
# Conflicts:
#	core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java
2019-01-26 16:47:58 +01:00
creeper123123321 9ee8e6efa7 Velocity and maybe better version detector 2019-01-26 11:48:28 -02:00
Matsv f9e2a37816 Merge with masta 2019-01-26 12:29:55 +01:00
Matsv ec33f48674 Merge with masta 2019-01-26 12:23:18 +01:00
Marco Neuhaus 847a54493a add more rewirtes 2019-01-23 20:49:49 +01:00
Foorcee 0d0334a963 add more 2019-01-23 17:37:59 +01:00
Foorcee 16514526c1 add some more items rewrites 2019-01-23 17:28:53 +01:00
Marco Neuhaus ef5125e972 fix rewrite 2019-01-23 15:02:55 +01:00
Myles 5aaa352705 Merge pull request #86 from Gerrygames/master
fix package name
2019-01-23 13:39:50 +00:00
Myles 15db59f439 Merge pull request #84 from Gerrygames/removeUnusedColor
remove unused colors from team prefix/suffix
2019-01-23 13:39:20 +00:00
Gerrygames 8448b9628e replace tabs 2019-01-23 14:37:07 +01:00
Marco Neuhaus 55b4f6c080 fix rewrite 2019-01-23 13:31:05 +01:00
Marco Neuhaus 53b4151a26 start implementing item rewrite 2019-01-23 13:11:52 +01:00
Marco Neuhaus e6b438a9e0 Merge remote-tracking branch 'remotes/origin/removeUnusedColor' into 1.13_items 2019-01-23 12:26:38 +01:00
Gerrygames 2f1c54ca93 fix package name 2019-01-23 11:15:26 +01:00
Myles f05bbbc2a1 Merge pull request #83 from Gerrygames/1.13
fix tab complete
2019-01-22 22:54:29 +00:00
Gerrygames 42bfe19c9c block action block ids 2019-01-22 22:37:24 +01:00
Gerrygames 22a486752b remove sysout 2019-01-22 21:49:17 +01:00
Gerrygames 8519ad8cf1 fix actionbar color 2019-01-22 21:41:49 +01:00
Gerrygames 7b9cde9946 fix wrong protocol 2019-01-22 21:25:53 +01:00
Gerrygames c539cc6e57 fix NPE 2019-01-22 20:59:00 +01:00
Gerrygames 3fc55638f9 fix NPE 2019-01-22 20:33:39 +01:00
Gerrygames e5a110f24f fix mapping issue 2019-01-22 15:42:09 +01:00
Gerrygames ccf132ff50 remove unused colors from team prefix/suffix 2019-01-22 14:41:50 +01:00
Gerrygames 4f9334c1dd fix tab complete 2019-01-22 13:58:06 +01:00
Matsv 905cd9cf0d Merge branch 'master' of https://github.com/Matsv/ViaBackwards into dev 2019-01-21 22:23:43 +01:00
Matsv 085c9e13ad Fix typo 2019-01-21 22:23:25 +01:00
Mats 7c49689738 Merge pull request #81 from Gerrygames/1.13
fix teams packet, rewrite items in metadata
2019-01-21 22:18:12 +01:00
Gerrygames 3b2128acaa fix metadata index 2019-01-21 22:16:35 +01:00
Mats 233c1c80b4 Merge pull request #82 from Gerrygames/master
use BLOCK_CHANGE_RECORD_ARRAY
2019-01-21 22:15:59 +01:00
Gerrygames 34ed045ba6 arrow metadata fix 2019-01-21 21:35:40 +01:00
Gerrygames 0018159c89 fix tab complete 2019-01-21 21:12:48 +01:00
Gerrygames 97bd12fc33 use BLOCK_CHANGE_RECORD_ARRAY 2019-01-21 16:24:05 +01:00
Gerrygames 5a3b59ce29 fix boss bar packet 2019-01-21 16:05:46 +01:00
Gerrygames 88e83f9aad use ViaBackwards logger instead of ViaVersions 2019-01-21 14:37:48 +01:00
Gerrygames fadebbc17b rewrite items in metadata 2019-01-21 14:18:24 +01:00
Gerrygames e261ced701 fix teams packet 2019-01-21 14:04:29 +01:00
Matsv 03768d7124 Handle mob spawner changes 2019-01-20 20:23:40 +01:00
Matsv 520eb15ce9 Handle skull block entities 2019-01-20 17:19:26 +01:00
Matsv fd4c9b5e6c Implement banner block entity 2019-01-20 16:08:53 +01:00
Matsv 803ae8a7ac Implement flowerpot handling 2019-01-20 14:49:51 +01:00
Matsv 97b81cf782 Implement basic block entity interface & handle beds 2019-01-20 14:15:21 +01:00
Matsv 404dce4a32 Handle new wolf colors 2019-01-20 12:06:24 +01:00
Matsv be8c1b69dc Implement tab-complete 2019-01-19 18:54:26 +01:00
Matsv c9067354c0 Rewrite AreaEffectCloud (TODO Particle rewrite) 2019-01-19 16:11:15 +01:00
Matsv c829e857d2 Remove debug comments 2019-01-19 15:55:13 +01:00
Matsv 842631feef Rewrite metadata changes en add missing entity track 2019-01-19 15:53:31 +01:00
Matsv 87f217ca37 Rewrite entity types 2019-01-19 14:04:11 +01:00
Matsv 3cd91d87a4 Rewrite meta types 2019-01-19 12:50:33 +01:00
Matsv d1d94570e7 Handle metadata & entity type rewrite 2019-01-19 12:35:30 +01:00
Matsv bc0cb10406 Handle entity/dimension tracking correctly 2019-01-19 12:11:11 +01:00
Mats 6634cd1377 Merge pull request #79 from Gerrygames/1.13
Plugin messages/new packets
2019-01-19 11:52:56 +01:00
Gerrygames d6ca3891a1 lever mapping 2019-01-18 14:13:21 +01:00
Gerrygames 99af95e0a8 mapping for doors 2019-01-18 13:55:04 +01:00
Gerrygames fbbce29da7 fix some missing mappings 2019-01-18 13:33:14 +01:00
Gerrygames 688654adcc remove debug 2019-01-18 11:44:41 +01:00
Gerrygames 9ad0c34603 most of the easy block mappings 2019-01-18 11:42:29 +01:00
Gerrygames 8d7fee16b8 Plugin messages/new packets 2019-01-17 17:30:25 +01:00
Mats cc68ef758f Merge pull request #77 from Gerrygames/1.13
sound and entity id mappings
2019-01-16 14:43:53 +01:00
Gerrygames c950fe2125 sound and entity id mappings 2019-01-16 14:41:40 +01:00
Mats e0b48f5f49 Merge pull request #76 from Gerrygames/1.13
some more progress on 1.13
2019-01-16 13:12:53 +01:00
Gerrygames b9a2404f9c some more progress on 1.13 2019-01-16 12:47:30 +01:00
Gerrygames f0ef119440 Rewrite map colors added in 1.12 2018-12-05 13:33:42 +00:00
Myles 45cece245c Merge branch 'master' into dev 2018-12-05 13:27:35 +00:00
Myles 4bac50dec2 Merge pull request #66 from ForceUpdate1/master
Implement 1.13, 1.13.1 support for 1.13.2 servers
2018-12-04 15:23:31 +00:00
Myles 814ccf1b29 Merge pull request #70 from Gerrygames/master
ViaVersion 2.0.0 compatibility
2018-11-26 08:07:40 +00:00
Gerrygames 7296017ab8 ViaVersion 2.0.0 compatibility 2018-11-20 15:32:49 +01:00
Marco Neuhaus d0dec2539d fix books 2018-11-13 10:59:33 +01:00
Marco Neuhaus ae3142c2f5 remove fileheader 2018-11-12 23:52:56 +01:00
Marco Neuhaus a5599deb8e add Support 1.13.2 to 1.13.1
little particle fix for 1.13.1 to 1.13
2018-11-12 23:47:11 +01:00
ForceUpdate1 989439926c Merge pull request #2 from ForceUpdate1/master
1.13.1 support
2018-11-12 22:19:23 +01:00
ForceUpdate1 f636b67dca Merge branch 'dev' into master 2018-11-12 22:19:12 +01:00
ForceUpdate1 7db91a9a38 Merge pull request #1 from Matsv/dev
Dev
2018-11-12 22:17:08 +01:00
Matsv d484545bef Change keepAlive's initial value to fix Gerrygames/ViaRewind#14 2018-11-10 18:17:53 +00:00
Matsv ce7c525155 Basic block translation 2018-10-25 16:04:20 +02:00
Matsv 9d34038eab Rewrite changed packet ids 2018-10-25 14:01:03 +02:00
Matsv e91ed55963 Merge branch 'master' of https://github.com/Matsv/ViaBackwards into dev
# Conflicts:
#	all/pom.xml
#	bukkit/pom.xml
#	bungee/pom.xml
#	core/pom.xml
#	pom.xml
#	sponge/pom.xml
2018-10-25 10:32:27 +02:00
Marco Neuhaus f2e35a0c5a add comment 2018-08-28 19:47:01 +02:00
Marco Neuhaus 00ad68389c add mappings for bossbar
add mappings for tab complete
2018-08-28 18:49:13 +02:00
Marco Neuhaus bc19f1a57d add mappings for advancements
add mappings for tags
2018-08-28 18:13:56 +02:00
Marco Neuhaus 35cabf34b0 Add support for 1.13 at 1.13.1 server
TODO:
* add Tab complete
* add boss bar
* add Advancements
* add tags
2018-08-28 18:06:57 +02:00
Myles c7159721cb Remove protocols for now
So it gives outdated version message instead of errors...
2018-08-21 16:44:44 +01:00
Myles f8a6e9723a Merge pull request #65 from Gerrygames/dev
Rewrite map colors added in 1.12
2018-08-16 14:41:38 +01:00
Gerrygames 69c68bf300 Rewrite map colors added in 1.12 2018-08-16 15:15:44 +02:00
Matsv 4919b8748a Preparations for 1.13 support development 2018-07-22 23:15:59 +02:00
Myles 43ad787bda Merge pull request #50 from Matsv/master
Merge master into dev
2018-07-10 12:19:49 +01:00
creeper123123321 f9ad3b59f1 Fix #25 (#38)
* Fix #25

* Update PlayerPackets1_11.java
2018-03-19 22:45:43 +01:00
Matsv 2a756616f4 Change keepAlive's initial value to fix Gerrygames/ViaRewind#14 2018-02-05 20:51:34 +01:00
Myles 7fbd546d43 Ensure ViaBackwards init is after ViaVersion on sponge 2017-10-12 12:16:38 +01:00
Myles 903c1999eb Don't use casting for validation of keep alive, use hashCodes.
Also disregard valid ones sent twice.
2017-09-30 21:08:05 +01:00
Myles d36a076942 2.3.1 - Disregard any incorrect keep-alives, credits to @Shevchik 2017-09-20 14:16:22 +01:00
Myles 30f339400e 2.3.0 - 1.12.2 Support 2017-09-19 00:25:33 +01:00
CDAGaming af190b0422 Update Dependencies (#24)
* Update Dependencies

* Undo Guava Dependency Changes
2017-08-23 02:05:50 +02:00
Matsv f7824e1df5 Bump version 2017-08-04 14:03:35 +02:00
Matsv 2168145d58 Prevent crash for now 2017-08-03 15:44:34 +02:00
Matsv ebb1323129 Prepare for 1.12.1 2017-08-02 14:08:37 +02:00
Matsv 34ca6324c5 Possibility to suppress type not found errors 2017-07-30 12:23:00 +02:00
Matsv 908931e174 Make metadata item rewrite check the Type instead of the MetaType fixes #17 2017-07-30 12:17:20 +02:00
Matsv 1f15c9e8f1 Back to snapshot 2017-07-30 12:14:59 +02:00
Matsv 9a0686685c Bump version 2017-07-29 14:11:43 +02:00
Matsv ccc63966c6 Change shulkerbox data fixes #15 2017-07-29 14:05:10 +02:00
Matsv 18d8ab068d Remove debug message 2017-07-29 13:32:03 +02:00
Matsv 227396d08a Format replacement items differently 2017-07-29 13:24:17 +02:00
Matsv dbc92572fd Fix NPE for unknown beds & keep original NBT data 2017-07-29 13:19:59 +02:00
Matsv ea2f603cf7 Possibility to hide warning using suppressMetadataErrors fixes #14 2017-07-04 21:12:09 +02:00
Matsv a5aa9e7281 Handle nulls in EntityRewriter (#11) 2017-06-21 19:30:48 +02:00
Matsv 0e5ee7063f Back to snapshot 2017-06-14 17:57:12 +02:00
Matsv d95630c4d0 Bump version 2017-06-14 17:31:32 +02:00
Matsv 451202335d Add supported versions to README 2017-06-14 16:27:42 +02:00
Matsv 36be58f775 Change sout to logger 2017-06-14 15:41:36 +02:00
Matsv a23204a86c Use a hanging bat for sitting parrot 2017-06-14 15:16:52 +02:00
Matsv 4928dab3f0 Fix achievement popup "Open Inventory" visible forever 2017-06-14 14:59:48 +02:00
Matsv b6bf2cd950 Handle observer facing position 2017-06-13 21:06:07 +02:00
Matsv 469936308c Implement shoulder indication 2017-06-13 20:48:02 +02:00
Matsv d330b64bba Modify pitch instead of changing volume (-: 2017-06-13 19:34:30 +02:00
Matsv 258ca46428 Remap 1_12 sounds 2017-06-13 19:30:36 +02:00
Matsv e4998e267e Remove some todos 2017-06-13 17:10:56 +02:00
Matsv adc84452d5 Fix invisible illusionator 2017-06-13 16:56:47 +02:00
Matsv ce89d1c724 Store Parrot tamed data 2017-06-13 16:32:43 +02:00
Matsv 354660a374 Change ShulkerBoxes to EnderChests to fix breaking/picking it up 2017-06-13 15:38:16 +02:00
Matsv a47e845847 Fix Llama inventory offset, replacement sounds for 1.11 & fix NPE 2017-06-13 15:33:43 +02:00
Matsv da84e30936 Rename some classes 2017-06-13 13:59:48 +02:00
Matsv 0f52fdf3b6 Let the knowledge book glow (: 2017-06-13 13:55:48 +02:00
Matsv dfe8c90da4 Patch signs not empty in 1.9-1.9.2 2017-06-13 13:40:28 +02:00
Matsv 9ed4a15b32 Implement a color variable for item names 2017-06-12 21:50:21 +02:00
Matsv 961991a316 Fix null translate chat message fields 2017-06-12 21:28:26 +02:00
Matsv e9878f68b9 Basic advancements handling 2017-06-12 21:06:30 +02:00
Matsv 95532bcdd5 Show entity names when replaced 2017-06-12 19:18:44 +02:00
Matsv a8e81935cc Handle FallingBlocks in 1.9.4-1.11.2 2017-06-10 16:34:08 +02:00
Matsv 2a1f6602ba Fix the Item Rewriter, implement 1.12 block rewrites & handle fallingblocks 2017-06-10 16:15:37 +02:00
Matsv d113e11c3b Metadata change voor illagers (Should be changed @ wiki.vg) 2017-06-08 19:35:26 +02:00
Matsv 5a4dd8bb6a ILLUSION_ILLAGER -> EVOCATION_ILLAGER (Better suggestions are welcome, bow will be invisible with the current entity.) 2017-06-08 18:43:23 +02:00
Matsv 85286095d7 Parrot -> Bat 2017-06-08 18:29:38 +02:00
Matsv 34d9ccbd5b Let PAaaS generate the sound changes 2017-06-08 17:27:58 +02:00
Matsv d98a511757 Bump viaversion & handle metadata changes 2017-06-08 17:07:55 +02:00
Matsv cb93950785 Map Packet ID changes for 1.12 2017-06-08 16:29:01 +02:00
Matsv ddf5324a82 Rename disabled llama slots & bump viaversion 2017-06-08 15:39:10 +02:00
Matsv 67d3eef37a Handle new Llama inventory 2017-06-08 15:31:34 +02:00
Matsv 7fda9dba0d Woops, forgot the new Shulker Shell item 2017-06-03 12:39:35 +02:00
Matsv da2e802e29 Handle chested horse metadata correctly 2017-06-03 12:22:47 +02:00
Matsv 347d449f51 Fix invisible shulkerboxes 2017-06-03 12:05:37 +02:00
Matsv 41d1ceb7cd Play Guardian animation when Totem of Undying is used. 2017-06-03 11:54:05 +02:00
Matsv 2060a698bd Fix Spawn eggs 2017-06-03 11:47:08 +02:00
Matsv ff73405d92 Rewrite Entity Type for spawners 2017-06-01 20:26:10 +02:00
Matsv 878230ebb1 Cleanup BlockItemRewriter & EntityRewriter 2017-06-01 19:09:48 +02:00
Matsv f33c694dd3 Cancel Shulker Decleration @ Update Block Entity & rewrite some sounds 2017-06-01 15:03:27 +02:00
Matsv 5ef109c037 Rewrite SoundRewriter and generate placeholders for 1.11 2017-05-31 21:02:34 +02:00
Matsv 373f519464 Cleanup 2017-05-31 14:09:50 +02:00
Matsv 51c502486e Continue 1.11 update. 2017-05-31 00:03:42 +02:00
Matsv 168803ae8a Update ViaVersion 2016-12-26 13:36:07 +01:00
Matsv a22ab7f625 Update ViaVersion 2016-12-26 13:34:55 +01:00
Matsv 4e5a12a514 Remove the instanceof check since it's no longer required. 2016-11-19 15:57:08 +01:00
Matsv 6cf94fce66 Change the way how EntityTrackers work to work correctly with multiple versions (WIP) 2016-11-19 15:51:38 +01:00
Matsv 0549cb5c3a Merge branches 'dev' and 'master' of https://github.com/Matsv/ViaBackwards into dev 2016-11-19 12:01:57 +01:00
Matsv 58810243dc Start working on the 1.11 update (Far from stable) 2016-11-19 12:01:22 +01:00
Matsv 04508e8c5c Back to snapshot 2016-11-19 10:57:55 +01:00
Mats 2e82e5e6c2 Merge pull request #8 from Matsv/dev
Multi platform
2016-11-14 18:03:32 +01:00
Matsv 4630b08fee Bump version for Spigot release 2016-11-14 18:01:01 +01:00
Matsv 73e739310e Bump version 2016-11-13 14:08:56 +01:00
Matsv 5711d9edb1 Merge branch 'dev' of https://github.com/Matsv/ViaBackwards into dev 2016-10-15 17:12:32 +02:00
Matsv 5f316f242e Rename Protocol1_9To1_10 to ...1_9_4... 2016-10-15 17:12:01 +02:00
Mats 30c3e8eec1 Merge pull request #7 from Maxqia/dev 2016-10-04 00:43:23 +02:00
Max Qian 2e536fc57c *Facepalm* 2016-10-03 15:41:31 -07:00
Matsv aada25b865 Remove debug message 2016-10-03 15:42:26 +02:00
Matsv 89e43cc1dc Hi MIT :) 2016-10-03 15:40:19 +02:00
Matsv debce2e8f7 Sync with master 2016-10-03 15:28:25 +02:00
Matsv a21bd3acec Basic support for multiplatform ViaBackwards (Bungee doesn't seem to work correctly yet) 2016-10-03 15:20:38 +02:00
Mats a586c2c50a Update ISSUE_TEMPLATE.md 2016-09-29 16:30:02 +02:00
Mats fc66620615 Cleanup README.md 2016-09-28 20:28:03 +02:00
Mats afe15e1f7a Merge pull request #5 from nick-2017/patch-2 2016-09-20 23:11:39 +02:00
Nick 953aead1e7 Update plugin.yml 2016-09-20 22:09:25 +01:00
Matsv b8713db19c Bump version to devbuild 2016-09-17 11:36:25 +02:00
Matsv fc993809d6 Patch for LibsDisguises, they are sending too big chunks. :'( Fix #3 2016-09-17 11:32:35 +02:00
Matsv 7418492ef1 Update the ISSUE_TEMPLATE to use /viaversion dump 2016-08-26 16:37:22 +02:00
Matsv 305cc5514a Bump version 2016-08-08 20:38:57 +02:00
Matsv 00ae7b09da Remove wrong metadata from the list, and warn people about it when ViaVersion debug is enabled. 2016-08-08 20:22:44 +02:00
Matsv ceacce741a Change the formatting and check if ClientWorld is already in the map 2016-08-08 18:02:18 +02:00
Matsv e26c34daf5 Fix some warnings 2016-08-06 12:43:46 +02:00
Matsv 782b29baed Change ISSUE_TEMPLATE.md text size 2016-08-05 18:54:26 +02:00
Matsv 4e04aac322 Back to snapshot 2016-08-05 18:39:43 +02:00
299 changed files with 34129 additions and 2174 deletions

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
[*]
charset = utf-8
indent_size = 4
indent_style = space
insert_final_newline = false
tab_width = 4
[*.java]
ij_java_class_count_to_use_import_on_demand = 999999
ij_java_names_count_to_use_import_on_demand = 999999
ij_java_imports_layout = *, |, $*
ij_java_generate_final_locals = true
ij_java_generate_final_parameters = true
[{*.json,*.yml}]
indent_size = 2
+2
View File
@@ -0,0 +1,2 @@
github: kennytv
patreon: kennytv
-17
View File
@@ -1,17 +0,0 @@
##### What version of ViaBackwards are you using? Type /ver ViaBackwards:
##### What version of ViaVersion are you using? Type /ver ViaVersion:
##### What version of Spigot are you using? Type /ver:
##### What plugins are you using? Type /plugins:
##### How/when does this error happen? login?:
##### Is there an error in the console? Use pastebin.com. Is there a kick message?:
+96
View File
@@ -0,0 +1,96 @@
name: Bug Report
description: Report a bug or console error
labels: [unconfirmed]
body:
- type: markdown
attributes:
value: "**Before reporting a bug, please see if using master/dev builds from https://ci.viaversion.com/ fixes your issue.**"
- type: input
attributes:
label: "'/viaversion dump' Output"
description: |
Run `/viaversion dump` in the console or in the chat, then copy and paste the given link here.
placeholder: |
https://dump.viaversion.com/...
validations:
required: true
- type: textarea
attributes:
label: Console Error
description: |
If you encounter warnings/errors in your console, **paste them with https://mclo.gs/ and put the paste link here**.
If the error is small/less than 10 lines, you may put it directly into this field.
value: |
```
Put the mclo.gs link or text here.
```
placeholder: Please do not remove the grave accents; simply replace the line of text in the middle.
validations:
required: false
- type: textarea
attributes:
label: Bug Description
description: |
Describe the unexpected behavior.
If you want to attach screenshots, use the comment field at the bottom of the page.
placeholder: |
Example: "Placing signs on 1.13.2 causes text to disappear."
validations:
required: true
- type: textarea
attributes:
label: Steps to Reproduce
description: |
List the steps on how we can reproduce the issue. Make sure we can easily understand what you mean with each step.
placeholder: |
Example:
1. Login with a 1.13.2 client
2. Place a sign
3. The sign text is displayed wrong
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: |
Describe what exactly you expected to happen.
placeholder: |
Example: "Placed sign text should not disappear."
validations:
required: true
- type: textarea
attributes:
label: Additional Server Info
description: |
Do you use a proxy (eg. Velocity)? What software do you use and what plugins?
placeholder: |
Example: "I also use Velocity with the following plugins: x, y, z"
validations:
required: false
- type: checkboxes
attributes:
label: Checklist
description: Make sure you have followed each of the steps outlined here.
options:
- label: Via plugins are only running on **EITHER** the backend servers (e.g. Paper) **OR** the proxy (e.g. Velocity), **not on both**.
required: true
- label: I have included a ViaVersion dump.
required: true
- label: If applicable, I have included a paste (**not a screenshot**) of the error.
required: true
- label: I have tried a build from https://ci.viaversion.com/ and the issue still persists.
required: true
- type: markdown
attributes:
value: |
## Comments And Screenshots
If needed, add **screenshots to help explain your problem** in the comment field below.
+8
View File
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Dev builds
url: https://ci.viaversion.com/
about: Before reporting a bug, please check if using master/dev builds from our ci fixes your issue.
- name: ViaVersion Discord
url: https://discord.gg/viaversion
about: For smaller issues or questions, you can also join our Discord server.
@@ -0,0 +1,38 @@
name: Feature Request
description: Suggest a feature to be added
labels: [Feature Request]
body:
- type: textarea
attributes:
label: Problem Description
description: |
Describe the issue you are facing or why you need the feature to be added.
placeholder: |
I am always frustrated with...
validations:
required: true
- type: textarea
attributes:
label: Solution Description
description: |
Describe the solution you would like to see.
validations:
required: true
- type: textarea
attributes:
label: Alternatives
description: |
Describe alternatives you have considered.
validations:
required: false
- type: textarea
attributes:
label: Additional Info
description: |
Does the feature apply to any specific version or environment?
validations:
required: false
+23
View File
@@ -0,0 +1,23 @@
name: Java CI with Gradle
on: [push, pull_request]
jobs:
build:
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
check-latest: true
- name: Build with Gradle
run: ./gradlew build
+27
View File
@@ -0,0 +1,27 @@
name: Publish to Hangar and Modrinth
on:
push:
branches:
- master
- dev
jobs:
publish:
if: github.repository_owner == 'ViaVersion'
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2
- name: Set up JDK 17
uses: actions/setup-java@v4
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
+82 -103
View File
@@ -1,105 +1,35 @@
# Created by .ignore support plugin (hsz.mobi)
### Maven template
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
### NetBeans template
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
.nb-gradle/
### Eclipse template
### Java files ###
*.class
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# Package Files
#*.jar
*.war
*.ear
# Eclipse Core
.project
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
# Ignore project files
*.iml
# CDT-specific (C/C++ Development Tooling)
.cproject
# Ignore IDEA directory
.idea/*
!.idea/copyright/*
!.idea/scopes/*
# JDT-specific (Eclipse Java Development Tools)
.classpath
# Include the project's dictionary
!.idea/dictionaries/
!.idea/dictionaries/*
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml
# Sensitive or high-churn files:
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml
# Gradle:
.idea/gradle.xml
.idea/libraries
# Mongo Explorer plugin:
.idea/mongoSettings.xml
## File-based project format:
# File-based project format:
*.ipr
*.iws
## Plugin-specific files:
### Plugin-specific files: ###
# IntelliJ
/out/
@@ -113,18 +43,67 @@ atlassian-ide-plugin.xml
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Java template
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Eclipse ###
*.pydevproject
.metadata
.gradle
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
# Eclipse Core
.project
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# JDT-specific (Eclipse Java Development Tools)
.classpath
# PDT-specific
.buildpath
# sbteclipse plugin
.target
# TeXlipse plugin
.texlipse
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
.nb-gradle/
+10
View File
@@ -0,0 +1,10 @@
<component name="CopyrightManager">
<settings>
<module2copyright>
<element module="ViaBackwards" copyright="viabackwards-gpl" />
</module2copyright>
<LanguageOptions name="__TEMPLATE__">
<option name="addBlankAfter" value="false" />
</LanguageOptions>
</settings>
</component>
+6
View File
@@ -0,0 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards&#10;Copyright (C) 2016-&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="viabackwards-gpl" />
</copyright>
</component>
+3
View File
@@ -0,0 +1,3 @@
<component name="DependencyValidationManager">
<scope name="ViaBackwards" pattern="com.viaversion.viabackwards..*" />
</component>
+7 -7
View File
@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -645,14 +645,14 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname}
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
@@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+62 -10
View File
@@ -1,13 +1,65 @@
# ViaBackwards
Allows 1.9.x on a 1.10 Spigot server.
Requires [ViaVersion](http://viaversion.com) to be installed
[![Latest Release](https://img.shields.io/github/v/release/ViaVersion/ViaBackwards)](https://github.com/ViaVersion/ViaBackwards/releases)
[![Build Status](https://github.com/ViaVersion/ViaBackwards/actions/workflows/gradle.yml/badge.svg?branch=master)](https://github.com/ViaVersion/ViaBackwards/actions)
[![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://viaversion.com/discord)
TODO:
- [ ] Cleanup code
- [ ] Improve the rewriters
- [ ] Make it possible to send metadata with the rewriteEntityId
- [ ] Add support for sound names
- [ ] Create JavaDocs
- [ ] Improve the Entity tracker system to work good with multiple versions.
- [ ] Make it possible to choose your own replacement blocks
**Allows older Minecraft client versions to connect to newer server versions.**
Requires [ViaVersion](https://hangar.papermc.io/ViaVersion/ViaVersion) to be installed..
Supported Versions
-
As a plugin, ViaBackwards runs on servers on releases 1.10-latest. Versions from the dev branch will also support the
latest snapshot. You can also use ViaBackwards in ViaFabric or ViaFabricPlus.
See [HERE](https://github.com/ViaVersion) for an overview of the different Via* projects.
Releases/Dev Builds
-
You can find releases in the following places:
- **Hangar (for our plugins)**: https://hangar.papermc.io/ViaVersion/ViaBackwards
- **Modrinth (for our mods)**: https://modrinth.com/mod/viabackwards
- **GitHub**: https://github.com/ViaVersion/ViaBackwards/releases
Dev builds for **all** of our projects are on our Jenkins server:
- **Jenkins**: https://ci.viaversion.com/view/ViaBackwards/
Known issues
-
* 1.17+ min_y and height world values that are not 0/256 **are not supported**. Clients older than
1.17 will not be able to see or interact with blocks below y=0 and above y=255
* <1.17 clients on 1.17+ servers might experience inventory desyncs on certain inventory click actions
* Sound mappings are incomplete ([see here](https://github.com/ViaVersion/ViaBackwards/issues/326))
* <1.19.4 clients on 1.20+ servers won't be able to use the smithing table, this can be fixed by
installing [AxSmithing](https://github.com/ViaVersionAddons/AxSmithing)
Other Links
-
**Maven:** https://repo.viaversion.com
**List of contributors:** https://github.com/ViaVersion/ViaBackwards/graphs/contributors
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.
You need JDK 17 or newer to build ViaBackwards.
License
-
This project is licensed under the [GNU General Public License Version 3](LICENSE).
Special Thanks
-
![https://www.yourkit.com/](https://www.yourkit.com/images/yklogo.png)
[YourKit](https://www.yourkit.com/) supports open source projects with innovative and intelligent tools
for monitoring and profiling Java and .NET applications.
YourKit is the creator of [YourKit Java Profiler](https://www.yourkit.com/java/profiler/),
[YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/),
and [YourKit YouMonitor](https://www.yourkit.com/youmonitor/).
+12
View File
@@ -0,0 +1,12 @@
plugins {
`kotlin-dsl`
}
repositories {
gradlePluginPortal()
}
dependencies {
// version must be manually kept in sync with the one in root project settings.gradle.kts
implementation("com.github.johnrengelman", "shadow", "8.1.1")
}
+45
View File
@@ -0,0 +1,45 @@
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import java.io.ByteArrayOutputStream
fun Project.latestCommitHash(): String {
val byteOut = ByteArrayOutputStream()
exec {
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
standardOutput = byteOut
}
return byteOut.toString(Charsets.UTF_8.name()).trim()
}
fun Project.latestCommitMessage(): String {
val byteOut = ByteArrayOutputStream()
exec {
commandLine = listOf("git", "log", "-1", "--pretty=%B")
standardOutput = byteOut
}
return byteOut.toString(Charsets.UTF_8.name()).trim()
}
fun Project.branchName(): String {
val byteOut = ByteArrayOutputStream()
exec {
commandLine = listOf("git", "rev-parse", "--abbrev-ref", "HEAD")
standardOutput = byteOut
}
return byteOut.toString(Charsets.UTF_8.name()).trim()
}
fun Project.parseMinecraftSnapshotVersion(version: String): String? {
val separatorIndex = version.indexOf('-')
val lastSeparatorIndex = version.lastIndexOf('-')
if (separatorIndex == -1 || separatorIndex == lastSeparatorIndex) {
return null
}
return version.substring(separatorIndex + 1, lastSeparatorIndex)
}
fun JavaPluginExtension.javaTarget(version: Int) {
sourceCompatibility = JavaVersion.toVersion(version)
targetCompatibility = JavaVersion.toVersion(version)
}
@@ -0,0 +1,25 @@
plugins {
`java-library`
}
tasks {
// Variable replacements
processResources {
filesMatching(listOf("plugin.yml", "fabric.mod.json")) {
expand("version" to project.version, "description" to project.description, "url" to "https://viaversion.com/backwards")
}
}
javadoc {
options.encoding = Charsets.UTF_8.name()
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
}
compileJava {
options.encoding = Charsets.UTF_8.name()
options.compilerArgs.addAll(listOf("-nowarn", "-Xlint:-unchecked", "-Xlint:-deprecation"))
}
}
java {
javaTarget(17)
withSourcesJar()
}
Whitespace-only changes.
@@ -0,0 +1,47 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.named
plugins {
id("vb.base-conventions")
id("maven-publish")
id("com.github.johnrengelman.shadow")
}
tasks {
named<Jar>("jar") {
archiveClassifier.set("unshaded")
from(project.rootProject.file("LICENSE"))
}
val shadowJar = named<ShadowJar>("shadowJar") {
archiveClassifier.set("")
configureRelocations()
}
named("build") {
dependsOn(shadowJar)
}
}
publishing {
publications.create<MavenPublication>("mavenJava") {
groupId = rootProject.group as String
artifactId = project.name
version = rootProject.version as String
artifact(tasks["shadowJar"])
artifact(tasks["sourcesJar"])
}
repositories.maven {
name = "Via"
url = uri("https://repo.viaversion.com/")
credentials(PasswordCredentials::class)
authentication {
create<BasicAuthentication>("basic")
}
}
}
fun ShadowJar.configureRelocations() {
relocate("com.google.gson", "com.viaversion.viaversion.libs.gson")
relocate("it.unimi.dsi.fastutil", "com.viaversion.viaversion.libs.fastutil")
}
+25
View File
@@ -0,0 +1,25 @@
plugins {
base
id("vb.build-logic")
}
allprojects {
group = "com.viaversion"
version = property("projectVersion") as String // from gradle.properties
description = "Allows older Minecraft client versions to connect to newer server versions."
}
val main = setOf(
projects.viabackwards,
projects.viabackwardsCommon,
projects.viabackwardsBukkit,
projects.viabackwardsVelocity,
projects.viabackwardsFabric
).map { it.dependencyProject }
subprojects {
when (this) {
in main -> plugins.apply("vb.shadow-conventions")
else -> plugins.apply("vb.base-conventions")
}
}
+7
View File
@@ -0,0 +1,7 @@
dependencies {
compileOnlyApi(projects.viabackwardsCommon)
compileOnly(libs.paper) {
exclude("com.google.code.gson", "gson")
exclude("javax.persistence", "persistence-api")
}
}
@@ -0,0 +1,79 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards;
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
import com.viaversion.viabackwards.listener.BlockBreakListener;
import com.viaversion.viabackwards.listener.FireDamageListener;
import com.viaversion.viabackwards.listener.FireExtinguishListener;
import com.viaversion.viabackwards.listener.LecternInteractListener;
import com.viaversion.viabackwards.listener.PlayerItemDropListener;
import com.viaversion.viabackwards.protocol.v1_20_2to1_20.provider.AdvancementCriteriaProvider;
import com.viaversion.viabackwards.provider.BukkitAdvancementCriteriaProvider;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import java.io.File;
import org.bukkit.plugin.java.JavaPlugin;
public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
public BukkitPlugin() {
Via.getManager().addEnableListener(() -> init(new File(getDataFolder(), "config.yml")));
}
@Override
public void onEnable() {
if (Via.getManager().getInjector().lateProtocolVersionSetting()) {
// Enable in the next tick
Via.getPlatform().runSync(this::enable, 1);
} else {
enable();
}
}
private void enable() {
final ProtocolVersion protocolVersion = Via.getAPI().getServerVersion().highestSupportedProtocolVersion();
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_17)) {
new PlayerItemDropListener(this).register();
}
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_16)) {
new FireExtinguishListener(this).register();
}
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_14)) {
new LecternInteractListener(this).register();
}
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_12)) {
new FireDamageListener(this).register();
}
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_11)) {
new BlockBreakListener(this).register();
}
final ViaProviders providers = Via.getManager().getProviders();
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_2)) {
providers.use(AdvancementCriteriaProvider.class, new BukkitAdvancementCriteriaProvider());
}
}
@Override
public void disable() {
getPluginLoader().disablePlugin(this);
}
}
@@ -0,0 +1,54 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.listener;
import com.viaversion.viabackwards.BukkitPlugin;
import com.viaversion.viabackwards.protocol.v1_11to1_10.Protocol1_11To1_10;
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
public class BlockBreakListener extends ViaBukkitListener {
public BlockBreakListener(final BukkitPlugin plugin) {
super(plugin, Protocol1_11To1_10.class);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(final BlockBreakEvent event) {
if (!event.isCancelled()) {
return;
}
final Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE || !isOnPipe(player)) {
return;
}
// Resend the item in the hand to sync durability
final int slot = player.getInventory().getHeldItemSlot();
final ItemStack item = player.getInventory().getItem(slot);
if (item != null && item.getType().getMaxDurability() > 0) {
player.getInventory().setItem(slot, item);
}
}
}
@@ -0,0 +1,54 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.listener;
import com.viaversion.viabackwards.BukkitPlugin;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
public class FireDamageListener extends ViaBukkitListener {
public FireDamageListener(BukkitPlugin plugin) {
super(plugin, Protocol1_12To1_11_1.class);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFireDamage(EntityDamageEvent event) {
if (event.getEntityType() != EntityType.PLAYER) return;
EntityDamageEvent.DamageCause cause = event.getCause();
if (cause != EntityDamageEvent.DamageCause.FIRE
&& cause != EntityDamageEvent.DamageCause.FIRE_TICK
&& cause != EntityDamageEvent.DamageCause.LAVA
&& cause != EntityDamageEvent.DamageCause.DROWNING) {
return;
}
Player player = (Player) event.getEntity();
if (isOnPipe(player)) {
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_HURT, SoundCategory.PLAYERS, 1, 1);
}
}
}
@@ -0,0 +1,53 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.listener;
import com.viaversion.viabackwards.BukkitPlugin;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.Protocol1_16To1_15_2;
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
public class FireExtinguishListener extends ViaBukkitListener {
public FireExtinguishListener(BukkitPlugin plugin) {
super(plugin, Protocol1_16To1_15_2.class);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFireExtinguish(PlayerInteractEvent event) {
if (event.getAction() != Action.LEFT_CLICK_BLOCK) return;
Block block = event.getClickedBlock();
if (block == null) return;
Player player = event.getPlayer();
if (!isOnPipe(player)) return;
Block relative = block.getRelative(event.getBlockFace());
if (relative.getType() == Material.FIRE) {
event.setCancelled(true);
relative.setType(Material.AIR);
}
}
}
@@ -0,0 +1,65 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.listener;
import com.viaversion.viabackwards.BukkitPlugin;
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.Protocol1_14To1_13_2;
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Lectern;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
public class LecternInteractListener extends ViaBukkitListener {
public LecternInteractListener(BukkitPlugin plugin) {
super(plugin, Protocol1_14To1_13_2.class);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onLecternInteract(PlayerInteractEvent event) {
Block block = event.getClickedBlock();
if (block == null || block.getType() != Material.LECTERN) return;
Player player = event.getPlayer();
if (!isOnPipe(player)) return;
Lectern lectern = (Lectern) block.getState();
ItemStack book = lectern.getInventory().getItem(0);
if (book == null) return;
BookMeta meta = (BookMeta) book.getItemMeta();
// Open a book with the text of the lectern's writable book
ItemStack newBook = new ItemStack(Material.WRITTEN_BOOK);
BookMeta newBookMeta = (BookMeta) newBook.getItemMeta();
//noinspection deprecation
newBookMeta.setPages(meta.getPages());
newBookMeta.setAuthor("an upsidedown person");
newBookMeta.setTitle("buk");
newBook.setItemMeta(newBookMeta);
player.openBook(newBook);
event.setCancelled(true);
}
}
@@ -0,0 +1,48 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.listener;
import com.viaversion.viabackwards.BukkitPlugin;
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13;
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.ItemStack;
public class PlayerItemDropListener extends ViaBukkitListener {
public PlayerItemDropListener(final BukkitPlugin plugin) {
super(plugin, Protocol1_13_1To1_13.class); // Starts with 1.13 clients on 1.17 servers
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onItemDrop(final PlayerDropItemEvent event) {
final Player player = event.getPlayer();
if (!isOnPipe(player)) {
return;
}
// Resend the item in the hand
final int slot = player.getInventory().getHeldItemSlot();
final ItemStack item = player.getInventory().getItem(slot);
player.getInventory().setItem(slot, item);
}
}
@@ -0,0 +1,34 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.provider;
import com.viaversion.viabackwards.protocol.v1_20_2to1_20.provider.AdvancementCriteriaProvider;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.advancement.Advancement;
public final class BukkitAdvancementCriteriaProvider extends AdvancementCriteriaProvider {
private static final String[] EMPTY_CRITERIA = new String[0];
@Override
public String[] getCriteria(final String key) {
final Advancement advancement = Bukkit.getAdvancement(NamespacedKey.fromString(key));
return advancement == null ? EMPTY_CRITERIA : advancement.getCriteria().toArray(EMPTY_CRITERIA);
}
}
+11
View File
@@ -0,0 +1,11 @@
name: ViaBackwards
version: ${version}
description: ${description}
main: com.viaversion.viabackwards.BukkitPlugin
api-version: 1.13
folia-supported: true
authors: [Matsv, kennytv, Gerrygames, creeper123123321, ForceUpdate1, EnZaXD]
website: ${url}
depend: [ViaVersion]
+26
View File
@@ -0,0 +1,26 @@
plugins {
id("net.kyori.blossom")
id("org.jetbrains.gradle.plugin.idea-ext")
}
sourceSets {
main {
blossom {
javaSources {
property("version", project.version.toString())
property("impl_version", "git-ViaBackwards-${project.version}:${rootProject.latestCommitHash()}")
}
}
}
}
dependencies {
compileOnlyApi(libs.viaver)
compileOnlyApi(libs.netty)
compileOnlyApi(libs.guava)
compileOnlyApi(libs.checkerQual)
}
java {
withJavadocJar()
}
@@ -0,0 +1,32 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.utils;
public final class VersionInfo {
public static final String VERSION = "{{ version }}";
private static final String IMPLEMENTATION_VERSION = "{{ impl_version }}";
public static String getVersion() {
return VERSION;
}
public static String getImplementationVersion() {
return IMPLEMENTATION_VERSION;
}
}
@@ -0,0 +1,44 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards;
import com.google.common.base.Preconditions;
import com.viaversion.viabackwards.api.ViaBackwardsConfig;
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
public final class ViaBackwards {
private static ViaBackwardsPlatform platform;
private static ViaBackwardsConfig config;
public static void init(ViaBackwardsPlatform platform, ViaBackwardsConfig config) {
Preconditions.checkArgument(ViaBackwards.platform == null, "ViaBackwards is already initialized");
ViaBackwards.platform = platform;
ViaBackwards.config = config;
}
public static ViaBackwardsPlatform getPlatform() {
return platform;
}
public static ViaBackwardsConfig getConfig() {
return config;
}
}
@@ -0,0 +1,112 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards;
import com.viaversion.viaversion.util.Config;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
public class ViaBackwardsConfig extends Config implements com.viaversion.viabackwards.api.ViaBackwardsConfig {
private boolean addCustomEnchantsToLore;
private boolean addTeamColorToPrefix;
private boolean fix1_13FacePlayer;
private boolean alwaysShowOriginalMobName;
private boolean fix1_13FormattedInventoryTitles;
private boolean handlePingsAsInvAcknowledgements;
private boolean suppressEmulationWarnings;
public ViaBackwardsConfig(File configFile, Logger logger) {
super(configFile, logger);
}
@Override
public void reload() {
super.reload();
loadFields();
}
private void loadFields() {
addCustomEnchantsToLore = getBoolean("add-custom-enchants-into-lore", true);
addTeamColorToPrefix = getBoolean("add-teamcolor-to-prefix", true);
fix1_13FacePlayer = getBoolean("fix-1_13-face-player", false);
fix1_13FormattedInventoryTitles = getBoolean("fix-formatted-inventory-titles", true);
alwaysShowOriginalMobName = getBoolean("always-show-original-mob-name", true);
handlePingsAsInvAcknowledgements = getBoolean("handle-pings-as-inv-acknowledgements", false);
suppressEmulationWarnings = getBoolean("suppress-emulation-warnings", false);
}
@Override
public boolean addCustomEnchantsToLore() {
return addCustomEnchantsToLore;
}
@Override
public boolean addTeamColorTo1_13Prefix() {
return addTeamColorToPrefix;
}
@Override
public boolean isFix1_13FacePlayer() {
return fix1_13FacePlayer;
}
@Override
public boolean fix1_13FormattedInventoryTitle() {
return fix1_13FormattedInventoryTitles;
}
@Override
public boolean alwaysShowOriginalMobName() {
return alwaysShowOriginalMobName;
}
@Override
public boolean handlePingsAsInvAcknowledgements() {
return handlePingsAsInvAcknowledgements || Boolean.getBoolean("com.viaversion.handlePingsAsInvAcknowledgements");
}
@Override
public boolean suppressEmulationWarnings() {
return suppressEmulationWarnings;
}
@Override
public URL getDefaultConfigURL() {
return getClass().getClassLoader().getResource("assets/viabackwards/config.yml");
}
@Override
public InputStream getDefaultConfigInputStream() {
return getClass().getClassLoader().getResourceAsStream("assets/viabackwards/config.yml");
}
@Override
protected void handleConfig(Map<String, Object> map) {
}
@Override
public List<String> getUnsupportedOptions() {
return Collections.emptyList();
}
}
@@ -0,0 +1,72 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
import org.checkerframework.checker.nullness.qual.Nullable;
public abstract class BackwardsProtocol<CU extends ClientboundPacketType, CM extends ClientboundPacketType, SM extends ServerboundPacketType, SU extends ServerboundPacketType>
extends AbstractProtocol<CU, CM, SM, SU> {
protected BackwardsProtocol() {
}
protected BackwardsProtocol(@Nullable Class<CU> oldClientboundPacketEnum, @Nullable Class<CM> clientboundPacketEnum,
@Nullable Class<SM> oldServerboundPacketEnum, @Nullable Class<SU> serverboundPacketEnum) {
super(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum);
}
/**
* Waits for the given protocol to be loaded to then asynchronously execute the runnable for this protocol.
*/
protected void executeAsyncAfterLoaded(Class<? extends Protocol> protocolClass, Runnable runnable) {
Via.getManager().getProtocolManager().addMappingLoaderFuture(getClass(), protocolClass, runnable);
}
@Override
protected void registerPackets() {
super.registerPackets();
final BackwardsMappingData mappingData = getMappingData();
if (mappingData != null && mappingData.getViaVersionProtocolClass() != null) {
executeAsyncAfterLoaded(mappingData.getViaVersionProtocolClass(), this::loadMappingData);
}
}
@Override
public boolean hasMappingDataToLoad() {
// Manually load them later, since they depend on VV's mappings
return false;
}
@Override
public @Nullable BackwardsMappingData getMappingData() { // Change return type to BackwardsMappings
return null;
}
@Override
public @Nullable TranslatableRewriter<CU> getComponentRewriter() {
return null;
}
}
@@ -0,0 +1,73 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api;
import com.viaversion.viaversion.api.configuration.Config;
public interface ViaBackwardsConfig extends Config {
/**
* Mimics name and level of a custom enchant through the item's lore.
*
* @return true if enabled
*/
boolean addCustomEnchantsToLore();
/**
* Writes the color of the scoreboard team after the prefix.
*
* @return true if enabled
*/
boolean addTeamColorTo1_13Prefix();
/**
* Converts the new 1.13 face player packets to look packets.
*
* @return true if enabled
*/
boolean isFix1_13FacePlayer();
/**
* Converts the 1.13 face look-at packet for 1.12- players. Requires a bit of extra caching.
*
* @return true if enabled
*/
boolean fix1_13FormattedInventoryTitle();
/**
* Always shows the original mob's name instead of only when hovering over them with the cursor.
*
* @return true if enabled
*/
boolean alwaysShowOriginalMobName();
/**
* Sends inventory acknowledgement packets to act as a replacement for ping packets for sub 1.17 clients.
* This only takes effect for ids in the short range. Useful for anticheat compatibility.
*
* @return true if enabled
*/
boolean handlePingsAsInvAcknowledgements();
/**
* Suppresses warnings of missing emulations for certain features that are not supported (e.g. world height in 1.17+).
*
* @return true if enabled
*/
boolean suppressEmulationWarnings();
}
@@ -0,0 +1,178 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.ViaBackwardsConfig;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.v1_11to1_10.Protocol1_11To1_10;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
import com.viaversion.viabackwards.protocol.v1_11_1to1_11.Protocol1_11_1To1_11;
import com.viaversion.viabackwards.protocol.v1_12_2to1_12_1.Protocol1_12_2To1_12_1;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.Protocol1_13To1_12_2;
import com.viaversion.viabackwards.protocol.v1_12_1to1_12.Protocol1_12_1To1_12;
import com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.Protocol1_13_2To1_13_1;
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.Protocol1_14To1_13_2;
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13;
import com.viaversion.viabackwards.protocol.v1_14_2to1_14_1.Protocol1_14_2To1_14_1;
import com.viaversion.viabackwards.protocol.v1_14_3to1_14_2.Protocol1_14_3To1_14_2;
import com.viaversion.viabackwards.protocol.v1_14_4to1_14_3.Protocol1_14_4To1_14_3;
import com.viaversion.viabackwards.protocol.v1_15to1_14_4.Protocol1_15To1_14_4;
import com.viaversion.viabackwards.protocol.v1_14_1to1_14.Protocol1_14_1To1_14;
import com.viaversion.viabackwards.protocol.v1_15_2to1_15_1.Protocol1_15_2To1_15_1;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.Protocol1_16To1_15_2;
import com.viaversion.viabackwards.protocol.v1_15_1to1_15.Protocol1_15_1To1_15;
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.Protocol1_16_2To1_16_1;
import com.viaversion.viabackwards.protocol.v1_16_3to1_16_2.Protocol1_16_3To1_16_2;
import com.viaversion.viabackwards.protocol.v1_16_4to1_16_3.Protocol1_16_4To1_16_3;
import com.viaversion.viabackwards.protocol.v1_17to1_16_4.Protocol1_17To1_16_4;
import com.viaversion.viabackwards.protocol.v1_16_1to1_16.Protocol1_16_1To1_16;
import com.viaversion.viabackwards.protocol.v1_18to1_17_1.Protocol1_18To1_17_1;
import com.viaversion.viabackwards.protocol.v1_17_1to1_17.Protocol1_17_1To1_17;
import com.viaversion.viabackwards.protocol.v1_19to1_18_2.Protocol1_19To1_18_2;
import com.viaversion.viabackwards.protocol.v1_18_2to1_18.Protocol1_18_2To1_18;
import com.viaversion.viabackwards.protocol.v1_19_3to1_19_1.Protocol1_19_3To1_19_1;
import com.viaversion.viabackwards.protocol.v1_19_4to1_19_3.Protocol1_19_4To1_19_3;
import com.viaversion.viabackwards.protocol.v1_20to1_19_4.Protocol1_20To1_19_4;
import com.viaversion.viabackwards.protocol.v1_19_1to1_19.Protocol1_19_1To1_19;
import com.viaversion.viabackwards.protocol.v1_20_3to1_20_2.Protocol1_20_3To1_20_2;
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.Protocol1_20_5To1_20_3;
import com.viaversion.viabackwards.protocol.v1_20_2to1_20.Protocol1_20_2To1_20;
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.Protocol1_21To1_20_5;
import com.viaversion.viabackwards.protocol.v1_9_3to1_9_1.Protocol1_9_3To1_9_1;
import com.viaversion.viabackwards.protocol.v1_10to1_9_3.Protocol1_10To1_9_3;
import com.viaversion.viabackwards.protocol.v1_9_1to1_9.Protocol1_9_1To1_9;
import com.viaversion.viabackwards.utils.VersionInfo;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.protocol.ProtocolManager;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.update.Version;
import java.io.File;
import java.util.Arrays;
import java.util.logging.Logger;
public interface ViaBackwardsPlatform {
String MINIMUM_VV_VERSION = "5.0.0";
/**
* Initialize ViaBackwards.
*/
default void init(final File configFile) {
ViaBackwardsConfig config = new ViaBackwardsConfig(configFile, getLogger());
config.reload();
Via.getManager().getConfigurationProvider().register(config);
ViaBackwards.init(this, config);
if (isOutdated()) {
disable();
return;
}
Via.getManager().getSubPlatforms().add(VersionInfo.getImplementationVersion());
getLogger().info("Loading translations...");
TranslatableRewriter.loadTranslatables();
getLogger().info("Registering protocols...");
final ProtocolManager protocolManager = Via.getManager().getProtocolManager();
protocolManager.registerProtocol(new Protocol1_9_1To1_9(), ProtocolVersion.v1_9, ProtocolVersion.v1_9_1);
protocolManager.registerProtocol(new Protocol1_9_3To1_9_1(), Arrays.asList(ProtocolVersion.v1_9_1, ProtocolVersion.v1_9_2), ProtocolVersion.v1_9_3);
protocolManager.registerProtocol(new Protocol1_10To1_9_3(), ProtocolVersion.v1_9_3, ProtocolVersion.v1_10);
protocolManager.registerProtocol(new Protocol1_11To1_10(), ProtocolVersion.v1_10, ProtocolVersion.v1_11);
protocolManager.registerProtocol(new Protocol1_11_1To1_11(), ProtocolVersion.v1_11, ProtocolVersion.v1_11_1);
protocolManager.registerProtocol(new Protocol1_12To1_11_1(), ProtocolVersion.v1_11_1, ProtocolVersion.v1_12);
protocolManager.registerProtocol(new Protocol1_12_1To1_12(), ProtocolVersion.v1_12, ProtocolVersion.v1_12_1);
protocolManager.registerProtocol(new Protocol1_12_2To1_12_1(), ProtocolVersion.v1_12_1, ProtocolVersion.v1_12_2);
protocolManager.registerProtocol(new Protocol1_13To1_12_2(), ProtocolVersion.v1_12_2, ProtocolVersion.v1_13);
protocolManager.registerProtocol(new Protocol1_13_1To1_13(), ProtocolVersion.v1_13, ProtocolVersion.v1_13_1);
protocolManager.registerProtocol(new Protocol1_13_2To1_13_1(), ProtocolVersion.v1_13_1, ProtocolVersion.v1_13_2);
protocolManager.registerProtocol(new Protocol1_14To1_13_2(), ProtocolVersion.v1_13_2, ProtocolVersion.v1_14);
protocolManager.registerProtocol(new Protocol1_14_1To1_14(), ProtocolVersion.v1_14, ProtocolVersion.v1_14_1);
protocolManager.registerProtocol(new Protocol1_14_2To1_14_1(), ProtocolVersion.v1_14_1, ProtocolVersion.v1_14_2);
protocolManager.registerProtocol(new Protocol1_14_3To1_14_2(), ProtocolVersion.v1_14_2, ProtocolVersion.v1_14_3);
protocolManager.registerProtocol(new Protocol1_14_4To1_14_3(), ProtocolVersion.v1_14_3, ProtocolVersion.v1_14_4);
protocolManager.registerProtocol(new Protocol1_15To1_14_4(), ProtocolVersion.v1_14_4, ProtocolVersion.v1_15);
protocolManager.registerProtocol(new Protocol1_15_1To1_15(), ProtocolVersion.v1_15, ProtocolVersion.v1_15_1);
protocolManager.registerProtocol(new Protocol1_15_2To1_15_1(), ProtocolVersion.v1_15_1, ProtocolVersion.v1_15_2);
protocolManager.registerProtocol(new Protocol1_16To1_15_2(), ProtocolVersion.v1_15_2, ProtocolVersion.v1_16);
protocolManager.registerProtocol(new Protocol1_16_1To1_16(), ProtocolVersion.v1_16, ProtocolVersion.v1_16_1);
protocolManager.registerProtocol(new Protocol1_16_2To1_16_1(), ProtocolVersion.v1_16_1, ProtocolVersion.v1_16_2);
protocolManager.registerProtocol(new Protocol1_16_3To1_16_2(), ProtocolVersion.v1_16_2, ProtocolVersion.v1_16_3);
protocolManager.registerProtocol(new Protocol1_16_4To1_16_3(), ProtocolVersion.v1_16_3, ProtocolVersion.v1_16_4);
protocolManager.registerProtocol(new Protocol1_17To1_16_4(), ProtocolVersion.v1_16_4, ProtocolVersion.v1_17);
protocolManager.registerProtocol(new Protocol1_17_1To1_17(), ProtocolVersion.v1_17, ProtocolVersion.v1_17_1);
protocolManager.registerProtocol(new Protocol1_18To1_17_1(), ProtocolVersion.v1_17_1, ProtocolVersion.v1_18);
protocolManager.registerProtocol(new Protocol1_18_2To1_18(), ProtocolVersion.v1_18, ProtocolVersion.v1_18_2);
protocolManager.registerProtocol(new Protocol1_19To1_18_2(), ProtocolVersion.v1_18_2, ProtocolVersion.v1_19);
protocolManager.registerProtocol(new Protocol1_19_1To1_19(), ProtocolVersion.v1_19, ProtocolVersion.v1_19_1);
protocolManager.registerProtocol(new Protocol1_19_3To1_19_1(), ProtocolVersion.v1_19_1, ProtocolVersion.v1_19_3);
protocolManager.registerProtocol(new Protocol1_19_4To1_19_3(), ProtocolVersion.v1_19_3, ProtocolVersion.v1_19_4);
protocolManager.registerProtocol(new Protocol1_20To1_19_4(), ProtocolVersion.v1_19_4, ProtocolVersion.v1_20);
protocolManager.registerProtocol(new Protocol1_20_2To1_20(), ProtocolVersion.v1_20, ProtocolVersion.v1_20_2);
protocolManager.registerProtocol(new Protocol1_20_3To1_20_2(), ProtocolVersion.v1_20_2, ProtocolVersion.v1_20_3);
protocolManager.registerProtocol(new Protocol1_20_5To1_20_3(), ProtocolVersion.v1_20_3, ProtocolVersion.v1_20_5);
protocolManager.registerProtocol(new Protocol1_21To1_20_5(), ProtocolVersion.v1_20_5, ProtocolVersion.v1_21);
}
/**
* Logger provided by the platform.
*
* @return logger instance
*/
Logger getLogger();
default boolean isOutdated() {
String vvVersion = Via.getPlatform().getPluginVersion();
if (vvVersion != null && new Version(vvVersion).compareTo(new Version(MINIMUM_VV_VERSION + "--")) < 0) {
getLogger().severe("================================");
getLogger().severe("YOUR VIAVERSION IS OUTDATED (you are running " + vvVersion + ")");
getLogger().severe("PLEASE USE VIAVERSION " + MINIMUM_VV_VERSION + " OR NEWER");
getLogger().severe("LINK: https://ci.viaversion.com/");
getLogger().severe("VIABACKWARDS WILL NOW DISABLE");
getLogger().severe("================================");
return true;
}
return false;
}
/**
* Disable the plugin.
*/
void disable();
/**
* Returns ViaBackwards's data folder.
*
* @return data folder
*/
File getDataFolder();
}
@@ -0,0 +1,207 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.data;
import com.google.common.base.Preconditions;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.BiMappings;
import com.viaversion.viaversion.api.data.IdentityMappings;
import com.viaversion.viaversion.api.data.MappingData;
import com.viaversion.viaversion.api.data.MappingDataBase;
import com.viaversion.viaversion.api.data.Mappings;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectArrayMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.NumberTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viaversion.util.Key;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.checkerframework.checker.nullness.qual.Nullable;
public class BackwardsMappingData extends MappingDataBase {
private final Class<? extends Protocol<?, ?, ?, ?>> vvProtocolClass;
protected Int2ObjectMap<MappedItem> backwardsItemMappings;
private Map<String, String> backwardsSoundMappings;
private Map<String, String> entityNames;
private Int2ObjectMap<String> enchantmentNames;
public BackwardsMappingData(final String unmappedVersion, final String mappedVersion) {
this(unmappedVersion, mappedVersion, null);
}
public BackwardsMappingData(final String unmappedVersion, final String mappedVersion, @Nullable final Class<? extends Protocol<?, ?, ?, ?>> vvProtocolClass) {
super(unmappedVersion, mappedVersion);
Preconditions.checkArgument(vvProtocolClass == null || !BackwardsProtocol.class.isAssignableFrom(vvProtocolClass));
this.vvProtocolClass = vvProtocolClass;
}
@Override
protected void loadExtras(final CompoundTag data) {
final CompoundTag itemNames = data.getCompoundTag("itemnames");
if (itemNames != null) {
Preconditions.checkNotNull(itemMappings);
backwardsItemMappings = new Int2ObjectOpenHashMap<>(itemNames.size());
final CompoundTag extraItemData = data.getCompoundTag("itemdata");
for (final Map.Entry<String, Tag> entry : itemNames.entrySet()) {
final StringTag name = (StringTag) entry.getValue();
final int id = Integer.parseInt(entry.getKey());
Integer customModelData = null;
if (extraItemData != null && extraItemData.contains(entry.getKey())) {
final CompoundTag entryTag = extraItemData.getCompoundTag(entry.getKey());
final NumberTag customModelDataTag = entryTag.getNumberTag("custom_model_data");
customModelData = customModelDataTag != null ? customModelDataTag.asInt() : null;
}
backwardsItemMappings.put(id, new MappedItem(getNewItemId(id), name.getValue(), customModelData));
}
}
this.entityNames = loadNameByStringMappings(data, "entitynames");
this.enchantmentNames = loadNameByIdMappings(data, "enchantmentnames");
this.backwardsSoundMappings = loadNameByStringMappings(data, "soundnames");
}
private @Nullable Map<String, String> loadNameByStringMappings(final CompoundTag data, final String key) {
final CompoundTag nameMappings = data.getCompoundTag(key);
if (nameMappings == null) {
return null;
}
final Map<String, String> map = new HashMap<>(nameMappings.size());
for (final Map.Entry<String, Tag> entry : nameMappings.entrySet()) {
final StringTag mappedTag = (StringTag) entry.getValue();
map.put(entry.getKey(), mappedTag.getValue());
}
return map;
}
private @Nullable Int2ObjectMap<String> loadNameByIdMappings(final CompoundTag data, final String key) {
final CompoundTag nameMappings = data.getCompoundTag(key);
if (nameMappings == null) {
return null;
}
final Int2ObjectMap<String> map = new Int2ObjectArrayMap<>(nameMappings.size());
for (final Map.Entry<String, Tag> entry : nameMappings.entrySet()) {
final StringTag mappedTag = (StringTag) entry.getValue();
map.put(Integer.parseInt(entry.getKey()), mappedTag.getValue());
}
return map;
}
@Override
protected @Nullable BiMappings loadBiMappings(final CompoundTag data, final String key) {
if (key.equals("items") && vvProtocolClass != null) {
Mappings mappings = super.loadMappings(data, key);
final MappingData mappingData = Via.getManager().getProtocolManager().getProtocol(vvProtocolClass).getMappingData();
if (mappingData != null && mappingData.getItemMappings() != null) {
final BiMappings vvItemMappings = mappingData.getItemMappings();
if (mappings == null) {
mappings = new IdentityMappings(vvItemMappings.mappedSize(), vvItemMappings.size());
}
return ItemMappings.of(mappings, vvItemMappings);
}
}
return super.loadBiMappings(data, key);
}
/**
* @see #getMappedItem(int) for custom backwards mappings
*/
@Override
public int getNewItemId(final int id) {
// Don't warn on missing here
return this.itemMappings.getNewId(id);
}
@Override
public int getNewBlockId(final int id) {
// Don't warn on missing here
return this.blockMappings.getNewId(id);
}
@Override
public int getOldItemId(final int id) {
// Warn on missing
return checkValidity(id, this.itemMappings.inverse().getNewId(id), "item");
}
@Override
public int getNewAttributeId(final int id) {
return this.attributeMappings.getNewId(id);
}
public @Nullable MappedItem getMappedItem(final int id) {
return backwardsItemMappings != null ? backwardsItemMappings.get(id) : null;
}
public @Nullable String getMappedNamedSound(final String id) {
if (backwardsSoundMappings == null) {
return null;
}
return backwardsSoundMappings.get(Key.stripMinecraftNamespace(id));
}
public @Nullable String mappedEntityName(final String entityName) {
if (entityNames == null) {
getLogger().log(Level.SEVERE, "No entity mappings found when requesting them for " + entityName, new RuntimeException());
return null;
}
return entityNames.get(entityName);
}
public @Nullable String mappedEnchantmentName(final int enchantmentId) {
if (enchantmentNames == null) {
ViaBackwards.getPlatform().getLogger().log(Level.SEVERE, "No enchantment name mappings found when requesting " + enchantmentId, new RuntimeException());
return null;
}
return enchantmentNames.get(enchantmentId);
}
public @Nullable Int2ObjectMap<MappedItem> getBackwardsItemMappings() {
return backwardsItemMappings;
}
public @Nullable Map<String, String> getBackwardsSoundMappings() {
return backwardsSoundMappings;
}
public @Nullable Class<? extends Protocol<?, ?, ?, ?>> getViaVersionProtocolClass() {
return vvProtocolClass;
}
@Override
protected Logger getLogger() {
return ViaBackwards.getPlatform().getLogger();
}
@Override
protected @Nullable CompoundTag readMappingsFile(final String name) {
return BackwardsMappingDataLoader.INSTANCE.loadNBTFromDir(name);
}
}
@@ -0,0 +1,87 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.data;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viaversion.api.data.MappingDataLoader;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.Tag;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.logging.Logger;
import org.checkerframework.checker.nullness.qual.Nullable;
public class BackwardsMappingDataLoader extends MappingDataLoader {
public static final BackwardsMappingDataLoader INSTANCE = new BackwardsMappingDataLoader(BackwardsMappingDataLoader.class, "assets/viabackwards/data/");
public BackwardsMappingDataLoader(final Class<?> dataLoaderClass, final String dataPath) {
super(dataLoaderClass, dataPath);
}
/**
* Returns nbt data from the plugin folder or packed assets.
* If a file with the same name exists in the plugin folder, the data of the original packed tag will be merged with the file's tag.
*
* @param name name of the file
* @return nbt data from the plugin folder or packed assets
*/
public @Nullable CompoundTag loadNBTFromDir(final String name) {
final CompoundTag packedData = loadNBT(name);
final File file = new File(getDataFolder(), name);
if (!file.exists()) {
return packedData;
}
getLogger().info("Loading " + name + " from plugin folder");
try {
final CompoundTag fileData = MAPPINGS_READER.read(file.toPath(), false);
return mergeTags(packedData, fileData);
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
private CompoundTag mergeTags(final CompoundTag original, final CompoundTag extra) {
for (final Map.Entry<String, Tag> entry : extra.entrySet()) {
if (entry.getValue() instanceof CompoundTag) {
// For compound tags, don't replace the entire tag
final CompoundTag originalEntry = original.getCompoundTag(entry.getKey());
if (originalEntry != null) {
mergeTags(originalEntry, (CompoundTag) entry.getValue());
continue;
}
}
original.put(entry.getKey(), entry.getValue());
}
return original;
}
@Override
public Logger getLogger() {
return ViaBackwards.getPlatform().getLogger();
}
@Override
public File getDataFolder() {
return ViaBackwards.getPlatform().getDataFolder();
}
}
@@ -0,0 +1,38 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.data;
import com.viaversion.viaversion.api.data.BiMappingsBase;
import com.viaversion.viaversion.api.data.Mappings;
public final class ItemMappings extends BiMappingsBase {
private ItemMappings(final Mappings mappings, final Mappings inverse) {
super(mappings, inverse);
}
public static ItemMappings of(final Mappings mappings, final Mappings inverse) {
return new ItemMappings(mappings, inverse);
}
@Override
public void setNewId(final int id, final int mappedId) {
// Only set one-way
mappings.setNewId(id, mappedId);
}
}
@@ -0,0 +1,57 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.data;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viaversion.util.ComponentUtil;
import org.checkerframework.checker.nullness.qual.Nullable;
public class MappedItem {
private final int id;
private final String jsonName;
private final Tag tagName;
private final Integer customModelData;
public MappedItem(final int id, final String name) {
this(id, name, null);
}
public MappedItem(final int id, final String name, @Nullable final Integer customModelData) {
this.id = id;
this.jsonName = ComponentUtil.legacyToJsonString("§f" + name, true);
this.tagName = ComponentUtil.jsonStringToTag(jsonName);
this.customModelData = customModelData;
}
public int id() {
return id;
}
public String jsonName() {
return jsonName;
}
public Tag tagName() {
return tagName;
}
public @Nullable Integer customModelData() {
return customModelData;
}
}
@@ -0,0 +1,93 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.data;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.viaversion.util.IdAndData;
import org.checkerframework.checker.nullness.qual.Nullable;
public class MappedLegacyBlockItem {
private final int id;
private final short data;
private final String name;
private final IdAndData block;
private BlockEntityHandler blockEntityHandler;
public MappedLegacyBlockItem(int id) {
this(id, (short) -1, null, Type.ITEM);
}
public MappedLegacyBlockItem(int id, short data, @Nullable String name, Type type) {
this.id = id;
this.data = data;
this.name = name != null ? "§f" + name : null;
this.block = type != Type.ITEM ? data != -1 ? new IdAndData(id, data) : new IdAndData(id) : null;
}
public int getId() {
return id;
}
public short getData() {
return data;
}
public String getName() {
return name;
}
public IdAndData getBlock() {
return block;
}
public boolean hasBlockEntityHandler() {
return blockEntityHandler != null;
}
public @Nullable BlockEntityHandler getBlockEntityHandler() {
return blockEntityHandler;
}
public void setBlockEntityHandler(@Nullable BlockEntityHandler blockEntityHandler) {
this.blockEntityHandler = blockEntityHandler;
}
@FunctionalInterface
public interface BlockEntityHandler {
CompoundTag handleOrNewCompoundTag(int block, CompoundTag tag);
}
public enum Type {
ITEM("items"),
BLOCK_ITEM("block-items"),
BLOCK("blocks");
final String name;
Type(final String name) {
this.name = name;
}
public String getName() {
return name;
}
}
}
@@ -0,0 +1,39 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.entities.storage;
import com.viaversion.viabackwards.api.BackwardsProtocol;
public class EntityObjectData extends EntityReplacement {
private final int objectData;
public EntityObjectData(BackwardsProtocol<?, ?, ?, ?> protocol, String key, int id, int replacementId, int objectData) {
super(protocol, key, id, replacementId);
this.objectData = objectData;
}
@Override
public boolean isObjectType() {
return true;
}
@Override
public int objectData() {
return objectData;
}
}
@@ -0,0 +1,120 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.entities.storage;
import com.viaversion.viabackwards.api.rewriters.EntityRewriterBase;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.util.ProtocolLogger;
import java.util.function.Supplier;
public class EntityPositionHandler {
public static final double RELATIVE_MOVE_FACTOR = 32 * 128;
private final EntityRewriterBase<?, ?> entityRewriter;
private final Class<? extends EntityPositionStorage> storageClass;
private final Supplier<? extends EntityPositionStorage> storageSupplier;
private boolean warnedForMissingEntity;
public EntityPositionHandler(EntityRewriterBase<?, ?> entityRewriter,
Class<? extends EntityPositionStorage> storageClass, Supplier<? extends EntityPositionStorage> storageSupplier) {
this.entityRewriter = entityRewriter;
this.storageClass = storageClass;
this.storageSupplier = storageSupplier;
}
public void cacheEntityPosition(PacketWrapper wrapper, boolean create, boolean relative) {
cacheEntityPosition(wrapper,
wrapper.get(Types.DOUBLE, 0), wrapper.get(Types.DOUBLE, 1), wrapper.get(Types.DOUBLE, 2), create, relative);
}
public void cacheEntityPosition(PacketWrapper wrapper, double x, double y, double z, boolean create, boolean relative) {
int entityId = wrapper.get(Types.VAR_INT, 0);
StoredEntityData storedEntity = entityRewriter.tracker(wrapper.user()).entityData(entityId);
if (storedEntity == null) {
if (Via.getManager().isDebug()) { // There is too many plugins violating this out there, and reading seems to be hard! :>
ProtocolLogger logger = entityRewriter.protocol().getLogger();
logger.warning("Stored entity with id " + entityId + " missing at position: " + x + " - " + y + " - " + z + " in " + storageClass.getSimpleName());
if (entityId == -1 && x == 0 && y == 0 && z == 0) {
logger.warning("DO NOT REPORT THIS TO VIA, THIS IS A PLUGIN ISSUE");
} else if (!warnedForMissingEntity) {
warnedForMissingEntity = true;
logger.warning("This is very likely caused by a plugin sending a teleport packet for an entity outside of the player's range.");
}
}
return;
}
EntityPositionStorage positionStorage;
if (create) {
positionStorage = storageSupplier.get();
storedEntity.put(positionStorage);
} else {
positionStorage = storedEntity.get(storageClass);
if (positionStorage == null) {
entityRewriter.protocol().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName());
return;
}
}
positionStorage.setCoordinates(x, y, z, relative);
}
public EntityPositionStorage getStorage(UserConnection user, int entityId) {
StoredEntityData storedEntity = entityRewriter.tracker(user).entityData(entityId);
EntityPositionStorage entityStorage;
if (storedEntity == null || (entityStorage = storedEntity.get(EntityPositionStorage.class)) == null) {
entityRewriter.protocol().getLogger().warning("Untracked entity with id " + entityId + " in " + storageClass.getSimpleName());
return null;
}
return entityStorage;
}
public static void writeFacingAngles(PacketWrapper wrapper, double x, double y, double z, double targetX, double targetY, double targetZ) {
double dX = targetX - x;
double dY = targetY - y;
double dZ = targetZ - z;
double r = Math.sqrt(dX * dX + dY * dY + dZ * dZ);
double yaw = -Math.atan2(dX, dZ) / Math.PI * 180;
if (yaw < 0) {
yaw = 360 + yaw;
}
double pitch = -Math.asin(dY / r) / Math.PI * 180;
wrapper.write(Types.BYTE, (byte) (yaw * 256f / 360f));
wrapper.write(Types.BYTE, (byte) (pitch * 256f / 360f));
}
public static void writeFacingDegrees(PacketWrapper wrapper, double x, double y, double z, double targetX, double targetY, double targetZ) {
double dX = targetX - x;
double dY = targetY - y;
double dZ = targetZ - z;
double r = Math.sqrt(dX * dX + dY * dY + dZ * dZ);
double yaw = -Math.atan2(dX, dZ) / Math.PI * 180;
if (yaw < 0) {
yaw = 360 + yaw;
}
double pitch = -Math.asin(dY / r) / Math.PI * 180;
wrapper.write(Types.FLOAT, (float) yaw);
wrapper.write(Types.FLOAT, (float) pitch);
}
}
@@ -0,0 +1,48 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.entities.storage;
public abstract class EntityPositionStorage {
private double x;
private double y;
private double z;
public double x() {
return x;
}
public double y() {
return y;
}
public double z() {
return z;
}
public void setCoordinates(double x, double y, double z, boolean relative) {
if (relative) {
this.x += x;
this.y += y;
this.z += z;
} else {
this.x = x;
this.y = y;
this.z = z;
}
}
}
@@ -0,0 +1,134 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.entities.storage;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.viaversion.util.ComponentUtil;
import java.util.Locale;
import org.checkerframework.checker.nullness.qual.Nullable;
public class EntityReplacement {
private final BackwardsProtocol<?, ?, ?, ?> protocol;
private final int id;
private final int replacementId;
private final String key;
private ComponentType componentType = ComponentType.NONE;
private MetaCreator defaultMeta;
public EntityReplacement(BackwardsProtocol<?, ?, ?, ?> protocol, EntityType type, int replacementId) {
this(protocol, type.name(), type.getId(), replacementId);
}
public EntityReplacement(BackwardsProtocol<?, ?, ?, ?> protocol, String key, int id, int replacementId) {
this.protocol = protocol;
this.id = id;
this.replacementId = replacementId;
this.key = key.toLowerCase(Locale.ROOT);
}
public EntityReplacement jsonName() {
this.componentType = ComponentType.JSON;
return this;
}
public EntityReplacement tagName() {
this.componentType = ComponentType.TAG;
return this;
}
public EntityReplacement plainName() {
this.componentType = ComponentType.PLAIN;
return this;
}
public EntityReplacement spawnMetadata(MetaCreator handler) {
this.defaultMeta = handler;
return this;
}
public boolean hasBaseMeta() {
return this.defaultMeta != null;
}
public int typeId() {
return id;
}
/**
* @return custom mobname, can be either a String or a JsonElement
*/
public @Nullable Object entityName() {
if (componentType == ComponentType.NONE) {
return null;
}
final String name = protocol.getMappingData().mappedEntityName(key);
if (name == null) {
return null;
}
if (componentType == ComponentType.JSON) {
return ComponentUtil.legacyToJson(name);
} else if (componentType == ComponentType.TAG) {
return new StringTag(name);
}
return name;
}
public int replacementId() {
return replacementId;
}
public @Nullable MetaCreator defaultMeta() {
return defaultMeta;
}
public boolean isObjectType() {
return false;
}
public int objectData() {
return -1;
}
@Override
public String toString() {
return "EntityData{" +
"id=" + id +
", mobName='" + key + '\'' +
", replacementId=" + replacementId +
", defaultMeta=" + defaultMeta +
'}';
}
@FunctionalInterface
public interface MetaCreator {
void createMeta(WrappedMetadata storage);
}
private enum ComponentType {
PLAIN,
JSON,
TAG,
NONE
}
}
@@ -0,0 +1,71 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.entities.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Types;
public abstract class PlayerPositionStorage implements StorableObject {
private double x;
private double y;
private double z;
protected PlayerPositionStorage() {
}
public double x() {
return x;
}
public double y() {
return y;
}
public double z() {
return z;
}
public void setX(final double x) {
this.x = x;
}
public void setY(final double y) {
this.y = y;
}
public void setZ(final double z) {
this.z = z;
}
public void setCoordinates(PacketWrapper wrapper, boolean relative) {
setCoordinates(wrapper.get(Types.DOUBLE, 0), wrapper.get(Types.DOUBLE, 1), wrapper.get(Types.DOUBLE, 2), relative);
}
public void setCoordinates(double x, double y, double z, boolean relative) {
if (relative) {
this.x += x;
this.y += y;
this.z += z;
} else {
this.x = x;
this.y = y;
this.z = z;
}
}
}
@@ -0,0 +1,51 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.entities.storage;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public record WrappedMetadata(List<EntityData> metadataList) {
public boolean has(EntityData data) {
return this.metadataList.contains(data);
}
public void remove(EntityData data) {
this.metadataList.remove(data);
}
public void remove(int index) {
metadataList.removeIf(meta -> meta.id() == index);
}
public void add(EntityData data) {
this.metadataList.add(data);
}
public @Nullable EntityData get(int index) {
for (EntityData meta : this.metadataList) {
if (index == meta.id()) {
return meta;
}
}
return null;
}
}
@@ -0,0 +1,125 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.nbt.tag.ByteTag;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.IntTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.NumberTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.MappedItem;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
import com.viaversion.viaversion.api.type.Type;
import org.checkerframework.checker.nullness.qual.Nullable;
public class BackwardsItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
T extends BackwardsProtocol<C, ?, ?, S>> extends BackwardsItemRewriterBase<C, S, T> {
public BackwardsItemRewriter(T protocol, Type<Item> itemType, Type<Item[]> itemArrayType) {
super(protocol, itemType, itemArrayType, true);
}
public BackwardsItemRewriter(T protocol, Type<Item> itemType, Type<Item[]> itemArrayType, Type<Item> mappedItemType, Type<Item[]> mappedItemArrayType) {
super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType, true);
}
@Override
public @Nullable Item handleItemToClient(UserConnection connection, @Nullable Item item) {
if (item == null) {
return null;
}
CompoundTag display = item.tag() != null ? item.tag().getCompoundTag("display") : null;
if (protocol.getComponentRewriter() != null && display != null) {
// Handle name and lore components
StringTag name = display.getStringTag("Name");
if (name != null) {
String newValue = protocol.getComponentRewriter().processText(connection, name.getValue()).toString();
if (!newValue.equals(name.getValue())) {
saveStringTag(display, name, "Name");
}
name.setValue(newValue);
}
ListTag<StringTag> lore = display.getListTag("Lore", StringTag.class);
if (lore != null) {
boolean changed = false;
for (StringTag loreEntry : lore) {
String newValue = protocol.getComponentRewriter().processText(connection, loreEntry.getValue()).toString();
if (!changed && !newValue.equals(loreEntry.getValue())) {
// Backup original lore before doing any modifications
changed = true;
saveListTag(display, lore, "Lore");
}
loreEntry.setValue(newValue);
}
}
}
MappedItem data = protocol.getMappingData() != null ? protocol.getMappingData().getMappedItem(item.identifier()) : null;
if (data == null) {
// Just rewrite the id
return super.handleItemToClient(connection, item);
}
if (item.tag() == null) {
item.setTag(new CompoundTag());
}
// Save original id, set remapped id
item.tag().putInt(nbtTagName("id"), item.identifier());
item.setIdentifier(data.id());
// Add custom model data
if (data.customModelData() != null && !item.tag().contains("CustomModelData")) {
item.tag().putInt("CustomModelData", data.customModelData());
}
// Set custom name - only done if there is no original one
if (display == null) {
item.tag().put("display", display = new CompoundTag());
}
if (!display.contains("Name")) {
display.put("Name", new StringTag(data.jsonName()));
display.put(nbtTagName("customName"), new ByteTag(false));
}
return item;
}
@Override
public @Nullable Item handleItemToServer(UserConnection connection, @Nullable Item item) {
if (item == null) return null;
super.handleItemToServer(connection, item);
if (item.tag() != null) {
Tag originalId = item.tag().remove(nbtTagName("id"));
if (originalId instanceof IntTag) {
item.setIdentifier(((NumberTag) originalId).asInt());
}
}
return item;
}
}
@@ -0,0 +1,113 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viaversion.rewriter.ItemRewriter;
import java.util.ArrayList;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public abstract class BackwardsItemRewriterBase<C extends ClientboundPacketType, S extends ServerboundPacketType,
T extends BackwardsProtocol<C, ?, ?, S>> extends ItemRewriter<C, S, T> {
protected final boolean jsonNameFormat;
protected BackwardsItemRewriterBase(T protocol, Type<Item> itemType, Type<Item[]> itemArrayType, Type<Item> mappedItemType, Type<Item[]> mappedItemArrayType, boolean jsonFormat) {
super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType);
this.jsonNameFormat = jsonFormat;
}
protected BackwardsItemRewriterBase(T protocol, Type<Item> itemType, Type<Item[]> itemArrayType, boolean jsonNameFormat) {
this(protocol, itemType, itemArrayType, itemType, itemArrayType, jsonNameFormat);
}
@Override
public @Nullable Item handleItemToServer(UserConnection connection, @Nullable Item item) {
if (item == null) return null;
super.handleItemToServer(connection, item);
restoreDisplayTag(item);
return item;
}
protected boolean hasBackupTag(CompoundTag tag, String tagName) {
return tag.contains(nbtTagName(tagName));
}
protected void saveStringTag(CompoundTag tag, StringTag original, String name) {
// Multiple places might try to backup data
String backupName = nbtTagName(name);
if (!tag.contains(backupName)) {
tag.putString(backupName, original.getValue());
}
}
protected void saveListTag(CompoundTag tag, ListTag<?> original, String name) {
// Multiple places might try to backup data
String backupName = nbtTagName(name);
if (!tag.contains(backupName)) {
tag.put(backupName, original.copy());
}
}
protected void restoreDisplayTag(Item item) {
if (item.tag() == null) return;
CompoundTag display = item.tag().getCompoundTag("display");
if (display != null) {
// Remove custom name / restore original name
if (display.remove(nbtTagName("customName")) != null) {
display.remove("Name");
} else {
restoreStringTag(display, "Name");
}
// Restore lore
restoreListTag(display, "Lore");
}
}
protected void restoreStringTag(CompoundTag tag, String tagName) {
Tag original = tag.remove(nbtTagName(tagName));
if (original instanceof StringTag) {
tag.putString(tagName, ((StringTag) original).getValue());
}
}
protected void restoreListTag(CompoundTag tag, String tagName) {
Tag original = tag.remove(nbtTagName(tagName));
if (original instanceof ListTag) {
tag.put(tagName, ((ListTag<?>) original).copy());
}
}
@Override
public String nbtTagName() {
return "VB|" + protocol.getClass().getSimpleName();
}
}
@@ -0,0 +1,217 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.IntTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.NumberTag;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.api.data.MappedItem;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.FullMappings;
import com.viaversion.viaversion.api.minecraft.data.StructuredData;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntFunction;
import com.viaversion.viaversion.rewriter.StructuredItemRewriter;
import java.util.ArrayList;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
T extends BackwardsProtocol<C, ?, ?, S>> extends StructuredItemRewriter<C, S, T> {
public BackwardsStructuredItemRewriter(final T protocol, final Type<Item> itemType, final Type<Item[]> itemArrayType) {
super(protocol, itemType, itemArrayType);
}
public BackwardsStructuredItemRewriter(final T protocol, final Type<Item> itemType, final Type<Item[]> itemArrayType, final Type<Item> mappedItemType, final Type<Item[]> mappedItemArrayType) {
super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType);
}
@Override
public Item handleItemToClient(final UserConnection connection, final Item item) {
if (item.isEmpty()) {
return item;
}
final StructuredDataContainer dataContainer = item.dataContainer();
final BackwardsMappingData mappingData = protocol.getMappingData();
if (mappingData != null && mappingData.getDataComponentSerializerMappings() != null) {
final FullMappings mappings = mappingData.getDataComponentSerializerMappings();
dataContainer.setIdLookup(protocol, true);
dataContainer.updateIds(protocol, mappings::getNewId);
}
if (protocol.getComponentRewriter() != null) {
// Handle name and lore components
final StructuredData<Tag> customNameData = dataContainer.getNonEmpty(StructuredDataKey.CUSTOM_NAME);
if (customNameData != null) {
final Tag originalName = customNameData.value().copy();
protocol.getComponentRewriter().processTag(connection, customNameData.value());
if (!customNameData.value().equals(originalName)) {
saveTag(createCustomTag(item), originalName, "Name");
}
}
final StructuredData<Tag[]> loreData = dataContainer.getNonEmpty(StructuredDataKey.LORE);
if (loreData != null) {
for (final Tag tag : loreData.value()) {
protocol.getComponentRewriter().processTag(connection, tag);
}
}
}
Int2IntFunction itemIdRewriter = null;
Int2IntFunction blockIdRewriter = null;
if (mappingData != null) {
itemIdRewriter = mappingData.getItemMappings() != null ? mappingData::getNewItemId : null;
blockIdRewriter = mappingData.getBlockMappings() != null ? mappingData::getNewBlockId : null;
}
final MappedItem mappedItem = mappingData != null ? mappingData.getMappedItem(item.identifier()) : null;
if (mappedItem == null) {
// Just rewrite the id
if (mappingData != null && mappingData.getItemMappings() != null) {
item.setIdentifier(mappingData.getNewItemId(item.identifier()));
}
updateItemComponents(connection, dataContainer, this::handleItemToClient, itemIdRewriter, blockIdRewriter);
return item;
}
// Save original id, set remapped id
final CompoundTag tag = createCustomTag(item);
tag.putInt(nbtTagName("id"), item.identifier());
item.setIdentifier(mappedItem.id());
// Add custom model data
if (mappedItem.customModelData() != null && !dataContainer.contains(StructuredDataKey.CUSTOM_MODEL_DATA)) {
dataContainer.set(StructuredDataKey.CUSTOM_MODEL_DATA, mappedItem.customModelData());
}
// Set custom name - only done if there is no original one
if (!dataContainer.contains(StructuredDataKey.CUSTOM_NAME)) {
dataContainer.set(StructuredDataKey.CUSTOM_NAME, mappedItem.tagName());
tag.putBoolean(nbtTagName("customName"), true);
}
updateItemComponents(connection, dataContainer, this::handleItemToClient, itemIdRewriter, blockIdRewriter);
return item;
}
@Override
public Item handleItemToServer(final UserConnection connection, final Item item) {
if (item.isEmpty()) {
return item;
}
final BackwardsMappingData mappingData = protocol.getMappingData();
final StructuredDataContainer dataContainer = item.dataContainer();
if (mappingData != null) {
if (mappingData.getItemMappings() != null) {
item.setIdentifier(mappingData.getOldItemId(item.identifier()));
}
final FullMappings dataComponentMappings = mappingData.getDataComponentSerializerMappings();
if (dataComponentMappings != null) {
dataContainer.setIdLookup(protocol, false);
dataContainer.updateIds(protocol, id -> dataComponentMappings.inverse().getNewId(id));
}
}
final CompoundTag tag = customTag(item);
if (tag != null) {
final Tag originalId = tag.remove(nbtTagName("id"));
if (originalId instanceof IntTag) {
item.setIdentifier(((NumberTag) originalId).asInt());
}
}
restoreTextComponents(item);
Int2IntFunction itemIdRewriter = null;
Int2IntFunction blockIdRewriter = null;
if (mappingData != null) {
itemIdRewriter = mappingData.getItemMappings() != null ? mappingData::getOldItemId : null;
blockIdRewriter = mappingData.getBlockMappings() != null ? mappingData::getOldBlockId : null;
}
updateItemComponents(connection, dataContainer, this::handleItemToServer, itemIdRewriter, blockIdRewriter);
return item;
}
protected @Nullable CompoundTag customTag(final Item item) {
final StructuredData<CompoundTag> customData = item.dataContainer().getNonEmpty(StructuredDataKey.CUSTOM_DATA);
return customData != null ? customData.value() : null;
}
protected void saveListTag(CompoundTag tag, ListTag<?> original, String name) {
// Multiple places might try to backup data
String backupName = nbtTagName(name);
if (!tag.contains(backupName)) {
tag.put(backupName, original.copy());
}
}
public <T extends Tag> @Nullable ListTag<T> removeListTag(CompoundTag tag, String tagName, Class<T> tagType) {
String backupName = nbtTagName(tagName);
ListTag<T> data = tag.getListTag(backupName, tagType);
if (data == null) {
return null;
}
tag.remove(backupName);
return data;
}
protected void saveGenericTagList(CompoundTag tag, List<Tag> original, String name) {
// List tags cannot contain tags of different types, so we have to store them a bit more awkwardly as an indexed compound tag
String backupName = nbtTagName(name);
if (!tag.contains(backupName)) {
CompoundTag output = new CompoundTag();
for (int i = 0; i < original.size(); i++) {
output.put(Integer.toString(i), original.get(i));
}
tag.put(backupName, output);
}
}
protected List<Tag> removeGenericTagList(CompoundTag tag, String name) {
String backupName = nbtTagName(name);
CompoundTag data = tag.getCompoundTag(backupName);
if (data == null) {
return null;
}
tag.remove(backupName);
return new ArrayList<>(data.values());
}
@Override
public String nbtTagName() {
return "VB|" + protocol.getClass().getSimpleName();
}
}
@@ -0,0 +1,163 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.NumberTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.viaversion.util.ComponentUtil;
import com.viaversion.viaversion.util.Key;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Rewriter to handle the addition of new enchantments.
*/
public class EnchantmentRewriter {
protected final Map<String, String> enchantmentMappings = new HashMap<>();
protected final BackwardsItemRewriter<?, ?, ?> itemRewriter;
private final boolean jsonFormat;
public EnchantmentRewriter(BackwardsItemRewriter<?, ?, ?> itemRewriter, boolean jsonFormat) {
this.itemRewriter = itemRewriter;
this.jsonFormat = jsonFormat;
}
public EnchantmentRewriter(BackwardsItemRewriter<?, ?, ?> itemRewriter) {
this(itemRewriter, true);
}
public void registerEnchantment(String key, String replacementLore) {
enchantmentMappings.put(Key.stripMinecraftNamespace(key), replacementLore);
}
public void handleToClient(Item item) {
CompoundTag tag = item.tag();
if (tag == null) return;
if (tag.getListTag("Enchantments") != null) {
rewriteEnchantmentsToClient(tag, false);
}
if (tag.getListTag("StoredEnchantments") != null) {
rewriteEnchantmentsToClient(tag, true);
}
}
public void handleToServer(Item item) {
CompoundTag tag = item.tag();
if (tag == null) return;
if (tag.contains(itemRewriter.nbtTagName("Enchantments"))) {
rewriteEnchantmentsToServer(tag, false);
}
if (tag.contains(itemRewriter.nbtTagName("StoredEnchantments"))) {
rewriteEnchantmentsToServer(tag, true);
}
}
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
String key = storedEnchant ? "StoredEnchantments" : "Enchantments";
ListTag<CompoundTag> enchantments = tag.getListTag(key, CompoundTag.class);
List<StringTag> loreToAdd = new ArrayList<>();
boolean changed = false;
Iterator<CompoundTag> iterator = enchantments.iterator();
while (iterator.hasNext()) {
CompoundTag enchantmentEntry = iterator.next();
StringTag idTag = enchantmentEntry.getStringTag("id");
if (idTag == null) {
continue;
}
String enchantmentId = Key.stripMinecraftNamespace(idTag.getValue());
String remappedName = enchantmentMappings.get(enchantmentId);
if (remappedName != null) {
if (!changed) {
// Backup original before doing modifications
itemRewriter.saveListTag(tag, enchantments, key);
changed = true;
}
iterator.remove();
NumberTag levelTag = enchantmentEntry.getNumberTag("lvl");
int level = levelTag != null ? levelTag.asInt() : 1;
String loreValue = remappedName + " " + getRomanNumber(level);
if (jsonFormat) {
loreValue = ComponentUtil.legacyToJsonString(loreValue);
}
loreToAdd.add(new StringTag(loreValue));
}
}
if (!loreToAdd.isEmpty()) {
// Add dummy enchant for the glow effect if there are no actual enchantments left
if (!storedEnchant && enchantments.isEmpty()) {
CompoundTag dummyEnchantment = new CompoundTag();
dummyEnchantment.putString("id", "");
dummyEnchantment.putShort("lvl", (short) 0);
enchantments.add(dummyEnchantment);
}
CompoundTag display = tag.getCompoundTag("display");
if (display == null) {
tag.put("display", display = new CompoundTag());
}
ListTag<StringTag> loreTag = display.getListTag("Lore", StringTag.class);
if (loreTag == null) {
display.put("Lore", loreTag = new ListTag<>(StringTag.class));
} else {
// Save original lore
itemRewriter.saveListTag(display, loreTag, "Lore");
}
loreToAdd.addAll(loreTag.getValue());
loreTag.setValue(loreToAdd);
}
}
public void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnchant) {
// Just restore the original tag ig present (lore is always restored in the item rewriter)
String key = storedEnchant ? "StoredEnchantments" : "Enchantments";
itemRewriter.restoreListTag(tag, key);
}
public static String getRomanNumber(int number) {
return switch (number) {
case 1 -> "I";
case 2 -> "II";
case 3 -> "III";
case 4 -> "IV";
case 5 -> "V";
case 6 -> "VI";
case 7 -> "VII";
case 8 -> "VIII";
case 9 -> "IX";
case 10 -> "X";
default -> Integer.toString(number);
};
}
}
@@ -0,0 +1,154 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_14;
public abstract class EntityRewriter<C extends ClientboundPacketType, T extends BackwardsProtocol<C, ?, ?, ?>> extends EntityRewriterBase<C, T> {
protected EntityRewriter(T protocol) {
this(protocol, Types1_14.ENTITY_DATA_TYPES.optionalComponentType, Types1_14.ENTITY_DATA_TYPES.booleanType);
}
protected EntityRewriter(T protocol, EntityDataType displayType, EntityDataType displayVisibilityType) {
super(protocol, displayType, 2, displayVisibilityType, 3);
}
@Override
public void registerTrackerWithData(C packetType, EntityType fallingBlockType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity id
map(Types.UUID); // 1 - Entity UUID
map(Types.VAR_INT); // 2 - Entity Type
map(Types.DOUBLE); // 3 - X
map(Types.DOUBLE); // 4 - Y
map(Types.DOUBLE); // 5 - Z
map(Types.BYTE); // 6 - Pitch
map(Types.BYTE); // 7 - Yaw
map(Types.INT); // 8 - Data
handler(getSpawnTrackerWithDataHandler(fallingBlockType));
}
});
}
@Override
public void registerTrackerWithData1_19(C packetType, EntityType fallingBlockType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // Entity id
map(Types.UUID); // Entity UUID
map(Types.VAR_INT); // Entity type
map(Types.DOUBLE); // X
map(Types.DOUBLE); // Y
map(Types.DOUBLE); // Z
map(Types.BYTE); // Pitch
map(Types.BYTE); // Yaw
map(Types.BYTE); // Head yaw
map(Types.VAR_INT); // Data
handler(getSpawnTrackerWithDataHandler1_19(fallingBlockType));
}
});
}
public PacketHandler getSpawnTrackerWithDataHandler(EntityType fallingBlockType) {
return wrapper -> {
// Check against the UNMAPPED entity type
EntityType entityType = trackAndMapEntity(wrapper);
if (entityType == fallingBlockType) {
int blockState = wrapper.get(Types.INT, 0);
wrapper.set(Types.INT, 0, protocol.getMappingData().getNewBlockStateId(blockState));
}
};
}
public PacketHandler getSpawnTrackerWithDataHandler1_19(EntityType fallingBlockType) {
return wrapper -> {
if (protocol.getMappingData() == null) {
return;
}
// Check against the UNMAPPED entity type
EntityType entityType = trackAndMapEntity(wrapper);
if (entityType == fallingBlockType) {
int blockState = wrapper.get(Types.VAR_INT, 2);
wrapper.set(Types.VAR_INT, 2, protocol.getMappingData().getNewBlockStateId(blockState));
}
};
}
public void registerSpawnTracker(C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity ID
map(Types.UUID); // 1 - Entity UUID
map(Types.VAR_INT); // 2 - Entity Type
handler(wrapper -> trackAndMapEntity(wrapper));
}
});
}
/**
* Returns a handler to track the current world and uncache entity data on world changes.
*
* @return handler to track the current world
*/
public PacketHandler worldTrackerHandlerByKey() {
return wrapper -> {
EntityTracker tracker = tracker(wrapper.user());
String world = wrapper.get(Types.STRING, 1);
if (tracker.currentWorld() != null && !tracker.currentWorld().equals(world)) {
tracker.clearEntities();
tracker.trackClientEntity();
}
tracker.setCurrentWorld(world);
};
}
/**
* Sets the mapped entity id and returns the unmapped entity type.
*
* @param wrapper packet wrapper
* @return unmapped (!) entity type
*/
protected EntityType trackAndMapEntity(PacketWrapper wrapper) {
int typeId = wrapper.get(Types.VAR_INT, 1);
EntityType entityType = typeFromId(typeId);
tracker(wrapper.user()).addEntity(wrapper.get(Types.VAR_INT, 0), entityType);
int mappedTypeId = newEntityId(entityType.getId());
if (typeId != mappedTypeId) {
wrapper.set(Types.VAR_INT, 1, mappedTypeId);
}
return entityType;
}
}
@@ -0,0 +1,252 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.google.common.base.Preconditions;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.entities.storage.EntityReplacement;
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.data.entity.TrackedEntity;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.rewriter.EntityRewriter;
import com.viaversion.viaversion.rewriter.entitydata.EntityDataHandlerEvent;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Entity rewriter base class.
*
* @see com.viaversion.viabackwards.api.rewriters.EntityRewriter
* @see LegacyEntityRewriter
*/
public abstract class EntityRewriterBase<C extends ClientboundPacketType, T extends BackwardsProtocol<C, ?, ?, ?>> extends EntityRewriter<C, T> {
private final Int2ObjectMap<EntityReplacement> entityDataMappings = new Int2ObjectOpenHashMap<>();
private final EntityDataType displayNameMetaType;
private final EntityDataType displayVisibilityMetaType;
private final int displayNameIndex;
private final int displayVisibilityIndex;
EntityRewriterBase(T protocol, EntityDataType displayNameMetaType, int displayNameIndex,
EntityDataType displayVisibilityMetaType, int displayVisibilityIndex) {
super(protocol, false);
this.displayNameMetaType = displayNameMetaType;
this.displayNameIndex = displayNameIndex;
this.displayVisibilityMetaType = displayVisibilityMetaType;
this.displayVisibilityIndex = displayVisibilityIndex;
}
@Override
public void handleEntityData(int entityId, List<EntityData> entityDataList, UserConnection connection) {
final TrackedEntity entity = tracker(connection).entity(entityId);
final boolean initialMetadata = !(entity != null && entity.hasSentEntityData());
super.handleEntityData(entityId, entityDataList, connection);
if (entity == null) {
return; // Don't handle untracked entities - basically always the fault of a plugin sending virtual entities through concurrency-unsafe handling
}
// Set the mapped entity name if there is no custom name set already
final EntityReplacement entityMapping = entityDataForType(entity.entityType());
final Object displayNameObject;
if (entityMapping != null && (displayNameObject = entityMapping.entityName()) != null) {
final EntityData displayName = getData(displayNameIndex, entityDataList);
if (initialMetadata) {
if (displayName == null) {
// Add it as new metadata
entityDataList.add(new EntityData(displayNameIndex, displayNameMetaType, displayNameObject));
addDisplayVisibilityMeta(entityDataList);
} else if (displayName.getValue() == null || displayName.getValue().toString().isEmpty()) {
// Overwrite the existing null/empty display name
displayName.setValue(displayNameObject);
addDisplayVisibilityMeta(entityDataList);
}
} else if (displayName != null && (displayName.getValue() == null || displayName.getValue().toString().isEmpty())) {
// Overwrite null/empty display name
displayName.setValue(displayNameObject);
addDisplayVisibilityMeta(entityDataList);
}
}
// Add any other extra meta for mapped entities
if (entityMapping != null && entityMapping.hasBaseMeta() && initialMetadata) {
entityMapping.defaultMeta().createMeta(new WrappedMetadata(entityDataList));
}
}
private void addDisplayVisibilityMeta(List<EntityData> metadataList) {
if (alwaysShowOriginalMobName()) {
removeMeta(displayVisibilityIndex, metadataList);
metadataList.add(new EntityData(displayVisibilityIndex, displayVisibilityMetaType, getDisplayVisibilityMetaValue()));
}
}
protected Object getDisplayVisibilityMetaValue() {
return true;
}
protected boolean alwaysShowOriginalMobName() {
return ViaBackwards.getConfig().alwaysShowOriginalMobName();
}
protected @Nullable EntityData getData(int metaIndex, List<EntityData> metadataList) {
for (EntityData metadata : metadataList) {
if (metadata.id() == metaIndex) {
return metadata;
}
}
return null;
}
protected void removeMeta(int metaIndex, List<EntityData> metadataList) {
metadataList.removeIf(meta -> meta.id() == metaIndex);
}
protected boolean hasData(EntityType type) {
return entityDataMappings.containsKey(type.getId());
}
protected @Nullable EntityReplacement entityDataForType(EntityType type) {
return entityDataMappings.get(type.getId());
}
protected @Nullable StoredEntityData storedEntityData(EntityDataHandlerEvent event) {
return tracker(event.user()).entityData(event.entityId());
}
/**
* Maps an entity type to another with extra data.
* Note that both types should be of the same version.
*
* @param type entity type
* @param mappedType mapped entity type
* @return created entity data
* @see #mapEntityType(EntityType, EntityType) for id only rewriting
*/
protected EntityReplacement mapEntityTypeWithData(EntityType type, EntityType mappedType) {
Preconditions.checkArgument(type.getClass() == mappedType.getClass(), "Both entity types need to be of the same class");
// Already rewrite the id here
int mappedReplacementId = newEntityId(mappedType.getId());
EntityReplacement data = new EntityReplacement(protocol, type, mappedReplacementId);
mapEntityType(type.getId(), mappedReplacementId);
entityDataMappings.put(type.getId(), data);
return data;
}
public void registerMetaTypeHandler(
@Nullable EntityDataType itemType,
@Nullable EntityDataType blockStateType,
@Nullable EntityDataType optionalBlockStateType,
@Nullable EntityDataType particleType,
@Nullable EntityDataType componentType,
@Nullable EntityDataType optionalComponentType
) {
filter().handler((event, meta) -> {
EntityDataType type = meta.dataType();
if (type == itemType) {
protocol.getItemRewriter().handleItemToClient(event.user(), meta.value());
} else if (type == blockStateType) {
int data = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
} else if (type == optionalBlockStateType) {
int data = meta.value();
if (data != 0) {
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
}
} else if (type == particleType) {
rewriteParticle(event.user(), meta.value());
} else if (type == optionalComponentType || type == componentType) {
JsonElement text = meta.value();
protocol.getComponentRewriter().processText(event.user(), text);
}
});
}
public void registerMetaTypeHandler1_20_3(
@Nullable EntityDataType itemType,
@Nullable EntityDataType blockStateType,
@Nullable EntityDataType optionalBlockStateType,
@Nullable EntityDataType particleType,
@Nullable EntityDataType particlesType,
@Nullable EntityDataType componentType,
@Nullable EntityDataType optionalComponentType
) {
filter().handler((event, meta) -> {
EntityDataType type = meta.dataType();
if (type == itemType) {
meta.setValue(protocol.getItemRewriter().handleItemToClient(event.user(), meta.value()));
} else if (type == blockStateType) {
int data = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
} else if (type == optionalBlockStateType) {
int data = meta.value();
if (data != 0) {
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
}
} else if (type == particleType) {
rewriteParticle(event.user(), meta.value());
} else if (type == particlesType) {
Particle[] particles = meta.value();
for (final Particle particle : particles) {
rewriteParticle(event.user(), particle);
}
} else if (type == optionalComponentType || type == componentType) {
protocol.getComponentRewriter().processTag(event.user(), meta.value());
}
});
}
// ONLY TRACKS, DOESN'T REWRITE IDS
protected PacketHandler getTrackerHandler(Type<? extends Number> intType, int typeIndex) {
return wrapper -> {
Number id = wrapper.get(intType, typeIndex);
tracker(wrapper.user()).addEntity(wrapper.get(Types.VAR_INT, 0), typeFromId(id.intValue()));
};
}
protected PacketHandler getTrackerHandler() {
return getTrackerHandler(Types.VAR_INT, 1);
}
protected PacketHandler getTrackerHandler(EntityType entityType, Type<? extends Number> intType) {
return wrapper -> tracker(wrapper.user()).addEntity((int) wrapper.get(intType, 0), entityType);
}
protected PacketHandler getDimensionHandler(int index) {
return wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
int dimensionId = wrapper.get(Types.INT, index);
clientWorld.setEnvironment(dimensionId);
};
}
}
@@ -0,0 +1,389 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.MappedLegacyBlockItem;
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.data.BlockColors1_11_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
import com.viaversion.nbt.tag.ByteTag;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.IntTag;
import com.viaversion.nbt.tag.NumberTag;
import com.viaversion.nbt.tag.ShortTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viaversion.util.ComponentUtil;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import com.viaversion.viaversion.util.IdAndData;
import org.checkerframework.checker.nullness.qual.Nullable;
public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
T extends BackwardsProtocol<C, ?, ?, S>> extends BackwardsItemRewriterBase<C, S, T> {
protected final Int2ObjectMap<MappedLegacyBlockItem> itemReplacements = new Int2ObjectOpenHashMap<>(8); // Raw id -> mapped data
protected final Int2ObjectMap<MappedLegacyBlockItem> blockReplacements = new Int2ObjectOpenHashMap<>(8); // Raw id -> mapped data
protected LegacyBlockItemRewriter(T protocol, String name, Type<Item> itemType, Type<Item[]> itemArrayType, Type<Item> mappedItemType, Type<Item[]> mappedItemArrayType) {
super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType, false);
Int2ObjectMap<MappedLegacyBlockItem> blockItemReplacements = new Int2ObjectOpenHashMap<>(8);
final JsonObject jsonObject = readMappingsFile("item-mappings-" + name + ".json");
addMappings(MappedLegacyBlockItem.Type.ITEM, jsonObject, itemReplacements);
addMappings(MappedLegacyBlockItem.Type.BLOCK_ITEM, jsonObject, blockItemReplacements);
addMappings(MappedLegacyBlockItem.Type.BLOCK, jsonObject, blockReplacements);
blockReplacements.putAll(blockItemReplacements);
itemReplacements.putAll(blockItemReplacements);
}
protected LegacyBlockItemRewriter(T protocol, String name, Type<Item> itemType, Type<Item[]> itemArrayType) {
this(protocol, name, itemType, itemArrayType, itemType, itemArrayType);
}
protected LegacyBlockItemRewriter(T protocol, String name) {
this(protocol, name, Types.ITEM1_8, Types.ITEM1_8_SHORT_ARRAY);
}
private void addMappings(MappedLegacyBlockItem.Type type, JsonObject object, Int2ObjectMap<MappedLegacyBlockItem> mappings) {
if (object.has(type.getName())) {
final JsonObject mappingsObject = object.getAsJsonObject(type.getName());
for (Map.Entry<String, JsonElement> dataEntry : mappingsObject.entrySet()) {
addMapping(dataEntry.getKey(), dataEntry.getValue().getAsJsonObject(), type, mappings);
}
}
}
private void addMapping(String key, JsonObject object, MappedLegacyBlockItem.Type type, Int2ObjectMap<MappedLegacyBlockItem> mappings) {
int id = object.getAsJsonPrimitive("id").getAsInt();
JsonPrimitive jsonData = object.getAsJsonPrimitive("data");
short data = jsonData != null ? jsonData.getAsShort() : 0;
String name = type != MappedLegacyBlockItem.Type.BLOCK ? object.getAsJsonPrimitive("name").getAsString() : null;
if (key.indexOf('-') == -1) {
int unmappedId;
int dataSeparatorIndex = key.indexOf(':');
if (dataSeparatorIndex != -1) {
// Include data
short unmappedData = Short.parseShort(key.substring(dataSeparatorIndex + 1));
unmappedId = Integer.parseInt(key.substring(0, dataSeparatorIndex));
unmappedId = IdAndData.toRawData(unmappedId, unmappedData);
} else {
unmappedId = IdAndData.toRawData(Integer.parseInt(key), -1);
}
mappings.put(unmappedId, new MappedLegacyBlockItem(id, data, name, type));
return;
}
// Range of ids
String[] split = key.split("-", 2);
int from = Integer.parseInt(split[0]);
int to = Integer.parseInt(split[1]);
// Special block color handling
if (name != null && name.contains("%color%")) {
for (int i = from; i <= to; i++) {
mappings.put(IdAndData.toRawData(i, -1), new MappedLegacyBlockItem(id, data, name.replace("%color%", BlockColors1_11_1.get(i - from)), type));
}
} else {
MappedLegacyBlockItem mappedBlockItem = new MappedLegacyBlockItem(id, data, name, type);
for (int i = from; i <= to; i++) {
mappings.put(IdAndData.toRawData(i, -1), mappedBlockItem);
}
}
}
public void registerBlockChange(C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Types.BLOCK_POSITION1_8); // 0 - Block Position
map(Types.VAR_INT); // 1 - Block
handler(wrapper -> {
int idx = wrapper.get(Types.VAR_INT, 0);
wrapper.set(Types.VAR_INT, 0, handleBlockId(idx));
});
}
});
}
public void registerMultiBlockChange(C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Types.INT); // 0 - Chunk X
map(Types.INT); // 1 - Chunk Z
map(Types.BLOCK_CHANGE_ARRAY);
handler(wrapper -> {
for (BlockChangeRecord record : wrapper.get(Types.BLOCK_CHANGE_ARRAY, 0)) {
record.setBlockId(handleBlockId(record.getBlockId()));
}
});
}
});
}
@Override
public @Nullable Item handleItemToClient(UserConnection connection, @Nullable Item item) {
if (item == null) return null;
MappedLegacyBlockItem data = getMappedItem(item.identifier(), item.data());
if (data == null) {
// Just rewrite the id
return super.handleItemToClient(connection, item);
}
if (item.tag() == null) {
item.setTag(new CompoundTag());
}
short originalData = item.data();
item.tag().putInt(nbtTagName("id"), item.identifier());
item.setIdentifier(data.getId());
// Keep original data if mapped data is set to -1
if (data.getData() != -1) {
item.setData(data.getData());
item.tag().putShort(nbtTagName("data"), originalData);
}
// Set display name
if (data.getName() != null) {
CompoundTag display = item.tag().getCompoundTag("display");
if (display == null) {
item.tag().put("display", display = new CompoundTag());
}
StringTag nameTag = display.getStringTag("Name");
if (nameTag == null) {
nameTag = new StringTag(data.getName());
display.put("Name", nameTag);
display.put(nbtTagName("customName"), new ByteTag(false));
}
// Handle colors
String value = nameTag.getValue();
if (value.contains("%vb_color%")) {
display.putString("Name", value.replace("%vb_color%", BlockColors1_11_1.get(originalData)));
}
}
return item;
}
@Override
public @Nullable Item handleItemToServer(UserConnection connection, @Nullable final Item item) {
if (item == null) return null;
super.handleItemToServer(connection, item);
if (item.tag() != null) {
Tag originalId = item.tag().remove(nbtTagName("id"));
if (originalId instanceof IntTag) {
item.setIdentifier(((NumberTag) originalId).asInt());
}
Tag originalData = item.tag().remove(nbtTagName("data"));
if (originalData instanceof ShortTag) {
item.setData(((NumberTag) originalData).asShort());
}
}
return item;
}
public PacketHandler getFallingBlockHandler() {
return wrapper -> {
final EntityTypes1_12.ObjectType type = EntityTypes1_12.ObjectType.findById(wrapper.get(Types.BYTE, 0));
if (type == EntityTypes1_12.ObjectType.FALLING_BLOCK) {
final int objectData = wrapper.get(Types.INT, 0);
final IdAndData block = handleBlock(objectData & 4095, objectData >> 12 & 15);
if (block == null) return;
wrapper.set(Types.INT, 0, block.getId() | block.getData() << 12);
}
};
}
public @Nullable IdAndData handleBlock(int blockId, int data) {
MappedLegacyBlockItem settings = getMappedBlock(blockId, data);
if (settings == null) {
return null;
}
IdAndData block = settings.getBlock();
// For some blocks, the data can still be useful (:
if (block.getData() == -1) {
return block.withData(data);
}
return block;
}
public int handleBlockId(final int rawId) {
final int id = IdAndData.getId(rawId);
final int data = IdAndData.getData(rawId);
final IdAndData mappedBlock = handleBlock(id, data);
if (mappedBlock == null) return rawId;
return IdAndData.toRawData(mappedBlock.getId(), mappedBlock.getData());
}
public void handleChunk(Chunk chunk) {
// Map Block Entities
Map<Pos, CompoundTag> tags = new HashMap<>();
for (CompoundTag tag : chunk.getBlockEntities()) {
NumberTag xTag;
NumberTag yTag;
NumberTag zTag;
if ((xTag = tag.getNumberTag("x")) == null
|| (yTag = tag.getNumberTag("y")) == null
|| (zTag = tag.getNumberTag("z")) == null) {
continue;
}
Pos pos = new Pos(xTag.asInt() & 0xF, yTag.asInt(), zTag.asInt() & 0xF);
tags.put(pos, tag);
// Handle given Block Entities
if (pos.y() < 0 || pos.y() > 255) continue; // 1.17
ChunkSection section = chunk.getSections()[pos.y() >> 4];
if (section == null) continue;
int block = section.palette(PaletteType.BLOCKS).idAt(pos.x(), pos.y() & 0xF, pos.z());
MappedLegacyBlockItem settings = getMappedBlock(block);
if (settings != null && settings.hasBlockEntityHandler()) {
settings.getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
}
}
for (int i = 0; i < chunk.getSections().length; i++) {
ChunkSection section = chunk.getSections()[i];
if (section == null) {
continue;
}
boolean hasBlockEntityHandler = false;
// Map blocks
DataPalette palette = section.palette(PaletteType.BLOCKS);
for (int j = 0; j < palette.size(); j++) {
int block = palette.idByIndex(j);
int btype = block >> 4;
int meta = block & 0xF;
IdAndData b = handleBlock(btype, meta);
if (b != null) {
palette.setIdByIndex(j, IdAndData.toRawData(b.getId(), b.getData()));
}
// We already know that is has a handler
if (hasBlockEntityHandler) continue;
MappedLegacyBlockItem settings = getMappedBlock(block);
if (settings != null && settings.hasBlockEntityHandler()) {
hasBlockEntityHandler = true;
}
}
if (!hasBlockEntityHandler) continue;
// We need to handle a Block Entity :(
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
int block = palette.idAt(x, y, z);
MappedLegacyBlockItem settings = getMappedBlock(block);
if (settings == null || !settings.hasBlockEntityHandler()) continue;
Pos pos = new Pos(x, (y + (i << 4)), z);
// Already handled above
if (tags.containsKey(pos)) continue;
CompoundTag tag = new CompoundTag();
tag.putInt("x", x + (chunk.getX() << 4));
tag.putInt("y", y + (i << 4));
tag.putInt("z", z + (chunk.getZ() << 4));
settings.getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
chunk.getBlockEntities().add(tag);
}
}
}
}
}
protected CompoundTag getNamedTag(String text) {
CompoundTag tag = new CompoundTag();
CompoundTag displayTag = new CompoundTag();
tag.put("display", displayTag);
text = "§r" + text;
displayTag.putString("Name", jsonNameFormat ? ComponentUtil.legacyToJsonString(text) : text);
return tag;
}
private @Nullable MappedLegacyBlockItem getMappedBlock(int id, int data) {
MappedLegacyBlockItem mapping = blockReplacements.get(IdAndData.toRawData(id, data));
return mapping != null ? mapping : blockReplacements.get(IdAndData.toRawData(id, -1));
}
private @Nullable MappedLegacyBlockItem getMappedItem(int id, int data) {
MappedLegacyBlockItem mapping = itemReplacements.get(IdAndData.toRawData(id, data));
return mapping != null ? mapping : itemReplacements.get(IdAndData.toRawData(id, -1));
}
private @Nullable MappedLegacyBlockItem getMappedBlock(int rawId) {
int id = IdAndData.getId(rawId);
int data = IdAndData.getData(rawId);
return getMappedBlock(id, data);
}
protected JsonObject readMappingsFile(final String name) {
return BackwardsMappingDataLoader.INSTANCE.loadFromDataDir(name);
}
private record Pos(int x, short y, int z) {
public Pos(int x, int y, int z) {
this(x, (short) y, z);
}
}
}
@@ -0,0 +1,191 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.nbt.tag.ByteTag;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.IntTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.NumberTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.nbt.tag.Tag;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class LegacyEnchantmentRewriter {
private final Map<Short, String> enchantmentMappings = new HashMap<>();
private final String nbtTagName;
private final boolean dummyEnchantment;
private Set<Short> hideLevelForEnchants;
public LegacyEnchantmentRewriter(String nbtTagName) {
this(nbtTagName, true);
}
public LegacyEnchantmentRewriter(String nbtTagName, boolean dummyEnchantment) {
this.nbtTagName = nbtTagName;
this.dummyEnchantment = dummyEnchantment;
}
public void registerEnchantment(int id, String replacementLore) {
enchantmentMappings.put((short) id, replacementLore);
}
public void handleToClient(Item item) {
CompoundTag tag = item.tag();
if (tag == null) return;
if (tag.getListTag("ench") != null) {
rewriteEnchantmentsToClient(tag, false);
}
if (tag.getListTag("StoredEnchantments") != null) {
rewriteEnchantmentsToClient(tag, true);
}
}
public void handleToServer(Item item) {
CompoundTag tag = item.tag();
if (tag == null) return;
if (tag.getListTag(nbtTagName + "|ench", CompoundTag.class) != null) {
rewriteEnchantmentsToServer(tag, false);
}
if (tag.getListTag(nbtTagName + "|StoredEnchantments", CompoundTag.class) != null) {
rewriteEnchantmentsToServer(tag, true);
}
}
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
String key = storedEnchant ? "StoredEnchantments" : "ench";
ListTag<CompoundTag> enchantments = tag.getListTag(key, CompoundTag.class);
ListTag<CompoundTag> remappedEnchantments = new ListTag<>(CompoundTag.class);
List<StringTag> lore = new ArrayList<>();
for (CompoundTag enchantmentEntry : enchantments.copy()) {
NumberTag idTag = enchantmentEntry.getNumberTag("id");
if (idTag == null) continue;
short newId = idTag.asShort();
String enchantmentName = enchantmentMappings.get(newId);
if (enchantmentName != null) {
enchantments.remove(enchantmentEntry);
NumberTag levelTag = enchantmentEntry.getNumberTag("lvl");
short level = levelTag != null ? levelTag.asShort() : 1;
if (hideLevelForEnchants != null && hideLevelForEnchants.contains(newId)) {
lore.add(new StringTag(enchantmentName));
} else {
lore.add(new StringTag(enchantmentName + " " + EnchantmentRewriter.getRomanNumber(level)));
}
remappedEnchantments.add(enchantmentEntry);
}
}
if (!lore.isEmpty()) {
if (this.dummyEnchantment && !storedEnchant && enchantments.isEmpty()) {
CompoundTag dummyEnchantment = new CompoundTag();
dummyEnchantment.putShort("id", (short) 0);
dummyEnchantment.putShort("lvl", (short) 0);
enchantments.add(dummyEnchantment);
tag.put(nbtTagName + "|dummyEnchant", new ByteTag(false));
NumberTag hideFlags = tag.getNumberTag("HideFlags");
if (hideFlags == null) {
hideFlags = new IntTag();
} else {
tag.putInt(nbtTagName + "|oldHideFlags", hideFlags.asByte());
}
int flags = hideFlags.asByte() | 1;
tag.putInt("HideFlags", flags);
}
tag.put(nbtTagName + "|" + key, remappedEnchantments);
CompoundTag display = tag.getCompoundTag("display");
if (display == null) {
tag.put("display", display = new CompoundTag());
}
ListTag<StringTag> loreTag = display.getListTag("Lore", StringTag.class);
if (loreTag == null) {
display.put("Lore", loreTag = new ListTag<>(StringTag.class));
}
lore.addAll(loreTag.getValue());
loreTag.setValue(lore);
}
}
public void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnchant) {
String key = storedEnchant ? "StoredEnchantments" : "ench";
ListTag<CompoundTag> enchantments = tag.getListTag(key, CompoundTag.class);
if (enchantments == null) {
enchantments = new ListTag<>(CompoundTag.class);
}
if (!storedEnchant && tag.remove(nbtTagName + "|dummyEnchant") != null) {
for (CompoundTag enchantment : enchantments.copy()) {
NumberTag idTag = enchantment.getNumberTag("id");
NumberTag levelTag = enchantment.getNumberTag("lvl");
short id = idTag != null ? idTag.asShort() : 0;
short level = levelTag != null ? levelTag.asShort() : 0;
if (id == 0 && level == 0) {
enchantments.remove(enchantment);
}
}
Tag hideFlags = tag.remove(nbtTagName + "|oldHideFlags");
if (hideFlags instanceof IntTag intTag) {
tag.putInt("HideFlags", intTag.asByte());
} else {
tag.remove("HideFlags");
}
}
CompoundTag display = tag.getCompoundTag("display");
// A few null checks just to be safe, though they shouldn't actually be
ListTag<StringTag> lore = display != null ? display.getListTag("Lore", StringTag.class) : null;
ListTag<CompoundTag> remappedEnchantments = (ListTag<CompoundTag>) tag.remove(nbtTagName + "|" + key);
for (CompoundTag enchantment : remappedEnchantments.copy()) {
enchantments.add(enchantment);
if (lore != null && !lore.isEmpty()) {
lore.remove(lore.get(0));
}
}
if (lore != null && lore.isEmpty()) {
display.remove("Lore");
if (display.isEmpty()) {
tag.remove("display");
}
}
tag.put(key, enchantments);
}
public void setHideLevelForEnchants(int... enchants) {
this.hideLevelForEnchants = new HashSet<>();
for (int enchant : enchants) {
hideLevelForEnchants.add((short) enchant);
}
}
}
@@ -0,0 +1,182 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.entities.storage.EntityReplacement;
import com.viaversion.viabackwards.api.entities.storage.EntityObjectData;
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.ObjectType;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_9;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import org.checkerframework.checker.nullness.qual.Nullable;
public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T extends BackwardsProtocol<C, ?, ?, ?>> extends EntityRewriterBase<C, T> {
private final Map<ObjectType, EntityReplacement> objectTypes = new HashMap<>();
protected LegacyEntityRewriter(T protocol) {
this(protocol, EntityDataTypes1_9.STRING, EntityDataTypes1_9.BOOLEAN);
}
protected LegacyEntityRewriter(T protocol, EntityDataType displayType, EntityDataType displayVisibilityType) {
super(protocol, displayType, 2, displayVisibilityType, 3);
}
protected EntityObjectData mapObjectType(ObjectType oldObjectType, ObjectType replacement, int data) {
EntityObjectData entData = new EntityObjectData(protocol, oldObjectType.getType().name(), oldObjectType.getId(), replacement.getId(), data);
objectTypes.put(oldObjectType, entData);
return entData;
}
protected @Nullable EntityReplacement getObjectData(ObjectType type) {
return objectTypes.get(type);
}
protected void registerRespawn(C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Types.INT);
handler(wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
clientWorld.setEnvironment(wrapper.get(Types.INT, 0));
});
}
});
}
protected void registerJoinGame(C packetType, EntityType playerType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Types.INT); // 0 - Entity ID
map(Types.UNSIGNED_BYTE); // 1 - Gamemode
map(Types.INT); // 2 - Dimension
handler(wrapper -> {
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
clientChunks.setEnvironment(wrapper.get(Types.INT, 1));
addTrackedEntity(wrapper, wrapper.get(Types.INT, 0), playerType);
});
}
});
}
@Override
public void registerSetEntityData(C packetType, Type<List<EntityData>> oldMetaType, Type<List<EntityData>> newMetaType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity ID
if (oldMetaType != null) {
map(oldMetaType, newMetaType);
} else {
map(newMetaType);
}
handler(wrapper -> {
List<EntityData> metadata = wrapper.get(newMetaType, 0);
handleEntityData(wrapper.get(Types.VAR_INT, 0), metadata, wrapper.user());
});
}
});
}
@Override
public void registerSetEntityData(C packetType, Type<List<EntityData>> metaType) {
registerSetEntityData(packetType, null, metaType);
}
protected PacketHandler getMobSpawnRewriter(Type<List<EntityData>> metaType, IdSetter idSetter) {
return wrapper -> {
int entityId = wrapper.get(Types.VAR_INT, 0);
EntityType type = tracker(wrapper.user()).entityType(entityId);
List<EntityData> metadata = wrapper.get(metaType, 0);
handleEntityData(entityId, metadata, wrapper.user());
EntityReplacement entityReplacement = entityDataForType(type);
if (entityReplacement != null) {
idSetter.setId(wrapper, entityReplacement.replacementId());
if (entityReplacement.hasBaseMeta()) {
entityReplacement.defaultMeta().createMeta(new WrappedMetadata(metadata));
}
}
};
}
public PacketHandler getMobSpawnRewriter(Type<List<EntityData>> metaType) {
return getMobSpawnRewriter(metaType, (wrapper, id) -> wrapper.set(Types.UNSIGNED_BYTE, 0, (short) id));
}
public PacketHandler getMobSpawnRewriter1_11(Type<List<EntityData>> metaType) {
return getMobSpawnRewriter(metaType, (wrapper, id) -> wrapper.set(Types.VAR_INT, 1, id));
}
protected PacketHandler getObjectTrackerHandler() {
return wrapper -> addTrackedEntity(wrapper, wrapper.get(Types.VAR_INT, 0), objectTypeFromId(wrapper.get(Types.BYTE, 0)));
}
protected PacketHandler getTrackerAndMetaHandler(Type<List<EntityData>> metaType, EntityType entityType) {
return wrapper -> {
addTrackedEntity(wrapper, wrapper.get(Types.VAR_INT, 0), entityType);
List<EntityData> metadata = wrapper.get(metaType, 0);
handleEntityData(wrapper.get(Types.VAR_INT, 0), metadata, wrapper.user());
};
}
protected PacketHandler getObjectRewriter(Function<Byte, ObjectType> objectGetter) {
return wrapper -> {
ObjectType type = objectGetter.apply(wrapper.get(Types.BYTE, 0));
if (type == null) {
protocol.getLogger().warning("Could not find Entity Type" + wrapper.get(Types.BYTE, 0));
return;
}
EntityReplacement data = getObjectData(type);
if (data != null) {
wrapper.set(Types.BYTE, 0, (byte) data.replacementId());
if (data.objectData() != -1) {
wrapper.set(Types.INT, 0, data.objectData());
}
}
};
}
@Deprecated
protected void addTrackedEntity(PacketWrapper wrapper, int entityId, EntityType type) {
tracker(wrapper.user()).addEntity(entityId, type);
}
@FunctionalInterface
protected interface IdSetter {
void setId(PacketWrapper wrapper, int id);
}
}
@@ -0,0 +1,79 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viaversion.api.rewriter.RewriterBase;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
@Deprecated
public abstract class LegacySoundRewriter<T extends BackwardsProtocol<?, ?, ?, ?>> extends RewriterBase<T> {
protected final Int2ObjectMap<SoundData> soundRewrites = new Int2ObjectOpenHashMap<>(64);
protected LegacySoundRewriter(T protocol) {
super(protocol);
}
public SoundData added(int id, int replacement) {
return added(id, replacement, -1);
}
public SoundData added(int id, int replacement, float newPitch) {
SoundData data = new SoundData(replacement, true, newPitch, true);
soundRewrites.put(id, data);
return data;
}
public SoundData removed(int id) {
SoundData data = new SoundData(-1, false, -1, false);
soundRewrites.put(id, data);
return data;
}
public int handleSounds(int soundId) {
int newSoundId = soundId;
SoundData data = soundRewrites.get(soundId);
if (data != null) return data.replacementSound();
for (Int2ObjectMap.Entry<SoundData> entry : soundRewrites.int2ObjectEntrySet()) {
if (soundId > entry.getIntKey()) {
if (entry.getValue().added()) {
newSoundId--;
} else {
newSoundId++;
}
}
}
return newSoundId;
}
public boolean hasPitch(int soundId) {
SoundData data = soundRewrites.get(soundId);
return data != null && data.changePitch();
}
public float handlePitch(int soundId) {
SoundData data = soundRewrites.get(soundId);
return data != null ? data.newPitch() : 1F;
}
public record SoundData(int replacementSound, boolean changePitch, float newPitch, boolean added) {
}
}
@@ -0,0 +1,60 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.rewriter.IdRewriteFunction;
public final class MapColorRewriter {
/**
* Returns a packethandler to rewrite map data color ids. Reading starts from the icon count.
*
* @param rewriter id rewriter returning mapped colors, or -1 if unmapped
* @return packethandler to rewrite map data color ids
*/
public static PacketHandler getRewriteHandler(IdRewriteFunction rewriter) {
return wrapper -> {
int iconCount = wrapper.passthrough(Types.VAR_INT);
for (int i = 0; i < iconCount; i++) {
wrapper.passthrough(Types.VAR_INT); // Type
wrapper.passthrough(Types.BYTE); // X
wrapper.passthrough(Types.BYTE); // Z
wrapper.passthrough(Types.BYTE); // Direction
wrapper.passthrough(Types.OPTIONAL_COMPONENT); // Display Name
}
short columns = wrapper.passthrough(Types.UNSIGNED_BYTE);
if (columns < 1) return;
wrapper.passthrough(Types.UNSIGNED_BYTE); // Rows
wrapper.passthrough(Types.UNSIGNED_BYTE); // X
wrapper.passthrough(Types.UNSIGNED_BYTE); // Z
byte[] data = wrapper.passthrough(Types.BYTE_ARRAY_PRIMITIVE);
for (int i = 0; i < data.length; i++) {
int color = data[i] & 0xFF;
int mappedColor = rewriter.rewrite(color);
if (mappedColor != -1) {
data[i] = (byte) mappedColor;
}
}
};
}
}
@@ -0,0 +1,137 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viaversion.api.minecraft.Holder;
import com.viaversion.viaversion.api.minecraft.SoundEvent;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types;
public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversion.viaversion.rewriter.SoundRewriter<C> {
private final BackwardsProtocol<C, ?, ?, ?> protocol;
public SoundRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol) {
super(protocol);
this.protocol = protocol;
}
public void registerNamedSound(final C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Types.STRING); // Sound identifier
handler(getNamedSoundHandler());
}
});
}
public void registerStopSound(final C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
handler(getStopSoundHandler());
}
});
}
public PacketHandler getNamedSoundHandler() {
return wrapper -> {
final String soundId = wrapper.get(Types.STRING, 0);
final String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
if (mappedId == null) {
return;
}
if (!mappedId.isEmpty()) {
wrapper.set(Types.STRING, 0, mappedId);
} else {
wrapper.cancel();
}
};
}
public PacketHandler getStopSoundHandler() {
return wrapper -> {
final byte flags = wrapper.passthrough(Types.BYTE);
if ((flags & 0x02) == 0) return; // No sound specified
if ((flags & 0x01) != 0) {
wrapper.passthrough(Types.VAR_INT); // Source
}
final String soundId = wrapper.read(Types.STRING);
final String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
if (mappedId == null) {
// No mapping found
wrapper.write(Types.STRING, soundId);
return;
}
if (!mappedId.isEmpty()) {
wrapper.write(Types.STRING, mappedId);
} else {
// Cancel if set to empty
wrapper.cancel();
}
};
}
@Override
public void registerSound1_19_3(final C packetType) {
protocol.registerClientbound(packetType, getSoundHandler1_19_3());
}
public PacketHandler getSoundHandler1_19_3() {
return wrapper -> {
Holder<SoundEvent> soundEventHolder = wrapper.read(Types.SOUND_EVENT);
if (soundEventHolder.isDirect()) {
wrapper.write(Types.SOUND_EVENT, rewriteSoundEvent(wrapper, soundEventHolder));
return;
}
final int mappedId = idRewriter.rewrite(soundEventHolder.id());
if (mappedId == -1) {
wrapper.cancel();
return;
}
if (mappedId != soundEventHolder.id()) {
soundEventHolder = Holder.of(mappedId);
}
wrapper.write(Types.SOUND_EVENT, soundEventHolder);
};
}
public Holder<SoundEvent> rewriteSoundEvent(final PacketWrapper wrapper, final Holder<SoundEvent> soundEventHolder) {
final SoundEvent soundEvent = soundEventHolder.value();
final String mappedIdentifier = protocol.getMappingData().getMappedNamedSound(soundEvent.identifier());
if (mappedIdentifier != null) {
if (!mappedIdentifier.isEmpty()) {
return Holder.of(soundEvent.withIdentifier(mappedIdentifier));
}
wrapper.cancel();
}
return soundEventHolder;
}
}
@@ -0,0 +1,201 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.nbt.tag.ByteTag;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.NumberTag;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viaversion.api.data.Mappings;
import com.viaversion.viaversion.api.minecraft.data.StructuredData;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.item.data.Enchantments;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
import com.viaversion.viaversion.libs.fastutil.ints.IntIntPair;
import com.viaversion.viaversion.libs.fastutil.objects.ObjectIterator;
import com.viaversion.viaversion.rewriter.IdRewriteFunction;
import com.viaversion.viaversion.util.ComponentUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class StructuredEnchantmentRewriter {
protected final BackwardsStructuredItemRewriter<?, ?, ?> itemRewriter;
private boolean rewriteIds = true;
public StructuredEnchantmentRewriter(final BackwardsStructuredItemRewriter<?, ?, ?> itemRewriter) {
this.itemRewriter = itemRewriter;
}
public void handleToClient(final Item item) {
final StructuredDataContainer data = item.dataContainer();
final BackwardsMappingData mappingData = itemRewriter.protocol().getMappingData();
final IdRewriteFunction idRewriteFunction = id -> {
final Mappings mappings = mappingData.getEnchantmentMappings();
return mappings.getNewId(id);
};
final DescriptionSupplier descriptionSupplier = (id, level) -> {
final String remappedName = mappingData.mappedEnchantmentName(id);
return ComponentUtil.jsonStringToTag(ComponentUtil.legacyToJsonString("§7" + remappedName + " " + EnchantmentRewriter.getRomanNumber(level), true));
};
rewriteEnchantmentsToClient(data, StructuredDataKey.ENCHANTMENTS, idRewriteFunction, descriptionSupplier, false);
rewriteEnchantmentsToClient(data, StructuredDataKey.STORED_ENCHANTMENTS, idRewriteFunction, descriptionSupplier, true);
}
public void handleToServer(final Item item) {
final StructuredDataContainer data = item.dataContainer();
final StructuredData<CompoundTag> customData = data.getNonEmpty(StructuredDataKey.CUSTOM_DATA);
if (customData == null) {
return;
}
final CompoundTag tag = customData.value();
rewriteEnchantmentsToServer(data, tag, StructuredDataKey.ENCHANTMENTS);
rewriteEnchantmentsToServer(data, tag, StructuredDataKey.STORED_ENCHANTMENTS);
}
public void rewriteEnchantmentsToClient(final StructuredDataContainer data, final StructuredDataKey<Enchantments> key, final IdRewriteFunction rewriteFunction, final DescriptionSupplier descriptionSupplier, final boolean storedEnchant) {
final StructuredData<Enchantments> enchantmentsData = data.getNonEmpty(key);
if (enchantmentsData == null) {
return;
}
final CompoundTag tag = data.computeIfAbsent(StructuredDataKey.CUSTOM_DATA, $ -> new CompoundTag()).value();
final Enchantments enchantments = enchantmentsData.value();
final List<Tag> loreToAdd = new ArrayList<>();
boolean changed = false;
final ObjectIterator<Int2IntMap.Entry> iterator = enchantments.enchantments().int2IntEntrySet().iterator();
final List<IntIntPair> updatedIds = new ArrayList<>();
while (iterator.hasNext()) {
final Int2IntMap.Entry entry = iterator.next();
final int id = entry.getIntKey();
final int mappedId = rewriteFunction.rewrite(id);
if (mappedId != -1) {
if (rewriteIds) {
// Update the map after to iteration to preserve the current ids before possibly saving the original, avoid CME
updatedIds.add(IntIntPair.of(id, mappedId));
}
continue;
}
final int level = entry.getIntValue();
final Tag description = descriptionSupplier.get(id, level);
if (description != null) {
if (!changed) {
// Backup original before doing modifications
itemRewriter.saveListTag(tag, asTag(enchantments), key.identifier());
changed = true;
}
loreToAdd.add(description);
iterator.remove();
}
}
for (final IntIntPair pair : updatedIds) {
final int level = enchantments.enchantments().remove(pair.firstInt());
enchantments.add(pair.secondInt(), level);
}
if (loreToAdd.isEmpty()) {
// No removed enchantments
return;
}
// Add glint override if there are no enchantments left
if (!storedEnchant && enchantments.size() == 0) {
final StructuredData<Boolean> glintOverride = data.getNonEmpty(StructuredDataKey.ENCHANTMENT_GLINT_OVERRIDE);
if (glintOverride != null) {
tag.putBoolean(itemRewriter.nbtTagName("glint"), glintOverride.value());
} else {
tag.putBoolean(itemRewriter.nbtTagName("noglint"), true);
}
data.set(StructuredDataKey.ENCHANTMENT_GLINT_OVERRIDE, true);
}
// Save original lore
final StructuredData<Tag[]> loreData = data.getNonEmpty(StructuredDataKey.LORE);
if (loreData != null) {
final List<Tag> loreList = Arrays.asList(loreData.value());
itemRewriter.saveGenericTagList(tag, loreList, "lore");
loreToAdd.addAll(loreList);
} else {
tag.putBoolean(itemRewriter.nbtTagName("nolore"), true);
}
if (enchantments.showInTooltip()) {
tag.putBoolean(itemRewriter.nbtTagName("show_" + key.identifier()), true);
}
data.set(StructuredDataKey.LORE, loreToAdd.toArray(new Tag[0]));
}
private ListTag<CompoundTag> asTag(final Enchantments enchantments) {
final ListTag<CompoundTag> listTag = new ListTag<>(CompoundTag.class);
for (final Int2IntMap.Entry entry : enchantments.enchantments().int2IntEntrySet()) {
final CompoundTag enchantment = new CompoundTag();
enchantment.putInt("id", entry.getIntKey());
enchantment.putInt("lvl", entry.getIntValue());
listTag.add(enchantment);
}
return listTag;
}
public void rewriteEnchantmentsToServer(final StructuredDataContainer data, final CompoundTag tag, final StructuredDataKey<Enchantments> key) {
final ListTag<CompoundTag> enchantmentsTag = itemRewriter.removeListTag(tag, key.identifier(), CompoundTag.class);
if (enchantmentsTag == null) {
return;
}
final Tag glintTag = tag.remove(itemRewriter.nbtTagName("glint"));
if (glintTag instanceof ByteTag) {
data.set(StructuredDataKey.ENCHANTMENT_GLINT_OVERRIDE, ((NumberTag) glintTag).asBoolean());
} else if (tag.remove(itemRewriter.nbtTagName("noglint")) != null) {
data.remove(StructuredDataKey.ENCHANTMENT_GLINT_OVERRIDE);
}
final List<Tag> lore = itemRewriter.removeGenericTagList(tag, "lore");
if (lore != null) {
data.set(StructuredDataKey.LORE, lore.toArray(new Tag[0]));
} else if (tag.remove(itemRewriter.nbtTagName("nolore")) != null) {
data.remove(StructuredDataKey.LORE);
}
final Enchantments enchantments = new Enchantments(tag.remove(itemRewriter.nbtTagName("show_" + key.identifier())) != null);
for (final CompoundTag enchantment : enchantmentsTag) {
enchantments.add(enchantment.getInt("id"), enchantment.getInt("lvl"));
}
data.set(key, enchantments);
}
public void setRewriteIds(final boolean rewriteIds) {
this.rewriteIds = rewriteIds;
}
@FunctionalInterface
public interface DescriptionSupplier {
Tag get(int id, int level);
}
}
@@ -0,0 +1,93 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import java.util.HashMap;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.Nullable;
public class TranslatableRewriter<C extends ClientboundPacketType> extends ComponentRewriter<C> {
private static final Map<String, Map<String, String>> TRANSLATABLES = new HashMap<>();
private final Map<String, String> translatables;
public static void loadTranslatables() {
if (!TRANSLATABLES.isEmpty()) {
throw new IllegalStateException("Translatables already loaded!");
}
fillTranslatables(BackwardsMappingDataLoader.INSTANCE.loadFromDataDir("translation-mappings.json"), TRANSLATABLES);
}
public static void fillTranslatables(final JsonObject jsonObject, final Map<String, Map<String, String>> translatables) {
for (final Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
final Map<String, String> versionMappings = new HashMap<>();
translatables.put(entry.getKey(), versionMappings);
for (final Map.Entry<String, JsonElement> translationEntry : entry.getValue().getAsJsonObject().entrySet()) {
versionMappings.put(translationEntry.getKey(), translationEntry.getValue().getAsString());
}
}
}
public TranslatableRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol, final ReadType type) {
this(protocol, type, protocol.getClass().getSimpleName().replace("Protocol", "").split("To")[0].replace("_", "."));
}
public TranslatableRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol, final ReadType type, final String version) {
super(protocol, type);
final Map<String, String> translatableMappings = getTranslatableMappings(version);
if (translatableMappings == null) {
protocol.getLogger().warning("Missing " + version + " translatables!");
this.translatables = new HashMap<>();
} else {
this.translatables = translatableMappings;
}
}
@Override
protected void handleTranslate(final JsonObject root, final String translate) {
final String newTranslate = mappedTranslationKey(translate);
if (newTranslate != null) {
root.addProperty("translate", newTranslate);
}
}
@Override
protected void handleTranslate(final UserConnection connection, final CompoundTag parentTag, final StringTag translateTag) {
final String newTranslate = mappedTranslationKey(translateTag.getValue());
if (newTranslate != null) {
parentTag.put("translate", new StringTag(newTranslate));
}
}
public @Nullable String mappedTranslationKey(final String translationKey) {
return translatables.get(translationKey);
}
public Map<String, String> getTranslatableMappings(final String sectionIdentifier) {
return TRANSLATABLES.get(sectionIdentifier);
}
}
@@ -0,0 +1,127 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_10to1_9_3;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.v1_10to1_9_3.rewriter.BlockItemPacketRewriter1_10;
import com.viaversion.viabackwards.protocol.v1_10to1_9_3.rewriter.EntityPacketRewriter1_10;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
public class Protocol1_10To1_9_3 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.10", "1.9.4");
private static final ValueTransformer<Float, Short> TO_OLD_PITCH = new ValueTransformer<>(Types.UNSIGNED_BYTE) {
public Short transform(PacketWrapper packetWrapper, Float inputValue) {
return (short) Math.round(inputValue * 63.5F);
}
};
private final EntityPacketRewriter1_10 entityRewriter = new EntityPacketRewriter1_10(this);
private final BlockItemPacketRewriter1_10 itemRewriter = new BlockItemPacketRewriter1_10(this);
public Protocol1_10To1_9_3() {
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
}
@Override
protected void registerPackets() {
entityRewriter.register();
itemRewriter.register();
SoundRewriter<ClientboundPackets1_9_3> soundRewriter = new SoundRewriter<>(this);
registerClientbound(ClientboundPackets1_9_3.CUSTOM_SOUND, new PacketHandlers() {
@Override
public void register() {
map(Types.STRING); // 0 - Sound name
map(Types.VAR_INT); // 1 - Sound Category
map(Types.INT); // 2 - x
map(Types.INT); // 3 - y
map(Types.INT); // 4 - z
map(Types.FLOAT); // 5 - Volume
map(Types.FLOAT, TO_OLD_PITCH); // 6 - Pitch
handler(soundRewriter.getNamedSoundHandler());
}
});
registerClientbound(ClientboundPackets1_9_3.SOUND, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Sound name
map(Types.VAR_INT); // 1 - Sound Category
map(Types.INT); // 2 - x
map(Types.INT); // 3 - y
map(Types.INT); // 4 - z
map(Types.FLOAT); // 5 - Volume
map(Types.FLOAT, TO_OLD_PITCH); // 6 - Pitch
handler(soundRewriter.getSoundHandler());
}
});
registerServerbound(ServerboundPackets1_9_3.RESOURCE_PACK, new PacketHandlers() {
@Override
public void register() {
read(Types.STRING); // 0 - Hash
map(Types.VAR_INT); // 1 - Result
}
});
TranslatableRewriter<ClientboundPackets1_9_3> componentRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
componentRewriter.registerComponentPacket(ClientboundPackets1_9_3.CHAT);
}
@Override
public void init(UserConnection user) {
if (!user.has(ClientWorld.class)) {
user.put(new ClientWorld());
}
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_10.EntityType.PLAYER));
}
@Override
public BackwardsMappingData getMappingData() {
return MAPPINGS;
}
@Override
public EntityPacketRewriter1_10 getEntityRewriter() {
return entityRewriter;
}
@Override
public BlockItemPacketRewriter1_10 getItemRewriter() {
return itemRewriter;
}
@Override
public boolean hasMappingDataToLoad() {
return true;
}
}
@@ -0,0 +1,91 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_10to1_9_3.rewriter;
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
import com.viaversion.viabackwards.protocol.v1_10to1_9_3.Protocol1_10To1_9_3;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
public class BlockItemPacketRewriter1_10 extends LegacyBlockItemRewriter<ClientboundPackets1_9_3, ServerboundPackets1_9_3, Protocol1_10To1_9_3> {
public BlockItemPacketRewriter1_10(Protocol1_10To1_9_3 protocol) {
super(protocol, "1.10");
}
@Override
protected void registerPackets() {
registerBlockChange(ClientboundPackets1_9_3.BLOCK_UPDATE);
registerMultiBlockChange(ClientboundPackets1_9_3.CHUNK_BLOCKS_UPDATE);
registerSetSlot(ClientboundPackets1_9_3.CONTAINER_SET_SLOT);
registerSetContent(ClientboundPackets1_9_3.CONTAINER_SET_CONTENT);
registerSetEquippedItem(ClientboundPackets1_9_3.SET_EQUIPPED_ITEM);
registerCustomPayloadTradeList(ClientboundPackets1_9_3.CUSTOM_PAYLOAD);
registerContainerClick(ServerboundPackets1_9_3.CONTAINER_CLICK);
registerSetCreativeModeSlot(ServerboundPackets1_9_3.SET_CREATIVE_MODE_SLOT);
protocol.registerClientbound(ClientboundPackets1_9_3.LEVEL_CHUNK, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
ChunkType1_9_3 type = ChunkType1_9_3.forEnvironment(clientWorld.getEnvironment());
Chunk chunk = wrapper.passthrough(type);
handleChunk(chunk);
});
// Rewrite metadata items
protocol.getEntityRewriter().filter().handler((event, meta) -> {
if (meta.dataType().type().equals(Types.ITEM1_8)) // Is Item
meta.setValue(handleItemToClient(event.user(), (Item) meta.getValue()));
});
// Particle
protocol.registerClientbound(ClientboundPackets1_9_3.LEVEL_PARTICLES, new PacketHandlers() {
@Override
public void register() {
map(Types.INT);
map(Types.BOOLEAN);
map(Types.FLOAT);
map(Types.FLOAT);
map(Types.FLOAT);
map(Types.FLOAT);
map(Types.FLOAT);
map(Types.FLOAT);
map(Types.FLOAT);
map(Types.INT);
handler(wrapper -> {
int id = wrapper.get(Types.INT, 0);
if (id == 46) { // new falling_dust
wrapper.set(Types.INT, 0, 38); // -> block_dust
}
});
}
});
}
}
@@ -0,0 +1,171 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_10to1_9_3.rewriter;
import com.viaversion.viabackwards.api.entities.storage.EntityReplacement;
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
import com.viaversion.viabackwards.protocol.v1_10to1_9_3.Protocol1_10To1_9_3;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_9;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_9;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import java.util.List;
public class EntityPacketRewriter1_10 extends LegacyEntityRewriter<ClientboundPackets1_9_3, Protocol1_10To1_9_3> {
public EntityPacketRewriter1_10(Protocol1_10To1_9_3 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
protocol.registerClientbound(ClientboundPackets1_9_3.ADD_ENTITY, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity id
map(Types.UUID); // 1 - UUID
map(Types.BYTE); // 2 - Type
map(Types.DOUBLE); // 3 - x
map(Types.DOUBLE); // 4 - y
map(Types.DOUBLE); // 5 - z
map(Types.BYTE); // 6 - Pitch
map(Types.BYTE); // 7 - Yaw
map(Types.INT); // 8 - data
// Track Entity
handler(getObjectTrackerHandler());
handler(getObjectRewriter(EntityTypes1_11.ObjectType::findById));
handler(protocol.getItemRewriter().getFallingBlockHandler());
}
});
registerTracker(ClientboundPackets1_9_3.ADD_EXPERIENCE_ORB, EntityTypes1_10.EntityType.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_9_3.ADD_GLOBAL_ENTITY, EntityTypes1_10.EntityType.LIGHTNING_BOLT);
protocol.registerClientbound(ClientboundPackets1_9_3.ADD_MOB, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity id
map(Types.UUID); // 1 - UUID
map(Types.UNSIGNED_BYTE); // 2 - Entity Type
map(Types.DOUBLE); // 3 - X
map(Types.DOUBLE); // 4 - Y
map(Types.DOUBLE); // 5 - Z
map(Types.BYTE); // 6 - Yaw
map(Types.BYTE); // 7 - Pitch
map(Types.BYTE); // 8 - Head Pitch
map(Types.SHORT); // 9 - Velocity X
map(Types.SHORT); // 10 - Velocity Y
map(Types.SHORT); // 11 - Velocity Z
map(Types1_9.ENTITY_DATA_LIST); // 12 - Metadata
// Track entity
handler(getTrackerHandler(Types.UNSIGNED_BYTE, 0));
// Rewrite entity type / metadata
handler(wrapper -> {
int entityId = wrapper.get(Types.VAR_INT, 0);
EntityType type = tracker(wrapper.user()).entityType(entityId);
List<EntityData> metadata = wrapper.get(Types1_9.ENTITY_DATA_LIST, 0);
handleEntityData(wrapper.get(Types.VAR_INT, 0), metadata, wrapper.user());
EntityReplacement entityReplacement = entityDataForType(type);
if (entityReplacement != null) {
WrappedMetadata storage = new WrappedMetadata(metadata);
wrapper.set(Types.UNSIGNED_BYTE, 0, (short) entityReplacement.replacementId());
if (entityReplacement.hasBaseMeta())
entityReplacement.defaultMeta().createMeta(storage);
}
});
}
});
registerTracker(ClientboundPackets1_9_3.ADD_PAINTING, EntityTypes1_10.EntityType.PAINTING);
registerJoinGame(ClientboundPackets1_9_3.LOGIN, EntityTypes1_10.EntityType.PLAYER);
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
protocol.registerClientbound(ClientboundPackets1_9_3.ADD_PLAYER, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity ID
map(Types.UUID); // 1 - Player UUID
map(Types.DOUBLE); // 2 - X
map(Types.DOUBLE); // 3 - Y
map(Types.DOUBLE); // 4 - Z
map(Types.BYTE); // 5 - Yaw
map(Types.BYTE); // 6 - Pitch
map(Types1_9.ENTITY_DATA_LIST); // 7 - Metadata list
handler(getTrackerAndMetaHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_11.EntityType.PLAYER));
}
});
registerRemoveEntities(ClientboundPackets1_9_3.REMOVE_ENTITIES);
registerSetEntityData(ClientboundPackets1_9_3.SET_ENTITY_DATA, Types1_9.ENTITY_DATA_LIST);
}
@Override
protected void registerRewrites() {
mapEntityTypeWithData(EntityTypes1_10.EntityType.POLAR_BEAR, EntityTypes1_10.EntityType.SHEEP).plainName();
// Change the sheep color when the polar bear is standing up (index 13 -> Standing up)
filter().type(EntityTypes1_10.EntityType.POLAR_BEAR).index(13).handler((event, meta) -> {
boolean b = (boolean) meta.getValue();
meta.setTypeAndValue(EntityDataTypes1_9.BYTE, b ? (byte) (14 & 0x0F) : (byte) (0));
});
// Handle husk (index 13 -> Zombie Type)
filter().type(EntityTypes1_10.EntityType.ZOMBIE).index(13).handler((event, meta) -> {
if ((int) meta.getValue() == 6) { // Is type Husk
meta.setValue(0);
}
});
// Handle Stray (index 12 -> Skeleton Type)
filter().type(EntityTypes1_10.EntityType.SKELETON).index(12).handler((event, meta) -> {
if ((int) meta.getValue() == 2) {
meta.setValue(0); // Change to default skeleton
}
});
// Handle the missing NoGravity tag for every metadata
filter().removeIndex(5);
}
@Override
public EntityType typeFromId(int typeId) {
return EntityTypes1_10.getTypeFromId(typeId, false);
}
@Override
public EntityType objectTypeFromId(int typeId) {
return EntityTypes1_10.getTypeFromId(typeId, true);
}
}
@@ -0,0 +1,58 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_11_1to1_11;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.protocol.v1_11_1to1_11.rewriter.EntityPacketRewriter1_11_1;
import com.viaversion.viabackwards.protocol.v1_11_1to1_11.rewriter.ItemPacketRewriter1_11_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
public class Protocol1_11_1To1_11 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
private final EntityPacketRewriter1_11_1 entityRewriter = new EntityPacketRewriter1_11_1(this);
private final ItemPacketRewriter1_11_1 itemRewriter = new ItemPacketRewriter1_11_1(this);
public Protocol1_11_1To1_11() {
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
}
@Override
public void init(UserConnection user) {
if (!user.has(ClientWorld.class)) {
user.put(new ClientWorld());
}
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_11.EntityType.PLAYER));
}
@Override
public EntityPacketRewriter1_11_1 getEntityRewriter() {
return entityRewriter;
}
@Override
public ItemPacketRewriter1_11_1 getItemRewriter() {
return itemRewriter;
}
}
@@ -0,0 +1,128 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_11_1to1_11.rewriter;
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
import com.viaversion.viabackwards.protocol.v1_11_1to1_11.Protocol1_11_1To1_11;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_9;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
public class EntityPacketRewriter1_11_1 extends LegacyEntityRewriter<ClientboundPackets1_9_3, Protocol1_11_1To1_11> {
public EntityPacketRewriter1_11_1(Protocol1_11_1To1_11 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
protocol.registerClientbound(ClientboundPackets1_9_3.ADD_ENTITY, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity id
map(Types.UUID); // 1 - UUID
map(Types.BYTE); // 2 - Type
map(Types.DOUBLE); // 3 - x
map(Types.DOUBLE); // 4 - y
map(Types.DOUBLE); // 5 - z
map(Types.BYTE); // 6 - Pitch
map(Types.BYTE); // 7 - Yaw
map(Types.INT); // 8 - data
// Track Entity
handler(getObjectTrackerHandler());
handler(getObjectRewriter(EntityTypes1_11.ObjectType::findById));
}
});
registerTracker(ClientboundPackets1_9_3.ADD_EXPERIENCE_ORB, EntityTypes1_11.EntityType.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_9_3.ADD_GLOBAL_ENTITY, EntityTypes1_11.EntityType.LIGHTNING_BOLT);
protocol.registerClientbound(ClientboundPackets1_9_3.ADD_MOB, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity id
map(Types.UUID); // 1 - UUID
map(Types.VAR_INT); // 2 - Entity Type
map(Types.DOUBLE); // 3 - X
map(Types.DOUBLE); // 4 - Y
map(Types.DOUBLE); // 5 - Z
map(Types.BYTE); // 6 - Yaw
map(Types.BYTE); // 7 - Pitch
map(Types.BYTE); // 8 - Head Pitch
map(Types.SHORT); // 9 - Velocity X
map(Types.SHORT); // 10 - Velocity Y
map(Types.SHORT); // 11 - Velocity Z
map(Types1_9.ENTITY_DATA_LIST); // 12 - Metadata
// Track entity
handler(getTrackerHandler());
// Rewrite entity type / metadata
handler(getMobSpawnRewriter1_11(Types1_9.ENTITY_DATA_LIST));
}
});
registerTracker(ClientboundPackets1_9_3.ADD_PAINTING, EntityTypes1_11.EntityType.PAINTING);
registerJoinGame(ClientboundPackets1_9_3.LOGIN, EntityTypes1_11.EntityType.PLAYER);
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
protocol.registerClientbound(ClientboundPackets1_9_3.ADD_PLAYER, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity ID
map(Types.UUID); // 1 - Player UUID
map(Types.DOUBLE); // 2 - X
map(Types.DOUBLE); // 3 - Y
map(Types.DOUBLE); // 4 - Z
map(Types.BYTE); // 5 - Yaw
map(Types.BYTE); // 6 - Pitch
map(Types1_9.ENTITY_DATA_LIST); // 7 - Metadata list
handler(getTrackerAndMetaHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_11.EntityType.PLAYER));
}
});
registerRemoveEntities(ClientboundPackets1_9_3.REMOVE_ENTITIES);
registerSetEntityData(ClientboundPackets1_9_3.SET_ENTITY_DATA, Types1_9.ENTITY_DATA_LIST);
}
@Override
protected void registerRewrites() {
// Handle non-existing firework metadata (index 7 entity id for boosting)
filter().type(EntityTypes1_11.EntityType.FIREWORK_ROCKET).cancel(7);
// Handle non-existing pig metadata (index 14 - boost time)
filter().type(EntityTypes1_11.EntityType.PIG).cancel(14);
}
@Override
public EntityType typeFromId(int typeId) {
return EntityTypes1_11.getTypeFromId(typeId, false);
}
@Override
public EntityType objectTypeFromId(int typeId) {
return EntityTypes1_11.getTypeFromId(typeId, true);
}
}
@@ -0,0 +1,81 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_11_1to1_11.rewriter;
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
import com.viaversion.viabackwards.api.rewriters.LegacyEnchantmentRewriter;
import com.viaversion.viabackwards.protocol.v1_11_1to1_11.Protocol1_11_1To1_11;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
public class ItemPacketRewriter1_11_1 extends LegacyBlockItemRewriter<ClientboundPackets1_9_3, ServerboundPackets1_9_3, Protocol1_11_1To1_11> {
private LegacyEnchantmentRewriter enchantmentRewriter;
public ItemPacketRewriter1_11_1(Protocol1_11_1To1_11 protocol) {
super(protocol, "1.11.1");
}
@Override
protected void registerPackets() {
registerSetSlot(ClientboundPackets1_9_3.CONTAINER_SET_SLOT);
registerSetContent(ClientboundPackets1_9_3.CONTAINER_SET_CONTENT);
registerSetEquippedItem(ClientboundPackets1_9_3.SET_EQUIPPED_ITEM);
registerCustomPayloadTradeList(ClientboundPackets1_9_3.CUSTOM_PAYLOAD);
registerContainerClick(ServerboundPackets1_9_3.CONTAINER_CLICK);
registerSetCreativeModeSlot(ServerboundPackets1_9_3.SET_CREATIVE_MODE_SLOT);
// Handle item metadata
protocol.getEntityRewriter().filter().handler((event, meta) -> {
if (meta.dataType().type().equals(Types.ITEM1_8)) { // Is Item
meta.setValue(handleItemToClient(event.user(), (Item) meta.getValue()));
}
});
}
@Override
protected void registerRewrites() {
enchantmentRewriter = new LegacyEnchantmentRewriter(nbtTagName());
enchantmentRewriter.registerEnchantment(22, "§7Sweeping Edge");
}
@Override
public Item handleItemToClient(UserConnection connection, Item item) {
if (item == null) return null;
super.handleItemToClient(connection, item);
enchantmentRewriter.handleToClient(item);
return item;
}
@Override
public Item handleItemToServer(UserConnection connection, Item item) {
if (item == null) return null;
super.handleItemToServer(connection, item);
enchantmentRewriter.handleToServer(item);
return item;
}
}
@@ -0,0 +1,99 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_11to1_10;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.BlockItemPacketRewriter1_11;
import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.EntityPacketRewriter1_11;
import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.PlayerPacketRewriter1_11;
import com.viaversion.viabackwards.protocol.v1_11to1_10.storage.WindowTracker;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
public class Protocol1_11To1_10 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.11", "1.10");
private final EntityPacketRewriter1_11 entityRewriter = new EntityPacketRewriter1_11(this);
private final BlockItemPacketRewriter1_11 itemRewriter = new BlockItemPacketRewriter1_11(this);
private TranslatableRewriter<ClientboundPackets1_9_3> componentRewriter;
public Protocol1_11To1_10() {
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
}
@Override
protected void registerPackets() {
entityRewriter.register();
itemRewriter.register();
PlayerPacketRewriter1_11.register(this);
SoundRewriter<ClientboundPackets1_9_3> soundRewriter = new SoundRewriter<>(this);
soundRewriter.registerNamedSound(ClientboundPackets1_9_3.CUSTOM_SOUND);
soundRewriter.registerSound(ClientboundPackets1_9_3.SOUND);
componentRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
componentRewriter.registerComponentPacket(ClientboundPackets1_9_3.CHAT);
}
@Override
public void init(UserConnection user) {
if (!user.has(ClientWorld.class)) {
user.put(new ClientWorld());
}
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_11.EntityType.PLAYER));
if (!user.has(WindowTracker.class)) {
user.put(new WindowTracker());
}
}
@Override
public BackwardsMappingData getMappingData() {
return MAPPINGS;
}
@Override
public EntityPacketRewriter1_11 getEntityRewriter() {
return entityRewriter;
}
@Override
public BlockItemPacketRewriter1_11 getItemRewriter() {
return itemRewriter;
}
public TranslatableRewriter<ClientboundPackets1_9_3> getComponentRewriter() {
return componentRewriter;
}
@Override
public boolean hasMappingDataToLoad() {
return true;
}
}
@@ -0,0 +1,48 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_11to1_10.data;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
public class SplashPotionMappings1_10 {
private static final Int2IntMap DATA = new Int2IntOpenHashMap(14, 0.99F);
static {
DATA.defaultReturnValue(-1);
DATA.put(2039713, 5); // night vision
DATA.put(8356754, 7); // invisibility
DATA.put(2293580, 9); // jump boost
DATA.put(14981690, 12); // fire resistance
DATA.put(8171462, 14); // swiftness
DATA.put(5926017, 17); // slowness
DATA.put(3035801, 19); // water breathing
DATA.put(16262179, 21); // instant health
DATA.put(4393481, 23); // instant damage
DATA.put(5149489, 25); // poison
DATA.put(13458603, 28); // regeneration
DATA.put(9643043, 31); // strength
DATA.put(4738376, 34); // weakness
DATA.put(3381504, 36); // luck
}
public static int getOldData(int data) {
return DATA.get(data);
}
}
@@ -0,0 +1,358 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter;
import com.viaversion.viabackwards.api.data.MappedLegacyBlockItem;
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
import com.viaversion.viabackwards.api.rewriters.LegacyEnchantmentRewriter;
import com.viaversion.viabackwards.protocol.v1_11to1_10.Protocol1_11To1_10;
import com.viaversion.viabackwards.protocol.v1_11to1_10.storage.ChestedHorseStorage;
import com.viaversion.viabackwards.protocol.v1_11to1_10.storage.WindowTracker;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.api.minecraft.item.DataItem;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.viaversion.protocols.v1_10to1_11.data.EntityMappings1_11;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
import com.viaversion.viaversion.util.IdAndData;
import java.util.Arrays;
import java.util.Optional;
public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<ClientboundPackets1_9_3, ServerboundPackets1_9_3, Protocol1_11To1_10> {
private LegacyEnchantmentRewriter enchantmentRewriter;
public BlockItemPacketRewriter1_11(Protocol1_11To1_10 protocol) {
super(protocol, "1.11");
}
@Override
protected void registerPackets() {
registerBlockChange(ClientboundPackets1_9_3.BLOCK_UPDATE);
registerMultiBlockChange(ClientboundPackets1_9_3.CHUNK_BLOCKS_UPDATE);
protocol.registerClientbound(ClientboundPackets1_9_3.CONTAINER_SET_SLOT, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // 0 - Window ID
map(Types.SHORT); // 1 - Slot ID
map(Types.ITEM1_8); // 2 - Slot Value
handler(wrapper -> handleItemToClient(wrapper.user(), wrapper.get(Types.ITEM1_8, 0)));
// Handle Llama
handler(wrapper -> {
if (isLlama(wrapper.user())) {
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
if (horse.isEmpty()) {
return;
}
ChestedHorseStorage storage = horse.get();
int currentSlot = wrapper.get(Types.SHORT, 0);
wrapper.set(Types.SHORT, 0, ((Integer) (currentSlot = getNewSlotId(storage, currentSlot))).shortValue());
wrapper.set(Types.ITEM1_8, 0, getNewItem(storage, currentSlot, wrapper.get(Types.ITEM1_8, 0)));
}
});
}
});
protocol.registerClientbound(ClientboundPackets1_9_3.CONTAINER_SET_CONTENT, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // 0 - Window ID
map(Types.ITEM1_8_SHORT_ARRAY); // 1 - Window Values
handler(wrapper -> {
Item[] stacks = wrapper.get(Types.ITEM1_8_SHORT_ARRAY, 0);
for (int i = 0; i < stacks.length; i++)
stacks[i] = handleItemToClient(wrapper.user(), stacks[i]);
if (isLlama(wrapper.user())) {
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
if (horse.isEmpty()) {
return;
}
ChestedHorseStorage storage = horse.get();
stacks = Arrays.copyOf(stacks, !storage.isChested() ? 38 : 53);
for (int i = stacks.length - 1; i >= 0; i--) {
stacks[getNewSlotId(storage, i)] = stacks[i];
stacks[i] = getNewItem(storage, i, stacks[i]);
}
wrapper.set(Types.ITEM1_8_SHORT_ARRAY, 0, stacks);
}
});
}
});
registerSetEquippedItem(ClientboundPackets1_9_3.SET_EQUIPPED_ITEM);
registerCustomPayloadTradeList(ClientboundPackets1_9_3.CUSTOM_PAYLOAD);
protocol.registerServerbound(ServerboundPackets1_9_3.CONTAINER_CLICK, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // 0 - Window ID
map(Types.SHORT); // 1 - Slot
map(Types.BYTE); // 2 - Button
map(Types.SHORT); // 3 - Action number
map(Types.VAR_INT); // 4 - Mode
map(Types.ITEM1_8); // 5 - Clicked Item
handler(wrapper -> handleItemToServer(wrapper.user(), wrapper.get(Types.ITEM1_8, 0)));
// Llama slot
handler(wrapper -> {
if (isLlama(wrapper.user())) {
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
if (horse.isEmpty()) {
return;
}
ChestedHorseStorage storage = horse.get();
int clickSlot = wrapper.get(Types.SHORT, 0);
int correctSlot = getOldSlotId(storage, clickSlot);
wrapper.set(Types.SHORT, 0, ((Integer) correctSlot).shortValue());
}
});
}
});
registerSetCreativeModeSlot(ServerboundPackets1_9_3.SET_CREATIVE_MODE_SLOT);
protocol.registerClientbound(ClientboundPackets1_9_3.LEVEL_CHUNK, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
ChunkType1_9_3 type = ChunkType1_9_3.forEnvironment(clientWorld.getEnvironment()); // Use the 1.10 Chunk type since nothing changed.
Chunk chunk = wrapper.passthrough(type);
handleChunk(chunk);
// only patch it for signs for now
for (CompoundTag tag : chunk.getBlockEntities()) {
StringTag idTag = tag.getStringTag("id");
if (idTag == null) continue;
String id = idTag.getValue();
if (id.equals("minecraft:sign")) {
idTag.setValue("Sign");
}
}
});
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketHandlers() {
@Override
public void register() {
map(Types.BLOCK_POSITION1_8); // 0 - Position
map(Types.UNSIGNED_BYTE); // 1 - Action
map(Types.NAMED_COMPOUND_TAG); // 2 - NBT
handler(wrapper -> {
// Remove on shulkerbox decleration
if (wrapper.get(Types.UNSIGNED_BYTE, 0) == 10) {
wrapper.cancel();
}
// Handler Spawners
if (wrapper.get(Types.UNSIGNED_BYTE, 0) == 1) {
CompoundTag tag = wrapper.get(Types.NAMED_COMPOUND_TAG, 0);
EntityMappings1_11.toClientSpawner(tag, true);
}
});
}
});
protocol.registerClientbound(ClientboundPackets1_9_3.OPEN_SCREEN, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // 0 - Window ID
map(Types.STRING); // 1 - Window Type
map(Types.COMPONENT); // 2 - Title
map(Types.UNSIGNED_BYTE); // 3 - Slots
handler(wrapper -> {
int entityId = -1;
// Passthrough Entity ID
if (wrapper.get(Types.STRING, 0).equals("EntityHorse")) {
entityId = wrapper.passthrough(Types.INT);
}
// Rewrite window title
protocol.getComponentRewriter().processText(wrapper.user(), wrapper.get(Types.COMPONENT, 0));
// Track Inventory
String inventory = wrapper.get(Types.STRING, 0);
WindowTracker windowTracker = wrapper.user().get(WindowTracker.class);
windowTracker.setInventory(inventory);
windowTracker.setEntityId(entityId);
// Change llama slotcount to the donkey one
if (isLlama(wrapper.user())) {
wrapper.set(Types.UNSIGNED_BYTE, 1, (short) 17);
}
});
}
});
protocol.registerClientbound(ClientboundPackets1_9_3.CONTAINER_CLOSE, new PacketHandlers() {
@Override
public void register() {
// Inventory tracking
handler(wrapper -> {
WindowTracker windowTracker = wrapper.user().get(WindowTracker.class);
windowTracker.setInventory(null);
windowTracker.setEntityId(-1);
});
}
});
protocol.registerServerbound(ServerboundPackets1_9_3.CONTAINER_CLOSE, new PacketHandlers() {
@Override
public void register() {
// Inventory tracking
handler(wrapper -> {
WindowTracker windowTracker = wrapper.user().get(WindowTracker.class);
windowTracker.setInventory(null);
windowTracker.setEntityId(-1);
});
}
});
protocol.getEntityRewriter().filter().handler((event, meta) -> {
if (meta.dataType().type().equals(Types.ITEM1_8)) // Is Item
meta.setValue(handleItemToClient(event.user(), (Item) meta.getValue()));
});
}
@Override
protected void registerRewrites() {
// Handle spawner block entity (map to itself with custom handler)
MappedLegacyBlockItem data = itemReplacements.computeIfAbsent(IdAndData.toRawData(52), s -> new MappedLegacyBlockItem(52));
data.setBlockEntityHandler((b, tag) -> {
EntityMappings1_11.toClientSpawner(tag, true);
return tag;
});
enchantmentRewriter = new LegacyEnchantmentRewriter(nbtTagName());
enchantmentRewriter.registerEnchantment(71, "§cCurse of Vanishing");
enchantmentRewriter.registerEnchantment(10, "§cCurse of Binding");
enchantmentRewriter.setHideLevelForEnchants(71, 10); // Curses do not display their level
}
@Override
public Item handleItemToClient(UserConnection connection, Item item) {
if (item == null) return null;
super.handleItemToClient(connection, item);
CompoundTag tag = item.tag();
if (tag == null) return item;
// Rewrite spawn eggs (id checks are done in the method itself)
EntityMappings1_11.toClientItem(item, true);
enchantmentRewriter.handleToClient(item);
return item;
}
@Override
public Item handleItemToServer(UserConnection connection, Item item) {
if (item == null) return null;
super.handleItemToServer(connection, item);
CompoundTag tag = item.tag();
if (tag == null) return item;
// Rewrite spawn eggs (id checks are done in the method itself)
EntityMappings1_11.toServerItem(item, true);
enchantmentRewriter.handleToServer(item);
return item;
}
private boolean isLlama(UserConnection user) {
WindowTracker tracker = user.get(WindowTracker.class);
if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
EntityTracker entTracker = user.getEntityTracker(Protocol1_11To1_10.class);
StoredEntityData entityData = entTracker.entityData(tracker.getEntityId());
return entityData != null && entityData.type().is(EntityTypes1_11.EntityType.LLAMA);
}
return false;
}
private Optional<ChestedHorseStorage> getChestedHorse(UserConnection user) {
WindowTracker tracker = user.get(WindowTracker.class);
if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
EntityTracker entTracker = user.getEntityTracker(Protocol1_11To1_10.class);
StoredEntityData entityData = entTracker.entityData(tracker.getEntityId());
if (entityData != null)
return Optional.of(entityData.get(ChestedHorseStorage.class));
}
return Optional.empty();
}
private int getNewSlotId(ChestedHorseStorage storage, int slotId) {
int totalSlots = !storage.isChested() ? 38 : 53;
int strength = storage.isChested() ? storage.getLiamaStrength() : 0;
int startNonExistingFormula = 2 + 3 * strength;
int offsetForm = 15 - (3 * strength);
if (slotId >= startNonExistingFormula && totalSlots > (slotId + offsetForm))
return offsetForm + slotId;
if (slotId == 1)
return 0;
return slotId;
}
private int getOldSlotId(ChestedHorseStorage storage, int slotId) {
int strength = storage.isChested() ? storage.getLiamaStrength() : 0;
int startNonExistingFormula = 2 + 3 * strength;
int endNonExistingFormula = 2 + 3 * (storage.isChested() ? 5 : 0);
int offsetForm = endNonExistingFormula - startNonExistingFormula;
if (slotId == 1 || slotId >= startNonExistingFormula && slotId < endNonExistingFormula)
return 0;
if (slotId >= endNonExistingFormula)
return slotId - offsetForm;
if (slotId == 0)
return 1;
return slotId;
}
private Item getNewItem(ChestedHorseStorage storage, int slotId, Item current) {
int strength = storage.isChested() ? storage.getLiamaStrength() : 0;
int startNonExistingFormula = 2 + 3 * strength;
int endNonExistingFormula = 2 + 3 * (storage.isChested() ? 5 : 0);
if (slotId >= startNonExistingFormula && slotId < endNonExistingFormula)
return new DataItem(166, (byte) 1, (short) 0, getNamedTag("§4SLOT DISABLED"));
if (slotId == 1)
return null;
return current;
}
}
@@ -0,0 +1,368 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter;
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
import com.viaversion.viabackwards.protocol.v1_11to1_10.Protocol1_11To1_10;
import com.viaversion.viabackwards.protocol.v1_11to1_10.data.SplashPotionMappings1_10;
import com.viaversion.viabackwards.protocol.v1_11to1_10.storage.ChestedHorseStorage;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_9;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_9;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import java.util.List;
public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPackets1_9_3, Protocol1_11To1_10> {
public EntityPacketRewriter1_11(Protocol1_11To1_10 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
protocol.registerClientbound(ClientboundPackets1_9_3.LEVEL_EVENT, new PacketHandlers() {
@Override
public void register() {
map(Types.INT);
map(Types.BLOCK_POSITION1_8);
map(Types.INT);
handler(wrapper -> {
int type = wrapper.get(Types.INT, 0);
if (type == 2002 || type == 2007) {
// 2007 potion id doesn't exist in 1.10
if (type == 2007) {
wrapper.set(Types.INT, 0, 2002);
}
int mappedData = SplashPotionMappings1_10.getOldData(wrapper.get(Types.INT, 1));
if (mappedData != -1) {
wrapper.set(Types.INT, 1, mappedData);
}
}
});
}
});
protocol.registerClientbound(ClientboundPackets1_9_3.ADD_ENTITY, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity id
map(Types.UUID); // 1 - UUID
map(Types.BYTE); // 2 - Type
map(Types.DOUBLE); // 3 - x
map(Types.DOUBLE); // 4 - y
map(Types.DOUBLE); // 5 - z
map(Types.BYTE); // 6 - Pitch
map(Types.BYTE); // 7 - Yaw
map(Types.INT); // 8 - data
// Track Entity
handler(getObjectTrackerHandler());
handler(getObjectRewriter(EntityTypes1_11.ObjectType::findById));
handler(protocol.getItemRewriter().getFallingBlockHandler());
}
});
registerTracker(ClientboundPackets1_9_3.ADD_EXPERIENCE_ORB, EntityTypes1_11.EntityType.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_9_3.ADD_GLOBAL_ENTITY, EntityTypes1_11.EntityType.LIGHTNING_BOLT);
protocol.registerClientbound(ClientboundPackets1_9_3.ADD_MOB, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity id
map(Types.UUID); // 1 - UUID
map(Types.VAR_INT, Types.UNSIGNED_BYTE); // 2 - Entity Type
map(Types.DOUBLE); // 3 - X
map(Types.DOUBLE); // 4 - Y
map(Types.DOUBLE); // 5 - Z
map(Types.BYTE); // 6 - Yaw
map(Types.BYTE); // 7 - Pitch
map(Types.BYTE); // 8 - Head Pitch
map(Types.SHORT); // 9 - Velocity X
map(Types.SHORT); // 10 - Velocity Y
map(Types.SHORT); // 11 - Velocity Z
map(Types1_9.ENTITY_DATA_LIST); // 12 - Metadata
// Track entity
handler(getTrackerHandler(Types.UNSIGNED_BYTE, 0));
// Rewrite entity type / metadata
handler(getMobSpawnRewriter(Types1_9.ENTITY_DATA_LIST));
// Sub 1.11 clients will error if the list is empty
handler(wrapper -> {
List<EntityData> metadata = wrapper.get(Types1_9.ENTITY_DATA_LIST, 0);
if (metadata.isEmpty()) {
metadata.add(new EntityData(0, EntityDataTypes1_9.BYTE, (byte) 0));
}
});
}
});
registerTracker(ClientboundPackets1_9_3.ADD_PAINTING, EntityTypes1_11.EntityType.PAINTING);
registerJoinGame(ClientboundPackets1_9_3.LOGIN, EntityTypes1_11.EntityType.PLAYER);
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
protocol.registerClientbound(ClientboundPackets1_9_3.ADD_PLAYER, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity ID
map(Types.UUID); // 1 - Player UUID
map(Types.DOUBLE); // 2 - X
map(Types.DOUBLE); // 3 - Y
map(Types.DOUBLE); // 4 - Z
map(Types.BYTE); // 5 - Yaw
map(Types.BYTE); // 6 - Pitch
map(Types1_9.ENTITY_DATA_LIST); // 7 - Metadata list
handler(getTrackerAndMetaHandler(Types1_9.ENTITY_DATA_LIST, EntityTypes1_11.EntityType.PLAYER));
handler(wrapper -> {
// Sub 1.11 clients will cry if the list is empty
List<EntityData> metadata = wrapper.get(Types1_9.ENTITY_DATA_LIST, 0);
if (metadata.isEmpty()) {
metadata.add(new EntityData(0, EntityDataTypes1_9.BYTE, (byte) 0));
}
});
}
});
registerRemoveEntities(ClientboundPackets1_9_3.REMOVE_ENTITIES);
registerSetEntityData(ClientboundPackets1_9_3.SET_ENTITY_DATA, Types1_9.ENTITY_DATA_LIST);
protocol.registerClientbound(ClientboundPackets1_9_3.ENTITY_EVENT, new PacketHandlers() {
@Override
public void register() {
map(Types.INT); // 0 - Entity ID
map(Types.BYTE); // 1 - Entity Status
handler(wrapper -> {
byte b = wrapper.get(Types.BYTE, 0);
if (b == 35) {
wrapper.clearPacket();
wrapper.setPacketType(ClientboundPackets1_9_3.GAME_EVENT);
wrapper.write(Types.UNSIGNED_BYTE, (short) 10); // Play Elder Guardian animation
wrapper.write(Types.FLOAT, 0F);
}
});
}
});
}
@Override
protected void registerRewrites() {
// Guardian
mapEntityTypeWithData(EntityTypes1_11.EntityType.ELDER_GUARDIAN, EntityTypes1_11.EntityType.GUARDIAN);
// Skeletons
mapEntityTypeWithData(EntityTypes1_11.EntityType.WITHER_SKELETON, EntityTypes1_11.EntityType.SKELETON).spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(1)));
mapEntityTypeWithData(EntityTypes1_11.EntityType.STRAY, EntityTypes1_11.EntityType.SKELETON).plainName().spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(2)));
// Zombies
mapEntityTypeWithData(EntityTypes1_11.EntityType.HUSK, EntityTypes1_11.EntityType.ZOMBIE).plainName().spawnMetadata(storage -> handleZombieType(storage, 6));
mapEntityTypeWithData(EntityTypes1_11.EntityType.ZOMBIE_VILLAGER, EntityTypes1_11.EntityType.ZOMBIE).spawnMetadata(storage -> handleZombieType(storage, 1));
// Horses
mapEntityTypeWithData(EntityTypes1_11.EntityType.HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(0))); // Nob able to ride the horse without having the MetaType sent.
mapEntityTypeWithData(EntityTypes1_11.EntityType.DONKEY, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
mapEntityTypeWithData(EntityTypes1_11.EntityType.MULE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(2)));
mapEntityTypeWithData(EntityTypes1_11.EntityType.SKELETON_HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(4)));
mapEntityTypeWithData(EntityTypes1_11.EntityType.ZOMBIE_HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(3)));
// New mobs
mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOKER_FANGS, EntityTypes1_11.EntityType.SHULKER);
mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOKER, EntityTypes1_11.EntityType.VILLAGER).plainName();
mapEntityTypeWithData(EntityTypes1_11.EntityType.VEX, EntityTypes1_11.EntityType.BAT).plainName();
mapEntityTypeWithData(EntityTypes1_11.EntityType.VINDICATOR, EntityTypes1_11.EntityType.VILLAGER).plainName().spawnMetadata(storage -> storage.add(new EntityData(13, EntityDataTypes1_9.VAR_INT, 4))); // Base Profession
mapEntityTypeWithData(EntityTypes1_11.EntityType.LLAMA, EntityTypes1_11.EntityType.HORSE).plainName().spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
mapEntityTypeWithData(EntityTypes1_11.EntityType.LLAMA_SPIT, EntityTypes1_11.EntityType.SNOWBALL);
mapObjectType(EntityTypes1_11.ObjectType.LLAMA_SPIT, EntityTypes1_11.ObjectType.SNOWBALL, -1);
// Replace with endertorchthingies
mapObjectType(EntityTypes1_11.ObjectType.EVOKER_FANGS, EntityTypes1_11.ObjectType.FALLING_BLOCK, 198 | 1 << 12);
// Handle ElderGuardian & target metadata
filter().type(EntityTypes1_11.EntityType.GUARDIAN).index(12).handler((event, meta) -> {
boolean b = (boolean) meta.getValue();
int bitmask = b ? 0x02 : 0;
if (event.entityType() == EntityTypes1_11.EntityType.ELDER_GUARDIAN) {
bitmask |= 0x04;
}
meta.setTypeAndValue(EntityDataTypes1_9.BYTE, (byte) bitmask);
});
// Handle skeleton swing
filter().type(EntityTypes1_11.EntityType.ABSTRACT_SKELETON).index(12).toIndex(13);
/*
ZOMBIE CHANGES
*/
filter().type(EntityTypes1_11.EntityType.ZOMBIE).handler((event, meta) -> {
switch (meta.id()) {
case 13 -> event.cancel();
case 14 -> event.setIndex(15);
case 15 -> event.setIndex(14);
case 16 -> {
// Profession
event.setIndex(13);
meta.setValue(1 + (int) meta.getValue());
}
}
});
// Handle Evocation Illager
filter().type(EntityTypes1_11.EntityType.EVOKER).index(12).handler((event, meta) -> {
event.setIndex(13);
meta.setTypeAndValue(EntityDataTypes1_9.VAR_INT, ((Byte) meta.getValue()).intValue()); // Change the profession for the states
});
// Handle Vex (Remove this field completely since the position is not updated correctly when idling for bats. Sad ):
filter().type(EntityTypes1_11.EntityType.VEX).index(12).handler((event, meta) -> {
meta.setValue((byte) 0x00);
});
// Handle VindicationIllager
filter().type(EntityTypes1_11.EntityType.VINDICATOR).index(12).handler((event, meta) -> {
event.setIndex(13);
meta.setTypeAndValue(EntityDataTypes1_9.VAR_INT, ((Number) meta.getValue()).intValue() == 1 ? 2 : 4);
});
/*
HORSES
*/
// Handle horse flags
filter().type(EntityTypes1_11.EntityType.ABSTRACT_HORSE).index(13).handler((event, meta) -> {
StoredEntityData data = storedEntityData(event);
byte b = (byte) meta.getValue();
if (data.has(ChestedHorseStorage.class) && data.get(ChestedHorseStorage.class).isChested()) {
b |= 0x08; // Chested
meta.setValue(b);
}
});
// Create chested horse storage
filter().type(EntityTypes1_11.EntityType.CHESTED_HORSE).handler((event, meta) -> {
StoredEntityData data = storedEntityData(event);
if (!data.has(ChestedHorseStorage.class)) {
data.put(new ChestedHorseStorage());
}
});
// Handle horse armor
filter().type(EntityTypes1_11.EntityType.HORSE).index(16).toIndex(17);
// Handle chested horse
filter().type(EntityTypes1_11.EntityType.CHESTED_HORSE).index(15).handler((event, meta) -> {
StoredEntityData data = storedEntityData(event);
ChestedHorseStorage storage = data.get(ChestedHorseStorage.class);
boolean b = (boolean) meta.getValue();
storage.setChested(b);
event.cancel();
});
// Get rid of Liama metadata
filter().type(EntityTypes1_11.EntityType.LLAMA).handler((event, meta) -> {
StoredEntityData data = storedEntityData(event);
ChestedHorseStorage storage = data.get(ChestedHorseStorage.class);
int index = event.index();
// Store them for later (:
switch (index) {
case 16 -> {
storage.setLiamaStrength((int) meta.getValue());
event.cancel();
}
case 17 -> {
storage.setLiamaCarpetColor((int) meta.getValue());
event.cancel();
}
case 18 -> {
storage.setLiamaVariant((int) meta.getValue());
event.cancel();
}
}
});
// Handle Horse (Correct owner)
filter().type(EntityTypes1_11.EntityType.ABSTRACT_HORSE).index(14).toIndex(16);
// Handle villager - Change non-existing profession
filter().type(EntityTypes1_11.EntityType.VILLAGER).index(13).handler((event, meta) -> {
if ((int) meta.getValue() == 5) {
meta.setValue(0);
}
});
// handle new Shulker color meta
filter().type(EntityTypes1_11.EntityType.SHULKER).cancel(15);
}
/*
0 - Skeleton
1 - Wither Skeleton
2 - Stray
*/
private EntityData getSkeletonTypeMeta(int type) {
return new EntityData(12, EntityDataTypes1_9.VAR_INT, type);
}
/*
0 - Zombie
1-5 - Villager with profession
6 - Husk
*/
private EntityData getZombieTypeMeta(int type) {
return new EntityData(13, EntityDataTypes1_9.VAR_INT, type);
}
private void handleZombieType(WrappedMetadata storage, int type) {
EntityData meta = storage.get(13);
if (meta == null) {
storage.add(getZombieTypeMeta(type));
}
}
/*
Horse 0
Donkey 1
Mule 2
Zombie horse 3
Skeleton horse 4
*/
private EntityData getHorseMetaType(int type) {
return new EntityData(14, EntityDataTypes1_9.VAR_INT, type);
}
@Override
public EntityType typeFromId(int typeId) {
return EntityTypes1_11.getTypeFromId(typeId, false);
}
@Override
public EntityType objectTypeFromId(int typeId) {
return EntityTypes1_11.getTypeFromId(typeId, true);
}
}
@@ -0,0 +1,93 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter;
import com.viaversion.viabackwards.protocol.v1_11to1_10.Protocol1_11To1_10;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
import com.viaversion.viaversion.util.ComponentUtil;
public class PlayerPacketRewriter1_11 {
private static final ValueTransformer<Short, Float> TO_NEW_FLOAT = new ValueTransformer<>(Types.FLOAT) {
@Override
public Float transform(PacketWrapper wrapper, Short inputValue) {
return inputValue / 16f;
}
};
public static void register(Protocol1_11To1_10 protocol) {
protocol.registerClientbound(ClientboundPackets1_9_3.SET_TITLES, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Action
handler(wrapper -> {
int action = wrapper.get(Types.VAR_INT, 0);
if (action == 2) { // Handle the new ActionBar
JsonElement message = wrapper.read(Types.COMPONENT);
wrapper.clearPacket();
wrapper.setPacketType(ClientboundPackets1_9_3.CHAT);
// https://bugs.mojang.com/browse/MC-119145
String legacy = ComponentUtil.jsonToLegacy(message);
message = new JsonObject();
message.getAsJsonObject().addProperty("text", legacy);
wrapper.write(Types.COMPONENT, message);
wrapper.write(Types.BYTE, (byte) 2);
} else if (action > 2) {
wrapper.set(Types.VAR_INT, 0, action - 1); // Move everything one position down
}
});
}
});
protocol.registerClientbound(ClientboundPackets1_9_3.TAKE_ITEM_ENTITY, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Collected entity id
map(Types.VAR_INT); // 1 - Collector entity id
handler(wrapper -> wrapper.read(Types.VAR_INT)); // Ignore item pickup count
}
});
protocol.registerServerbound(ServerboundPackets1_9_3.USE_ITEM_ON, new PacketHandlers() {
@Override
public void register() {
map(Types.BLOCK_POSITION1_8); // 0 - Location
map(Types.VAR_INT); // 1 - Face
map(Types.VAR_INT); // 2 - Hand
map(Types.UNSIGNED_BYTE, TO_NEW_FLOAT);
map(Types.UNSIGNED_BYTE, TO_NEW_FLOAT);
map(Types.UNSIGNED_BYTE, TO_NEW_FLOAT);
}
});
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_11to1_10.storage;
public class ChestedHorseStorage {
private boolean chested;
private int liamaStrength;
private int liamaCarpetColor = -1;
private int liamaVariant;
public boolean isChested() {
return chested;
}
public void setChested(boolean chested) {
this.chested = chested;
}
public int getLiamaStrength() {
return liamaStrength;
}
public void setLiamaStrength(int liamaStrength) {
this.liamaStrength = liamaStrength;
}
public int getLiamaCarpetColor() {
return liamaCarpetColor;
}
public void setLiamaCarpetColor(int liamaCarpetColor) {
this.liamaCarpetColor = liamaCarpetColor;
}
public int getLiamaVariant() {
return liamaVariant;
}
public void setLiamaVariant(int liamaVariant) {
this.liamaVariant = liamaVariant;
}
@Override
public String toString() {
return "ChestedHorseStorage{" + "chested=" + chested + ", liamaStrength=" + liamaStrength + ", liamaCarpetColor=" + liamaCarpetColor + ", liamaVariant=" + liamaVariant + '}';
}
}
@@ -0,0 +1,48 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_11to1_10.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
public class WindowTracker implements StorableObject {
private String inventory;
private int entityId = -1;
public String getInventory() {
return inventory;
}
public void setInventory(String inventory) {
this.inventory = inventory;
}
public int getEntityId() {
return entityId;
}
public void setEntityId(int entityId) {
this.entityId = entityId;
}
@Override
public String toString() {
return "WindowTracker{" + "inventory='" + inventory + '\'' + ", entityId=" + entityId + '}';
}
}
@@ -0,0 +1,37 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12_1to1_12;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ServerboundPackets1_12;
import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ClientboundPackets1_12_1;
import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ServerboundPackets1_12_1;
public class Protocol1_12_1To1_12 extends BackwardsProtocol<ClientboundPackets1_12_1, ClientboundPackets1_12, ServerboundPackets1_12_1, ServerboundPackets1_12> {
public Protocol1_12_1To1_12() {
super(ClientboundPackets1_12_1.class, ClientboundPackets1_12.class, ServerboundPackets1_12_1.class, ServerboundPackets1_12.class);
}
@Override
protected void registerPackets() {
cancelClientbound(ClientboundPackets1_12_1.PLACE_GHOST_RECIPE);
cancelServerbound(ServerboundPackets1_12.CRAFTING_RECIPE_PLACEMENT);
}
}
@@ -0,0 +1,70 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12_2to1_12_1;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.protocol.v1_12_2to1_12_1.storage.KeepAliveTracker;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ClientboundPackets1_12_1;
import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ServerboundPackets1_12_1;
public class Protocol1_12_2To1_12_1 extends BackwardsProtocol<ClientboundPackets1_12_1, ClientboundPackets1_12_1, ServerboundPackets1_12_1, ServerboundPackets1_12_1> {
public Protocol1_12_2To1_12_1() {
super(ClientboundPackets1_12_1.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12_1.class, ServerboundPackets1_12_1.class);
}
@Override
protected void registerPackets() {
registerClientbound(ClientboundPackets1_12_1.KEEP_ALIVE, new PacketHandlers() {
@Override
public void register() {
handler(packetWrapper -> {
Long keepAlive = packetWrapper.read(Types.LONG);
packetWrapper.user().get(KeepAliveTracker.class).setKeepAlive(keepAlive);
packetWrapper.write(Types.VAR_INT, keepAlive.hashCode());
});
}
});
registerServerbound(ServerboundPackets1_12_1.KEEP_ALIVE, new PacketHandlers() {
@Override
public void register() {
handler(packetWrapper -> {
int keepAlive = packetWrapper.read(Types.VAR_INT);
long realKeepAlive = packetWrapper.user().get(KeepAliveTracker.class).getKeepAlive();
if (keepAlive != Long.hashCode(realKeepAlive)) {
packetWrapper.cancel(); // Wrong data, cancel packet
return;
}
packetWrapper.write(Types.LONG, realKeepAlive);
// Reset KeepAliveTracker (to prevent sending same valid value in a row causing a timeout)
packetWrapper.user().get(KeepAliveTracker.class).setKeepAlive(Integer.MAX_VALUE);
});
}
});
}
@Override
public void init(UserConnection userConnection) {
userConnection.put(new KeepAliveTracker());
}
}
@@ -0,0 +1,38 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12_2to1_12_1.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
public class KeepAliveTracker implements StorableObject {
private long keepAlive = Integer.MAX_VALUE;
public long getKeepAlive() {
return keepAlive;
}
public void setKeepAlive(long keepAlive) {
this.keepAlive = keepAlive;
}
@Override
public String toString() {
return "KeepAliveTracker{" + "keepAlive=" + keepAlive + '}';
}
}
@@ -0,0 +1,106 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12to1_11_1;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.storage.ShoulderTracker;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter.BlockItemPacketRewriter1_12;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter.ComponentRewriter1_12;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter.EntityPacketRewriter1_12;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter.SoundPacketRewriter1_12;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ServerboundPackets1_12;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
import com.viaversion.viaversion.util.ComponentUtil;
import com.viaversion.viaversion.util.SerializerVersion;
public class Protocol1_12To1_11_1 extends BackwardsProtocol<ClientboundPackets1_12, ClientboundPackets1_9_3, ServerboundPackets1_12, ServerboundPackets1_9_3> {
private static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.12", "1.11");
private final EntityPacketRewriter1_12 entityRewriter = new EntityPacketRewriter1_12(this);
private final BlockItemPacketRewriter1_12 itemRewriter = new BlockItemPacketRewriter1_12(this);
private final ComponentRewriter1_12 componentRewriter = new ComponentRewriter1_12(this);
public Protocol1_12To1_11_1() {
super(ClientboundPackets1_12.class, ClientboundPackets1_9_3.class, ServerboundPackets1_12.class, ServerboundPackets1_9_3.class);
}
@Override
protected void registerPackets() {
itemRewriter.register();
entityRewriter.register();
componentRewriter.registerComponentPacket(ClientboundPackets1_12.CHAT);
new SoundPacketRewriter1_12(this).register();
registerClientbound(ClientboundPackets1_12.SET_TITLES, wrapper -> {
int action = wrapper.passthrough(Types.VAR_INT);
if (action >= 0 && action <= 2) {
// Should be done globally in the component rewriter, but /shrug for now
String component = wrapper.read(Types.COMPONENT).toString();
wrapper.write(Types.COMPONENT, ComponentUtil.convertJsonOrEmpty(component, SerializerVersion.V1_12, SerializerVersion.V1_9));
}
});
cancelClientbound(ClientboundPackets1_12.UPDATE_ADVANCEMENTS);
cancelClientbound(ClientboundPackets1_12.RECIPE);
cancelClientbound(ClientboundPackets1_12.SELECT_ADVANCEMENTS_TAB);
}
@Override
public void init(UserConnection user) {
if (!user.has(ClientWorld.class)) {
user.put(new ClientWorld());
}
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_12.EntityType.PLAYER));
user.put(new ShoulderTracker(user));
}
@Override
public BackwardsMappingData getMappingData() {
return MAPPINGS;
}
@Override
public EntityPacketRewriter1_12 getEntityRewriter() {
return entityRewriter;
}
@Override
public BlockItemPacketRewriter1_12 getItemRewriter() {
return itemRewriter;
}
public ComponentRewriter1_12 getComponentRewriter() {
return componentRewriter;
}
@Override
public boolean hasMappingDataToLoad() {
return true;
}
}
@@ -0,0 +1,46 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.data;
public class BlockColors1_11_1 {
private static final String[] COLORS = new String[16];
static {
COLORS[0] = "White";
COLORS[1] = "Orange";
COLORS[2] = "Magenta";
COLORS[3] = "Light Blue";
COLORS[4] = "Yellow";
COLORS[5] = "Lime";
COLORS[6] = "Pink";
COLORS[7] = "Gray";
COLORS[8] = "Light Gray";
COLORS[9] = "Cyan";
COLORS[10] = "Purple";
COLORS[11] = "Blue";
COLORS[12] = "Brown";
COLORS[13] = "Green";
COLORS[14] = "Red";
COLORS[15] = "Black";
}
public static String get(int key) {
return key >= 0 && key < COLORS.length ? COLORS[key] : "Unknown color";
}
}
@@ -0,0 +1,97 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.data;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
public class MapColorMappings1_11_1 {
private static final Int2IntMap MAPPING = new Int2IntOpenHashMap(64, 0.99F);
static {
MAPPING.defaultReturnValue(-1);
MAPPING.put(144, 59); // (148, 124, 114) -> (148, 124, 114)
MAPPING.put(145, 56); // (180, 153, 139) -> (180, 153, 139)
MAPPING.put(146, 56); // (209, 177, 161) -> (209, 177, 161)
MAPPING.put(147, 45); // (111, 94, 85) -> (111, 94, 85)
MAPPING.put(148, 63); // (112, 58, 25) -> (112, 58, 25)
MAPPING.put(149, 60); // (137, 71, 31) -> (137, 71, 31)
MAPPING.put(150, 60); // (159, 82, 36) -> (159, 82, 36)
MAPPING.put(151, 136); // (84, 43, 19) -> (84, 43, 19)
MAPPING.put(152, 83); // (105, 61, 76) -> (105, 61, 76)
MAPPING.put(153, 83); // (129, 75, 93) -> (129, 75, 93)
MAPPING.put(154, 80); // (149, 87, 108) -> (149, 87, 108)
MAPPING.put(155, 115); // (79, 46, 57) -> (79, 46, 57)
MAPPING.put(156, 39); // (79, 76, 97) -> (79, 76, 97)
MAPPING.put(157, 39); // (97, 93, 119) -> (97, 93, 119)
MAPPING.put(158, 36); // (112, 108, 138) -> (112, 108, 138)
MAPPING.put(159, 47); // (59, 57, 73) -> (59, 57, 73)
MAPPING.put(160, 60); // (131, 94, 25) -> (131, 94, 25)
MAPPING.put(161, 61); // (160, 115, 31) -> (160, 115, 31)
MAPPING.put(162, 62); // (186, 133, 36) -> (186, 133, 36)
MAPPING.put(163, 137); // (98, 70, 19) -> (98, 70, 19)
MAPPING.put(164, 108); // (73, 83, 37) -> (73, 83, 37)
MAPPING.put(165, 108); // (89, 101, 46) -> (89, 101, 46)
MAPPING.put(166, 109); // (103, 117, 53) -> (103, 117, 53)
MAPPING.put(167, 111); // (55, 62, 28) -> (55, 62, 28)
MAPPING.put(168, 112); // (113, 54, 55) -> (113, 54, 55)
MAPPING.put(169, 113); // (138, 66, 67) -> (138, 66, 67)
MAPPING.put(170, 114); // (160, 77, 78) -> (160, 77, 78)
MAPPING.put(171, 115); // (85, 41, 41) -> (85, 41, 41)
MAPPING.put(172, 118); // (40, 29, 25) -> (40, 29, 25)
MAPPING.put(173, 107); // (49, 35, 30) -> (49, 35, 30)
MAPPING.put(174, 107); // (57, 41, 35) -> (57, 41, 35)
MAPPING.put(175, 118); // (30, 22, 19) -> (30, 22, 19)
MAPPING.put(176, 91); // (95, 76, 69) -> (95, 76, 69)
MAPPING.put(177, 45); // (116, 92, 85) -> (116, 92, 85)
MAPPING.put(178, 46); // (135, 107, 98) -> (135, 107, 98)
MAPPING.put(179, 47); // (71, 57, 52) -> (71, 57, 52)
MAPPING.put(180, 85); // (61, 65, 65) -> (61, 65, 65)
MAPPING.put(181, 44); // (75, 79, 79) -> (75, 79, 79)
MAPPING.put(182, 27); // (87, 92, 92) -> (87, 92, 92)
MAPPING.put(183, 84); // (46, 49, 49) -> (46, 49, 49)
MAPPING.put(184, 83); // (86, 52, 62) -> (86, 52, 62)
MAPPING.put(185, 83); // (105, 63, 76) -> (105, 63, 76)
MAPPING.put(186, 83); // (122, 73, 88) -> (122, 73, 88)
MAPPING.put(187, 84); // (65, 39, 47) -> (65, 39, 47)
MAPPING.put(188, 84); // (54, 44, 65) -> (54, 44, 65)
MAPPING.put(189, 71); // (66, 53, 79) -> (66, 53, 79)
MAPPING.put(190, 71); // (76, 62, 92) -> (76, 62, 92)
MAPPING.put(191, 87); // (40, 33, 49) -> (40, 33, 49)
MAPPING.put(192, 107); // (54, 35, 25) -> (54, 35, 25)
MAPPING.put(193, 139); // (66, 43, 30) -> (66, 43, 30)
MAPPING.put(194, 43); // (76, 50, 35) -> (76, 50, 35)
MAPPING.put(195, 107); // (40, 26, 19) -> (40, 26, 19)
MAPPING.put(196, 111); // (54, 58, 30) -> (54, 58, 30)
MAPPING.put(197, 111); // (66, 71, 36) -> (66, 71, 36)
MAPPING.put(198, 111); // (76, 82, 42) -> (76, 82, 42)
MAPPING.put(199, 107); // (40, 43, 22) -> (40, 43, 22)
MAPPING.put(200, 112); // (100, 42, 32) -> (100, 42, 32)
MAPPING.put(201, 113); // (123, 52, 40) -> (123, 52, 40)
MAPPING.put(202, 113); // (142, 60, 46) -> (142, 60, 46)
MAPPING.put(203, 115); // (75, 32, 24) -> (75, 32, 24)
MAPPING.put(204, 116); // (26, 16, 11) -> (26, 16, 11)
MAPPING.put(205, 117); // (32, 19, 14) -> (32, 19, 14)
MAPPING.put(206, 107); // (37, 22, 16) -> (37, 22, 16)
MAPPING.put(207, 119); // (20, 12, 8) -> (20, 12, 8)
}
public static int getNearestOldColor(int color) {
return MAPPING.getOrDefault(color, color);
}
}
@@ -0,0 +1,253 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter;
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.data.MapColorMappings1_11_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.IntArrayTag;
import com.viaversion.nbt.tag.LongArrayTag;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ServerboundPackets1_12;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
import java.util.Iterator;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.Nullable;
public class BlockItemPacketRewriter1_12 extends LegacyBlockItemRewriter<ClientboundPackets1_12, ServerboundPackets1_9_3, Protocol1_12To1_11_1> {
public BlockItemPacketRewriter1_12(Protocol1_12To1_11_1 protocol) {
super(protocol, "1.12");
}
@Override
protected void registerPackets() {
registerBlockChange(ClientboundPackets1_12.BLOCK_UPDATE);
registerMultiBlockChange(ClientboundPackets1_12.CHUNK_BLOCKS_UPDATE);
protocol.registerClientbound(ClientboundPackets1_12.MAP_ITEM_DATA, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT);
map(Types.BYTE);
map(Types.BOOLEAN);
handler(wrapper -> {
int count = wrapper.passthrough(Types.VAR_INT);
for (int i = 0; i < count * 3; i++) {
wrapper.passthrough(Types.BYTE);
}
});
handler(wrapper -> {
short columns = wrapper.passthrough(Types.UNSIGNED_BYTE);
if (columns <= 0) return;
wrapper.passthrough(Types.UNSIGNED_BYTE); // Rows
wrapper.passthrough(Types.UNSIGNED_BYTE); // X
wrapper.passthrough(Types.UNSIGNED_BYTE); // Z
byte[] data = wrapper.read(Types.BYTE_ARRAY_PRIMITIVE);
for (int i = 0; i < data.length; i++) {
short color = (short) (data[i] & 0xFF);
if (color > 143) {
color = (short) MapColorMappings1_11_1.getNearestOldColor(color);
data[i] = (byte) color;
}
}
wrapper.write(Types.BYTE_ARRAY_PRIMITIVE, data);
});
}
});
registerSetSlot(ClientboundPackets1_12.CONTAINER_SET_SLOT);
registerSetContent(ClientboundPackets1_12.CONTAINER_SET_CONTENT);
registerSetEquippedItem(ClientboundPackets1_12.SET_EQUIPPED_ITEM);
registerCustomPayloadTradeList(ClientboundPackets1_12.CUSTOM_PAYLOAD);
protocol.registerServerbound(ServerboundPackets1_9_3.CONTAINER_CLICK, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // 0 - Window ID
map(Types.SHORT); // 1 - Slot
map(Types.BYTE); // 2 - Button
map(Types.SHORT); // 3 - Action number
map(Types.VAR_INT); // 4 - Mode
map(Types.ITEM1_8); // 5 - Clicked Item
handler(wrapper -> {
if (wrapper.get(Types.VAR_INT, 0) == 1) { // Shift click
// https://github.com/ViaVersion/ViaVersion/pull/754
// Previously clients grab the item from the clicked slot *before* it has
// been moved however now they grab the slot item *after* it has been moved
// and send that in the packet.
wrapper.set(Types.ITEM1_8, 0, null); // Set null item (probably will work)
// Apologize (may happen in some cases, maybe if inventory is full?)
PacketWrapper confirm = wrapper.create(ServerboundPackets1_12.CONTAINER_ACK);
confirm.write(Types.UNSIGNED_BYTE, wrapper.get(Types.UNSIGNED_BYTE, 0));
confirm.write(Types.SHORT, wrapper.get(Types.SHORT, 1));
confirm.write(Types.BOOLEAN, false); // Success - not used
wrapper.sendToServer(Protocol1_12To1_11_1.class);
wrapper.cancel();
confirm.sendToServer(Protocol1_12To1_11_1.class);
return;
}
Item item = wrapper.get(Types.ITEM1_8, 0);
handleItemToServer(wrapper.user(), item);
});
}
});
registerSetCreativeModeSlot(ServerboundPackets1_9_3.SET_CREATIVE_MODE_SLOT);
protocol.registerClientbound(ClientboundPackets1_12.LEVEL_CHUNK, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
ChunkType1_9_3 type = ChunkType1_9_3.forEnvironment(clientWorld.getEnvironment()); // Use the 1.9.4 Chunk type since nothing changed.
Chunk chunk = wrapper.passthrough(type);
handleChunk(chunk);
});
protocol.registerClientbound(ClientboundPackets1_12.BLOCK_ENTITY_DATA, new PacketHandlers() {
@Override
public void register() {
map(Types.BLOCK_POSITION1_8); // 0 - Position
map(Types.UNSIGNED_BYTE); // 1 - Action
map(Types.NAMED_COMPOUND_TAG); // 2 - NBT
handler(wrapper -> {
// Remove bed color
if (wrapper.get(Types.UNSIGNED_BYTE, 0) == 11)
wrapper.cancel();
});
}
});
protocol.getEntityRewriter().filter().handler((event, meta) -> {
if (meta.dataType().type().equals(Types.ITEM1_8)) // Is Item
meta.setValue(handleItemToClient(event.user(), (Item) meta.getValue()));
});
protocol.registerServerbound(ServerboundPackets1_9_3.CLIENT_COMMAND, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // Action ID
handler(wrapper -> {
// Open Inventory
if (wrapper.get(Types.VAR_INT, 0) == 2) {
wrapper.cancel();
}
});
}
});
}
@Override
public @Nullable Item handleItemToClient(UserConnection connection, Item item) {
if (item == null) return null;
super.handleItemToClient(connection, item);
if (item.tag() != null) {
CompoundTag backupTag = new CompoundTag();
if (handleNbtToClient(item.tag(), backupTag)) {
item.tag().put("Via|LongArrayTags", backupTag);
}
}
return item;
}
private boolean handleNbtToClient(CompoundTag compoundTag, CompoundTag backupTag) {
// Long array tags were introduced in 1.12 - just remove them
// Only save the removed tags instead of blindly copying the entire nbt again
Iterator<Map.Entry<String, Tag>> iterator = compoundTag.iterator();
boolean hasLongArrayTag = false;
while (iterator.hasNext()) {
Map.Entry<String, Tag> entry = iterator.next();
if (entry.getValue() instanceof CompoundTag tag) {
CompoundTag nestedBackupTag = new CompoundTag();
backupTag.put(entry.getKey(), nestedBackupTag);
hasLongArrayTag |= handleNbtToClient(tag, nestedBackupTag);
} else if (entry.getValue() instanceof LongArrayTag tag) {
backupTag.put(entry.getKey(), fromLongArrayTag(tag));
iterator.remove();
hasLongArrayTag = true;
}
}
return hasLongArrayTag;
}
@Override
public @Nullable Item handleItemToServer(UserConnection connection, Item item) {
if (item == null) return null;
super.handleItemToServer(connection, item);
if (item.tag() != null) {
if (item.tag().remove("Via|LongArrayTags") instanceof CompoundTag tag) {
handleNbtToServer(item.tag(), tag);
}
}
return item;
}
private void handleNbtToServer(CompoundTag compoundTag, CompoundTag backupTag) {
// Restore the removed long array tags
for (Map.Entry<String, Tag> entry : backupTag) {
if (entry.getValue() instanceof CompoundTag) {
CompoundTag nestedTag = compoundTag.getCompoundTag(entry.getKey());
handleNbtToServer(nestedTag, (CompoundTag) entry.getValue());
} else {
compoundTag.put(entry.getKey(), fromIntArrayTag((IntArrayTag) entry.getValue()));
}
}
}
private IntArrayTag fromLongArrayTag(LongArrayTag tag) {
int[] intArray = new int[tag.length() * 2];
long[] longArray = tag.getValue();
int i = 0;
for (long l : longArray) {
intArray[i++] = (int) (l >> 32);
intArray[i++] = (int) l;
}
return new IntArrayTag(intArray);
}
private LongArrayTag fromIntArrayTag(IntArrayTag tag) {
long[] longArray = new long[tag.length() / 2];
int[] intArray = tag.getValue();
for (int i = 0, j = 0; i < intArray.length; i += 2, j++) {
longArray[j] = (long) intArray[i] << 32 | ((long) intArray[i + 1] & 0xFFFFFFFFL);
}
return new LongArrayTag(longArray);
}
}
@@ -0,0 +1,51 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
public class ComponentRewriter1_12 extends TranslatableRewriter<ClientboundPackets1_12> {
public ComponentRewriter1_12(Protocol1_12To1_11_1 protocol) {
super(protocol, ComponentRewriter.ReadType.JSON);
}
@Override
public void processText(UserConnection connection, JsonElement element) {
super.processText(connection, element);
if (element == null || !element.isJsonObject()) {
return;
}
JsonObject object = element.getAsJsonObject();
JsonElement keybind = object.remove("keybind");
if (keybind == null) {
return;
}
//TODO Add nicer text for the key, also use this component rewriter in more packets
object.addProperty("text", keybind.getAsString());
}
}
@@ -0,0 +1,295 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter;
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.storage.ParrotStorage;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.storage.ShoulderTracker;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_12;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_12;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import com.viaversion.nbt.tag.CompoundTag;
public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPackets1_12, Protocol1_12To1_11_1> {
public EntityPacketRewriter1_12(Protocol1_12To1_11_1 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
protocol.registerClientbound(ClientboundPackets1_12.ADD_ENTITY, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity id
map(Types.UUID); // 1 - UUID
map(Types.BYTE); // 2 - Type
map(Types.DOUBLE); // 3 - x
map(Types.DOUBLE); // 4 - y
map(Types.DOUBLE); // 5 - z
map(Types.BYTE); // 6 - Pitch
map(Types.BYTE); // 7 - Yaw
map(Types.INT); // 8 - data
// Track Entity
handler(getObjectTrackerHandler());
handler(getObjectRewriter(EntityTypes1_12.ObjectType::findById));
handler(protocol.getItemRewriter().getFallingBlockHandler());
}
});
registerTracker(ClientboundPackets1_12.ADD_EXPERIENCE_ORB, EntityTypes1_12.EntityType.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_12.ADD_GLOBAL_ENTITY, EntityTypes1_12.EntityType.LIGHTNING_BOLT);
protocol.registerClientbound(ClientboundPackets1_12.ADD_MOB, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity id
map(Types.UUID); // 1 - UUID
map(Types.VAR_INT); // 2 - Entity Type
map(Types.DOUBLE); // 3 - X
map(Types.DOUBLE); // 4 - Y
map(Types.DOUBLE); // 5 - Z
map(Types.BYTE); // 6 - Yaw
map(Types.BYTE); // 7 - Pitch
map(Types.BYTE); // 8 - Head Pitch
map(Types.SHORT); // 9 - Velocity X
map(Types.SHORT); // 10 - Velocity Y
map(Types.SHORT); // 11 - Velocity Z
map(Types1_12.ENTITY_DATA_LIST); // 12 - Metadata
// Track entity
handler(getTrackerHandler());
// Rewrite entity type / metadata
handler(getMobSpawnRewriter1_11(Types1_12.ENTITY_DATA_LIST));
}
});
registerTracker(ClientboundPackets1_12.ADD_PAINTING, EntityTypes1_12.EntityType.PAINTING);
protocol.registerClientbound(ClientboundPackets1_12.ADD_PLAYER, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity ID
map(Types.UUID); // 1 - Player UUID
map(Types.DOUBLE); // 2 - X
map(Types.DOUBLE); // 3 - Y
map(Types.DOUBLE); // 4 - Z
map(Types.BYTE); // 5 - Yaw
map(Types.BYTE); // 6 - Pitch
map(Types1_12.ENTITY_DATA_LIST); // 7 - Metadata list
handler(getTrackerAndMetaHandler(Types1_12.ENTITY_DATA_LIST, EntityTypes1_12.EntityType.PLAYER));
}
});
protocol.registerClientbound(ClientboundPackets1_12.LOGIN, new PacketHandlers() {
@Override
public void register() {
map(Types.INT); // 0 - Entity ID
map(Types.UNSIGNED_BYTE); // 1 - Gamemode
map(Types.INT); // 2 - Dimension
handler(getTrackerHandler(EntityTypes1_12.EntityType.PLAYER, Types.INT));
handler(getDimensionHandler(1));
handler(wrapper -> {
ShoulderTracker tracker = wrapper.user().get(ShoulderTracker.class);
tracker.setEntityId(wrapper.get(Types.INT, 0));
});
// Send fake inventory achievement
handler(packetWrapper -> {
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9_3.AWARD_STATS, packetWrapper.user());
wrapper.write(Types.VAR_INT, 1);
wrapper.write(Types.STRING, "achievement.openInventory");
wrapper.write(Types.VAR_INT, 1);
wrapper.scheduleSend(Protocol1_12To1_11_1.class);
});
}
});
registerRespawn(ClientboundPackets1_12.RESPAWN);
registerRemoveEntities(ClientboundPackets1_12.REMOVE_ENTITIES);
registerSetEntityData(ClientboundPackets1_12.SET_ENTITY_DATA, Types1_12.ENTITY_DATA_LIST);
protocol.registerClientbound(ClientboundPackets1_12.UPDATE_ATTRIBUTES, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT);
map(Types.INT);
handler(wrapper -> {
int size = wrapper.get(Types.INT, 0);
int newSize = size;
for (int i = 0; i < size; i++) {
String key = wrapper.read(Types.STRING);
// Remove new attribute
if (key.equals("generic.flyingSpeed")) {
newSize--;
wrapper.read(Types.DOUBLE);
int modSize = wrapper.read(Types.VAR_INT);
for (int j = 0; j < modSize; j++) {
wrapper.read(Types.UUID);
wrapper.read(Types.DOUBLE);
wrapper.read(Types.BYTE);
}
} else {
wrapper.write(Types.STRING, key);
wrapper.passthrough(Types.DOUBLE);
int modSize = wrapper.passthrough(Types.VAR_INT);
for (int j = 0; j < modSize; j++) {
wrapper.passthrough(Types.UUID);
wrapper.passthrough(Types.DOUBLE);
wrapper.passthrough(Types.BYTE);
}
}
}
if (newSize != size) {
wrapper.set(Types.INT, 0, newSize);
}
});
}
});
}
@Override
protected void registerRewrites() {
mapEntityTypeWithData(EntityTypes1_12.EntityType.PARROT, EntityTypes1_12.EntityType.BAT).plainName().spawnMetadata(storage -> storage.add(new EntityData(12, EntityDataTypes1_12.BYTE, (byte) 0x00)));
mapEntityTypeWithData(EntityTypes1_12.EntityType.ILLUSIONER, EntityTypes1_12.EntityType.EVOKER).plainName();
filter().handler((event, meta) -> {
if (meta.dataType() == EntityDataTypes1_12.COMPONENT) {
protocol.getComponentRewriter().processText(event.user(), (JsonElement) meta.getValue());
}
});
// Handle Illager
filter().type(EntityTypes1_12.EntityType.EVOKER).removeIndex(12);
filter().type(EntityTypes1_12.EntityType.ILLUSIONER).index(0).handler((event, meta) -> {
byte mask = (byte) meta.getValue();
if ((mask & 0x20) == 0x20) {
mask &= ~0x20;
}
meta.setValue(mask);
});
// Create Parrot storage
filter().type(EntityTypes1_12.EntityType.PARROT).handler((event, meta) -> {
StoredEntityData data = storedEntityData(event);
if (!data.has(ParrotStorage.class)) {
data.put(new ParrotStorage());
}
});
// Parrot remove animal metadata
filter().type(EntityTypes1_12.EntityType.PARROT).cancel(12); // Is baby
filter().type(EntityTypes1_12.EntityType.PARROT).index(13).handler((event, meta) -> {
StoredEntityData data = storedEntityData(event);
ParrotStorage storage = data.get(ParrotStorage.class);
boolean isSitting = (((byte) meta.getValue()) & 0x01) == 0x01;
boolean isTamed = (((byte) meta.getValue()) & 0x04) == 0x04;
if (!storage.isTamed() && isTamed) {
// TODO do something to let the user know it's done
}
storage.setTamed(isTamed);
if (isSitting) {
event.setIndex(12);
meta.setValue((byte) 0x01);
storage.setSitting(true);
} else if (storage.isSitting()) {
event.setIndex(12);
meta.setValue((byte) 0x00);
storage.setSitting(false);
} else {
event.cancel();
}
}); // Flags (Is sitting etc, might be useful in the future
filter().type(EntityTypes1_12.EntityType.PARROT).cancel(14); // Owner
filter().type(EntityTypes1_12.EntityType.PARROT).cancel(15); // Variant
// Left shoulder entity data
filter().type(EntityTypes1_12.EntityType.PLAYER).index(15).handler((event, meta) -> {
CompoundTag tag = (CompoundTag) meta.getValue();
ShoulderTracker tracker = event.user().get(ShoulderTracker.class);
if (tag.isEmpty() && tracker.getLeftShoulder() != null) {
tracker.setLeftShoulder(null);
tracker.update();
} else if (tag.getStringTag("id") != null && event.entityId() == tracker.getEntityId()) {
String id = tag.getStringTag("id").getValue();
if (tracker.getLeftShoulder() == null || !tracker.getLeftShoulder().equals(id)) {
tracker.setLeftShoulder(id);
tracker.update();
}
}
event.cancel();
});
// Right shoulder entity data
filter().type(EntityTypes1_12.EntityType.PLAYER).index(16).handler((event, meta) -> {
CompoundTag tag = (CompoundTag) event.data().getValue();
ShoulderTracker tracker = event.user().get(ShoulderTracker.class);
if (tag.isEmpty() && tracker.getRightShoulder() != null) {
tracker.setRightShoulder(null);
tracker.update();
} else if (tag.getStringTag("id") != null && event.entityId() == tracker.getEntityId()) {
String id = tag.getStringTag("id").getValue();
if (tracker.getRightShoulder() == null || !tracker.getRightShoulder().equals(id)) {
tracker.setRightShoulder(id);
tracker.update();
}
}
event.cancel();
});
}
@Override
public EntityType typeFromId(int typeId) {
return EntityTypes1_12.getTypeFromId(typeId, false);
}
@Override
public EntityType objectTypeFromId(int typeId) {
return EntityTypes1_12.getTypeFromId(typeId, true);
}
}
@@ -0,0 +1,151 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter;
import com.viaversion.viabackwards.api.rewriters.LegacySoundRewriter;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
public class SoundPacketRewriter1_12 extends LegacySoundRewriter<Protocol1_12To1_11_1> {
public SoundPacketRewriter1_12(Protocol1_12To1_11_1 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
protocol.registerClientbound(ClientboundPackets1_12.CUSTOM_SOUND, new PacketHandlers() {
@Override
public void register() {
map(Types.STRING); // 0 - Sound name
map(Types.VAR_INT); // 1 - Sound Category
map(Types.INT); // 2 - x
map(Types.INT); // 3 - y
map(Types.INT); // 4 - z
map(Types.FLOAT); // 5 - Volume
map(Types.FLOAT); // 6 - Pitch
}
});
protocol.registerClientbound(ClientboundPackets1_12.SOUND, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Sound name
map(Types.VAR_INT); // 1 - Sound Category
map(Types.INT); // 2 - x
map(Types.INT); // 3 - y
map(Types.INT); // 4 - z
map(Types.FLOAT); // 5 - Volume
map(Types.FLOAT); // 6 - Pitch
handler(wrapper -> {
int oldId = wrapper.get(Types.VAR_INT, 0);
int newId = handleSounds(oldId);
if (newId == -1) {
wrapper.cancel();
return;
}
if (hasPitch(oldId)) {
wrapper.set(Types.FLOAT, 1, handlePitch(oldId));
}
wrapper.set(Types.VAR_INT, 0, newId);
});
}
});
}
@Override
protected void registerRewrites() {
//TODO use the diff file to also have named sound remaps
// (there were *A LOT* of refactored names)
// Replacement sounds, suggestions are always welcome
// Automatically generated from PAaaS
added(26, 277, 1.4f); // block.end_portal.spawn -> entity.lightning.thunder
added(27, -1); // block.end_portal_frame.fill
added(72, 70); // block.note.bell -> block.note.harp
added(73, 70); // block.note.chime -> block.note.harp
added(74, 70); // block.note.flute -> block.note.harp
added(75, 70); // block.note.guitar -> block.note.harp
added(80, 70); // block.note.xylophone -> block.note.harp
added(150, -1); // entity.boat.paddle_land
added(151, -1); // entity.boat.paddle_water
added(152, -1); // entity.bobber.retrieve
added(195, -1); // entity.endereye.death
added(274, 198, 0.8f); // entity.illusion_illager.ambient -> entity.evocation_illager.ambient
added(275, 199, 0.8f); // entity.illusion_illager.cast_spell -> entity.evocation_illager.cast_spell
added(276, 200, 0.8f); // entity.illusion_illager.death -> entity.evocation_illager.death
added(277, 201, 0.8f); // entity.illusion_illager.hurt -> entity.evocation_illager.hurt
added(278, 191, 0.9f); // entity.illusion_illager.mirror_move -> entity.endermen.teleport
added(279, 203, 1.5f); // entity.illusion_illager.prepare_blindness -> entity.evocation_illager.prepare_summon
added(280, 202, 0.8f); // entity.illusion_illager.prepare_mirror -> entity.evocation_illager.prepare_attack
added(319, 133, 0.6f); // entity.parrot.ambient -> entity.bat.ambient
added(320, 134, 1.7f); // entity.parrot.death -> entity.bat.death
added(321, 219, 1.5f); // entity.parrot.eat -> entity.generic.eat
added(322, 136, 0.7f); // entity.parrot.fly -> entity.bat.loop
added(323, 135, 1.6f); // entity.parrot.hurt -> entity.bat.hurt
added(324, 138, 1.5f); // entity.parrot.imitate.blaze -> entity.blaze.ambient
added(325, 163, 1.5f); // entity.parrot.imitate.creeper -> entity.creeper.primed
added(326, 170, 1.5f); // entity.parrot.imitate.elder_guardian -> entity.elder_guardian.ambient
added(327, 178, 1.5f); // entity.parrot.imitate.enderdragon -> entity.enderdragon.ambient
added(328, 186, 1.5f); // entity.parrot.imitate.enderman -> entity.endermen.ambient
added(329, 192, 1.5f); // entity.parrot.imitate.endermite -> entity.endermite.ambient
added(330, 198, 1.5f); // entity.parrot.imitate.evocation_illager -> entity.evocation_illager.ambient
added(331, 226, 1.5f); // entity.parrot.imitate.ghast -> entity.ghast.ambient
added(332, 259, 1.5f); // entity.parrot.imitate.husk -> entity.husk.ambient
added(333, 198, 1.3f); // entity.parrot.imitate.illusion_illager -> entity.evocation_illager.ambient
added(334, 291, 1.5f); // entity.parrot.imitate.magmacube -> entity.magmacube.squish
added(335, 321, 1.5f); // entity.parrot.imitate.polar_bear -> entity.polar_bear.ambient
added(336, 337, 1.5f); // entity.parrot.imitate.shulker -> entity.shulker.ambient
added(337, 347, 1.5f); // entity.parrot.imitate.silverfish -> entity.silverfish.ambient
added(338, 351, 1.5f); // entity.parrot.imitate.skeleton -> entity.skeleton.ambient
added(339, 363, 1.5f); // entity.parrot.imitate.slime -> entity.slime.squish
added(340, 376, 1.5f); // entity.parrot.imitate.spider -> entity.spider.ambient
added(341, 385, 1.5f); // entity.parrot.imitate.stray -> entity.stray.ambient
added(342, 390, 1.5f); // entity.parrot.imitate.vex -> entity.vex.ambient
added(343, 400, 1.5f); // entity.parrot.imitate.vindication_illager -> entity.vindication_illager.ambient
added(344, 403, 1.5f); // entity.parrot.imitate.witch -> entity.witch.ambient
added(345, 408, 1.5f); // entity.parrot.imitate.wither -> entity.wither.ambient
added(346, 414, 1.5f); // entity.parrot.imitate.wither_skeleton -> entity.wither_skeleton.ambient
added(347, 418, 1.5f); // entity.parrot.imitate.wolf -> entity.wolf.ambient
added(348, 427, 1.5f); // entity.parrot.imitate.zombie -> entity.zombie.ambient
added(349, 438, 1.5f); // entity.parrot.imitate.zombie_pigman -> entity.zombie_pig.ambient
added(350, 442, 1.5f); // entity.parrot.imitate.zombie_villager -> entity.zombie_villager.ambient
added(351, 155); // entity.parrot.step -> entity.chicken.step
added(368, 316); // entity.player.hurt_drown -> entity.player.hurt
added(369, 316); // entity.player.hurt_on_fire -> entity.player.hurt
// No replacement sounds for these, since it could be confusing, the toast doesn't show up
added(544, -1); // ui.toast.in
added(545, -1); // ui.toast.out
added(546, 317, 1.5f); // ui.toast.challenge_complete
}
}
@@ -0,0 +1,40 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.storage;
public class ParrotStorage {
private boolean tamed = true;
private boolean sitting = true;
public boolean isTamed() {
return tamed;
}
public void setTamed(boolean tamed) {
this.tamed = tamed;
}
public boolean isSitting() {
return sitting;
}
public void setSitting(boolean sitting) {
this.sitting = sitting;
}
}
@@ -0,0 +1,125 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.storage;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
import com.viaversion.viaversion.api.connection.StoredObject;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
import com.viaversion.viaversion.util.ComponentUtil;
import com.viaversion.viaversion.util.Key;
import java.util.Locale;
public class ShoulderTracker extends StoredObject {
private int entityId;
private String leftShoulder;
private String rightShoulder;
public ShoulderTracker(UserConnection user) {
super(user);
}
public void update() {
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_12.CHAT, getUser());
try {
wrapper.write(Types.COMPONENT, ComponentUtil.plainToJson(generateString()));
} catch (final Exception e) {
throw new RuntimeException(e);
}
wrapper.write(Types.BYTE, (byte) 2);
try {
wrapper.scheduleSend(Protocol1_12To1_11_1.class);
} catch (Exception e) {
ViaBackwards.getPlatform().getLogger().severe("Failed to send the shoulder indication");
e.printStackTrace();
}
}
// Does actionbar not support json colors? :(
private String generateString() {
StringBuilder builder = new StringBuilder();
// Empty spaces because the non-json formatting is weird
builder.append(" ");
if (leftShoulder == null) {
builder.append("§4§lNothing");
} else {
builder.append("§2§l").append(getName(leftShoulder));
}
builder.append("§8§l <- §7§lShoulders§8§l -> ");
if (rightShoulder == null) {
builder.append("§4§lNothing");
} else {
builder.append("§2§l").append(getName(rightShoulder));
}
return builder.toString();
}
private String getName(String current) {
current = Key.stripMinecraftNamespace(current);
String[] array = current.split("_");
StringBuilder builder = new StringBuilder();
for (String s : array) {
builder.append(s.substring(0, 1).toUpperCase(Locale.ROOT))
.append(s.substring(1))
.append(" ");
}
return builder.toString();
}
public int getEntityId() {
return entityId;
}
public void setEntityId(int entityId) {
this.entityId = entityId;
}
public String getLeftShoulder() {
return leftShoulder;
}
public void setLeftShoulder(String leftShoulder) {
this.leftShoulder = leftShoulder;
}
public String getRightShoulder() {
return rightShoulder;
}
public void setRightShoulder(String rightShoulder) {
this.rightShoulder = rightShoulder;
}
@Override
public String toString() {
return "ShoulderTracker{" + "entityId=" + entityId + ", leftShoulder='" + leftShoulder + '\'' + ", rightShoulder='" + rightShoulder + '\'' + '}';
}
}
@@ -0,0 +1,235 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13_1to1_13;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter.CommandRewriter1_13_1;
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter.EntityPacketRewriter1_13_1;
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter.ItemPacketRewriter1_13_1;
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter.WorldPacketRewriter1_13_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13;
import com.viaversion.viaversion.protocols.v1_13to1_13_1.Protocol1_13To1_13_1;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
import com.viaversion.viaversion.util.ComponentUtil;
public class Protocol1_13_1To1_13 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.13.2", "1.13", Protocol1_13To1_13_1.class);
private final EntityPacketRewriter1_13_1 entityRewriter = new EntityPacketRewriter1_13_1(this);
private final ItemPacketRewriter1_13_1 itemRewriter = new ItemPacketRewriter1_13_1(this);
private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
private final TagRewriter<ClientboundPackets1_13> tagRewriter = new TagRewriter<>(this);
public Protocol1_13_1To1_13() {
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
}
@Override
protected void registerPackets() {
super.registerPackets();
WorldPacketRewriter1_13_1.register(this);
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT);
translatableRewriter.registerPlayerCombat(ClientboundPackets1_13.PLAYER_COMBAT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST);
translatableRewriter.registerTitle(ClientboundPackets1_13.SET_TITLES);
translatableRewriter.registerPing();
new CommandRewriter1_13_1(this).registerDeclareCommands(ClientboundPackets1_13.COMMANDS);
registerServerbound(ServerboundPackets1_13.COMMAND_SUGGESTION, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT);
map(Types.STRING, new ValueTransformer<>(Types.STRING) {
@Override
public String transform(PacketWrapper wrapper, String inputValue) {
// 1.13 starts sending slash at start, so we remove it for compatibility
return !inputValue.startsWith("/") ? "/" + inputValue : inputValue;
}
});
}
});
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketHandlers() {
@Override
public void register() {
map(Types.ITEM1_13);
map(Types.BOOLEAN);
handler(wrapper -> {
itemRewriter.handleItemToServer(wrapper.user(), wrapper.get(Types.ITEM1_13, 0));
wrapper.write(Types.VAR_INT, 0);
});
}
});
registerClientbound(ClientboundPackets1_13.OPEN_SCREEN, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // Id
map(Types.STRING); // Window Type
handler(wrapper -> {
JsonElement title = wrapper.passthrough(Types.COMPONENT);
translatableRewriter.processText(wrapper.user(), title);
if (ViaBackwards.getConfig().fix1_13FormattedInventoryTitle()) {
if (title.isJsonObject() && title.getAsJsonObject().size() == 1
&& title.getAsJsonObject().has("translate")) {
// Hotfix simple translatable components from being converted to legacy text
return;
}
// https://bugs.mojang.com/browse/MC-124543
JsonObject legacyComponent = new JsonObject();
legacyComponent.addProperty("text", ComponentUtil.jsonToLegacy(title));
wrapper.set(Types.COMPONENT, 0, legacyComponent);
}
});
}
});
registerClientbound(ClientboundPackets1_13.COMMAND_SUGGESTIONS, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // Transaction id
map(Types.VAR_INT); // Start
map(Types.VAR_INT); // Length
map(Types.VAR_INT); // Count
handler(wrapper -> {
int start = wrapper.get(Types.VAR_INT, 1);
wrapper.set(Types.VAR_INT, 1, start - 1); // Offset by +1 to take into account / at beginning
// Passthrough suggestions
int count = wrapper.get(Types.VAR_INT, 3);
for (int i = 0; i < count; i++) {
wrapper.passthrough(Types.STRING);
wrapper.passthrough(Types.OPTIONAL_COMPONENT); // Tooltip
}
});
}
});
registerClientbound(ClientboundPackets1_13.BOSS_EVENT, new PacketHandlers() {
@Override
public void register() {
map(Types.UUID);
map(Types.VAR_INT);
handler(wrapper -> {
int action = wrapper.get(Types.VAR_INT, 0);
if (action == 0 || action == 3) {
translatableRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT));
if (action == 0) {
wrapper.passthrough(Types.FLOAT);
wrapper.passthrough(Types.VAR_INT);
wrapper.passthrough(Types.VAR_INT);
short flags = wrapper.read(Types.UNSIGNED_BYTE);
if ((flags & 0x04) != 0) flags |= 0x02;
wrapper.write(Types.UNSIGNED_BYTE, flags);
}
}
});
}
});
registerClientbound(ClientboundPackets1_13.UPDATE_ADVANCEMENTS, wrapper -> {
wrapper.passthrough(Types.BOOLEAN); // Reset/clear
int size = wrapper.passthrough(Types.VAR_INT); // Mapping size
for (int i = 0; i < size; i++) {
wrapper.passthrough(Types.STRING); // Identifier
wrapper.passthrough(Types.OPTIONAL_STRING); // Parent
// Display data
if (wrapper.passthrough(Types.BOOLEAN)) {
wrapper.passthrough(Types.COMPONENT); // Title
wrapper.passthrough(Types.COMPONENT); // Description
Item icon = wrapper.passthrough(Types.ITEM1_13);
itemRewriter.handleItemToClient(wrapper.user(), icon);
wrapper.passthrough(Types.VAR_INT); // Frame type
int flags = wrapper.passthrough(Types.INT); // Flags
if ((flags & 1) != 0)
wrapper.passthrough(Types.STRING); // Background texture
wrapper.passthrough(Types.FLOAT); // X
wrapper.passthrough(Types.FLOAT); // Y
}
wrapper.passthrough(Types.STRING_ARRAY); // Criteria
int arrayLength = wrapper.passthrough(Types.VAR_INT);
for (int array = 0; array < arrayLength; array++) {
wrapper.passthrough(Types.STRING_ARRAY); // String array
}
}
});
tagRewriter.register(ClientboundPackets1_13.UPDATE_TAGS, RegistryType.ITEM);
new StatisticsRewriter<>(this).register(ClientboundPackets1_13.AWARD_STATS);
}
@Override
public void init(UserConnection user) {
user.addEntityTracker(getClass(), new EntityTrackerBase(user, EntityTypes1_13.EntityType.PLAYER));
if (!user.has(ClientWorld.class)) {
user.put(new ClientWorld());
}
}
@Override
public BackwardsMappingData getMappingData() {
return MAPPINGS;
}
@Override
public EntityPacketRewriter1_13_1 getEntityRewriter() {
return entityRewriter;
}
@Override
public ItemPacketRewriter1_13_1 getItemRewriter() {
return itemRewriter;
}
public TranslatableRewriter<ClientboundPackets1_13> translatableRewriter() {
return translatableRewriter;
}
@Override
public TagRewriter<ClientboundPackets1_13> getTagRewriter() {
return tagRewriter;
}
}
@@ -0,0 +1,44 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter;
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
import com.viaversion.viaversion.rewriter.CommandRewriter;
import org.checkerframework.checker.nullness.qual.Nullable;
public class CommandRewriter1_13_1 extends CommandRewriter<ClientboundPackets1_13> {
public CommandRewriter1_13_1(Protocol1_13_1To1_13 protocol) {
super(protocol);
this.parserHandlers.put("minecraft:dimension", wrapper -> wrapper.write(Types.VAR_INT, 0)); // Single word
}
@Override
public @Nullable String handleArgumentType(String argumentType) {
if (argumentType.equals("minecraft:column_pos")) {
return "minecraft:vec2";
} else if (argumentType.equals("minecraft:dimension")) {
return "brigadier:string";
}
return super.handleArgumentType(argumentType);
}
}
@@ -0,0 +1,170 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter;
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_13;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
import java.util.List;
public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter<ClientboundPackets1_13, Protocol1_13_1To1_13> {
public EntityPacketRewriter1_13_1(Protocol1_13_1To1_13 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
protocol.registerClientbound(ClientboundPackets1_13.ADD_ENTITY, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity id
map(Types.UUID); // 1 - UUID
map(Types.BYTE); // 2 - Type
map(Types.DOUBLE); // 3 - X
map(Types.DOUBLE); // 4 - Y
map(Types.DOUBLE); // 5 - Z
map(Types.BYTE); // 6 - Pitch
map(Types.BYTE); // 7 - Yaw
map(Types.INT); // 8 - Data
handler(wrapper -> {
int entityId = wrapper.get(Types.VAR_INT, 0);
byte type = wrapper.get(Types.BYTE, 0);
EntityTypes1_13.EntityType entType = EntityTypes1_13.getTypeFromId(type, true);
if (entType == null) {
protocol.getLogger().warning("Could not find entity type " + type);
return;
}
// Rewrite falling block
if (entType.is(EntityTypes1_13.EntityType.FALLING_BLOCK)) {
int data = wrapper.get(Types.INT, 0);
wrapper.set(Types.INT, 0, protocol.getMappingData().getNewBlockStateId(data));
}
// Track Entity
tracker(wrapper.user()).addEntity(entityId, entType);
});
}
});
registerTracker(ClientboundPackets1_13.ADD_EXPERIENCE_ORB, EntityTypes1_13.EntityType.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_13.ADD_GLOBAL_ENTITY, EntityTypes1_13.EntityType.LIGHTNING_BOLT);
protocol.registerClientbound(ClientboundPackets1_13.ADD_MOB, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity ID
map(Types.UUID); // 1 - Entity UUID
map(Types.VAR_INT); // 2 - Entity Type
map(Types.DOUBLE); // 3 - X
map(Types.DOUBLE); // 4 - Y
map(Types.DOUBLE); // 5 - Z
map(Types.BYTE); // 6 - Yaw
map(Types.BYTE); // 7 - Pitch
map(Types.BYTE); // 8 - Head Pitch
map(Types.SHORT); // 9 - Velocity X
map(Types.SHORT); // 10 - Velocity Y
map(Types.SHORT); // 11 - Velocity Z
map(Types1_13.ENTITY_DATA_LIST); // 12 - Metadata
// Track Entity
handler(getTrackerHandler());
// Rewrite Metadata
handler(wrapper -> {
List<EntityData> metadata = wrapper.get(Types1_13.ENTITY_DATA_LIST, 0);
handleEntityData(wrapper.get(Types.VAR_INT, 0), metadata, wrapper.user());
});
}
});
protocol.registerClientbound(ClientboundPackets1_13.ADD_PLAYER, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity ID
map(Types.UUID); // 1 - Player UUID
map(Types.DOUBLE); // 2 - X
map(Types.DOUBLE); // 3 - Y
map(Types.DOUBLE); // 4 - Z
map(Types.BYTE); // 5 - Yaw
map(Types.BYTE); // 6 - Pitch
map(Types1_13.ENTITY_DATA_LIST); // 7 - Metadata
handler(getTrackerAndMetaHandler(Types1_13.ENTITY_DATA_LIST, EntityTypes1_13.EntityType.PLAYER));
}
});
registerTracker(ClientboundPackets1_13.ADD_PAINTING, EntityTypes1_13.EntityType.PAINTING);
registerJoinGame(ClientboundPackets1_13.LOGIN, EntityTypes1_13.EntityType.PLAYER);
registerRespawn(ClientboundPackets1_13.RESPAWN);
registerRemoveEntities(ClientboundPackets1_13.REMOVE_ENTITIES);
registerSetEntityData(ClientboundPackets1_13.SET_ENTITY_DATA, Types1_13.ENTITY_DATA_LIST);
}
@Override
protected void registerRewrites() {
// Rewrite items & blocks
filter().handler((event, meta) -> {
if (meta.dataType() == Types1_13.ENTITY_DATA_TYPES.itemType) {
protocol.getItemRewriter().handleItemToClient(event.user(), (Item) meta.getValue());
} else if (meta.dataType() == Types1_13.ENTITY_DATA_TYPES.optionalBlockStateType) {
// Convert to new block id
int data = (int) meta.getValue();
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
} else if (meta.dataType() == Types1_13.ENTITY_DATA_TYPES.particleType) {
rewriteParticle(event.user(), (Particle) meta.getValue());
} else if (meta.dataType() == Types1_13.ENTITY_DATA_TYPES.optionalComponentType || meta.dataType() == Types1_13.ENTITY_DATA_TYPES.componentType) {
JsonElement element = meta.value();
protocol.translatableRewriter().processText(event.user(), element);
}
});
// Remove shooter UUID
filter().type(EntityTypes1_13.EntityType.ABSTRACT_ARROW).cancel(7);
// Move colors to old position
filter().type(EntityTypes1_13.EntityType.SPECTRAL_ARROW).index(8).toIndex(7);
// Move loyalty level to old position
filter().type(EntityTypes1_13.EntityType.TRIDENT).index(8).toIndex(7);
// Rewrite Minecart blocks
registerBlockStateHandler(EntityTypes1_13.EntityType.ABSTRACT_MINECART, 9);
}
@Override
public EntityType typeFromId(int typeId) {
return EntityTypes1_13.getTypeFromId(typeId, false);
}
@Override
public EntityType objectTypeFromId(int typeId) {
return EntityTypes1_13.getTypeFromId(typeId, true);
}
}
@@ -0,0 +1,74 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter;
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13;
import com.viaversion.viaversion.rewriter.ItemRewriter;
public class ItemPacketRewriter1_13_1 extends ItemRewriter<ClientboundPackets1_13, ServerboundPackets1_13, Protocol1_13_1To1_13> {
public ItemPacketRewriter1_13_1(Protocol1_13_1To1_13 protocol) {
super(protocol, Types.ITEM1_13, Types.ITEM1_13_SHORT_ARRAY);
}
@Override
public void registerPackets() {
registerCooldown(ClientboundPackets1_13.COOLDOWN);
registerSetContent(ClientboundPackets1_13.CONTAINER_SET_CONTENT);
registerSetSlot(ClientboundPackets1_13.CONTAINER_SET_SLOT);
protocol.registerClientbound(ClientboundPackets1_13.CUSTOM_PAYLOAD, wrapper -> {
String channel = wrapper.passthrough(Types.STRING);
if (channel.equals("minecraft:trader_list")) {
wrapper.passthrough(Types.INT); //Passthrough Window ID
int size = wrapper.passthrough(Types.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
//Input Item
Item input = wrapper.passthrough(Types.ITEM1_13);
handleItemToClient(wrapper.user(), input);
//Output Item
Item output = wrapper.passthrough(Types.ITEM1_13);
handleItemToClient(wrapper.user(), output);
boolean secondItem = wrapper.passthrough(Types.BOOLEAN); //Has second item
if (secondItem) {
//Second Item
Item second = wrapper.passthrough(Types.ITEM1_13);
handleItemToClient(wrapper.user(), second);
}
wrapper.passthrough(Types.BOOLEAN); //Trade disabled
wrapper.passthrough(Types.INT); //Number of tools uses
wrapper.passthrough(Types.INT); //Maximum number of trade uses
}
}
});
registerSetEquippedItem(ClientboundPackets1_13.SET_EQUIPPED_ITEM);
registerContainerClick(ServerboundPackets1_13.CONTAINER_CLICK);
registerSetCreativeModeSlot(ServerboundPackets1_13.SET_CREATIVE_MODE_SLOT);
registerLevelParticles(ClientboundPackets1_13.LEVEL_PARTICLES, Types.FLOAT);
}
}
@@ -0,0 +1,78 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter;
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13;
import com.viaversion.viaversion.api.minecraft.BlockFace;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
import com.viaversion.viaversion.rewriter.BlockRewriter;
public class WorldPacketRewriter1_13_1 {
public static void register(Protocol1_13_1To1_13 protocol) {
BlockRewriter<ClientboundPackets1_13> blockRewriter = BlockRewriter.legacy(protocol);
protocol.registerClientbound(ClientboundPackets1_13.LEVEL_CHUNK, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
Chunk chunk = wrapper.passthrough(ChunkType1_13.forEnvironment(clientWorld.getEnvironment()));
blockRewriter.handleChunk(chunk);
});
blockRewriter.registerBlockEvent(ClientboundPackets1_13.BLOCK_EVENT);
blockRewriter.registerBlockUpdate(ClientboundPackets1_13.BLOCK_UPDATE);
blockRewriter.registerChunkBlocksUpdate(ClientboundPackets1_13.CHUNK_BLOCKS_UPDATE);
protocol.registerClientbound(ClientboundPackets1_13.LEVEL_EVENT, new PacketHandlers() {
@Override
public void register() {
map(Types.INT); // Effect Id
map(Types.BLOCK_POSITION1_8); // Location
map(Types.INT); // Data
handler(wrapper -> {
int id = wrapper.get(Types.INT, 0);
int data = wrapper.get(Types.INT, 1);
if (id == 1010) { // Play record
wrapper.set(Types.INT, 1, protocol.getMappingData().getNewItemId(data));
} else if (id == 2001) { // Block break + block break sound
wrapper.set(Types.INT, 1, protocol.getMappingData().getNewBlockStateId(data));
} else if (id == 2000) { // Smoke
switch (data) { // Down
case 0, 1 -> { // Up
BlockPosition pos = wrapper.get(Types.BLOCK_POSITION1_8, 0);
BlockFace relative = data == 0 ? BlockFace.BOTTOM : BlockFace.TOP;
wrapper.set(Types.BLOCK_POSITION1_8, 0, pos.getRelative(relative)); // Y Offset
wrapper.set(Types.INT, 1, 4); // Self
}
case 2 -> wrapper.set(Types.INT, 1, 1); // North
case 3 -> wrapper.set(Types.INT, 1, 7); // South
case 4 -> wrapper.set(Types.INT, 1, 3); // West
case 5 -> wrapper.set(Types.INT, 1, 5); // East
}
}
});
}
});
}
}
@@ -0,0 +1,81 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13_2to1_13_1;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.rewriter.EntityPacketRewriter1_13_2;
import com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.rewriter.ItemPacketRewriter1_13_2;
import com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.rewriter.WorldPacketRewriter1_13_2;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13;
public class Protocol1_13_2To1_13_1 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
public Protocol1_13_2To1_13_1() {
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
}
@Override
protected void registerPackets() {
ItemPacketRewriter1_13_2.register(this);
WorldPacketRewriter1_13_2.register(this);
EntityPacketRewriter1_13_2.register(this);
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketHandlers() {
@Override
public void register() {
map(Types.ITEM1_13, Types.ITEM1_13_2);
}
});
registerClientbound(ClientboundPackets1_13.UPDATE_ADVANCEMENTS, wrapper -> {
wrapper.passthrough(Types.BOOLEAN); // Reset/clear
int size = wrapper.passthrough(Types.VAR_INT); // Mapping size
for (int i = 0; i < size; i++) {
wrapper.passthrough(Types.STRING); // Identifier
wrapper.passthrough(Types.OPTIONAL_STRING); // Parent
// Display data
if (wrapper.passthrough(Types.BOOLEAN)) {
wrapper.passthrough(Types.COMPONENT); // Title
wrapper.passthrough(Types.COMPONENT); // Description
Item icon = wrapper.read(Types.ITEM1_13_2);
wrapper.write(Types.ITEM1_13, icon);
wrapper.passthrough(Types.VAR_INT); // Frame type
int flags = wrapper.passthrough(Types.INT); // Flags
if ((flags & 1) != 0)
wrapper.passthrough(Types.STRING); // Background texture
wrapper.passthrough(Types.FLOAT); // X
wrapper.passthrough(Types.FLOAT); // Y
}
wrapper.passthrough(Types.STRING_ARRAY); // Criteria
int arrayLength = wrapper.passthrough(Types.VAR_INT);
for (int array = 0; array < arrayLength; array++) {
wrapper.passthrough(Types.STRING_ARRAY); // String array
}
}
});
}
}
@@ -0,0 +1,93 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.rewriter;
import com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.Protocol1_13_2To1_13_1;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_13;
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
public class EntityPacketRewriter1_13_2 {
public static void register(Protocol1_13_2To1_13_1 protocol) {
protocol.registerClientbound(ClientboundPackets1_13.ADD_MOB, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity ID
map(Types.UUID); // 1 - Entity UUID
map(Types.VAR_INT); // 2 - Entity Type
map(Types.DOUBLE); // 3 - X
map(Types.DOUBLE); // 4 - Y
map(Types.DOUBLE); // 5 - Z
map(Types.BYTE); // 6 - Yaw
map(Types.BYTE); // 7 - Pitch
map(Types.BYTE); // 8 - Head Pitch
map(Types.SHORT); // 9 - Velocity X
map(Types.SHORT); // 10 - Velocity Y
map(Types.SHORT); // 11 - Velocity Z
map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 12 - Metadata
handler(wrapper -> {
for (EntityData metadata : wrapper.get(Types1_13.ENTITY_DATA_LIST, 0)) {
metadata.setDataType(Types1_13.ENTITY_DATA_TYPES.byId(metadata.dataType().typeId()));
}
});
}
});
protocol.registerClientbound(ClientboundPackets1_13.ADD_PLAYER, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity ID
map(Types.UUID); // 1 - Player UUID
map(Types.DOUBLE); // 2 - X
map(Types.DOUBLE); // 3 - Y
map(Types.DOUBLE); // 4 - Z
map(Types.BYTE); // 5 - Yaw
map(Types.BYTE); // 6 - Pitch
map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 7 - Metadata
handler(wrapper -> {
for (EntityData metadata : wrapper.get(Types1_13.ENTITY_DATA_LIST, 0)) {
metadata.setDataType(Types1_13.ENTITY_DATA_TYPES.byId(metadata.dataType().typeId()));
}
});
}
});
protocol.registerClientbound(ClientboundPackets1_13.SET_ENTITY_DATA, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity ID
map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 1 - Metadata list
handler(wrapper -> {
for (EntityData metadata : wrapper.get(Types1_13.ENTITY_DATA_LIST, 0)) {
metadata.setDataType(Types1_13.ENTITY_DATA_TYPES.byId(metadata.dataType().typeId()));
}
});
}
});
}
}
@@ -0,0 +1,137 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.rewriter;
import com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.Protocol1_13_2To1_13_1;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13;
public class ItemPacketRewriter1_13_2 {
public static void register(Protocol1_13_2To1_13_1 protocol) {
protocol.registerClientbound(ClientboundPackets1_13.CONTAINER_SET_SLOT, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // 0 - Window ID
map(Types.SHORT); // 1 - Slot ID
map(Types.ITEM1_13_2, Types.ITEM1_13); // 2 - Slot Value
}
});
protocol.registerClientbound(ClientboundPackets1_13.CONTAINER_SET_CONTENT, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // 0 - Window ID
map(Types.ITEM1_13_2_SHORT_ARRAY, Types.ITEM1_13_SHORT_ARRAY); // 1 - Window Values
}
});
protocol.registerClientbound(ClientboundPackets1_13.CUSTOM_PAYLOAD, new PacketHandlers() {
@Override
public void register() {
map(Types.STRING); // Channel
handler(wrapper -> {
String channel = wrapper.get(Types.STRING, 0);
if (channel.equals("minecraft:trader_list") || channel.equals("trader_list")) {
wrapper.passthrough(Types.INT); // Passthrough Window ID
int size = wrapper.passthrough(Types.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
// Input Item
wrapper.write(Types.ITEM1_13, wrapper.read(Types.ITEM1_13_2));
// Output Item
wrapper.write(Types.ITEM1_13, wrapper.read(Types.ITEM1_13_2));
boolean secondItem = wrapper.passthrough(Types.BOOLEAN); // Has second item
if (secondItem) {
wrapper.write(Types.ITEM1_13, wrapper.read(Types.ITEM1_13_2));
}
wrapper.passthrough(Types.BOOLEAN); // Trade disabled
wrapper.passthrough(Types.INT); // Number of tools uses
wrapper.passthrough(Types.INT); // Maximum number of trade uses
}
}
});
}
});
protocol.registerClientbound(ClientboundPackets1_13.SET_EQUIPPED_ITEM, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Entity ID
map(Types.VAR_INT); // 1 - Slot ID
map(Types.ITEM1_13_2, Types.ITEM1_13); // 2 - Item
}
});
protocol.registerClientbound(ClientboundPackets1_13.UPDATE_RECIPES, wrapper -> {
int recipesNo = wrapper.passthrough(Types.VAR_INT);
for (int i = 0; i < recipesNo; i++) {
wrapper.passthrough(Types.STRING); // Id
String type = wrapper.passthrough(Types.STRING);
if (type.equals("crafting_shapeless")) {
wrapper.passthrough(Types.STRING); // Group
int ingredientsNo = wrapper.passthrough(Types.VAR_INT);
for (int i1 = 0; i1 < ingredientsNo; i1++) {
wrapper.write(Types.ITEM1_13_ARRAY, wrapper.read(Types.ITEM1_13_2_ARRAY));
}
wrapper.write(Types.ITEM1_13, wrapper.read(Types.ITEM1_13_2));
} else if (type.equals("crafting_shaped")) {
int ingredientsNo = wrapper.passthrough(Types.VAR_INT) * wrapper.passthrough(Types.VAR_INT);
wrapper.passthrough(Types.STRING); // Group
for (int i1 = 0; i1 < ingredientsNo; i1++) {
wrapper.write(Types.ITEM1_13_ARRAY, wrapper.read(Types.ITEM1_13_2_ARRAY));
}
wrapper.write(Types.ITEM1_13, wrapper.read(Types.ITEM1_13_2));
} else if (type.equals("smelting")) {
wrapper.passthrough(Types.STRING); // Group
// Ingredient start
wrapper.write(Types.ITEM1_13_ARRAY, wrapper.read(Types.ITEM1_13_2_ARRAY));
// Ingredient end
wrapper.write(Types.ITEM1_13, wrapper.read(Types.ITEM1_13_2));
wrapper.passthrough(Types.FLOAT); // EXP
wrapper.passthrough(Types.VAR_INT); // Cooking time
}
}
});
protocol.registerServerbound(ServerboundPackets1_13.CONTAINER_CLICK, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // 0 - Window ID
map(Types.SHORT); // 1 - Slot
map(Types.BYTE); // 2 - Button
map(Types.SHORT); // 3 - Action number
map(Types.VAR_INT); // 4 - Mode
map(Types.ITEM1_13, Types.ITEM1_13_2); // 5 - Clicked Item
}
});
protocol.registerServerbound(ServerboundPackets1_13.SET_CREATIVE_MODE_SLOT, new PacketHandlers() {
@Override
public void register() {
map(Types.SHORT); // 0 - Slot
map(Types.ITEM1_13, Types.ITEM1_13_2); // 1 - Clicked Item
}
});
}
}
@@ -0,0 +1,52 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.rewriter;
import com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.Protocol1_13_2To1_13_1;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
public class WorldPacketRewriter1_13_2 {
public static void register(Protocol1_13_2To1_13_1 protocol) {
protocol.registerClientbound(ClientboundPackets1_13.LEVEL_PARTICLES, new PacketHandlers() {
@Override
public void register() {
map(Types.INT); // 0 - Particle ID
map(Types.BOOLEAN); // 1 - Long Distance
map(Types.FLOAT); // 2 - X
map(Types.FLOAT); // 3 - Y
map(Types.FLOAT); // 4 - Z
map(Types.FLOAT); // 5 - Offset X
map(Types.FLOAT); // 6 - Offset Y
map(Types.FLOAT); // 7 - Offset Z
map(Types.FLOAT); // 8 - Particle Data
map(Types.INT); // 9 - Particle Count
handler(wrapper -> {
int id = wrapper.get(Types.INT, 0);
if (id == 27) {
wrapper.write(Types.ITEM1_13, wrapper.read(Types.ITEM1_13_2));
}
});
}
});
}
}
@@ -0,0 +1,179 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13to1_12_2;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.data.BackwardsMappingData1_13;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.data.PaintingNames1_13;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.rewriter.BlockItemPacketRewriter1_13;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.rewriter.EntityPacketRewriter1_13;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.rewriter.PlayerPacketRewriter1_13;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.rewriter.SoundPacketRewriter1_13;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.storage.BackwardsBlockStorage;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.storage.NoteBlockStorage;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.storage.PlayerPositionStorage1_13;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.storage.TabCompleteStorage;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.libs.gson.JsonParser;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13;
import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ClientboundPackets1_12_1;
import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ServerboundPackets1_12_1;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.util.ComponentUtil;
import com.viaversion.viaversion.util.ProtocolLogger;
import org.checkerframework.checker.nullness.qual.Nullable;
public class Protocol1_13To1_12_2 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_12_1, ServerboundPackets1_13, ServerboundPackets1_12_1> {
public static final BackwardsMappingData1_13 MAPPINGS = new BackwardsMappingData1_13();
public static final ProtocolLogger LOGGER = new ProtocolLogger(Protocol1_13To1_12_2.class);
private final EntityPacketRewriter1_13 entityRewriter = new EntityPacketRewriter1_13(this);
private final BlockItemPacketRewriter1_13 blockItemPackets = new BlockItemPacketRewriter1_13(this);
private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON) {
@Override
protected void handleTranslate(JsonObject root, String translate) {
String mappedKey = mappedTranslationKey(translate);
if (mappedKey != null || (mappedKey = getMappingData().getTranslateMappings().get(translate)) != null) {
root.addProperty("translate", mappedKey);
}
}
};
private final TranslatableRewriter<ClientboundPackets1_13> translatableToLegacyRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON) {
@Override
protected void handleTranslate(JsonObject root, String translate) {
String mappedKey = mappedTranslationKey(translate);
if (mappedKey != null || (mappedKey = getMappingData().getTranslateMappings().get(translate)) != null) {
root.addProperty("translate", Protocol1_12_2To1_13.MAPPINGS.getMojangTranslation().getOrDefault(mappedKey, mappedKey));
}
}
};
public Protocol1_13To1_12_2() {
super(ClientboundPackets1_13.class, ClientboundPackets1_12_1.class, ServerboundPackets1_13.class, ServerboundPackets1_12_1.class);
}
@Override
protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_12_2To1_13.class, () -> {
MAPPINGS.load();
PaintingNames1_13.init();
Via.getManager().getProviders().register(BackwardsBlockEntityProvider.class, new BackwardsBlockEntityProvider());
});
translatableRewriter.registerPing();
translatableRewriter.registerBossEvent(ClientboundPackets1_13.BOSS_EVENT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT);
translatableRewriter.registerLegacyOpenWindow(ClientboundPackets1_13.OPEN_SCREEN);
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.DISCONNECT);
translatableRewriter.registerPlayerCombat(ClientboundPackets1_13.PLAYER_COMBAT);
translatableRewriter.registerTitle(ClientboundPackets1_13.SET_TITLES);
translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST);
blockItemPackets.register();
entityRewriter.register();
new PlayerPacketRewriter1_13(this).register();
new SoundPacketRewriter1_13(this).register();
cancelClientbound(ClientboundPackets1_13.TAG_QUERY);
cancelClientbound(ClientboundPackets1_13.PLACE_GHOST_RECIPE);
cancelClientbound(ClientboundPackets1_13.RECIPE);
cancelClientbound(ClientboundPackets1_13.UPDATE_ADVANCEMENTS);
cancelClientbound(ClientboundPackets1_13.UPDATE_RECIPES);
cancelClientbound(ClientboundPackets1_13.UPDATE_TAGS);
cancelServerbound(ServerboundPackets1_12_1.PLACE_RECIPE);
cancelServerbound(ServerboundPackets1_12_1.RECIPE_BOOK_UPDATE);
}
@Override
public void init(UserConnection user) {
if (!user.has(ClientWorld.class)) {
user.put(new ClientWorld());
}
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_13.EntityType.PLAYER));
user.put(new BackwardsBlockStorage());
user.put(new TabCompleteStorage());
if (ViaBackwards.getConfig().isFix1_13FacePlayer() && !user.has(PlayerPositionStorage1_13.class)) {
user.put(new PlayerPositionStorage1_13());
}
user.put(new NoteBlockStorage());
}
@Override
public BackwardsMappingData1_13 getMappingData() {
return MAPPINGS;
}
@Override
public ProtocolLogger getLogger() {
return LOGGER;
}
@Override
public EntityPacketRewriter1_13 getEntityRewriter() {
return entityRewriter;
}
@Override
public BlockItemPacketRewriter1_13 getItemRewriter() {
return blockItemPackets;
}
// Don't override the parent method
public TranslatableRewriter<ClientboundPackets1_13> translatableRewriter() {
return translatableRewriter;
}
public String jsonToLegacy(UserConnection connection, String value) {
if (value.isEmpty()) {
return "";
}
try {
return jsonToLegacy(connection, JsonParser.parseString(value));
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
public String jsonToLegacy(UserConnection connection, @Nullable JsonElement value) {
if (value == null || value.isJsonNull()) {
return "";
}
translatableToLegacyRewriter.processText(connection, value);
return ComponentUtil.jsonToLegacy(value);
}
}
@@ -0,0 +1,60 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.Protocol1_13To1_12_2;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.NumberTag;
public class BannerHandler implements BackwardsBlockEntityHandler {
private static final int WALL_BANNER_START = 7110; // 4 each
private static final int WALL_BANNER_STOP = 7173;
private static final int BANNER_START = 6854; // 16 each
private static final int BANNER_STOP = 7109;
@Override
public CompoundTag transform(int blockId, CompoundTag tag) {
// Normal banners
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
int color = (blockId - BANNER_START) >> 4;
tag.putInt("Base", 15 - color);
}
// Wall banners
else if (blockId >= WALL_BANNER_START && blockId <= WALL_BANNER_STOP) {
int color = (blockId - WALL_BANNER_START) >> 2;
tag.putInt("Base", 15 - color);
} else {
Protocol1_13To1_12_2.LOGGER.warning("Why does this block have the banner block entity? :(" + tag);
}
// Invert colors
ListTag<CompoundTag> patternsTag = tag.getListTag("Patterns", CompoundTag.class);
if (patternsTag != null) {
for (CompoundTag pattern : patternsTag) {
NumberTag colorTag = pattern.getNumberTag("Color");
pattern.putInt("Color", 15 - colorTag.asInt()); // Invert color id
}
}
return tag;
}
}
@@ -0,0 +1,35 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider;
import com.viaversion.nbt.tag.CompoundTag;
public class BedHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
@Override
public CompoundTag transform(int blockId, CompoundTag tag) {
int offset = blockId - 748;
int color = offset >> 4;
tag.putInt("color", color);
return tag;
}
}
@@ -0,0 +1,81 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.viaversion.util.Pair;
public class FlowerPotHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
private static final Int2ObjectMap<Pair<String, Byte>> FLOWERS = new Int2ObjectOpenHashMap<>(22, 0.99F);
private static final Pair<String, Byte> AIR = new Pair<>("minecraft:air", (byte) 0);
static {
FLOWERS.put(5265, AIR);
register(5266, "minecraft:sapling", (byte) 0);
register(5267, "minecraft:sapling", (byte) 1);
register(5268, "minecraft:sapling", (byte) 2);
register(5269, "minecraft:sapling", (byte) 3);
register(5270, "minecraft:sapling", (byte) 4);
register(5271, "minecraft:sapling", (byte) 5);
register(5272, "minecraft:tallgrass", (byte) 2);
register(5273, "minecraft:yellow_flower", (byte) 0);
register(5274, "minecraft:red_flower", (byte) 0);
register(5275, "minecraft:red_flower", (byte) 1);
register(5276, "minecraft:red_flower", (byte) 2);
register(5277, "minecraft:red_flower", (byte) 3);
register(5278, "minecraft:red_flower", (byte) 4);
register(5279, "minecraft:red_flower", (byte) 5);
register(5280, "minecraft:red_flower", (byte) 6);
register(5281, "minecraft:red_flower", (byte) 7);
register(5282, "minecraft:red_flower", (byte) 8);
register(5283, "minecraft:red_mushroom", (byte) 0);
register(5284, "minecraft:brown_mushroom", (byte) 0);
register(5285, "minecraft:deadbush", (byte) 0);
register(5286, "minecraft:cactus", (byte) 0);
}
private static void register(int id, String identifier, byte data) {
FLOWERS.put(id, new Pair<>(identifier, data));
}
public static boolean isFlowah(int id) {
return id >= 5265 && id <= 5286;
}
public Pair<String, Byte> getOrDefault(int blockId) {
Pair<String, Byte> pair = FLOWERS.get(blockId);
return pair != null ? pair : AIR;
}
// TODO THIS IS NEVER CALLED BECAUSE ITS NO LONGER A BLOCK ENTITY :(
@Override
public CompoundTag transform(int blockId, CompoundTag tag) {
Pair<String, Byte> item = getOrDefault(blockId);
tag.putString("Item", item.key());
tag.putInt("Data", item.value());
return tag;
}
}
@@ -0,0 +1,112 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.Protocol1_13To1_12_2;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.MappingDataLoader;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections.ConnectionData;
import java.util.Map;
import java.util.StringJoiner;
public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
private final Object2IntMap<String> pistonIds = new Object2IntOpenHashMap<>();
public PistonHandler() {
pistonIds.defaultReturnValue(-1);
if (Via.getConfig().isServersideBlockConnections()) {
Map<String, Integer> keyToId = ConnectionData.getKeyToId();
for (Map.Entry<String, Integer> entry : keyToId.entrySet()) {
if (!entry.getKey().contains("piston")) {
continue;
}
addEntries(entry.getKey(), entry.getValue());
}
} else {
ListTag<StringTag> blockStates = MappingDataLoader.INSTANCE.loadNBT("blockstates-1.13.nbt").getListTag("blockstates", StringTag.class);
for (int id = 0; id < blockStates.size(); id++) {
StringTag state = blockStates.get(id);
String key = state.getValue();
if (!key.contains("piston")) {
continue;
}
addEntries(key, id);
}
}
}
// There doesn't seem to be a nicer way around it :(
private void addEntries(String data, int id) {
id = Protocol1_13To1_12_2.MAPPINGS.getNewBlockStateId(id);
pistonIds.put(data, id);
String substring = data.substring(10);
if (!substring.startsWith("piston") && !substring.startsWith("sticky_piston")) return;
// Swap properties and add them to the map
String[] split = data.substring(0, data.length() - 1).split("\\[");
String[] properties = split[1].split(",");
data = split[0] + "[" + properties[1] + "," + properties[0] + "]";
pistonIds.put(data, id);
}
@Override
public CompoundTag transform(int blockId, CompoundTag tag) {
CompoundTag blockState = tag.getCompoundTag("blockState");
if (blockState == null) return tag;
String dataFromTag = getDataFromTag(blockState);
if (dataFromTag == null) return tag;
int id = pistonIds.getInt(dataFromTag);
if (id == -1) {
//TODO see why this could be null and if this is bad
return tag;
}
tag.putInt("blockId", id >> 4);
tag.putInt("blockData", id & 15);
return tag;
}
// The type hasn't actually been updated in the blockstorage, so we need to construct it
private String getDataFromTag(CompoundTag tag) {
StringTag name = tag.getStringTag("Name");
if (name == null) return null;
CompoundTag properties = tag.getCompoundTag("Properties");
if (properties == null) return name.getValue();
StringJoiner joiner = new StringJoiner(",", name.getValue() + "[", "]");
for (Map.Entry<String, Tag> entry : properties) {
if (!(entry.getValue() instanceof StringTag)) continue;
joiner.add(entry.getKey() + "=" + ((StringTag) entry.getValue()).getValue());
}
return joiner.toString();
}
}
Loaded 100 of 299 files, more files were not shown because too many files have changed in this diff. Show more