Compare commits

..
340 Commits
Author SHA1 Message Date
Nassim Jahnke 808605e06a 5.6.0 Release 2025-12-12 15:59:10 +01:00
Nassim Jahnke fb387bf9c5 Add missing particle readers 2025-12-12 15:59:10 +01:00
Nassim Jahnke a3ff540cb3 Remove empty mapped data component types in tooltip display 2025-12-12 15:59:10 +01:00
Nassim Jahnke 1cafd08326 Fix kinetic weapon condition reading 2025-12-12 15:59:10 +01:00
Nassim Jahnke d5458145a0 Remove snapshot bit 2025-12-12 15:59:10 +01:00
Nassim Jahnke 316e6ac1ba 1.21.11-rc3 2025-12-12 15:59:10 +01:00
Nassim Jahnke 6b66611810 Add new dimension and biome fields to nether and end 2025-12-12 15:59:09 +01:00
Nassim Jahnke 89176f4f11 1.21.11-rc2 2025-12-12 15:59:09 +01:00
Nassim Jahnke 0808c52317 1.21.11-rc1 2025-12-12 15:59:09 +01:00
Nassim Jahnke e93199fcfe 1.21.11-pre5 2025-12-12 15:59:09 +01:00
Nassim Jahnke 04e5dfdc4e 1.21.11-pre4 2025-12-12 15:59:09 +01:00
Nassim Jahnke cba704fe3d 1.21.11-pre3 2025-12-12 15:59:09 +01:00
Nassim Jahnke f2ef57673c 1.21.11-pre2 2025-12-12 15:59:09 +01:00
Nassim Jahnke 6f7e24ac9e 1.21.11-pre1 2025-12-12 15:59:08 +01:00
Nassim Jahnke 54bd8fb5f7 25w46a 2025-12-12 15:59:08 +01:00
Nassim Jahnke 22c0ddc5de Fix avatar arm type 2025-12-12 15:59:08 +01:00
Nassim Jahnke 43bb38f4cf Rename RESOURCE_LOCATION Type to IDENTIFIER
Includes method and local variable names of cross-version code. Key stays unchanged, as it's quite clear what it represents (and is shorter)
2025-12-12 15:59:08 +01:00
Nassim Jahnke b9f110219e 25w45a 2025-12-12 15:59:08 +01:00
Nassim Jahnke 4fc70ad603 25w44a 2025-12-12 15:59:08 +01:00
Nassim Jahnke 8c33faa4f5 Move around environment attributes 2025-12-12 15:59:07 +01:00
Nassim Jahnke 6375718b10 25w43a 2025-12-12 15:59:07 +01:00
Nassim Jahnke e51ea0eeb6 25w42a 2025-12-12 15:59:07 +01:00
Nassim Jahnke 5ce209e0e9 25w41a 2025-12-12 15:59:07 +01:00
github-actions[bot]andgradle-update-robot d232242997 Update Gradle Wrapper from 9.2.0 to 9.2.1 (#4718)
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2025-12-12 15:58:01 +01:00
Kichura 3e6d17274d Update workflow configs (#4725) 2025-12-06 20:33:13 +01:00
dependabot[bot] 4350c7f614 Bump actions/checkout from 5 to 6 (#4721)
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-24 21:58:40 +01:00
Nassim Jahnke aea0c6c76f Put set_player_team packets through component rewriter 2025-11-23 19:25:22 +01:00
Lumine1909 5b8b8f5e10 Fix 1.21.9->1.21.7 item entity_data id mapping (#4716) 2025-11-23 12:11:12 +01:00
Nassim Jahnke b46f771103 [ci skip] Update issue template
The "Expected Behavior" field is almost always unneeded and has only really been filled with "not get kicked" or the alike, so this simplifies reporting
2025-11-18 19:48:42 +01:00
Nassim Jahnke fb8430518b Implement painting variant key getter
Fixes #4705
2025-11-03 18:55:52 +01:00
github-actions[bot]andgradle-update-robot 9a686ee527 Update Gradle Wrapper from 9.1.0 to 9.2.0 (#4704)
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2025-11-03 16:52:06 +01:00
Nassim Jahnke cb3dd89c78 Implement more data hashing 2025-11-02 09:20:43 +01:00
FlorianMichael 5689389f3a Implement wolf sound & chicken variants hashing (#4698) 2025-11-01 22:20:36 +01:00
FlorianMichael ed07809c84 Fix typo in entity data types (#4697) 2025-10-30 16:57:31 +01:00
dependabot[bot] 081fc0db41 [ci skip] Bump actions/upload-artifact from 4 to 5 (#4695)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-27 21:10:36 +01:00
Nassim Jahnke 74d60c2126 Implement simple variants and instrument hashing 2025-10-20 15:45:58 +02:00
Nassim Jahnke d45f2cdd64 Implement more item data hashing 2025-10-20 13:58:15 +02:00
FlorianMichael 09898c8c1e Implement PROVIDES_TRIM_MATERIAL & TRIM item component hashing (#4691) 2025-10-20 11:38:48 +02:00
Nassim Jahnke 131660d89f Handle entity type changes in enchantment predicates
Fixes #4692
2025-10-20 11:26:33 +02:00
FlorianMichael 1c066873fd Fix InformativeException message (#4690) 2025-10-17 22:38:51 +02:00
Nassim Jahnke 8429689837 Fix test 2025-10-14 17:41:51 +02:00
FlorianMichael 19c8a1ce1b Remove deprecation on PacketTracker#getIntervalPackets & PacketTracker#setIntervalPackets (#4687) 2025-10-14 17:40:27 +02:00
木葉 Scarlet c6fdaf507f Improve mapping loader executor (#4660)
This should result in less thread spam on machines that are fast enough anyways
2025-10-14 17:40:08 +02:00
FlorianMichael 7b097b3e54 Strip trailing on chat messages in 1.10->1.11 (#4686)
Fixes https://github.com/ViaVersion/ViaVersion/issues/4683
2025-10-14 17:39:14 +02:00
Nassim Jahnke c14928defa Implement more item data hashing 2025-10-14 17:36:19 +02:00
Nassim Jahnke 6b4e74abe9 Bump version to 5.5.2-SNAPSHOT 2025-10-14 16:17:29 +02:00
Nassim Jahnke 1fb3aa8c7a 5.5.1 Release 2025-10-12 18:44:11 +02:00
木葉 Scarlet f175a903a3 Improve some collection usages (#4659) 2025-10-12 18:21:13 +02:00
FlorianMichael 7c80e37e3a Rewrite item ids in 1.12.2->1.13 show_item hover events (#4671) 2025-10-12 18:16:10 +02:00
FlorianMichael ff61e1d897 [ci skip] Update README.md (#4681) 2025-10-12 17:44:30 +02:00
AmirAli Mollaei d49272a41f Fix error when wolf_variant registry data isn't sent in 1.20.5->1.21 (#4655) 2025-10-11 13:01:19 +02:00
Nassim Jahnke bea6df1174 Add april fools snapshot identifiers 2025-10-07 19:44:27 +02:00
Nassim Jahnke 4ca84f6001 Fix <1.13 sounds for VB/VR
Technically unused in VV for now, but may also replace some in-code sound mappings later
2025-10-07 17:42:16 +02:00
Nassim Jahnke 61c079af19 Add 1.21.10 to 1.21.9 version string
No protocol changes
2025-10-07 16:06:55 +02:00
Nassim Jahnke e0b9deb128 Handle repairable item id changes 2025-10-07 15:38:09 +02:00
Nassim Jahnke 1d89bc7f95 Handle deeper lock component changes 2025-10-07 15:23:25 +02:00
dependabot[bot] 28c18c33fa Bump gradle/actions from 4 to 5 (#4678)
Bumps [gradle/actions](https://github.com/gradle/actions) from 4 to 5.
- [Release notes](https://github.com/gradle/actions/releases)
- [Commits](https://github.com/gradle/actions/compare/v4...v5)

---
updated-dependencies:
- dependency-name: gradle/actions
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-06 23:37:44 +02:00
Nassim Jahnke d08cb1b743 Handle debug sticks with changed blocks/properties 2025-10-06 20:31:14 +02:00
Nassim Jahnke fb18f69a0b Fix world border scale in 1.21.7->1.21.9 2025-10-05 22:05:44 +02:00
Nassim Jahnke 56e1d32aa0 Implement equippable item data hashing 2025-10-05 21:35:35 +02:00
FlorianMichael d4aa5a2fb3 More fixes to team packet filtering in 1.20.3->1.20.5 (#4674) 2025-10-05 21:23:25 +02:00
Nassim Jahnke b54a87f465 Re-shuffle mapping files to reduce size, include sound identifiers 2025-10-05 15:27:32 +02:00
RK_01 5acfa9faf7 Implement 1.21.7 -> 1.21.9 debug sample subscription translation (#4668) 2025-10-05 08:48:42 +02:00
LeonTG 638f4cd19a Fix player team tracking in 1.20.3->1.20.5 packet filtering (#4673) 2025-10-05 03:41:41 +02:00
Nassim Jahnke baf12dd516 Handle particles in biome effects
Fixes #4666
2025-10-04 10:36:17 +02:00
Nassim Jahnke 4b6b26fbba Allow empty block entity mappings in item data 2025-10-03 20:02:06 +02:00
Nassim Jahnke 5c5784795d Bump version to 5.5.1-SNAPSHOT 2025-10-03 20:01:35 +02:00
Nassim Jahnke 1f8e7515b1 5.5.0 Release 2025-10-03 13:46:23 +02:00
Nassim Jahnke 3778698018 Fix resolvable profile type order 2025-10-03 13:46:23 +02:00
Nassim Jahnke 40dd2be139 Prepare for the release later 2025-10-03 13:46:23 +02:00
FlorianMichael edbe2c92ce Add entity identifier when downgrading entity data components 2025-10-03 13:46:23 +02:00
Nassim Jahnke b9ae1ef43e Handle unknown block entity/entity types 2025-10-03 13:46:23 +02:00
Nassim Jahnke 4631fd1977 Remove unhandled compound tag entity data from bad packets 2025-10-03 13:46:22 +02:00
Nassim Jahnke 3d25686745 Handle key changes in item_model 2025-10-03 13:46:22 +02:00
Nassim Jahnke 18b5b2626a Remove snapshot bit 2025-10-03 13:46:22 +02:00
Nassim Jahnke 219ad4737a 1.21.9-rc1 2025-10-03 13:46:22 +02:00
riku6460 b9368ae80a Fix lighting in the end dimension in 1.21.7->1.21.9 2025-10-03 13:46:22 +02:00
Nassim Jahnke 03c80ccff8 1.21.9-pre4 2025-10-03 13:46:22 +02:00
Nassim Jahnke f6aed5578f 1.21.9-pre3 2025-10-03 13:46:21 +02:00
Nassim Jahnke 646de0b1af Handle changed bees data 2025-10-03 13:46:21 +02:00
Nassim Jahnke 4e33a40ede 1.21.9-pre2 2025-10-03 13:46:21 +02:00
Nassim Jahnke 21b0ac7a43 1.21.9-pre1 2025-10-03 13:46:21 +02:00
Nassim Jahnke 15d3944700 Fix mannequin entity data reading 2025-10-03 13:46:21 +02:00
Nassim Jahnke acd9a6f57c 25w37a 2025-10-03 13:46:20 +02:00
Nassim Jahnke d5fe4e22b4 25w36a/b 2025-10-03 13:46:20 +02:00
Nassim Jahnke 9f0c38915a 25w35a 2025-10-03 13:46:20 +02:00
Nassim Jahnke bc7f081b3a I figured out the magic numbers 2025-10-03 13:46:20 +02:00
Nassim Jahnke 46b6627f9f 25w34b
Minus some dynamic player profile stuff
2025-10-03 13:46:20 +02:00
Nassim Jahnke 51cc1843ad 25w33a 2025-10-03 13:46:19 +02:00
Nassim Jahnke 98d1d2cb49 25w32a 2025-10-03 13:46:19 +02:00
Nassim Jahnke 556560a0f3 25w31a 2025-10-03 13:46:19 +02:00
FlorianMichael be2534c6e6 Add missing game test payload sanitize in 1.20->1.20.2 (#4661) 2025-10-02 16:14:50 +02:00
RaynLegends d40d1bd232 Fix system messages sent during config state hidden on <= 1.12.2 servers (#4650)
Fixes ViaVersion/issues#4478
2025-09-21 18:32:14 +02:00
Nassim Jahnke 6143f78ccf Update dependencies 2025-09-20 22:36:43 +02:00
EnZaXD 52cdebc3d3 Execute stored object clear call inside the event loop (#4652)
This fixes NPE exceptions when players disconnect. A packet goes through the pipeline after setActive(false) was called causing NPE exceptions.
2025-09-20 22:35:47 +02:00
EnZaXD cdccae95e0 Remove serialize versions from item hasher (#4651) 2025-09-16 21:24:42 +02:00
EnZaXD b0c45e3ed3 Fix wrong shulker box mapping in 1.12.2->1.13 (#4641)
Closes https://github.com/ViaVersion/ViaVersion/issues/4636
2025-09-14 18:53:16 +02:00
EnZaXD 3ba518650c Filter invalid remove teams packets in 1.20.3->1.20.5 (#4643)
Closes https://github.com/ViaVersion/ViaVersion/issues/4564
2025-09-13 11:23:18 +02:00
Nassim Jahnke 5a303996a1 Cleanup and fixes to storable object task 2025-09-05 19:35:04 +02:00
FlorianMichael 695534e8a8 Don't run movement transmitter provider in netty thread 2025-09-05 19:02:51 +02:00
EnZaXD 16ba011243 Rename ProtocolRunnable, always submit tick logic into event loop (#4644) 2025-09-03 17:05:53 +02:00
Nassim Jahnke 0ea7271157 Update deps 2025-09-03 07:42:12 +02:00
EnZaXD dc2b2f1407 Rename RedirectProtocolVersion (#4642) 2025-09-01 21:01:30 +02:00
Nassim Jahnke 85baefc69b Log channel close outside of event loop when debug is enabled 2025-08-31 22:39:15 +02:00
riku6460andFlorianMichael 41e0fdc20f Add EntityTracker#clear and clear entities on entering configuration state (#4638)
Co-authored-by: FlorianMichael <florian.michael07@gmail.com>
2025-08-29 17:15:39 +02:00
dependabot[bot] 5c328fba33 Bump actions/setup-java from 4 to 5 (#4637)
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 4 to 5.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-26 15:35:43 +02:00
EnZaXD 91b11878fb Fix ViaAPI#getConnection javadoc and remove not needed code (#4635) 2025-08-20 17:38:19 +02:00
Nassim Jahnke 0ea5e07d63 Don't replace velocity servers section when merging with default config 2025-08-19 16:14:03 +02:00
Nassim Jahnke 152e4e77a8 Handle custom name in banner etc. in 1.21.4->1.21.5
Newer clients handle errors gracefully and will parse them okay, but this'll make sure they are properly set
2025-08-17 16:41:26 +02:00
Nassim Jahnke cf20c6397d Fix spawn_particles key 2025-08-15 08:35:34 +02:00
Nassim Jahnke 981672e2cf Update particle types in enchantments 2025-08-14 18:22:55 +02:00
dependabot[bot] d10b600e72 [ci skip] Bump actions/checkout from 4 to 5 (#4627)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-12 08:23:33 +02:00
Nassim Jahnke de9cec36c7 Don't hash empty items in container 2025-08-10 15:39:45 +02:00
Nassim Jahnke 6eb561607c Fix bad reference 2025-08-10 15:12:22 +02:00
Nassim Jahnke db3e1f605a Fix hashing of maps in lists 2025-08-10 15:04:39 +02:00
Nassim Jahnke 31583fc2d3 Update deps 2025-08-09 18:43:37 +02:00
Nassim Jahnke 6096ce4eea Add option to log blocked joins
Closes #4613
2025-08-09 18:21:15 +02:00
Nassim Jahnke 873da12233 Check if custom_name lock data is actually present in 1.21.2
Fixes #4622
2025-08-09 17:50:04 +02:00
EnZaXD 78191ea366 [ci skip] Gradle & Shadow 9.0.0; Rewrite .gitignore file (#4606) 2025-08-09 14:18:03 +02:00
EnZaXD f8d7c5c193 [ci skip] Fix packet id comments (#4621) 2025-08-09 13:11:52 +02:00
EnZaXD bc9c979e7d Don't make the protocol pipeline depend on simple protocol (#4619) 2025-08-08 18:59:19 +02:00
EnZaXD d686a9ddf0 Move protocol logger creation to AbstractProtocol#createLogger (#4620)
Allows VB to delegate the used logger to the VB platform logger
2025-08-08 15:36:25 +02:00
EnZaXD 9dd610605f Don't put legacy show_text value through json conversion in 1.21.1->.5 (#4611) 2025-08-05 09:19:31 +02:00
EnZaXD 219e163ac2 Add statistic mappings for 1.21.5->1.21.6 (#4609) 2025-08-03 09:33:56 +02:00
EnZaXD 925e7b4664 Add some backwards compatibility functions to PacketTracker (#4607) 2025-08-02 15:09:46 +02:00
criticalcynical 5a9f040af8 Fix wrong connections being removed when switching servers on proxy platforms (#4576) 2025-07-29 20:35:20 +02:00
Nassim Jahnke 992ad7f35a Fix max packet size check 2025-07-29 20:28:37 +02:00
EnZaXD bb93ac011c Null check original root section (#4604) 2025-07-29 19:38:13 +02:00
Nassim Jahnke 4070ea9f02 Revamp max-pps config
Add a config section for setting max packet size, add a toggle for disabling each tracker fully
2025-07-29 12:27:51 +02:00
EnZaXD 499efa1608 Convert HIDE_ADDITIONAL_TOOLTIP in both directions in 1.21.4->1.21.5 (#4600) 2025-07-29 12:19:10 +02:00
Nassim Jahnke 0196d9c83e Bump version to 5.5.0-SNAPSHOT 2025-07-29 12:11:59 +02:00
Nassim Jahnke 4c316de042 5.4.2 Release 2025-07-23 23:03:10 +02:00
EnZaXD 8ee5d7e680 Add missing biome name translations in 1.17.1->1.18 (#4597) 2025-07-22 20:50:33 +02:00
Nassim Jahnke 64c128d414 Fix 1.8/1.9 thrown potion entity data handling
Fixes #4596
2025-07-21 23:55:03 +02:00
Nassim Jahnke 77d11fc593 Update attribute modifier types in show item hovers
Fixes #4593
2025-07-18 20:50:46 +02:00
Nassim Jahnke 2c72a09809 Strip namespace from custom attribute id when getting names 2025-07-18 11:01:52 +02:00
Nassim Jahnke 3dbd81da76 [ci skip] Split up publishing steps
Putting them into the same step meant if one publish action failed, the second one wouldn't run. Before this change, Modrinth would often block Hangar from publishing
2025-07-17 16:10:15 +02:00
Nassim Jahnke a0116c7ea7 Add 1.21.8 version string to 1.21.7 2025-07-17 14:33:58 +02:00
Nassim Jahnke fd5dadbe01 [ci skip] Clean up imports 2025-07-14 12:36:56 +02:00
Kai df87a02c38 Update ViaNBT (#4585) 2025-07-14 12:25:59 +02:00
EnZaXD bb293b3e5d Add cancel-swing-in-inventory option for 1.15.2->1.16 inventory swing fix (#4587) 2025-07-14 12:24:53 +02:00
EnZaXDanddewgs ff03892b25 Fix some directions not being included in chunk-border-fix; Reduce packets sent by checking for needed chunks (#4586)
Co-authored-by: dewgs <23721849+dewgs@users.noreply.github.com>
2025-07-14 12:21:28 +02:00
EnZaXD eb51306d82 Fix ItemFactory#getSpawnEgg NoSuchMethodError on older Paper builds (#4582) 2025-07-13 08:40:09 +02:00
EnZaXD 81eb3362f3 [ci skip] Add Java resolving plugin (#4577) 2025-07-12 10:31:23 +02:00
EnZaXD 7f06b03453 Remove StorableObject#clearOnServerSwitch (#4583) 2025-07-12 10:30:30 +02:00
RK_01 c16432de2a Fix anticheat flags when respawning with 1.21.2+ clients on older servers (#4573)
Fixes #4572
2025-07-07 21:40:01 +02:00
Nassim Jahnke b162dbdff0 Add missing null check to allowed_entities rewrite
Fixes #4568
2025-07-05 13:55:55 +02:00
Nassim Jahnke dfbe57e304 Rewrite Equippable allowed_entities
Fixes #4567
2025-07-04 17:17:05 +02:00
Nassim Jahnke 6f6dc2c641 Rewrite attribute modifiers automatically via interface
An id change in 1.21.5->1.21.6 was missed
2025-06-30 21:27:00 +02:00
Nassim Jahnke 06990ec0c9 Bump version to 5.4.2-SNAPSHOT 2025-06-30 21:26:14 +02:00
Nassim Jahnke 351b42b5e5 5.4.1 Release 2025-06-30 09:56:25 +02:00
Nassim Jahnke 20e3c832fb 1.21.7-rc2 2025-06-30 09:49:48 +02:00
Nassim Jahnke ec9c121da2 1.21.7-rc1 2025-06-30 09:49:47 +02:00
FlorianMichael 12c773edea Add missing translatable mappings (#4542)
Fixes #3331
Fixes #4273
2025-06-30 09:47:33 +02:00
Nassim Jahnke 97b411aa6d Manually handle text component boolean entries
Fixes #4558
2025-06-29 16:36:12 +02:00
Nassim Jahnke 24f6c4f0fd Implement hashing for potion contents 2025-06-29 15:50:56 +02:00
FlorianMichael 9409c7d22a [ci skip] Add SECURITY.md (#4520) 2025-06-29 15:36:49 +02:00
FlorianMichael 17d94a17f0 Always write length in LengthPrefixedTagType 2025-06-29 11:51:38 +02:00
riku6460andFlorianMichael a1cb4d3691 Add Types#CUSTOM_CLICK_ACTION_TAG for VB (#4557)
* Add LengthPrefixedTagType for CUSTOM_CLICK_ACTION

* Move type into own class, add instance into Types

---------

Co-authored-by: FlorianMichael <florian.michael07@gmail.com>
2025-06-29 07:21:48 +02:00
Nassim Jahnke 1d5070a480 Allow mapping sound event holders to empty sounds 2025-06-27 10:24:34 +02:00
FlorianMichaelanddewgs f612adbd0a Rewrite player & display name in player info packet in 1.12.2->1.13 (#4550)
Fixes Tablist plugins on some servers breaking since the game profile name sent is used to determine the scoreboard team which name we rewrite in other packets, also adds missing component rewriter calls to the display names (Not that important given its only translation keys, but we are already here).

Co-authored-by: dewgs <23721849+dewgs@users.noreply.github.com>
2025-06-25 13:31:17 +02:00
FlorianMichael 6716beec5a Remove arbitrary chat-nbt-fix config option in 1.11.1->1.12 (#4551) 2025-06-25 13:28:23 +02:00
Nassim Jahnke d22b00e4a6 Add helper methods for registry entry rewriting 2025-06-22 22:53:08 +02:00
Nassim Jahnke fe9ca49920 Update mcstructs 2025-06-22 10:38:33 +02:00
PacksoliteandNassim Jahnke e1837dc578 Fix legacy block picking on some Paper forks (#4496)
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
2025-06-21 11:22:22 +02:00
booky 66eead2927 Fix missing clouds in 1.21.5->1.21.6 (#4538) 2025-06-21 11:00:19 +02:00
booky 937a2a2532 Fix server links button not visible in 1.21.5->1.21.6 (#4536)
The Minecraft 1.21.6 client will only show the server links if the the server_links dialog has been sent
2025-06-21 01:47:34 +02:00
Nassim Jahnke bee45ef9ef Use Cache get instead of Map compute
This may or may not fix concurrency issues from... somewhere (bad plugins/old guava impl?)
2025-06-20 21:40:37 +02:00
FlorianMichael 1946a65ab2 Add MathUtil#ceil 2025-06-20 21:36:44 +02:00
Nassim Jahnke f594a946d4 Bump version to 5.4.1-SNAPSHOT 2025-06-20 21:36:33 +02:00
Nassim Jahnke 7a0ec492d1 5.4.0 Release 2025-06-20 19:26:25 +02:00
Nassim Jahnke b4fac61eb9 Fix tinted leaves particle reading in 1.21.6 type 2025-06-20 19:26:19 +02:00
Nassim Jahnke 7817b7a422 Remove snapshot version 2025-06-17 02:14:13 +02:00
Nassim Jahnke ed266d296e 1.21.6-rc1 2025-06-17 02:13:06 +02:00
Nassim Jahnke 3ce324c1e1 1.21.6-pre4 2025-06-17 02:13:06 +02:00
Nassim Jahnke 835dc4733d 1.21.6-pre3 2025-06-17 02:13:06 +02:00
Nassim Jahnke aa66a6b482 1.21.6-pre2 2025-06-17 02:13:05 +02:00
Nassim Jahnke 406855d427 1.21.6-pre1 2025-06-17 02:13:05 +02:00
Nassim Jahnke fe5ba84f7a 25w21a 2025-06-17 02:13:05 +02:00
Nassim Jahnke f49495162b Use updated versioned types 2025-06-17 02:13:05 +02:00
Nassim Jahnke be5c451f42 25w20a 2025-06-17 02:13:05 +02:00
Nassim Jahnke 1517596a9f Add hashed item handling 2025-06-17 02:13:05 +02:00
Nassim Jahnke 6a89b84879 Fix attribute modifier writing 2025-06-17 02:13:05 +02:00
Nassim Jahnke c414458f1c 25w19a 2025-06-17 02:13:05 +02:00
Nassim Jahnke ec9086abc4 25w18a 2025-06-17 02:13:05 +02:00
Nassim Jahnke d6c16677fc 25w17a 2025-06-17 02:13:05 +02:00
Nassim Jahnke 7cd3a75ef8 Handle player_command change 2025-06-17 02:13:05 +02:00
Nassim Jahnke 0677cbaa3c 25w16a 2025-06-17 02:13:05 +02:00
Nassim Jahnke ab8b5abc48 25w15a
Is it 1.22? Is it 1.21.6? Who knows
2025-06-17 02:13:05 +02:00
FlorianMichael 60c67659d0 Filter invalid characters in command click events in 1.21.4->.5 (#4528)
Minecraft versions prior to 1.21.4 filter out invalid characters when handling the click event on the clientside while 1.21.5+ validates and throws in the network codec per ExtraCodecs#CHAT_STRING
2025-06-15 12:28:08 +02:00
dewgsandFlorianMichael 814190c2df Add missing dimension change checks for entity tracking (#4527)
Co-authored-by: FlorianMichael <florian.michael07@gmail.com>
2025-06-14 17:29:40 +02:00
RK_01 04d647bfef Fix respawning with 1.21.2+ clients on older vanilla servers (#4509) 2025-06-12 18:18:37 +02:00
FlorianMichael 930bf67229 Don't always send player inputs on Fabric servers in 1.21->1.21.2 (#4523) 2025-06-11 02:52:21 +02:00
FlorianMichael 51c3085180 Validate tag identifiers in block predicates in 1.20.3->1.20.5 (#4522)
As usual, versions <= 1.20.4 have the entire parsing code in a try catch block while 1.20.5+ needs valid data.

Closes https://github.com/ViaVersion/ViaVersion/issues/4515
2025-06-09 15:08:00 +02:00
FlorianMichael b981223e0a Make workflows manual runnable (#4521) 2025-06-08 23:56:14 +02:00
FlorianMichael 3951cff03a Cancel out unmapped (block) ids in HolderSetImpl (#4512)
In VB, mapping data will return -1 for missing block ids (which is for almost all blocks the case). This is made so that VV rewriters can cancel these blocks away nicely (as mostly used in places where it's better to show the user nothing rather than wrong blocks, such as statistics).

Fixes https://github.com/ViaVersion/ViaVersion/issues/4510
2025-05-28 07:41:21 +02:00
Nassim Jahnke 77a6ae37c0 Fix game profile null id hashing
Fixes #4506
2025-05-27 15:28:35 +02:00
Nassim Jahnke 12e201633f Fix rabbit variant hashing 2025-05-27 14:28:04 +02:00
Nassim Jahnke 8eb005e775 Fix tropical fish pattern hashing 2025-05-27 14:05:40 +02:00
RK_01 4d39c0007f Add QoL API for GameProfile (#4505) 2025-05-27 08:39:08 +02:00
FlorianMichael d9609e60b8 Don't fail on book pages rewrite in 1.8->1.9 as per Vanilla behaviour (#4504) 2025-05-26 20:22:29 +02:00
Nassim Jahnke ab3927dff7 Implement our own hash writing
This avoids a lot of indirection, wrapping/boxing and data copying while also making sure we can immediately implement them on new snapshots without waiting for a separate (also ever-growing) library.

The HashBuilder is partially copied from MCStructs, everything else was built anew to intentionally stay away from Vanilla's Codec design
2025-05-26 12:37:58 +02:00
FlorianMichael 1a60c52fa3 Don't convert creative-slot-lock/map-post-processing in 1.20.3->.5 (#4500) 2025-05-22 21:38:18 +02:00
github-actions[bot]andgradle-update-robot f88dae1828 Update Gradle Wrapper from 8.14 to 8.14.1 (#4501)
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2025-05-22 17:35:05 +02:00
Nassim JahnkeandFlorianMichael 2626773267 Refactor 1.20.5+ versioned types
Co-authored-by: FlorianMichael <florian.michael07@gmail.com>
2025-05-17 15:12:52 +02:00
Nassim Jahnke f16f1905b7 Move container handling into handleShowItem directly
Fixes ViaVersion/ViaBackwards#1010
2025-05-15 11:08:44 +02:00
Nassim Jahnke cc435b2b02 Move item id setter below backup method 2025-05-14 14:01:03 +02:00
Nassim Jahnke eb2d603aae Add protected handleRewritablesToServer method 2025-05-14 13:29:40 +02:00
Nassim Jahnke c30e0f45bc Split up item rewriter methods even more
Item backups and its restoration processes have to be more carefully placed around Rewritable handling, so the original/restored data stays untouched
2025-05-14 13:22:32 +02:00
Nassim Jahnke ebb24c73a2 Don't call super handleItemToClient with custom item hasher 2025-05-13 23:12:06 +02:00
Nassim Jahnke 575c5b9abf Move restoreBackupData call up 2025-05-13 22:55:46 +02:00
Nassim Jahnke 812694d74d Split updateItemDataComponents in two 2025-05-13 22:45:25 +02:00
Nassim Jahnke 1efaffbc7d Implement more data conversion
Most importantly attributes
2025-05-12 18:59:41 +02:00
FlorianMichael b03b5f7da7 [ci skip] Make the runViaProxy task work with Gradle's configuration cache (#4483) 2025-05-12 17:53:54 +02:00
Nassim Jahnke 3554db9e3a Prepare for hashed item rewriting 2025-05-11 23:10:20 +02:00
Nassim Jahnke a6d58fc02b Only track item when necessary, cleanup 2025-05-11 23:10:18 +02:00
RaphiMC e2045295a0 Hash item data components in 1.21.4->1.21.5 2025-05-11 23:10:17 +02:00
FlorianMichael a6b219c0df [ci skip] Allow build if Git is not installed or the project is downloaded as code zip (#4477) 2025-05-11 22:26:35 +02:00
FlorianMichael 0b5721d81e Check for non-negative value for damage & repair cost in 1.20.3->.5 (#4491)
In 1.20.5, codecs introduced the non-negative int type which will fail if a value <= 0 is present. In 1.20.4, Mojang gracefully handled negative values

Fixes https://github.com/ViaVersion/ViaFabricPlus/issues/763
2025-05-11 22:05:59 +02:00
FlorianMichael 5bad61e210 Don't perform length validation on zero bit storage in 1.18 palette type (#4479)
Minecraft has its own ZeroBitStorage type for this case so we don't need to perform the validation, also removed the comments as this is just how our code should work to match Vanilla behaviour (at least for the first one; I did not verify the readValues code)

Closes https://github.com/ViaVersion/ViaVersion/issues/4476
2025-05-05 21:06:37 +02:00
FlorianMichael e597d8faaa [ci skip] Include platform launcher runtime dependency for tests (#4474) 2025-04-29 10:21:30 +02:00
FelixandFlorianMichael d9eb7109bd Add missing PLAYER_CHAT handlers in 1.20/1.21 versions (#4472)
Co-authored-by: FlorianMichael <florian.michael07@gmail.com>
2025-04-28 11:57:10 +02:00
github-actions[bot]andgradle-update-robot 77d68306b6 Update Gradle Wrapper from 8.13 to 8.14 (#4471)
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2025-04-26 16:33:53 +02:00
FlorianMichael 16aec9c0a1 Fix legacy item/entity hover event + potion id in 1.21.4->1.21.5 (#4469) 2025-04-23 20:52:53 +02:00
FlorianMichael c6cde5fc10 Cancel unknown block entities in BlockRewriter#registerBlockEntityData (#4466) 2025-04-22 16:05:44 +02:00
Nassim Jahnke bf84eb0141 Add separate config option for text component conversion errors 2025-04-20 15:57:22 +02:00
Nassim Jahnke 4dfc3bd2be Make parts of item data component rewriting more generic via an interface 2025-04-16 10:59:20 +02:00
Nassim Jahnke b0c53ffdd3 Make helper method in Copyable static 2025-04-15 21:20:57 +02:00
Nassim Jahnke d65b2abc46 Ignore invalid data in signs 2025-04-15 20:46:13 +02:00
Nassim Jahnke 03313a1681 Catch text conversion errors 2025-04-15 10:02:00 +02:00
Nassim Jahnke 78c5e2c8e3 Convert hover events to legacy deep 2025-04-14 08:57:04 +02:00
FlorianMichael e467c7c03f Set correct data types in 1.8->1.9 CONTAINER_CLICK (#4460) 2025-04-14 08:55:45 +02:00
Nassim Jahnke 0c01425641 5.3.2 Release 2025-04-13 15:45:15 +02:00
Nassim Jahnke 01d26e7ac5 Make trimStrings public 2025-04-12 15:37:19 +02:00
Nassim Jahnke 99ea6c32ad Add client and server protocol to informative exception data 2025-04-11 22:20:38 +02:00
Nassim Jahnke cf231d92b1 Update mcstructs
Fixes ViaVersion/ViaBackwards#988
2025-04-10 18:58:23 +02:00
FlorianMichael f555188428 [ci skip] Print correct max read length in StringType sanity checks (#4456) 2025-04-10 16:16:46 +02:00
FlorianMichael 93d6fa2e78 Only add (block) entity id if needed for tooltips in 1.20.3->.5 2025-04-09 17:22:33 +02:00
Nassim Jahnke 162fcafb36 Ignore unknown entity data too in 1.20.3->1.20.5
Fixes #4433
Closes #4451
2025-04-09 16:24:03 +02:00
FlorianMichael 3d0a0fe590 Send player input every tick when in boat in 1.21->1.21.2 (#4449) 2025-04-09 16:14:07 +02:00
bookyandFlorianMichael b06556a84e Fix advancement menu background keys (#4454)
Co-authored-by: FlorianMichael <florian.michael07@gmail.com>
2025-04-09 15:56:06 +02:00
Nassim Jahnke ac8bb104b3 Fix primitive array copying 2025-04-08 15:54:02 +02:00
FlorianMichael 4b85ca7691 Fix handling of removed item components in 1.20.3->.5 component rewriter (#4452)
Only relevant for VB though as VV will never put empty structured data through it.
2025-04-08 15:34:30 +02:00
FlorianMichael ebd8eb79c1 Use correct version in json to tag conversion in 1.21.4->.5 (#4450) 2025-04-08 15:32:07 +02:00
Nassim Jahnke 09cffbfb33 Null check connection in Velocity connect listener 2025-04-05 18:35:24 +02:00
FlorianMichael 49a1bffc98 Only send the connection details if ViaVersion is active (#4434) 2025-04-05 11:54:06 +02:00
FlorianMichael da022a0b63 [ci skip] Fix ItemRewriter#registerContainerClick1_21_5 data order (#4435) 2025-04-05 11:53:36 +02:00
Nassim Jahnke 3beddaf522 Move show item container contents conversion to the right place
Fixes #4444
2025-04-05 11:53:08 +02:00
Nassim Jahnke 70139c6838 Bump version to 5.3.2-SNAPSHOT 2025-04-05 11:52:24 +02:00
Nassim Jahnke f040077c13 5.3.1 Release 2025-03-30 21:07:54 +02:00
Nassim Jahnke 1f404820b7 Track it on 1.21.4 servers already 2025-03-30 18:51:03 +02:00
Nassim Jahnke 742e70fff6 Small cleanup, track gamemode 2025-03-30 18:26:05 +02:00
Nassim Jahnke dd6a1a7f6e Update old version warning to <1.16 servers
The original <1.13 warning was added almost 5 years ago, since then more small issues have come up from newer clients having fundamental changes and server stats on those old versions have dropped even more. That said, ViaVersion will keep working on these servers presumably forever
2025-03-30 16:02:27 +02:00
Nassim Jahnke 08ef7c2f35 Add back legacy hover event conversion 2025-03-30 15:05:03 +02:00
Gero e128469313 Fix missing mapping of CHUNKS_BIOMES for 1.21.5 (#4425) 2025-03-30 11:56:29 +02:00
FlorianMichael cbb753271e [ci skip] Update repository declaration in GH workflow (#4424) 2025-03-29 20:28:41 +01:00
FlorianMichael 29f299d882 Update MCStructs to 3.0.0 (#4422) 2025-03-29 14:30:06 +01:00
Pablo Herrera 41138aabd1 Implement pick-block for legacy servers (#4412) 2025-03-29 13:07:44 +01:00
Nassim Jahnke b90f20cfeb Fix 1.20.3 disguised chat handler 2025-03-29 10:15:21 +01:00
Nassim Jahnke 585028beb7 Bump version to 5.3.1-SNAPSHOT 2025-03-29 10:14:45 +01:00
Nassim Jahnke 160eaa35aa 5.3.0 Release 2025-03-28 17:06:08 +01:00
Nassim Jahnke 9fb02581a6 Also check for hanging sign block entities 2025-03-28 17:04:59 +01:00
FlorianMichael 7d01d5363b Add TagUtil#getNamespacedTagKey and simplify code in component rewriter 2025-03-28 14:37:00 +01:00
Nassim Jahnke 8a549d7f11 And for disguised chat params 2025-03-28 14:12:41 +01:00
Nassim Jahnke 50e2db93b4 Also update name and target name 2025-03-28 14:12:41 +01:00
Nassim Jahnke 2d80c9526a Also process unsigned signed player chat 2025-03-28 14:12:41 +01:00
Nassim Jahnke 80d72121cf Check for horse saddles in entity data too 2025-03-28 14:12:41 +01:00
Nassim Jahnke ba11b3c214 Remove show_in_tooltip 2025-03-28 14:12:41 +01:00
Nassim Jahnke 2ee4c86dcb Remote snapshot version 2025-03-28 14:12:41 +01:00
Nassim Jahnke 97b8cbbc6f 1.21.5-rc2 2025-03-28 14:12:40 +01:00
riku6460 1a1ae41a7b Fix blockEntityHandler not being called when mappedId == id 2025-03-28 14:12:40 +01:00
Nassim Jahnke 2b7a86bc55 Play shield break and block sounds from entity events 2025-03-28 14:12:40 +01:00
Nassim Jahnke 175c320389 Simplify server container desync check with Paper API if present
Fixes desyncs on item drags due to missing item data for 1.21.5+ clients
2025-03-28 14:12:40 +01:00
RK_01 b22430a923 Moved hashed item conversion code into method (#16)
Allows for easy injection in platforms like ViaProxy or ViaFabricPlus
2025-03-28 14:12:40 +01:00
Nassim Jahnke c9f9e88ebe 1.21.5-rc1 2025-03-28 14:12:40 +01:00
Nassim Jahnke 7f0b3fc241 1.21.5-pre3 2025-03-28 14:12:39 +01:00
RK_01 e13b99e73a Use new blocks_attacks component for 1.8 sword blocking (#15) 2025-03-28 14:12:39 +01:00
Nassim Jahnke 304d9f04ec Send saddle equipment for pigs and striders 2025-03-28 14:12:39 +01:00
Nassim Jahnke 92b59fd904 Update dependencies 2025-03-28 14:12:39 +01:00
Nassim Jahnke 7e42ce2a5c 1.21.5-pre2 2025-03-28 14:12:39 +01:00
Nassim Jahnke d3475dc751 Fix pig saddle index 2025-03-28 14:12:39 +01:00
Nassim Jahnke cd6e5a3d7a 1.21.5-pre1 2025-03-28 14:12:38 +01:00
Nassim Jahnke 67e50ed6f4 Add missing provides_banner_patterns item data, fix entity variants 2025-03-28 14:12:38 +01:00
Nassim Jahnke 097ad1c721 Add helper methods for removing data components 2025-03-28 14:12:38 +01:00
FlorianMichael 6a4f5732e2 Handle show_in_tooltip values in chat item components 2025-03-28 14:12:38 +01:00
Nassim Jahnke 000769e7c5 Adventure mode predicate changes
🫠
2025-03-28 14:12:38 +01:00
Nassim Jahnke c725242713 Fix block entity removal OOB 2025-03-28 14:12:37 +01:00
Nassim Jahnke fd9d7d674b 25w10a 2025-03-28 14:12:37 +01:00
Nassim Jahnke 5c87388353 Update mappings 2025-03-28 14:12:37 +01:00
Nassim Jahnke 3b65720d04 Update ViaNBT 2025-03-28 14:12:37 +01:00
Nassim Jahnke 44af621c12 25w09b 2025-03-28 14:12:37 +01:00
Nassim Jahnke 4e33615d9e Update sign text 2025-03-28 14:12:37 +01:00
Nassim Jahnke a5b34b9fac 25w09a 2025-03-28 14:12:37 +01:00
Nassim Jahnke 674b81a5ce 25w08a 2025-03-28 14:12:36 +01:00
Nassim Jahnke 36a3a7bd32 Fix read of single value storage 2025-03-28 14:12:36 +01:00
Nassim Jahnke d2b2f56438 25w07a 2025-03-28 14:12:36 +01:00
Nassim Jahnke 5cb147f8c5 25w06a 2025-03-28 14:12:36 +01:00
Nassim Jahnke c1c6d7378d Fix optional holder type 2025-03-28 14:12:36 +01:00
Nassim Jahnke 3cd9d8c20b 25w05a 2025-03-28 14:12:35 +01:00
Nassim Jahnke 8faa00af14 Finish up things 2025-03-28 14:12:35 +01:00
Nassim Jahnke 2aa02cfc20 Mostly finished 25w04a 2025-03-28 14:12:35 +01:00
Nassim Jahnke 1071e68e6e Update show_text value key 2025-03-28 14:12:35 +01:00
Nassim Jahnke bcf4efacc5 Remove block entities if mapped to nothing 2025-03-28 14:12:35 +01:00
Nassim Jahnke 4ab3148dd9 25w03a 2025-03-28 14:12:34 +01:00
Nassim Jahnke b0269b53b7 Offset pig variant entity data type 2025-03-28 14:12:34 +01:00
Nassim Jahnke 5df2ffe6a8 Handle hover and click event changes
Changes to the component rewriter will be done in the public branch
2025-03-28 14:12:34 +01:00
Nassim Jahnke 0e8e58dc5c WIP 25w02a 2025-03-28 14:12:34 +01:00
FlorianMichael d1e27617a9 Update warning when no working pipe is found (#4416) 2025-03-26 21:24:19 +01:00
FlorianMichael 5ab4f49148 Add Copyable interface and unify copy() methods (#4413) 2025-03-25 16:37:00 +01:00
FlorianMichael 494da63b66 Rewrite ConnectionManager to track client/server connections (#4410) 2025-03-12 16:51:34 +01:00
Nassim Jahnke a0b0ed4b68 Make <1.21.2 container id types consistent with Vanilla again
... that's to say, to make them inconsistent thanks to special ids:
Byte:
- CONTAINER_SET_SLOT
- CONTAINER_CLICK
- PLACE_GHOST_RECIPE
- PLACE_RECIPE
- CONTAINER_BUTTON_CLICK
- CONTAINER_CLOSE (serverbound)
- CONTAINER_ACK (serverbound)
Unsigned byte (unchanged):
- OPEN_SCREEN
- CONTAINER_SET_CONTENT
- CONTAINER_SET_DATA
- HORSE_SCREEN_OPEN
- CONTAINER_CLOSE (clientbound)
- CONTAINER_ACK (clientbound)
Short (unchanged):
- SET_CREATIVE_MODE_SLOT

This doesn't change much in practice, but means it matches the Vanilla reading
2025-03-11 10:36:49 +01:00
FlorianMichael e9ec29a217 Javadoc fixes (#4391) 2025-03-08 15:21:24 +01:00
FlorianMichaelandNassim Jahnke fb5bc8254a Add connection details protocol implementation (#4371)
Adds an optional custom payload protocol which platforms can use to communicate the native version of users across backend servers, the current implementation supports Velocity by sending the player's native version to the backend servers. Platforms may call ConnectionDetails#sendConnectionDetails themselves to ensure the packet getting handled by the server.

Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
2025-03-04 15:54:37 +01:00
FlorianMichael a7bc03f6a9 Treat changes in client bound base protocol handlers as separate protocols (#4400) 2025-02-27 22:31:35 +01:00
github-actions[bot]andgradle-update-robot d1bea0326c Update Gradle Wrapper from 8.12.1 to 8.13 (#4396)
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2025-02-25 18:40:57 +01:00
Nassim Jahnke d3512c9e7f Check overrides too when removing item data 2025-02-25 13:42:52 +01:00
Nassim Jahnke 2f1f7538e5 Ignore invalid ingredients in registry data 2025-02-23 11:10:04 +01:00
FlorianMichael ac3362f950 Don't add damage types twice in 1.19.4->1.20 (#4389)
Closes https://github.com/ViaVersion/ViaFabricPlus/issues/652
2025-02-19 14:13:52 +01:00
FlorianMichael 74e510b056 Fix clientEntityId check in MovementTransmitterProvider (#4390) 2025-02-19 14:13:24 +01:00
FlorianMichael fdd263b806 Make functions optional which are not always required in ViaPlatform (#4370) 2025-02-16 13:56:32 +01:00
FlorianMichael a764cec4a9 Add DebugHandler#logPrePacketTransform/setLogPacketTransform (#4386) 2025-02-16 13:55:20 +01:00
FlorianMichael 764861e29b [ci skip] Migrate the user wiki to GitHub (#4382) 2025-02-10 15:37:14 +01:00
EnZaXD 3e946ff67e Add user feedback to /viaversion list & player if no players are found (#4369) 2025-01-31 22:36:39 +01:00
Nassim Jahnke dca45ceb0e Simplify read error 2025-01-30 17:13:12 +01:00
Florian 327ec23ae9 Add PacketTypeMap#ofUnsequenced helper function (#4368) 2025-01-30 13:51:10 +01:00
Florian 9cf7737502 Fix container hover event deserialization (#4365) 2025-01-29 15:37:38 +01:00
Florian 0c5fa1b00a Add ProtocolRunnable internal API (#4364) 2025-01-29 15:36:57 +01:00
EnZaXD 1ca075fe89 Only add minecraft:spit damage type if not sent by the server in 1.20.3->1.20.5 (#4361) 2025-01-27 22:03:12 +01:00
EnZaXD d7c50a0c06 Remove newly added registry entries when already sent be the server (#4352)
Closes https://github.com/ViaVersion/ViaFabricPlus/issues/683
2025-01-26 22:15:48 +01:00
github-actions[bot]andgradle-update-robot 0e98839cee Update Gradle Wrapper from 8.12 to 8.12.1 (#4359)
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2025-01-26 20:01:35 +01:00
EnZaXD 512ceeb401 Rewrite sound event in consumable/equippable components (#4358) 2025-01-25 22:15:55 +01:00
lowercasebtwandEnZaXD 1bf04b4769 Use "intentionally_empty" sound event for 1.8 blocking (#4357)
* Use "intentionally_empty" sound event for 1.8 blocking

* Rather use the sound identifier

---------

Co-authored-by: EnZaXD <florian.michael07@gmail.com>
2025-01-24 22:31:35 +01:00
Nassim Jahnke e24981031b Fix optional explosions hover event deserialization
Fixes ViaVersion/ViaBackwards#952
2025-01-17 12:29:20 +01:00
Nassim Jahnke 261188569d Update custom model data in items in block entities 2025-01-16 13:15:22 +01:00
EnZaXD d2f35708ed Add tag->component handlers in 1.20.5->1.21 component rewriter (#4172)
Used for hover event handling in ViaBackwards
2025-01-15 11:51:44 +01:00
EnZaXD d282f37483 Fix tracking of falling blocks (#4344)
* Fix tracking of falling blocks

Since they use the data int, we have to try get() without taking it in as it will otherwise always fail.

* Prevent server from sending bad data

* Null check
2025-01-11 23:04:22 +01:00
Nassim Jahnke b244776cc9 Move up method to ComponentRewriter interface 2025-01-10 21:25:38 +01:00
Nassim Jahnke 3418e2c21a Prepare ComponentRewriter for 1.21.5 changes 2025-01-10 20:56:36 +01:00
EnZaXD d05bdd9eda Keep empty items in CONTAINER in 1.20.3->1.20.5 (#4338) 2025-01-10 17:43:12 +01:00
EnZaXD a92e75b8cc Properly track minecart object entity types in <= 1.12.2 (#4339) 2025-01-10 17:07:09 +01:00
569 changed files with 22377 additions and 3666 deletions

No files matched your search

+2 -11
View File
@@ -50,21 +50,12 @@ body:
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.
**Please always include the client version(s) with which the issue happens. Ideally also try to find out, from what specific version onward/in what version range the issue happens.**
placeholder: |
Example:
1. Login with a 1.21.3 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."
3. The sign text disappears
validations:
required: true
+3 -1
View File
@@ -1,6 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
cooldown:
default-days: 7
directory: "/"
schedule:
interval: "weekly"
interval: "monthly"
+9 -10
View File
@@ -1,23 +1,22 @@
name: Java CI with Gradle
on: [push, pull_request]
name: Build
on: [pull_request, push, workflow_dispatch]
permissions:
contents: read
jobs:
build:
# Only run on PRs if the source branch is on a different repo. We do not need to run everything twice.
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
with:
persist-credentials: false
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # 5.0.0
- name: Set up JDK 17
uses: actions/setup-java@v4
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # 5.0.0
with:
distribution: 'temurin'
java-version: 17
@@ -26,8 +25,8 @@ jobs:
run: ./gradlew build
- name: Upload Artifacts to GitHub
# Only upload on the preview repository as there is no CI job for it.
if: ${{ github.repository == 'ViaVersionDev' && github.ref_name == 'preview' }}
uses: actions/upload-artifact@v4
if: ${{ github.repository == 'ViaVersion/ViaVersionDev' && github.ref_name == 'preview' }}
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # 5.0.0
with:
name: Artifacts
path: build/libs/
+16 -5
View File
@@ -4,6 +4,10 @@ on:
branches:
- master
- dev
workflow_dispatch:
permissions:
contents: read
jobs:
publish:
@@ -11,19 +15,26 @@ jobs:
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
with:
persist-credentials: false
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # 5.0.0
- name: Set up JDK 17
uses: actions/setup-java@v4
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # 5.0.0
with:
distribution: 'temurin'
java-version: 17
check-latest: true
- name: Publish
- name: Build with Gradle
run: ./gradlew build
- name: Publish to Hangar
env:
HANGAR_TOKEN: ${{ secrets.HANGAR_TOKEN }}
run: ./gradlew publishAllPublicationsToHangar --stacktrace
continue-on-error: true
- name: Publish to Modrinth
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: ./gradlew build modrinth publishAllPublicationsToHangar --stacktrace
run: ./gradlew modrinth --stacktrace
continue-on-error: true
+7 -2
View File
@@ -4,13 +4,18 @@ on:
schedule:
- cron: "0 0 * * 0"
permissions:
contents: write
pull-requests: write
jobs:
update-gradle-wrapper:
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
with:
fetch-depth: 0
persist-credentials: false
- name: Update Gradle Wrapper
uses: gradle-update/update-gradle-wrapper-action@v2
uses: gradle-update/update-gradle-wrapper-action@512b1875f3b6270828abfe77b247d5895a2da1e5 # 2.1.0
+19 -98
View File
@@ -1,115 +1,36 @@
### Java files ###
*.class
# Gradle
# Package Files
#*.jar
*.war
*.ear
.gradle/
build/
out/
classes/
.kotlin/
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# Eclipse
*.launch
# Idea
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
# Ignore project files
*.iml
# Ignore IDEA directory
.idea/*
.idea/
!.idea/copyright/*
!.idea/scopes/*
# Include the project's dictionary
!.idea/dictionaries/
!.idea/dictionaries/*
# File-based project format:
*.iml
*.ipr
*.iws
### Plugin-specific files: ###
# IntelliJ
/out/
# VSCode
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
### Eclipse ###
*.pydevproject
.metadata
.gradle
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
# Eclipse Core
.vscode/
bin/
.classpath
.project
# External tool builders
.externalToolBuilders/
# macOS
# 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/
### MacOS ###
.DS_Store
### Run Folder (ViaProxy) ###
common/run/
# Misc
run/
+3 -5
View File
@@ -8,7 +8,7 @@
it works on any platform you can think of.**
The base ViaVersion jar runs on Paper and Velocity. We also have projects integrating ViaVersion to run
on Fabric, Forge, Bungee, Sponge, or as a standalone proxy to join from basically any client version on
on Fabric, Forge, Sponge, or as a standalone proxy to join from basically any client version on
any server version from the past decade. **See [HERE](https://viaversion.com) for an overview of the different Via\* projects.**
Note that ViaVersion will be able to **run best on either Paper servers or through [ViaFabricPlus](https://github.com/ViaVersion/ViaFabricPlus?tab=readme-ov-file#viafabricplus)** due to having
@@ -16,9 +16,9 @@ direct access to client/server state and more extensive API.
Supported Versions:
![Table (https://i.imgur.com/zrQTcf0.png)](https://i.imgur.com/zrQTcf0.png)
![Table (https://ci.viaversion.com/userContent/images/T.png)](https://ci.viaversion.com/userContent/images/T.png)
**User Docs:** https://docs.viaversion.com/display/VIAVERSION/
**User Docs:** https://docs.viaversion.com
Snapshot support
--------
@@ -87,12 +87,10 @@ of the `build/libs` directory.
You need JDK 17 or newer to build ViaVersion.
Mapping Files
--------------
Mapping files are generated and managed in our [Mappings repository](https://github.com/ViaVersion/Mappings). The generated mapping output is stored [here](./common/src/main/resources/assets/viaversion).
Resources
--------
+10
View File
@@ -0,0 +1,10 @@
# Security Policy
## Reporting a Vulnerability
If you discover a **security vulnerability**, please **do not** open a public issue. Instead, use one of the following **confidential contact methods**:
* **Email:** [security@viaversion.com](mailto:security@viaversion.com)
* **Discord:** Join our [Discord server](https://discord.gg/viaversion) and visit the [#exploit-report](https://discord.com/channels/316206679014244363/1388847764137316485) channel for further instructions.
If your issue is **not security-related** (e.g., bug reports, feature requests, or usage questions), please use the [GitHub Issues page](https://github.com/ViaVersion/ViaVersion/issues) or contact us via the [Discord server](https://discord.gg/viaversion).
+5 -1
View File
@@ -29,7 +29,11 @@ dependencies {
api(libs.snakeYaml)
compileOnlyApi(libs.netty)
compileOnlyApi(libs.guava)
compileOnlyApi(libs.guava) {
exclude("com.google.errorprone", "error_prone_annotations")
exclude("org.jspecify", "jspecify")
exclude("com.google.j2objc", "j2objc-annotations")
}
compileOnlyApi(libs.checkerQual)
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2024 ViaVersion and contributors
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -114,7 +114,8 @@ public interface ViaAPI<T> {
ProtocolVersion getPlayerProtocolVersion(UUID uuid);
/**
* Returns whether Via injected into this player connection.
* Returns whether Via injected into this player connection. Note that this method may not work on
* clientside implementations and is generally not recommended to be used. Use {@link ConnectionManager} instead.
*
* @param uuid uuid of the player
* @return whether Via has a cached a UserConnection for this player
@@ -122,7 +123,8 @@ public interface ViaAPI<T> {
boolean isInjected(UUID uuid);
/**
* Returns the Via injected UserConnection if present.
* Returns the injected UserConnection if present. Note that this method may not work on
* clientside implementations and is generally not recommended to be used. Use {@link ConnectionManager} instead.
*
* @param uuid uuid of the player
* @return user connection if present
@@ -66,7 +66,7 @@ public interface ViaSubCommand {
*
* @param sender Command sender
* @param args Arguments
* @return commands executed succesfully if false, show usage
* @return commands executed successfully if false, show usage
*/
boolean execute(ViaCommandSender sender, String[] args);
@@ -30,7 +30,7 @@ public interface ViaVersionCommand {
* Register your own subcommand inside ViaVersion
*
* @param command Your own SubCommand instance to handle it.
* @throws IllegalArgumentException throws an exception when the subcommand already exists or if it's not valid, example: spacee
* @throws IllegalArgumentException throws an exception when the subcommand already exists or if it's not valid, example: space
*/
void registerSubCommand(ViaSubCommand command);
@@ -0,0 +1,27 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.configuration;
public record RateLimitConfig(boolean enabled, int maxRate, String maxRateKickMessage, int warningRate, int maxWarnings,
long trackingPeriodNanos, String warningKickMessage, String ratePlaceholder) {
}
@@ -147,6 +147,7 @@ public interface ViaVersionConfig extends Config {
*
* @return The number of packets a client can send per second.
*/
@Deprecated(forRemoval = true)
int getMaxPPS();
/**
@@ -154,6 +155,7 @@ public interface ViaVersionConfig extends Config {
*
* @return Kick message, with colour codes using '&amp;amp;'
*/
@Deprecated(forRemoval = true)
String getMaxPPSKickMessage();
/**
@@ -161,6 +163,7 @@ public interface ViaVersionConfig extends Config {
*
* @return Time in seconds that should be tracked for warnings
*/
@Deprecated(forRemoval = true)
int getTrackingPeriod();
/**
@@ -168,6 +171,7 @@ public interface ViaVersionConfig extends Config {
*
* @return The number of packets per second to count as a warning.
*/
@Deprecated(forRemoval = true)
int getWarningPPS();
/**
@@ -175,6 +179,7 @@ public interface ViaVersionConfig extends Config {
*
* @return The number of packets a client can send per second.
*/
@Deprecated(forRemoval = true)
int getMaxWarnings();
/**
@@ -182,8 +187,13 @@ public interface ViaVersionConfig extends Config {
*
* @return Kick message, with colour codes using '&amp;amp;'
*/
@Deprecated(forRemoval = true)
String getMaxWarningsKickMessage();
RateLimitConfig getPacketTrackerConfig();
RateLimitConfig getPacketSizeTrackerConfig();
/**
* Send supported versions in the status response packet
*
@@ -233,13 +243,6 @@ public interface ViaVersionConfig extends Config {
*/
boolean isChunkBorderFix();
/**
* Should we fix nbt array's in json chat messages for 1.12 clients
*
* @return true if enabled
*/
boolean is1_12NBTArrayFix();
/**
* Should we make team colours based on the last colour in team prefix
*
@@ -270,6 +273,8 @@ public interface ViaVersionConfig extends Config {
*/
String getBlockedDisconnectMsg();
boolean logBlockedJoins();
/**
* Get the message sent to players being kicked on reload.
* Players are kicked to stop the server crashing
@@ -285,6 +290,13 @@ public interface ViaVersionConfig extends Config {
*/
boolean isSuppressConversionWarnings();
/**
* Should we hide errors that occur when trying to convert text components?
*
* @return true if enabled
*/
boolean isSuppressTextComponentConversionWarnings();
/**
* Should we disable the 1.13 auto-complete feature to stop spam kicks? (for any server lower than 1.13)
*
@@ -478,4 +490,12 @@ public interface ViaVersionConfig extends Config {
* @return true if enabled
*/
boolean fix1_21PlacementRotation();
/**
* If enabled, cancel swing packets sent while having an inventory opened on 1.15.2 and below servers.
* This can cause false positives with anti-cheat plugins.
*
* @return true if enabled
*/
boolean cancelSwingInInventory();
}
@@ -28,51 +28,81 @@ import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Handles injected UserConnections
* Handles injected UserConnections.
* Check {@link UserConnection#isServerSide()} and {@link UserConnection#isClientSide()} to determine the connection type.
*/
public interface ConnectionManager {
/**
* Returns if Via injected into this player connection.
* Returns if Via has injected. See above for the connection types.
*
* @param playerId player uuid
* @param uuid player uuid
* @return true if the player is handled by Via
*/
boolean isClientConnected(UUID playerId);
boolean hasServerConnection(UUID uuid);
/**
* Frontend connections will have the UUID stored. Override this if your platform isn't always frontend.
* UUIDs can't be duplicate between frontend connections.
*
* @return true if the user is a frontend connection
*/
default boolean isFrontEnd(UserConnection connection) {
return !connection.isClientSide();
@Deprecated
default boolean isClientConnected(UUID uuid) {
return hasServerConnection(uuid);
}
/**
* Returns the frontend UserConnection from the player connected to this proxy server
* Returns null when there isn't a server or connection was not found
* When ViaVersion is reloaded, this method may not return some players.
* <p>
* Note that connections are removed as soon as their channel is closed,
* so avoid using this method during player quits for example.
* Returns if Via has injected. See above for the connection types.
*
* @return frontend UserConnection of the player connected to this proxy server
* @param uuid player uuid
* @return true if the player is handled by Via
*/
@Nullable UserConnection getConnectedClient(UUID clientIdentifier);
boolean hasClientConnection(UUID uuid);
/**
* Returns the UUID from the frontend connection to this proxy server
* Returns null when there isn't a server or this connection isn't frontend, or it doesn't have an id
* Returns the server UserConnection. See above for the connection types.
* When ViaVersion is reloaded, this method may not return some players.
* <p>
* Note that connections are removed as soon as their channel is closed,
* so avoid using this method during player quits for example.
*
* @return UUID of the frontend connection to this proxy server
* @return server UserConnection of the player or null
*/
@Nullable UUID getConnectedClientId(UserConnection connection);
@Nullable
UserConnection getServerConnection(UUID uuid);
@Deprecated
@Nullable default UserConnection getConnectedClient(UUID uuid) {
return getServerConnection(uuid);
}
/**
* Returns the client UserConnection. See above for the connection types.
* When ViaVersion is reloaded, this method may not return some players.
* <p>
* Note that connections are removed as soon as their channel is closed,
* so avoid using this method during player quits for example.
*
* @return client UserConnection of the player or null
*/
@Nullable
UserConnection getClientConnection(UUID uuid);
/**
* Returns a map containing the UUIDs and server UserConnections
* When ViaVersion is reloaded, this method may not return some players.
*
* @return map containing the UUIDs and frontend UserConnections
*/
Map<UUID, UserConnection> getServerConnections();
@Deprecated
default Map<UUID, UserConnection> getConnectedClients() {
return getServerConnections();
}
/**
* Returns a map containing the UUIDs and client UserConnections
* When ViaVersion is reloaded, this method may not return some players.
*
* @return map containing the UUIDs and client UserConnections
*/
Map<UUID, UserConnection> getClientConnections();
/**
* Returns all UserConnections which are registered
@@ -84,15 +114,6 @@ public interface ConnectionManager {
*/
Set<UserConnection> getConnections();
/**
* Returns a map containing the UUIDs and frontend UserConnections from players connected to this proxy server
* Returns empty list when there isn't a server
* When ViaVersion is reloaded, this method may not return some players.
*
* @return map containing the UUIDs and frontend UserConnections from players connected to this proxy server
*/
Map<UUID, UserConnection> getConnectedClients();
void onLoginSuccess(UserConnection connection);
void onDisconnect(UserConnection connection);
@@ -30,15 +30,6 @@ package com.viaversion.viaversion.api.connection;
*/
public interface StorableObject {
/**
* Returns whether the object should be uncached on a server switch.
*
* @return whether the object should be uncached on a server switch
*/
default boolean clearOnServerSwitch() {
return true;
}
default void onRemove() {
}
}
@@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.connection;
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.data.item.ItemHasher;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.PacketTracker;
@@ -99,6 +100,23 @@ public interface UserConnection {
*/
void addEntityTracker(Class<? extends Protocol> protocolClass, EntityTracker tracker);
/**
* Adds an item hasher to the user connection.
*
* @param protocolClass protocol class
* @param itemHasher item hasher
*/
void addItemHasher(Class<? extends Protocol> protocolClass, ItemHasher itemHasher);
/**
* Returns the item hasher by the given protocol class if present.
*
* @param protocolClass protocol class
* @param <T> item hasher type
* @return item hasher if present
*/
@Nullable <T extends ItemHasher> T getItemHasher(Class<? extends Protocol> protocolClass);
/**
* Returns the client world by the given protocol class if present.
*
@@ -121,17 +139,7 @@ public interface UserConnection {
/**
* Clear stored objects, entity trackers and client worlds.
*/
default void clearStoredObjects() {
clearStoredObjects(false);
}
/**
* Clear stored objects, entity trackers and client worlds.
* If cleared for a proxy server switch, some stored objects and tracker data will be retained.
*
* @param isServerSwitch whether the clear is due to a server switch
*/
void clearStoredObjects(boolean isServerSwitch);
void clearStoredObjects();
/**
* Sends a raw packet to the connection on the current thread.
@@ -186,9 +194,15 @@ public interface UserConnection {
/**
* Monitors serverbound packets and returns whether a packet can/should be processed.
*
* @param bytes the number of bytes in the packet
* @return false if this packet should be cancelled
*/
boolean checkServerboundPacket();
boolean checkServerboundPacket(int bytes);
@Deprecated(forRemoval = true)
default boolean checkServerboundPacket() {
return checkServerboundPacket(0);
}
/**
* Monitors clientbound packets and returns whether a packet can/should be processed.
@@ -201,6 +215,11 @@ public interface UserConnection {
* @see #checkClientboundPacket()
* @see #checkServerboundPacket()
*/
default boolean checkIncomingPacket(final int bytes) {
return isClientSide() ? checkClientboundPacket() : checkServerboundPacket(bytes);
}
@Deprecated(forRemoval = true)
default boolean checkIncomingPacket() {
return isClientSide() ? checkClientboundPacket() : checkServerboundPacket();
}
@@ -319,23 +338,35 @@ public interface UserConnection {
void setPendingDisconnect(boolean pendingDisconnect);
/**
* Returns whether this is a client-side connection.
* This is a mod integrated into the client itself, or for example a backend Velocity connection.
* Returns whether this is a backend connection.
* This is a mod integrated into the client, or for example a backend Velocity connection.
*
* @return whether this is a client-side connection
* @return whether this is a backend connection
*/
boolean isClientSide();
/**
* Returns whether this is a frontend connection.
* This is a plugin integrated into the server, or for example a frontend Velocity connection.
*
* @return whether this is a frontend connection
*/
default boolean isServerSide() {
return !isClientSide();
}
/**
* Returns whether {@link ViaVersionConfig#blockedProtocolVersions()} should be checked for this connection.
*
* @return whether blocked protocols should be applied
*/
boolean shouldApplyBlockProtocol();
default boolean shouldApplyBlockProtocol() {
return isServerSide();
}
/**
* Returns a newly generated uuid that will let a packet be passed through without
* transformig its contents if used together with {@link PacketWrapper#PASSTHROUGH_ID}.
* transforming its contents if used together with {@link PacketWrapper#PASSTHROUGH_ID}.
*
* @return generated passthrough token
*/
@@ -22,9 +22,13 @@
*/
package com.viaversion.viaversion.api.data;
import com.viaversion.viaversion.api.minecraft.RegistryKey;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.TagData;
import com.viaversion.viaversion.util.Key;
import it.unimi.dsi.fastutil.ints.IntSet;
import java.util.List;
import java.util.Locale;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface MappingData {
@@ -140,12 +144,14 @@ public interface MappingData {
@Nullable Mappings getBlockMappings();
@Nullable Mappings getBlockEntityMappings();
@Nullable FullMappings getFullBlockMappings();
@Nullable Mappings getBlockStateMappings();
@Nullable Mappings getSoundMappings();
@Nullable FullMappings getFullSoundMappings();
@Nullable Mappings getStatisticsMappings();
@Nullable Mappings getMenuMappings();
@@ -154,6 +160,8 @@ public interface MappingData {
@Nullable Mappings getPaintingMappings();
@Nullable FullMappings getBlockEntityMappings();
@Nullable FullMappings getAttributeMappings();
@Nullable FullMappings getEntityMappings();
@@ -163,4 +171,32 @@ public interface MappingData {
@Nullable FullMappings getRecipeSerializerMappings();
@Nullable FullMappings getDataComponentSerializerMappings();
default @Nullable FullMappings getFullMappings(final MappingType mappingType) {
return switch (mappingType) {
case ITEM -> getFullItemMappings();
case BLOCK -> getFullBlockMappings();
case SOUND -> getFullSoundMappings();
case ENTITY_TYPE -> getEntityMappings();
};
}
/**
* Set of block (not block state) ids that had their base type or properties changed.
*
* @return set of changed block ids, or null if not tracked/none are present
*/
@Nullable IntSet changedBlocks();
/**
* Type of mappings. Currently only relevant for ops writing of generic holder classes and expanded when needed.
*/
enum MappingType implements RegistryKey {
ITEM, BLOCK, SOUND, ENTITY_TYPE;
@Override
public Key key() {
return Key.of(name().toLowerCase(Locale.ROOT));
}
}
}
@@ -28,6 +28,8 @@ import com.viaversion.nbt.tag.Tag;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.TagData;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
@@ -44,17 +46,21 @@ public class MappingDataBase implements MappingData {
protected FullMappings recipeSerializerMappings;
protected FullMappings itemDataSerializerMappings;
protected FullMappings attributeMappings;
protected FullMappings blockEntityMappings;
protected ParticleMappings particleMappings;
protected BiMappings itemMappings;
protected BiMappings blockMappings;
protected Mappings blockStateMappings;
protected Mappings blockEntityMappings;
protected Mappings soundMappings;
protected Mappings statisticsMappings;
protected Mappings enchantmentMappings;
protected Mappings paintingMappings;
protected Mappings menuMappings;
protected Map<RegistryType, List<TagData>> tags;
/**
* Set of block ids that have had type or property changes.
*/
protected IntSet changedBlocks;
public MappingDataBase(final String unmappedVersion, final String mappedVersion) {
this.unmappedVersion = unmappedVersion;
@@ -68,10 +74,7 @@ public class MappingDataBase implements MappingData {
}
final CompoundTag data = readMappingsFile("mappings-" + unmappedVersion + "to" + mappedVersion + ".nbt");
blockMappings = loadBiMappings(data, "blocks");
blockStateMappings = loadMappings(data, "blockstates");
blockEntityMappings = loadMappings(data, "blockentities");
soundMappings = loadMappings(data, "sounds");
statisticsMappings = loadMappings(data, "statistics");
menuMappings = loadMappings(data, "menus");
enchantmentMappings = loadMappings(data, "enchantments");
@@ -80,12 +83,16 @@ public class MappingDataBase implements MappingData {
final CompoundTag unmappedIdentifierData = readUnmappedIdentifiersFile("identifiers-" + unmappedVersion + ".nbt");
final CompoundTag mappedIdentifierData = readMappedIdentifiersFile("identifiers-" + mappedVersion + ".nbt");
if (unmappedIdentifierData != null && mappedIdentifierData != null) {
itemMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "items");
itemMappings = loadFullOrBiMappings(data, unmappedIdentifierData, mappedIdentifierData, "items");
blockMappings = loadFullOrBiMappings(data, unmappedIdentifierData, mappedIdentifierData, "blocks");
soundMappings = loadFullOrBiMappings(data, unmappedIdentifierData, mappedIdentifierData, "sounds");
entityMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "entities");
argumentTypeMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "argumenttypes");
recipeSerializerMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "recipe_serializers");
itemDataSerializerMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "data_component_type");
attributeMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "attributes");
blockEntityMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "blockentities");
final List<String> unmappedParticles = identifiersFromGlobalIds(unmappedIdentifierData, "particles");
final List<String> mappedParticles = identifiersFromGlobalIds(mappedIdentifierData, "particles");
@@ -99,6 +106,8 @@ public class MappingDataBase implements MappingData {
} else {
// Might not have identifiers in older versions
itemMappings = loadBiMappings(data, "items");
blockMappings = loadBiMappings(data, "blocks");
soundMappings = loadMappings(data, "sounds");
}
final CompoundTag tagsTag = data.getCompoundTag("tags");
@@ -109,6 +118,11 @@ public class MappingDataBase implements MappingData {
loadTags(RegistryType.ENTITY, tagsTag);
}
final IntArrayTag changedBlocks = data.getIntArrayTag("changed_blocks");
if (changedBlocks != null) {
this.changedBlocks = new IntOpenHashSet(changedBlocks.getValue());
}
loadExtras(data);
}
@@ -132,6 +146,11 @@ public class MappingDataBase implements MappingData {
return MappingDataLoader.INSTANCE.loadMappings(data, key);
}
protected @Nullable BiMappings loadFullOrBiMappings(final CompoundTag data, final CompoundTag unmappedIdentifiersTag, final CompoundTag mappedIdentifiersTag, final String key) {
final FullMappings mappings = loadFullMappings(data, unmappedIdentifiersTag, mappedIdentifiersTag, key);
return mappings != null ? mappings : loadBiMappings(data, key);
}
protected @Nullable FullMappings loadFullMappings(final CompoundTag data, final CompoundTag unmappedIdentifiersTag, final CompoundTag mappedIdentifiersTag, final String key) {
if (!unmappedIdentifiersTag.contains(key) || !mappedIdentifiersTag.contains(key)) {
return null;
@@ -153,7 +172,7 @@ public class MappingDataBase implements MappingData {
}
private void loadTags(final RegistryType type, final CompoundTag data) {
final CompoundTag tag = data.getCompoundTag(type.resourceLocation());
final CompoundTag tag = data.getCompoundTag(type.identifier());
if (tag == null) {
return;
}
@@ -208,8 +227,8 @@ public class MappingDataBase implements MappingData {
}
@Override
public int getOldSoundId(final int i) {
return soundMappings.getNewIdOrDefault(i, 0);
public int getOldSoundId(final int id) {
return soundMappings.inverse().getNewIdOrDefault(id, 0);
}
@Override
@@ -224,8 +243,8 @@ public class MappingDataBase implements MappingData {
@Override
public @Nullable FullMappings getFullItemMappings() {
if (itemMappings instanceof FullMappings) {
return (FullMappings) itemMappings;
if (itemMappings instanceof FullMappings fullItemMappings) {
return fullItemMappings;
}
return null;
}
@@ -241,7 +260,15 @@ public class MappingDataBase implements MappingData {
}
@Override
public @Nullable Mappings getBlockEntityMappings() {
public @Nullable FullMappings getFullBlockMappings() {
if (blockMappings instanceof FullMappings fullBlockMappings) {
return fullBlockMappings;
}
return null;
}
@Override
public @Nullable FullMappings getBlockEntityMappings() {
return blockEntityMappings;
}
@@ -255,6 +282,14 @@ public class MappingDataBase implements MappingData {
return soundMappings;
}
@Override
public @Nullable FullMappings getFullSoundMappings() {
if (soundMappings instanceof FullMappings fullSoundMappings) {
return fullSoundMappings;
}
return null;
}
@Override
public @Nullable Mappings getStatisticsMappings() {
return statisticsMappings;
@@ -300,6 +335,11 @@ public class MappingDataBase implements MappingData {
return recipeSerializerMappings;
}
@Override
public @Nullable IntSet changedBlocks() {
return changedBlocks;
}
protected Logger getLogger() {
return Via.getPlatform().getLogger();
}
@@ -210,7 +210,7 @@ public class MappingDataLoader {
return null;
}
final int mappedSize = tag.getIntTag("mappedSize").asInt();
final int mappedSize = tag.getInt("mappedSize", -1);
final byte strategy = tag.getByteTag("id").asByte();
final V mappings;
if (strategy == DIRECT_ID) {
@@ -82,6 +82,11 @@ public interface EntityTracker {
*/
void clearEntities();
/**
* Clears all stored data, including entity types, entity data and client entity id.
*/
void clear();
/**
* Returns the stored entity data if an entity with the id is tracked, else null.
* If no data has been initialized yet, it will be done and returned by this method.
@@ -123,6 +128,20 @@ public interface EntityTracker {
*/
void setClientEntityId(int clientEntityId);
/**
* Returns whether the client player has the "insta build" ability, usually from creative mode.
*
* @return whether the client player can insta build
*/
boolean canInstaBuild();
/**
* Sets whether the client player has the "insta build" ability, usually from creative mode.
*
* @param instaBuild whether the client player can insta build
*/
void setInstaBuild(boolean instaBuild);
/**
* Returns the current world section height (block height / 16).
* This is always 16 for sub 1.17 worlds.
@@ -166,6 +185,20 @@ public interface EntityTracker {
*/
void setCurrentWorld(String currentWorld);
/**
* Returns the id of the current dimension, or -1 if unset (i.e. before 1.20.5).
*
* @return id of the current dimension, or -1 if unset
*/
int currentDimensionId();
/**
* Sets the id of the current dimension.
*
* @param currentDimensionId id of the current dimension
*/
void setCurrentDimensionId(int currentDimensionId);
int biomesSent();
void setBiomesSent(int biomesSent);
@@ -0,0 +1,42 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.data.item;
/**
* Used for converting items to hashed items and caching them for later use during serverbound packets.
* <p>
* Most of this stays in the internal module given non-permanent, imperfect caching as well as missing converters.
*/
public interface ItemHasher {
/**
* Returns whether this connection is currently processing a clientbound player inventory packet.
* <p>
* Used for checking when it is necessary to track/process item data hashes.
*
* @return true if processing a clientbound inventory packet, false otherwise
*/
boolean isProcessingClientboundInventoryPacket();
void setProcessingClientboundInventoryPacket(boolean processingClientboundInventoryPacket);
}
@@ -22,7 +22,6 @@
*/
package com.viaversion.viaversion.api.debug;
import com.google.common.annotations.Beta;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.protocol.packet.Direction;
import com.viaversion.viaversion.api.protocol.packet.PacketType;
@@ -50,7 +49,6 @@ public interface DebugHandler {
*
* @param packetTypeName packet type name
*/
@Beta
void addPacketTypeNameToLog(String packetTypeName);
/**
@@ -59,7 +57,6 @@ public interface DebugHandler {
*
* @param packetType packet type
*/
@Beta
void addPacketTypeToLog(PacketType packetType);
/**
@@ -67,22 +64,44 @@ public interface DebugHandler {
*
* @param packetTypeName packet type name
*/
@Beta
boolean removePacketTypeNameToLog(String packetTypeName);
/**
* Resets packet type filters.
*/
@Beta
void clearPacketTypesToLog();
/**
* Sets whether packets should be logged before and after being transformed.
*
* @param logPacketTransform whether packets should be logged
*/
default void setLogPacketTransform(boolean logPacketTransform) {
setLogPrePacketTransform(logPacketTransform);
setLogPostPacketTransform(logPacketTransform);
}
/**
* Returns whether packets should be logged before being transformed.
* Set to true by default.
*
* @return whether packets should be logged before being transformed
*/
boolean logPrePacketTransform();
/**
* Sets whether packets should be logged before being transformed.
*
* @param logPrePacketTransform whether packets should be logged before being transformed
*/
void setLogPrePacketTransform(boolean logPrePacketTransform);
/**
* Returns whether packets should be logged after being transformed.
* Set to false by default.
*
* @return whether packets should be logged after being transformed
*/
@Beta
boolean logPostPacketTransform();
/**
@@ -90,7 +109,6 @@ public interface DebugHandler {
*
* @param logPostPacketTransform whether packets should be logged after being transformed
*/
@Beta
void setLogPostPacketTransform(boolean logPostPacketTransform);
/**
@@ -103,7 +121,6 @@ public interface DebugHandler {
*/
boolean shouldLog(PacketWrapper wrapper, Direction direction);
@Beta
default void enableAndLogIds(final PacketType... packetTypes) {
setEnabled(true);
for (final PacketType packetType : packetTypes) {
@@ -0,0 +1,55 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.misc.HolderType;
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Represents an animal variant (e.g. for cows, pigs, chickens).
*
* @param modelType model type id
* @param texture texture path
* @param biomes biomes this variant can spawn in, if limited to specific biomes
*/
public record AnimalVariant(int modelType, String texture, @Nullable HolderSet biomes) {
public static HolderType<AnimalVariant> TYPE = new HolderType<>() {
@Override
public AnimalVariant readDirect(final ByteBuf buffer) {
final int modelType = Types.VAR_INT.readPrimitive(buffer);
final String texture = Types.STRING.read(buffer);
final HolderSet biomes = Types.OPTIONAL_HOLDER_SET.read(buffer);
return new AnimalVariant(modelType, texture, biomes);
}
@Override
public void writeDirect(final ByteBuf buffer, final AnimalVariant variant) {
Types.VAR_INT.writePrimitive(buffer, variant.modelType());
Types.STRING.write(buffer, variant.texture());
Types.OPTIONAL_HOLDER_SET.write(buffer, variant.biomes());
}
};
}
@@ -58,7 +58,7 @@ public class BlockChangeRecord1_16_2 implements BlockChangeRecord {
@Override
public short getY(int chunkSectionY) {
Preconditions.checkArgument(chunkSectionY >= 0, "Invalid chunkSectionY: " + chunkSectionY);
Preconditions.checkArgument(chunkSectionY >= 0, "Invalid chunkSectionY: %s", chunkSectionY);
return (short) ((chunkSectionY << 4) + sectionY);
}
@@ -33,7 +33,6 @@ public enum BlockFace {
TOP((byte) 0, (byte) 1, (byte) 0, EnumAxis.Y),
BOTTOM((byte) 0, (byte) -1, (byte) 0, EnumAxis.Y);
public static final BlockFace[] HORIZONTAL = {NORTH, SOUTH, EAST, WEST};
private static final Map<BlockFace, BlockFace> opposites = new EnumMap<>(BlockFace.class);
static {
@@ -0,0 +1,82 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public interface EitherHolder<T> {
/**
* Returns a direct or indirect value holder.
*
* @param value the value
* @param <T> the type of the value
* @return a new direct holder
*/
static <T> EitherHolder<T> of(final Holder<T> value) {
return new EitherHolderImpl<>(value, null);
}
/**
* Returns an indirect holder via the resource key.
*
* @param key the resource key
* @param <T> the type of the value
* @return a new holder with the given resource key
*/
static <T> EitherHolder<T> of(final String key) {
return new EitherHolderImpl<>(null, key);
}
/**
* Returns true if this holder is backed by a direct value.
*
* @return true if the holder is direct
* @see #hasKey()
*/
boolean hasHolder();
/**
* Returns true if this holder has a resource key.
*
* @return true if this holder has a resource key
* @see #hasHolder()
*/
boolean hasKey();
/**
* Returns the value of this holder.
*
* @return the value of this holder
* @throws IllegalArgumentException if this contains a resource key instead of a holder
* @see #hasHolder()
*/
Holder<T> holder();
/**
* Returns the resource key.
*
* @return the resource key
* @throws IllegalArgumentException if this contains a holder instead of a resource key
* @see #hasKey()
*/
String key();
}
@@ -0,0 +1,55 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.util.EitherImpl;
final class EitherHolderImpl<T> extends EitherImpl<Holder<T>, String> implements EitherHolder<T> {
EitherHolderImpl(final Holder<T> left, final String value) {
super(left, value);
}
@Override
public boolean hasHolder() {
return isLeft();
}
@Override
public boolean hasKey() {
return isRight();
}
@Override
public Holder<T> holder() {
Preconditions.checkArgument(hasHolder(), "Either does not have a holder");
return left();
}
@Override
public String key() {
Preconditions.checkArgument(hasKey(), "Either does not have a key");
return right();
}
}
@@ -24,22 +24,28 @@ package com.viaversion.viaversion.api.minecraft;
public enum GameMode {
NOT_SET(""),
SURVIVAL("Survival Mode"),
CREATIVE("Creative Mode"),
ADVENTURE("Adventure Mode"),
SPECTATOR("Spectator Mode");
NOT_SET("", -1),
SURVIVAL("Survival Mode", 0),
CREATIVE("Creative Mode", 1),
ADVENTURE("Adventure Mode", 2),
SPECTATOR("Spectator Mode", 3);
private final String text;
private final int id;
GameMode(String text) {
GameMode(String text, final int id) {
this.text = text;
this.id = id;
}
public String text() {
return text;
}
public int id() {
return id;
}
public static GameMode getById(int id) {
return switch (id) {
case -1 -> NOT_SET;
@@ -22,11 +22,35 @@
*/
package com.viaversion.viaversion.api.minecraft;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.checkerframework.checker.nullness.qual.Nullable;
public record GameProfile(@Nullable String name, @Nullable UUID id, Property[] properties) {
public record GameProfile(@Nullable String name, @Nullable UUID id, Property[] properties, boolean dynamic) {
public GameProfile(@Nullable final String name, @Nullable final UUID id, final Property[] properties) {
this(name, id, properties, true);
}
public GameProfile(@Nullable final String name, @Nullable final UUID id) {
this(name, id, new Property[0]);
}
public Map<String, List<Property>> propertiesMap() {
final Map<String, List<Property>> map = new HashMap<>();
for (Property property : properties) {
map.computeIfAbsent(property.name(), k -> new ArrayList<>()).add(property);
}
return map;
}
public record Property(String name, String value, @Nullable String signature) {
public Property(final String name, final String value) {
this(name, value, null);
}
}
}
@@ -23,6 +23,8 @@
package com.viaversion.viaversion.api.minecraft;
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
import java.util.function.Function;
import java.util.function.Supplier;
public interface Holder<T> {
@@ -88,5 +90,24 @@ public interface Holder<T> {
* @param rewriteFunction the function to rewrite the id
* @return a new holder with the id rewritten, or self
*/
Holder<T> updateId(final Int2IntFunction rewriteFunction);
default Holder<T> updateId(final Int2IntFunction rewriteFunction) {
return this.updateId(rewriteFunction, null);
}
/**
* Returns a new holder with the id rewritten using the given function, or self if this is a direct holder or the id did not change.
*
* @param rewriteFunction the function to rewrite the id
* @param ifMissing a supplier that provides a new holder if the id is missing (i.e. -1)
* @return a new holder with the id rewritten, or self
*/
Holder<T> updateId(Int2IntFunction rewriteFunction, Supplier<Holder<T>> ifMissing);
/**
* Returns a new holder with the value rewritten using the given function, or self if this is an id holder or the value did not change.
*
* @param rewriteFunction the function to rewrite the value
* @return a new holder with the value rewritten, or self
*/
Holder<T> updateValue(final Function<T, T> rewriteFunction);
}
@@ -22,7 +22,11 @@
*/
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.nbt.tag.Tag;
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
import java.util.function.Function;
/**
* Set of ids that either holds a string tag key or an array of ids.
@@ -32,7 +36,7 @@ public interface HolderSet {
/**
* Creates a new holder set for the given tag.
*
* @param tagKey the tag key
* @param tagKey the tag key, not including '#'
* @return a new holder set
*/
static HolderSet of(final String tagKey) {
@@ -49,10 +53,29 @@ public interface HolderSet {
return new HolderSetImpl.Ids(ids);
}
static HolderSet fromTag(final Tag tag, final Function<String, Integer> mappingFunction) {
if (tag instanceof StringTag stringTag) {
if (stringTag.getValue().startsWith("#")) {
return HolderSet.of(stringTag.getValue().substring(1));
}
final int id = mappingFunction.apply(stringTag.getValue());
return HolderSet.of(new int[]{id});
} else if (tag instanceof ListTag<?> listTag) {
final int[] ids = new int[listTag.size()];
for (int i = 0; i < listTag.size(); i++) {
final String value = ((StringTag) listTag.get(i)).getValue();
ids[i] = mappingFunction.apply(value);
}
return HolderSet.of(ids);
}
throw new IllegalArgumentException();
}
/**
* Gets the tag key.
* Gets the tag key, not including '#'.
*
* @return the tag key
* @return the tag key without a '#'
* @see #hasTagKey()
*/
String tagKey();
@@ -67,11 +67,17 @@ final class HolderSetImpl {
@Override
public HolderSet rewrite(final Int2IntFunction idRewriter) {
// Filter out negative ids as they would come from missing VB mapping data. This happens especially
// with block ids which are not mapped and thus written as -1 so VV rewriters can cancel them nicely.
final int[] mappedIds = new int[ids.length];
for (int i = 0; i < mappedIds.length; i++) {
mappedIds[i] = idRewriter.applyAsInt(ids[i]);
int validCount = 0;
for (final int id : ids) {
final int mappedId = idRewriter.applyAsInt(id);
if (mappedId != -1) {
mappedIds[validCount++] = mappedId;
}
}
return new Ids(mappedIds);
return new Ids(validCount == ids.length ? mappedIds : Arrays.copyOf(mappedIds, validCount));
}
@Override
@@ -24,6 +24,8 @@ package com.viaversion.viaversion.api.minecraft;
import com.google.common.base.Preconditions;
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
import java.util.function.Function;
import java.util.function.Supplier;
record IdHolder<T>(int id) implements Holder<T> {
@@ -47,14 +49,22 @@ record IdHolder<T>(int id) implements Holder<T> {
}
@Override
public Holder<T> updateId(final Int2IntFunction rewriteFunction) {
public Holder<T> updateId(final Int2IntFunction rewriteFunction, final Supplier<Holder<T>> ifMissing) {
final int rewrittenId = rewriteFunction.applyAsInt(id);
if (rewrittenId == id) {
return this;
}
if (rewrittenId == -1) {
if (ifMissing != null) {
return ifMissing.get();
}
throw new IllegalArgumentException("Received invalid id in updateId");
}
return Holder.of(rewrittenId);
}
@Override
public Holder<T> updateValue(final Function<T, T> rewriteFunction) {
return this;
}
}
@@ -23,8 +23,10 @@
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viaversion.api.minecraft.codec.Ops;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.misc.HolderType;
import com.viaversion.viaversion.util.Key;
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -69,5 +71,21 @@ public record PaintingVariant(int width, int height, String assetId, @Nullable T
Types.OPTIONAL_TAG.write(buffer, variant.title());
Types.OPTIONAL_TAG.write(buffer, variant.author());
}
@Override
public void writeDirect(final Ops ops, final PaintingVariant value) {
// Unused, cannot be direct despite having a direct network codec
ops.writeMap(map -> map
.write("width", Types.INT, value.width())
.write("height", Types.INT, value.height())
.write("asset_id", Types.IDENTIFIER, Key.of(value.assetId()))
.writeOptional("title", Types.TAG, value.title())
.writeOptional("author", Types.TAG, value.author()));
}
@Override
protected Key identifier(final Ops ops, final int id) {
return ops.context().registryAccess().registryKey("painting_variant", id);
}
};
}
@@ -22,15 +22,15 @@
*/
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.util.Copyable;
import com.viaversion.viaversion.util.IdHolder;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
public final class Particle implements IdHolder {
public final class Particle implements IdHolder, Copyable {
private final List<ParticleData<?>> arguments = new ArrayList<>(4);
private int id;
@@ -73,6 +73,7 @@ public final class Particle implements IdHolder {
arguments.set(index, new ParticleData<>(type, value));
}
@Override
public Particle copy() {
final Particle particle = new Particle(id);
for (ParticleData<?> argument : arguments) {
@@ -89,7 +90,7 @@ public final class Particle implements IdHolder {
'}';
}
public static final class ParticleData<T> {
public static final class ParticleData<T> implements Copyable {
private final Type<T> type;
private T value;
@@ -118,12 +119,9 @@ public final class Particle implements IdHolder {
wrapper.write(type, value);
}
@Override
public ParticleData<T> copy() {
if (value instanceof Item item) {
return new ParticleData<>(type, (T) item.copy());
} else {
return new ParticleData<>(type, value);
}
return new ParticleData<>(type, Copyable.copy(value));
}
@Override
@@ -23,6 +23,7 @@
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viaversion.util.Copyable;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -31,12 +32,13 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @param key key of the registry entry
* @param tag data of the registry entry, or null if the client should use its default
*/
public record RegistryEntry(String key, @Nullable Tag tag) {
public record RegistryEntry(String key, @Nullable Tag tag) implements Copyable {
public RegistryEntry withKey(final String key) {
return new RegistryEntry(key, tag != null ? tag.copy() : null);
}
@Override
public RegistryEntry copy() {
return new RegistryEntry(key, tag != null ? tag.copy() : null);
}
@@ -0,0 +1,42 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.viaversion.api.data.MappingData.MappingType;
import com.viaversion.viaversion.util.Key;
/**
* Holds a key for a registry.
* Depending on the context, the key may be used to get registry entries from either synchronized or hardcoded registries.
*
* @see MappingType
* @see #of(String)
*/
public interface RegistryKey {
Key key();
static RegistryKey of(final String key) {
return new SimpleRegistryKey(Key.of(key));
}
}
@@ -22,11 +22,12 @@
*/
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.viaversion.util.Key;
import java.util.HashMap;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.Nullable;
public enum RegistryType {
public enum RegistryType implements RegistryKey {
BLOCK("block"),
ITEM("item"),
@@ -40,7 +41,7 @@ public enum RegistryType {
static {
for (RegistryType type : getValues()) {
MAP.put(type.resourceLocation, type);
MAP.put(type.identifier, type);
}
}
@@ -48,17 +49,22 @@ public enum RegistryType {
return VALUES;
}
public static @Nullable RegistryType getByKey(String resourceKey) {
return MAP.get(resourceKey);
public static @Nullable RegistryType getByKey(String identifier) {
return MAP.get(identifier);
}
private final String resourceLocation;
private final String identifier;
RegistryType(final String resourceLocation) {
this.resourceLocation = resourceLocation;
RegistryType(final String identifier) {
this.identifier = identifier;
}
public String resourceLocation() {
return resourceLocation;
public String identifier() {
return identifier;
}
@Override
public Key key() {
return Key.of(identifier);
}
}
@@ -0,0 +1,37 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Profile that can be either dynamically filled by the client or is already static.
* The additional fields are optional overrides.
*/
public record ResolvableProfile(GameProfile profile, @Nullable String bodyTexture, @Nullable String capeTexture,
@Nullable String elytraTexture, @Nullable Integer modelType) {
public ResolvableProfile(final GameProfile profile) {
this(profile, null, null, null, null);
}
}
@@ -0,0 +1,33 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.viaversion.util.Key;
record SimpleRegistryKey(Key key) implements RegistryKey {
@Override
public String toString() {
return key.toString();
}
}
@@ -22,11 +22,21 @@
*/
package com.viaversion.viaversion.api.minecraft;
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
import org.checkerframework.checker.nullness.qual.Nullable;
public record SoundEvent(String identifier, @Nullable Float fixedRange) {
private static final Holder<SoundEvent> UNKNOWN = Holder.of(new SoundEvent("viaversion:unknown", 0F));
public SoundEvent withIdentifier(final String identifier) {
return new SoundEvent(identifier, this.fixedRange);
}
public static @Nullable Holder<SoundEvent> rewriteHolder(@Nullable final Holder<SoundEvent> holder, final Int2IntFunction soundRewriteFunction) {
if (holder == null) {
return null;
}
return holder.updateId(soundRewriteFunction, () -> UNKNOWN);
}
}
@@ -23,6 +23,8 @@
package com.viaversion.viaversion.api.minecraft;
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
import java.util.function.Function;
import java.util.function.Supplier;
record ValueHolder<T>(T value) implements Holder<T> {
@@ -42,7 +44,13 @@ record ValueHolder<T>(T value) implements Holder<T> {
}
@Override
public Holder<T> updateId(final Int2IntFunction rewriteFunction) {
public Holder<T> updateId(final Int2IntFunction rewriteFunction, final Supplier<Holder<T>> ifMissing) {
return this;
}
@Override
public Holder<T> updateValue(final Function<T, T> rewriteFunction) {
final T rewrittenValue = rewriteFunction.apply(value);
return rewrittenValue != value ? Holder.of(rewrittenValue) : this;
}
}
@@ -0,0 +1,28 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
public record Vector3d(double x, double y, double z) {
public static final Vector3d ZERO = new Vector3d(0, 0, 0);
}
@@ -143,6 +143,16 @@ public class BaseChunk implements Chunk {
this.heightMap = heightMap;
}
@Override
public Heightmap[] heightmaps() {
throw new UnsupportedOperationException();
}
@Override
public void setHeightmaps(final Heightmap[] heightmaps) {
throw new UnsupportedOperationException();
}
@Override
public List<CompoundTag> getBlockEntities() {
return blockEntities;
@@ -79,7 +79,8 @@ public interface Chunk {
* @return chunk section bit mask, only non-null for 1.17+ chunks
* @see #getBitmask()
*/
@Nullable BitSet getChunkMask();
@Nullable
BitSet getChunkMask();
void setChunkMask(BitSet chunkSectionMask);
@@ -88,7 +89,8 @@ public interface Chunk {
*
* @return array of nullable chunk sections
*/
@Nullable ChunkSection[] getSections();
@Nullable
ChunkSection[] getSections();
void setSections(ChunkSection[] sections);
@@ -106,10 +108,15 @@ public interface Chunk {
*
* @return compoundtag containing heightmaps if present
*/
@Nullable CompoundTag getHeightMap();
@Nullable
CompoundTag getHeightMap();
void setHeightMap(@Nullable CompoundTag heightMap);
Heightmap[] heightmaps();
void setHeightmaps(Heightmap[] heightmaps);
/**
* Returns a list of block entities.
*
@@ -123,6 +123,16 @@ public class Chunk1_18 implements Chunk {
this.heightMap = heightMap;
}
@Override
public Heightmap[] heightmaps() {
throw new UnsupportedOperationException();
}
@Override
public void setHeightmaps(final Heightmap[] heightmaps) {
throw new UnsupportedOperationException();
}
@Override
public List<CompoundTag> getBlockEntities() {
throw new UnsupportedOperationException();
@@ -0,0 +1,145 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
import java.util.BitSet;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public class Chunk1_21_5 implements Chunk {
protected final int x;
protected final int z;
protected ChunkSection[] sections;
protected Heightmap[] heightmaps;
protected final List<BlockEntity> blockEntities;
public Chunk1_21_5(int x, int z, ChunkSection[] sections, Heightmap[] heightmaps, List<BlockEntity> blockEntities) {
this.x = x;
this.z = z;
this.sections = sections;
this.heightmaps = heightmaps;
this.blockEntities = blockEntities;
}
@Override
public boolean isBiomeData() {
return false;
}
@Override
public int getX() {
return x;
}
@Override
public int getZ() {
return z;
}
@Override
public boolean isFullChunk() {
return true;
}
@Override
public boolean isIgnoreOldLightData() {
return false;
}
@Override
public void setIgnoreOldLightData(boolean ignoreOldLightData) {
throw new UnsupportedOperationException();
}
@Override
public int getBitmask() {
return -1;
}
@Override
public void setBitmask(int bitmask) {
throw new UnsupportedOperationException();
}
@Override
public @Nullable BitSet getChunkMask() {
return null;
}
@Override
public void setChunkMask(BitSet chunkSectionMask) {
throw new UnsupportedOperationException();
}
@Override
public ChunkSection[] getSections() {
return sections;
}
@Override
public void setSections(ChunkSection[] sections) {
this.sections = sections;
}
@Override
public int @Nullable [] getBiomeData() {
return null;
}
@Override
public void setBiomeData(int @Nullable [] biomeData) {
throw new UnsupportedOperationException();
}
@Override
public @Nullable CompoundTag getHeightMap() {
throw new UnsupportedOperationException();
}
@Override
public void setHeightMap(final CompoundTag heightMap) {
throw new UnsupportedOperationException();
}
@Override
public Heightmap[] heightmaps() {
return heightmaps;
}
@Override
public void setHeightmaps(final Heightmap[] heightmaps) {
this.heightmaps = heightmaps;
}
@Override
public List<CompoundTag> getBlockEntities() {
throw new UnsupportedOperationException();
}
@Override
public List<BlockEntity> blockEntities() {
return blockEntities;
}
}
@@ -0,0 +1,26 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.chunks;
public record Heightmap(int type, long[] data) {
}
@@ -0,0 +1,85 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.codec;
import com.viaversion.viaversion.api.data.MappingData;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.Key;
public interface CodecContext {
RegistryAccess registryAccess();
boolean mapped();
boolean isSupported(StructuredDataKey<?> key);
interface RegistryAccess {
Key item(int id);
Key attributeModifier(int id);
Key dataComponentType(int id);
Key entity(int id);
Key blockEntity(int id);
Key sound(int id);
/**
* Returns the key for a stored mapping type and its numeric id.
*
* @param mappingType mapping type
* @param id numeric id
* @return the key
*/
Key key(MappingData.MappingType mappingType, int id);
/**
* Returns the numeric id for a stored mapping type and its identifier.
*
* @param mappingType mapping type
* @param identifier identifier
* @return the numeric id, or -1 if not found
*/
int id(MappingData.MappingType mappingType, String identifier);
static RegistryAccess of(final Protocol<?, ?, ?, ?> protocol) {
return new RegistryAccessImpl(protocol);
}
/**
* Returns the key for a client-synchronized registry element.
*
* @param registry registry key
* @param id numeric id
* @return the key
*/
Key registryKey(String registry, int id);
RegistryAccess withMapped(boolean mapped);
}
}
@@ -0,0 +1,110 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.codec;
import com.viaversion.viaversion.api.type.Type;
import java.util.function.Consumer;
public class DelegatingOps implements Ops {
private final Ops delegate;
public DelegatingOps(final Ops delegate) {
this.delegate = delegate;
}
@Override
public CodecContext context() {
return delegate.context();
}
@Override
public void writeByte(final byte b) {
delegate.writeByte(b);
}
@Override
public void writeBytes(final byte[] array) {
delegate.writeBytes(array);
}
@Override
public void writeBoolean(final boolean b) {
delegate.writeBoolean(b);
}
@Override
public void writeShort(final short s) {
delegate.writeShort(s);
}
@Override
public void writeString(final CharSequence sequence) {
delegate.writeString(sequence);
}
@Override
public void writeInt(final int i) {
delegate.writeInt(i);
}
@Override
public void writeLong(final long l) {
delegate.writeLong(l);
}
@Override
public void writeFloat(final float f) {
delegate.writeFloat(f);
}
@Override
public void writeDouble(final double d) {
delegate.writeDouble(d);
}
@Override
public void writeInts(final int[] array) {
delegate.writeInts(array);
}
@Override
public void writeLongs(final long[] array) {
delegate.writeLongs(array);
}
@Override
public void writeList(final Consumer<ListSerializer> consumer) {
delegate.writeList(consumer);
}
@Override
public void writeMap(final Consumer<MapSerializer> consumer) {
delegate.writeMap(consumer);
}
@Override
public <V> void write(final Type<V> type, final V value) {
delegate.write(type, value);
}
}
@@ -0,0 +1,135 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.codec;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import java.util.Objects;
import java.util.function.Consumer;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface Ops {
CodecContext context();
void writeByte(byte b);
void writeBytes(byte[] array);
void writeBoolean(boolean b);
void writeShort(short s);
void writeString(CharSequence sequence);
void writeInt(int i);
void writeLong(long l);
void writeFloat(float f);
void writeDouble(double d);
void writeInts(int[] array);
void writeLongs(long[] array);
void writeList(Consumer<ListSerializer> consumer);
void writeMap(Consumer<MapSerializer> consumer);
<V> void write(final Type<V> type, final V value);
interface ListSerializer {
<V> ListSerializer write(Type<V> valueType, V value);
ListSerializer writeList(Consumer<ListSerializer> consumer);
ListSerializer writeMap(Consumer<MapSerializer> consumer);
}
interface MapSerializer {
<K, V> MapSerializer write(Type<K> keyType, K key, Type<V> valueType, V value);
default <V> MapSerializer write(final String key, final Type<V> type, final V value) {
write(Types.STRING, key, type, value);
return this;
}
/**
* Writes the given value or default value if the value is null.
*
* @param key map key
* @param type type of the value
* @param value the value to write, or null
* @param def default value to write if the value is null
* @return self
* @param <V> value type
*/
default <V> MapSerializer write(final String key, final Type<V> type, @Nullable final V value, final V def) {
write(Types.STRING, key, type, value != null ? value : def);
return this;
}
/**
* Writes the given value if it is not null.
*
* @param key map key
* @param type type of the value
* @param value the value to write, or null
* @return self
* @param <V> value type
*/
default <V> MapSerializer writeOptional(final String key, final Type<V> type, @Nullable final V value) {
if (value != null) {
write(Types.STRING, key, type, value);
}
return this;
}
/**
* Writes the given value if it is not null and not equal to the default value.
*
* @param key map key
* @param type type of the value
* @param value the value to write, or null
* @param def default value to compare against
* @return self
* @param <V> value type
*/
default <V> MapSerializer writeOptional(final String key, final Type<V> type, @Nullable final V value, final V def) {
if (value != null && !Objects.deepEquals(value, def)) {
write(Types.STRING, key, type, value);
}
return this;
}
MapSerializer writeList(String key, Consumer<ListSerializer> consumer);
MapSerializer writeMap(String key, Consumer<MapSerializer> consumer);
<T> MapSerializer writeInlinedMap(Type<T> valueType, T value);
}
}
@@ -0,0 +1,113 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.codec;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.data.FullMappings;
import com.viaversion.viaversion.api.data.MappingData;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.rewriter.RegistryDataRewriter;
import com.viaversion.viaversion.util.Key;
import com.viaversion.viaversion.util.KeyMappings;
import org.checkerframework.checker.nullness.qual.Nullable;
final class RegistryAccessImpl implements CodecContext.RegistryAccess {
private final RegistryDataRewriter registryDataRewriter;
private final MappingData mappingData;
private final boolean mapped;
RegistryAccessImpl(final Protocol<?, ?, ?, ?> protocol) {
this.mappingData = protocol.getMappingData();
this.registryDataRewriter = protocol.getRegistryDataRewriter();
this.mapped = false;
}
private RegistryAccessImpl(final MappingData mappingData, final RegistryDataRewriter registryDataRewriter, final boolean mapped) {
this.mappingData = mappingData;
this.registryDataRewriter = registryDataRewriter;
this.mapped = mapped;
}
@Override
public Key item(final int id) {
return key(mappingData.getFullItemMappings(), id);
}
@Override
public Key attributeModifier(final int id) {
return key(mappingData.getAttributeMappings(), id);
}
@Override
public Key dataComponentType(final int id) {
return key(mappingData.getDataComponentSerializerMappings(), id);
}
@Override
public Key entity(final int id) {
return key(mappingData.getEntityMappings(), id);
}
@Override
public Key blockEntity(final int id) {
return key(mappingData.getBlockEntityMappings(), id);
}
@Override
public Key sound(final int id) {
return key(mappingData.getFullSoundMappings(), id);
}
@Override
public Key key(final MappingData.MappingType mappingType, final int id) {
return key(mappingData.getFullMappings(mappingType), id);
}
@Override
public int id(final MappingData.MappingType mappingType, final String identifier) {
final FullMappings mappings = mappingData.getFullMappings(mappingType);
return mapped ? mappings.mappedId(identifier) : mappings.id(identifier);
}
@Override
public Key registryKey(final String registry, final int id) {
final KeyMappings mappings = registryDataRewriter.getMappings(registry);
Preconditions.checkNotNull(mappings, "No registry mappings for registry: " + registry);
final String identifier = id >= 0 && id < mappings.size() ? mappings.idToKey(id) : null;
return key(identifier, id);
}
private Key key(final FullMappings mappings, final int id) {
final String identifier = mapped ? mappings.mappedIdentifier(id) : mappings.identifier(id);
return key(identifier, id);
}
private Key key(@Nullable final String identifier, final int id) {
return identifier != null ? Key.of(identifier) : Key.of("viaversion", "unknown/" + id);
}
@Override
public CodecContext.RegistryAccess withMapped(final boolean mapped) {
return this.mapped == mapped ? this : new RegistryAccessImpl(this.mappingData, this.registryDataRewriter, mapped);
}
}
@@ -0,0 +1,104 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.codec;
import com.viaversion.viaversion.api.type.Type;
import java.util.function.Consumer;
public class ThrowingOps implements Ops {
@Override
public CodecContext context() {
throw new UnsupportedOperationException();
}
@Override
public void writeByte(final byte b) {
throw new UnsupportedOperationException();
}
@Override
public void writeBytes(final byte[] array) {
throw new UnsupportedOperationException();
}
@Override
public void writeBoolean(final boolean b) {
throw new UnsupportedOperationException();
}
@Override
public void writeShort(final short s) {
throw new UnsupportedOperationException();
}
@Override
public void writeString(final CharSequence sequence) {
throw new UnsupportedOperationException();
}
@Override
public void writeInt(final int i) {
throw new UnsupportedOperationException();
}
@Override
public void writeLong(final long l) {
throw new UnsupportedOperationException();
}
@Override
public void writeFloat(final float f) {
throw new UnsupportedOperationException();
}
@Override
public void writeDouble(final double d) {
throw new UnsupportedOperationException();
}
@Override
public void writeInts(final int[] array) {
throw new UnsupportedOperationException();
}
@Override
public void writeLongs(final long[] array) {
throw new UnsupportedOperationException();
}
@Override
public void writeList(final Consumer<ListSerializer> consumer) {
throw new UnsupportedOperationException();
}
@Override
public void writeMap(final Consumer<MapSerializer> consumer) {
throw new UnsupportedOperationException();
}
@Override
public <V> void write(final Type<V> type, final V value) {
throw new UnsupportedOperationException();
}
}
@@ -0,0 +1,45 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.codec.hash;
import com.viaversion.viaversion.api.minecraft.codec.Ops;
/**
* Hash operations. Note that this is different from Vanilla codecs, where this
* instead acts as a (re-usable) hasher directly rather than each method having
* self-contained return values.
*/
public interface Hasher extends Ops {
/**
* Returns the current hash value.
*
* @return the current hash value
*/
int hash();
/**
* Resets the hasher to its initial state.
*/
void reset();
}
@@ -53,6 +53,11 @@ final class EmptyStructuredData<T> implements StructuredData<T> {
return this.key;
}
@Override
public StructuredData<T> copy() {
return new EmptyStructuredData<>(this.key, this.id);
}
@Override
public T value() {
return null;
@@ -23,6 +23,8 @@
package com.viaversion.viaversion.api.minecraft.data;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.util.ArrayUtil;
import com.viaversion.viaversion.util.Copyable;
import io.netty.buffer.ByteBuf;
import java.util.Objects;
@@ -59,6 +61,11 @@ final class FilledStructuredData<T> implements StructuredData<T> {
return key;
}
@Override
public StructuredData<T> copy() {
return new FilledStructuredData<>(this.key, Copyable.copy(this.value), this.id);
}
@Override
public T value() {
return value;
@@ -96,7 +103,7 @@ final class FilledStructuredData<T> implements StructuredData<T> {
public String toString() {
return "FilledStructuredData{" +
"key=" + key +
", value=" + value +
", value=" + ArrayUtil.toString(value) +
", id=" + id +
'}';
}
@@ -22,11 +22,12 @@
*/
package com.viaversion.viaversion.api.minecraft.data;
import com.viaversion.viaversion.util.Copyable;
import com.viaversion.viaversion.util.IdHolder;
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface StructuredData<T> extends IdHolder {
public interface StructuredData<T> extends IdHolder, Copyable {
/**
* Returns filled structured data, equivalent to an Optional with a value in vanilla.
@@ -52,7 +53,8 @@ public interface StructuredData<T> extends IdHolder {
return new EmptyStructuredData<>(key, id);
}
@Nullable T value();
@Nullable
T value();
void setValue(final T value);
@@ -60,6 +62,9 @@ public interface StructuredData<T> extends IdHolder {
StructuredDataKey<T> key();
@Override
StructuredData<T> copy();
/**
* Returns whether the structured data is present. Even if true, the value may be null.
*
@@ -26,9 +26,11 @@ import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.FullMappings;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.Copyable;
import com.viaversion.viaversion.util.Unit;
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import java.util.Collection;
import java.util.Map;
import java.util.function.Function;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -53,7 +55,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* </ul>
* Other methods (e.g. {@link #getData(StructuredDataKey)} and {@link #has(StructuredDataKey)}) will handle both empty and non-empty data.
*/
public final class StructuredDataContainer {
public final class StructuredDataContainer implements Copyable {
private final Map<StructuredDataKey<?>, StructuredData<?>> data;
private FullMappings lookup;
@@ -71,7 +73,7 @@ public final class StructuredDataContainer {
}
public StructuredDataContainer() {
this(new Reference2ObjectOpenHashMap<>());
this(new Reference2ObjectOpenHashMap<>(0));
}
/**
@@ -188,6 +190,20 @@ public final class StructuredDataContainer {
this.data.remove(key);
}
/**
* Removes data by the given keys.
*
* @param keys data keys
* @see #replace(StructuredDataKey, Function)
* @see #replace(StructuredDataKey, StructuredDataKey, Function)
* @see #replaceKey(StructuredDataKey, StructuredDataKey)
*/
public void remove(final Collection<StructuredDataKey<?>> keys) {
for (final StructuredDataKey<?> key : keys) {
this.data.remove(key);
}
}
/**
* Returns whether there is data for the given key, either empty or non-empty.
*
@@ -225,7 +241,7 @@ public final class StructuredDataContainer {
/**
* Sets the lookup for serializer ids. Required to call most of the other methods.
*
* @param protocol protocol to retreive the id of the serializer from
* @param protocol protocol to retrieve the id of the serializer from
* @param mappedNames if the names are mapped (true if structures from the mapped version are added, false for the unmapped version)
*/
public void setIdLookup(final Protocol<?, ?, ?, ?> protocol, final boolean mappedNames) {
@@ -245,8 +261,13 @@ public final class StructuredDataContainer {
}
}
@Override
public StructuredDataContainer copy() {
final StructuredDataContainer copy = new StructuredDataContainer(new Reference2ObjectOpenHashMap<>(data));
final Reference2ObjectOpenHashMap<StructuredDataKey<?>, StructuredData<?>> map = new Reference2ObjectOpenHashMap<>();
for (final StructuredData<?> value : data.values()) {
map.put(value.key(), value.copy());
}
final StructuredDataContainer copy = new StructuredDataContainer(map);
copy.lookup = this.lookup;
return copy;
}
@@ -263,6 +284,10 @@ public final class StructuredDataContainer {
return data;
}
public boolean isEmpty() {
return data.isEmpty();
}
@Override
public String toString() {
return "StructuredDataContainer{" +
@@ -24,70 +24,114 @@ package com.viaversion.viaversion.api.minecraft.data;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viaversion.api.minecraft.EitherHolder;
import com.viaversion.viaversion.api.minecraft.GameProfile;
import com.viaversion.viaversion.api.minecraft.Holder;
import com.viaversion.viaversion.api.minecraft.HolderSet;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.PaintingVariant;
import com.viaversion.viaversion.api.minecraft.RegistryKey;
import com.viaversion.viaversion.api.minecraft.ResolvableProfile;
import com.viaversion.viaversion.api.minecraft.SoundEvent;
import com.viaversion.viaversion.api.minecraft.data.version.StructuredDataKeys1_20_5;
import com.viaversion.viaversion.api.minecraft.data.version.StructuredDataKeys1_21_11;
import com.viaversion.viaversion.api.minecraft.data.version.StructuredDataKeys1_21_2;
import com.viaversion.viaversion.api.minecraft.data.version.StructuredDataKeys1_21_5;
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate;
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrim;
import com.viaversion.viaversion.api.minecraft.item.data.AttackRange;
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_20_5;
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_21;
import com.viaversion.viaversion.api.minecraft.item.data.BannerPatternLayer;
import com.viaversion.viaversion.api.minecraft.item.data.Bee;
import com.viaversion.viaversion.api.minecraft.item.data.BlockEntityData;
import com.viaversion.viaversion.api.minecraft.item.data.BlockStateProperties;
import com.viaversion.viaversion.api.minecraft.item.data.BlocksAttacks;
import com.viaversion.viaversion.api.minecraft.item.data.Consumable1_21_2;
import com.viaversion.viaversion.api.minecraft.item.data.CustomModelData1_21_4;
import com.viaversion.viaversion.api.minecraft.item.data.DamageResistant;
import com.viaversion.viaversion.api.minecraft.item.data.DamageType;
import com.viaversion.viaversion.api.minecraft.item.data.DeathProtection;
import com.viaversion.viaversion.api.minecraft.item.data.DebugStickState;
import com.viaversion.viaversion.api.minecraft.item.data.DyedColor;
import com.viaversion.viaversion.api.minecraft.item.data.Enchantable;
import com.viaversion.viaversion.api.minecraft.item.data.Enchantments;
import com.viaversion.viaversion.api.minecraft.item.data.EntityData;
import com.viaversion.viaversion.api.minecraft.item.data.EnumTypes;
import com.viaversion.viaversion.api.minecraft.item.data.Equippable;
import com.viaversion.viaversion.api.minecraft.item.data.FilterableString;
import com.viaversion.viaversion.api.minecraft.item.data.FireworkExplosion;
import com.viaversion.viaversion.api.minecraft.item.data.Fireworks;
import com.viaversion.viaversion.api.minecraft.item.data.FoodProperties1_20_5;
import com.viaversion.viaversion.api.minecraft.item.data.FoodProperties1_21_2;
import com.viaversion.viaversion.api.minecraft.item.data.Instrument1_20_5;
import com.viaversion.viaversion.api.minecraft.item.data.Instrument1_21_2;
import com.viaversion.viaversion.api.minecraft.item.data.ItemModel;
import com.viaversion.viaversion.api.minecraft.item.data.JukeboxPlayable;
import com.viaversion.viaversion.api.minecraft.item.data.KineticWeapon;
import com.viaversion.viaversion.api.minecraft.item.data.LockCode;
import com.viaversion.viaversion.api.minecraft.item.data.LodestoneTracker;
import com.viaversion.viaversion.api.minecraft.item.data.PiercingWeapon;
import com.viaversion.viaversion.api.minecraft.item.data.PotDecorations;
import com.viaversion.viaversion.api.minecraft.item.data.PotionContents;
import com.viaversion.viaversion.api.minecraft.item.data.ProvidesTrimMaterial;
import com.viaversion.viaversion.api.minecraft.item.data.Repairable;
import com.viaversion.viaversion.api.minecraft.item.data.SuspiciousStewEffect;
import com.viaversion.viaversion.api.minecraft.item.data.SwingAnimation;
import com.viaversion.viaversion.api.minecraft.item.data.ToolProperties;
import com.viaversion.viaversion.api.minecraft.item.data.TooltipDisplay;
import com.viaversion.viaversion.api.minecraft.item.data.TropicalFishPattern;
import com.viaversion.viaversion.api.minecraft.item.data.Unbreakable;
import com.viaversion.viaversion.api.minecraft.item.data.UseCooldown;
import com.viaversion.viaversion.api.minecraft.item.data.UseEffects;
import com.viaversion.viaversion.api.minecraft.item.data.Weapon;
import com.viaversion.viaversion.api.minecraft.item.data.WritableBook;
import com.viaversion.viaversion.api.minecraft.item.data.WrittenBook;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.ArrayType;
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
import com.viaversion.viaversion.api.type.types.version.Types1_21;
import com.viaversion.viaversion.api.type.types.version.Types1_21_2;
import com.viaversion.viaversion.api.type.types.version.Types1_21_4;
import com.viaversion.viaversion.api.type.types.misc.SynchronizedRegistryEitherType;
import com.viaversion.viaversion.api.type.types.misc.SynchronizedRegistryValueType;
import com.viaversion.viaversion.api.type.types.version.VersionedTypes;
import com.viaversion.viaversion.util.Either;
import com.viaversion.viaversion.util.Key;
import com.viaversion.viaversion.util.Unit;
/**
* Holds data component keys.
*
* @param identifier string identifier
* @param type data type
* @param <T> data type
* @see VersionedTypes
*/
public record StructuredDataKey<T>(String identifier, Type<T> type) {
public static final StructuredDataKey<CompoundTag> CUSTOM_DATA = new StructuredDataKey<>("custom_data", Types.COMPOUND_TAG);
public static final StructuredDataKey<Integer> MAX_STACK_SIZE = new StructuredDataKey<>("max_stack_size", Types.VAR_INT);
public static final StructuredDataKey<Integer> MAX_DAMAGE = new StructuredDataKey<>("max_damage", Types.VAR_INT);
public static final StructuredDataKey<Integer> DAMAGE = new StructuredDataKey<>("damage", Types.VAR_INT);
public static final StructuredDataKey<Unbreakable> UNBREAKABLE = new StructuredDataKey<>("unbreakable", Unbreakable.TYPE);
public static final StructuredDataKey<Tag> CUSTOM_NAME = new StructuredDataKey<>("custom_name", Types.TAG);
public static final StructuredDataKey<Tag> ITEM_NAME = new StructuredDataKey<>("item_name", Types.TAG);
public static final StructuredDataKey<String> ITEM_MODEL = new StructuredDataKey<>("item_model", Types.STRING);
public static final StructuredDataKey<Tag[]> LORE = new StructuredDataKey<>("lore", new ArrayType<>(Types.TAG, 256));
public static final StructuredDataKey<Integer> RARITY = new StructuredDataKey<>("rarity", Types.VAR_INT);
public static final StructuredDataKey<Enchantments> ENCHANTMENTS = new StructuredDataKey<>("enchantments", Enchantments.TYPE);
public static final StructuredDataKey<AdventureModePredicate> CAN_PLACE_ON = new StructuredDataKey<>("can_place_on", AdventureModePredicate.TYPE);
public static final StructuredDataKey<AdventureModePredicate> CAN_BREAK = new StructuredDataKey<>("can_break", AdventureModePredicate.TYPE);
public static final StructuredDataKey<Unbreakable> UNBREAKABLE1_20_5 = new StructuredDataKey<>("unbreakable", Unbreakable.TYPE);
public static final StructuredDataKey<UseEffects> USE_EFFECTS = new StructuredDataKey<>("use_effects", UseEffects.TYPE);
public static final StructuredDataKey<Unit> UNBREAKABLE1_21_5 = new StructuredDataKey<>("unbreakable", Types.EMPTY);
public static final StructuredDataKey<Tag> CUSTOM_NAME = new StructuredDataKey<>("custom_name", Types.TEXT_COMPONENT_TAG);
public static final StructuredDataKey<Float> MINIMUM_ATTACK_CHARGE = new StructuredDataKey<>("minimum_attack_charge", Types.FLOAT);
public static final StructuredDataKey<DamageType> DAMAGE_TYPE = new StructuredDataKey<>("damage_type", DamageType.TYPE);
public static final StructuredDataKey<Tag> ITEM_NAME = new StructuredDataKey<>("item_name", Types.TEXT_COMPONENT_TAG);
public static final StructuredDataKey<ItemModel> ITEM_MODEL = new StructuredDataKey<>("item_model", ItemModel.TYPE);
public static final StructuredDataKey<Tag[]> LORE = new StructuredDataKey<>("lore", new ArrayType<>(Types.TEXT_COMPONENT_TAG, 256));
public static final StructuredDataKey<Integer> RARITY = new StructuredDataKey<>("rarity", EnumTypes.RARITY);
public static final StructuredDataKey<Enchantments> ENCHANTMENTS1_20_5 = new StructuredDataKey<>("enchantments", Enchantments.TYPE1_20_5);
public static final StructuredDataKey<Enchantments> ENCHANTMENTS1_21_5 = new StructuredDataKey<>("enchantments", Enchantments.TYPE1_21_5);
// 1.21.5+ predicates are in their own key classes
public static final StructuredDataKey<AdventureModePredicate> CAN_PLACE_ON1_20_5 = new StructuredDataKey<>("can_place_on", AdventureModePredicate.TYPE1_20_5);
public static final StructuredDataKey<AdventureModePredicate> CAN_BREAK1_20_5 = new StructuredDataKey<>("can_break", AdventureModePredicate.TYPE1_20_5);
public static final StructuredDataKey<AttributeModifiers1_20_5> ATTRIBUTE_MODIFIERS1_20_5 = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers1_20_5.TYPE);
public static final StructuredDataKey<AttributeModifiers1_21> ATTRIBUTE_MODIFIERS1_21 = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers1_21.TYPE);
public static final StructuredDataKey<AttributeModifiers1_21> ATTRIBUTE_MODIFIERS1_21 = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers1_21.TYPE1_21);
public static final StructuredDataKey<AttributeModifiers1_21> ATTRIBUTE_MODIFIERS1_21_5 = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers1_21.TYPE1_21_5);
public static final StructuredDataKey<AttributeModifiers1_21> ATTRIBUTE_MODIFIERS1_21_6 = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers1_21.TYPE1_21_6);
public static final StructuredDataKey<Integer> CUSTOM_MODEL_DATA1_20_5 = new StructuredDataKey<>("custom_model_data", Types.VAR_INT);
public static final StructuredDataKey<CustomModelData1_21_4> CUSTOM_MODEL_DATA1_21_4 = new StructuredDataKey<>("custom_model_data", CustomModelData1_21_4.TYPE);
public static final StructuredDataKey<Unit> HIDE_ADDITIONAL_TOOLTIP = new StructuredDataKey<>("hide_additional_tooltip", Types.EMPTY);
public static final StructuredDataKey<Unit> HIDE_TOOLTIP = new StructuredDataKey<>("hide_tooltip", Types.EMPTY);
public static final StructuredDataKey<TooltipDisplay> TOOLTIP_DISPLAY = new StructuredDataKey<>("tooltip_display", TooltipDisplay.TYPE);
public static final StructuredDataKey<Integer> REPAIR_COST = new StructuredDataKey<>("repair_cost", Types.VAR_INT);
public static final StructuredDataKey<Unit> CREATIVE_SLOT_LOCK = new StructuredDataKey<>("creative_slot_lock", Types.EMPTY);
public static final StructuredDataKey<Boolean> ENCHANTMENT_GLINT_OVERRIDE = new StructuredDataKey<>("enchantment_glint_override", Types.BOOLEAN);
@@ -96,65 +140,110 @@ public record StructuredDataKey<T>(String identifier, Type<T> type) {
public static final StructuredDataKey<FoodProperties1_20_5> FOOD1_21 = new StructuredDataKey<>("food", FoodProperties1_20_5.TYPE1_21);
public static final StructuredDataKey<FoodProperties1_21_2> FOOD1_21_2 = new StructuredDataKey<>("food", FoodProperties1_21_2.TYPE);
public static final StructuredDataKey<Consumable1_21_2> CONSUMABLE1_21_2 = new StructuredDataKey<>("consumable", Consumable1_21_2.TYPE);
public static final StructuredDataKey<Item> USE_REMAINDER1_21_2 = new StructuredDataKey<>("use_remainder", Types1_21_2.ITEM);
public static final StructuredDataKey<Item> USE_REMAINDER1_21_4 = new StructuredDataKey<>("use_remainder", Types1_21_4.ITEM);
public static final StructuredDataKey<UseCooldown> USE_COOLDOWN = new StructuredDataKey<>("use_cooldown", UseCooldown.TYPE);
public static final StructuredDataKey<Unit> FIRE_RESISTANT = new StructuredDataKey<>("fire_resistant", Types.EMPTY);
public static final StructuredDataKey<DamageResistant> DAMAGE_RESISTANT = new StructuredDataKey<>("damage_resistant", DamageResistant.TYPE);
public static final StructuredDataKey<ToolProperties> TOOL = new StructuredDataKey<>("tool", ToolProperties.TYPE);
public static final StructuredDataKey<Integer> ENCHANTABLE = new StructuredDataKey<>("enchantable", Types.VAR_INT);
public static final StructuredDataKey<Equippable> EQUIPPABLE = new StructuredDataKey<>("equippable", Equippable.TYPE);
public static final StructuredDataKey<HolderSet> REPAIRABLE = new StructuredDataKey<>("repairable", Types.HOLDER_SET);
public static final StructuredDataKey<ToolProperties> TOOL1_20_5 = new StructuredDataKey<>("tool", ToolProperties.TYPE1_20_5);
public static final StructuredDataKey<ToolProperties> TOOL1_21_5 = new StructuredDataKey<>("tool", ToolProperties.TYPE1_21_5);
public static final StructuredDataKey<Weapon> WEAPON = new StructuredDataKey<>("weapon", Weapon.TYPE);
public static final StructuredDataKey<AttackRange> ATTACK_RANGE = new StructuredDataKey<>("attack_range", AttackRange.TYPE);
public static final StructuredDataKey<Enchantable> ENCHANTABLE = new StructuredDataKey<>("enchantable", Enchantable.TYPE);
public static final StructuredDataKey<Equippable> EQUIPPABLE1_21_2 = new StructuredDataKey<>("equippable", Equippable.TYPE1_21_2);
public static final StructuredDataKey<Equippable> EQUIPPABLE1_21_5 = new StructuredDataKey<>("equippable", Equippable.TYPE1_21_5);
public static final StructuredDataKey<Equippable> EQUIPPABLE1_21_6 = new StructuredDataKey<>("equippable", Equippable.TYPE1_21_6);
public static final StructuredDataKey<Repairable> REPAIRABLE = new StructuredDataKey<>("repairable", Repairable.TYPE);
public static final StructuredDataKey<Unit> GLIDER = new StructuredDataKey<>("glider", Types.EMPTY);
public static final StructuredDataKey<String> TOOLTIP_STYLE = new StructuredDataKey<>("tooltip_style", Types.STRING);
public static final StructuredDataKey<Key> TOOLTIP_STYLE = new StructuredDataKey<>("tooltip_style", Types.IDENTIFIER);
public static final StructuredDataKey<DeathProtection> DEATH_PROTECTION = new StructuredDataKey<>("death_protection", DeathProtection.TYPE);
public static final StructuredDataKey<Enchantments> STORED_ENCHANTMENTS = new StructuredDataKey<>("stored_enchantments", Enchantments.TYPE);
public static final StructuredDataKey<DyedColor> DYED_COLOR = new StructuredDataKey<>("dyed_color", DyedColor.TYPE);
public static final StructuredDataKey<BlocksAttacks> BLOCKS_ATTACKS = new StructuredDataKey<>("blocks_attacks", BlocksAttacks.TYPE);
public static final StructuredDataKey<PiercingWeapon> PIERCING_WEAPON = new StructuredDataKey<>("piercing_weapon", PiercingWeapon.TYPE);
public static final StructuredDataKey<KineticWeapon> KINETIC_WEAPON = new StructuredDataKey<>("kinetic_weapon", KineticWeapon.TYPE);
public static final StructuredDataKey<SwingAnimation> SWING_ANIMATION = new StructuredDataKey<>("swing_animation", SwingAnimation.TYPE);
public static final StructuredDataKey<Enchantments> STORED_ENCHANTMENTS1_20_5 = new StructuredDataKey<>("stored_enchantments", Enchantments.TYPE1_20_5);
public static final StructuredDataKey<Enchantments> STORED_ENCHANTMENTS1_21_5 = new StructuredDataKey<>("stored_enchantments", Enchantments.TYPE1_21_5);
public static final StructuredDataKey<DyedColor> DYED_COLOR1_20_5 = new StructuredDataKey<>("dyed_color", DyedColor.TYPE1_20_5);
public static final StructuredDataKey<DyedColor> DYED_COLOR1_21_5 = new StructuredDataKey<>("dyed_color", DyedColor.TYPE1_21_5);
public static final StructuredDataKey<Integer> MAP_COLOR = new StructuredDataKey<>("map_color", Types.INT);
public static final StructuredDataKey<Integer> MAP_ID = new StructuredDataKey<>("map_id", Types.VAR_INT);
public static final StructuredDataKey<CompoundTag> MAP_DECORATIONS = new StructuredDataKey<>("map_decorations", Types.COMPOUND_TAG);
public static final StructuredDataKey<Integer> MAP_POST_PROCESSING = new StructuredDataKey<>("map_post_processing", Types.VAR_INT);
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES1_20_5 = new StructuredDataKey<>("charged_projectiles", Types1_20_5.ITEM_ARRAY);
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES1_21 = new StructuredDataKey<>("charged_projectiles", Types1_21.ITEM_ARRAY);
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES1_21_2 = new StructuredDataKey<>("charged_projectiles", Types1_21_2.ITEM_ARRAY);
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES1_21_4 = new StructuredDataKey<>("charged_projectiles", Types1_21_4.ITEM_ARRAY);
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS1_20_5 = new StructuredDataKey<>("bundle_contents", Types1_20_5.ITEM_ARRAY);
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS1_21 = new StructuredDataKey<>("bundle_contents", Types1_21.ITEM_ARRAY);
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS1_21_2 = new StructuredDataKey<>("bundle_contents", Types1_21_2.ITEM_ARRAY);
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS1_21_4 = new StructuredDataKey<>("bundle_contents", Types1_21_4.ITEM_ARRAY);
public static final StructuredDataKey<PotionContents> POTION_CONTENTS1_20_5 = new StructuredDataKey<>("potion_contents", PotionContents.TYPE1_20_5);
public static final StructuredDataKey<PotionContents> POTION_CONTENTS1_21_2 = new StructuredDataKey<>("potion_contents", PotionContents.TYPE1_21_2);
public static final StructuredDataKey<Float> POTION_DURATION_SCALE = new StructuredDataKey<>("potion_duration_scale", Types.FLOAT);
public static final StructuredDataKey<SuspiciousStewEffect[]> SUSPICIOUS_STEW_EFFECTS = new StructuredDataKey<>("suspicious_stew_effects", SuspiciousStewEffect.ARRAY_TYPE);
public static final StructuredDataKey<FilterableString[]> WRITABLE_BOOK_CONTENT = new StructuredDataKey<>("writable_book_content", FilterableString.ARRAY_TYPE);
public static final StructuredDataKey<WritableBook> WRITABLE_BOOK_CONTENT = new StructuredDataKey<>("writable_book_content", WritableBook.TYPE);
public static final StructuredDataKey<WrittenBook> WRITTEN_BOOK_CONTENT = new StructuredDataKey<>("written_book_content", WrittenBook.TYPE);
public static final StructuredDataKey<ArmorTrim> TRIM1_20_5 = new StructuredDataKey<>("trim", ArmorTrim.TYPE1_20_5);
public static final StructuredDataKey<ArmorTrim> TRIM1_21_2 = new StructuredDataKey<>("trim", ArmorTrim.TYPE1_21_2);
public static final StructuredDataKey<ArmorTrim> TRIM1_21_4 = new StructuredDataKey<>("trim", ArmorTrim.TYPE1_21_4);
public static final StructuredDataKey<CompoundTag> DEBUG_STICK_STATE = new StructuredDataKey<>("debug_stick_state", Types.COMPOUND_TAG);
public static final StructuredDataKey<CompoundTag> ENTITY_DATA = new StructuredDataKey<>("entity_data", Types.COMPOUND_TAG);
public static final StructuredDataKey<ArmorTrim> TRIM1_21_5 = new StructuredDataKey<>("trim", ArmorTrim.TYPE1_21_5);
public static final StructuredDataKey<DebugStickState> DEBUG_STICK_STATE = new StructuredDataKey<>("debug_stick_state", DebugStickState.TYPE);
public static final StructuredDataKey<CompoundTag> ENTITY_DATA1_20_5 = new StructuredDataKey<>("entity_data", Types.COMPOUND_TAG);
public static final StructuredDataKey<EntityData> ENTITY_DATA1_21_9 = new StructuredDataKey<>("entity_data", EntityData.TYPE);
public static final StructuredDataKey<CompoundTag> BUCKET_ENTITY_DATA = new StructuredDataKey<>("bucket_entity_data", Types.COMPOUND_TAG);
public static final StructuredDataKey<CompoundTag> BLOCK_ENTITY_DATA = new StructuredDataKey<>("block_entity_data", Types.COMPOUND_TAG);
public static final StructuredDataKey<CompoundTag> BLOCK_ENTITY_DATA1_20_5 = new StructuredDataKey<>("block_entity_data", Types.COMPOUND_TAG);
public static final StructuredDataKey<BlockEntityData> BLOCK_ENTITY_DATA1_21_9 = new StructuredDataKey<>("block_entity_data", BlockEntityData.TYPE);
public static final StructuredDataKey<Holder<Instrument1_20_5>> INSTRUMENT1_20_5 = new StructuredDataKey<>("instrument", Instrument1_20_5.TYPE);
public static final StructuredDataKey<Holder<Instrument1_21_2>> INSTRUMENT1_21_2 = new StructuredDataKey<>("instrument", Instrument1_21_2.TYPE);
public static final StructuredDataKey<EitherHolder<Instrument1_21_2>> INSTRUMENT1_21_5 = new StructuredDataKey<>("instrument", Instrument1_21_2.EITHER_HOLDER_TYPE);
public static final StructuredDataKey<ProvidesTrimMaterial> PROVIDES_TRIM_MATERIAL = new StructuredDataKey<>("provides_trim_material", ProvidesTrimMaterial.TYPE);
public static final StructuredDataKey<Integer> OMINOUS_BOTTLE_AMPLIFIER = new StructuredDataKey<>("ominous_bottle_amplifier", Types.VAR_INT);
public static final StructuredDataKey<JukeboxPlayable> JUKEBOX_PLAYABLE = new StructuredDataKey<>("jukebox_playable", JukeboxPlayable.TYPE);
public static final StructuredDataKey<JukeboxPlayable> JUKEBOX_PLAYABLE1_21 = new StructuredDataKey<>("jukebox_playable", JukeboxPlayable.TYPE1_21);
public static final StructuredDataKey<JukeboxPlayable> JUKEBOX_PLAYABLE1_21_5 = new StructuredDataKey<>("jukebox_playable", JukeboxPlayable.TYPE1_21_5);
public static final StructuredDataKey<Key> PROVIDES_BANNER_PATTERNS = new StructuredDataKey<>("provides_banner_patterns", Types.TAG_KEY);
public static final StructuredDataKey<Tag> RECIPES = new StructuredDataKey<>("recipes", Types.TAG);
public static final StructuredDataKey<LodestoneTracker> LODESTONE_TRACKER = new StructuredDataKey<>("lodestone_tracker", LodestoneTracker.TYPE);
public static final StructuredDataKey<FireworkExplosion> FIREWORK_EXPLOSION = new StructuredDataKey<>("firework_explosion", FireworkExplosion.TYPE);
public static final StructuredDataKey<Fireworks> FIREWORKS = new StructuredDataKey<>("fireworks", Fireworks.TYPE);
public static final StructuredDataKey<GameProfile> PROFILE = new StructuredDataKey<>("profile", Types.GAME_PROFILE);
public static final StructuredDataKey<String> NOTE_BLOCK_SOUND = new StructuredDataKey<>("note_block_sound", Types.STRING);
public static final StructuredDataKey<GameProfile> PROFILE1_20_5 = new StructuredDataKey<>("profile", Types.GAME_PROFILE);
public static final StructuredDataKey<ResolvableProfile> PROFILE1_21_9 = new StructuredDataKey<>("profile", Types.RESOLVABLE_PROFILE);
public static final StructuredDataKey<Key> NOTE_BLOCK_SOUND = new StructuredDataKey<>("note_block_sound", Types.IDENTIFIER);
public static final StructuredDataKey<BannerPatternLayer[]> BANNER_PATTERNS = new StructuredDataKey<>("banner_patterns", BannerPatternLayer.ARRAY_TYPE);
public static final StructuredDataKey<Integer> BASE_COLOR = new StructuredDataKey<>("base_color", Types.VAR_INT);
public static final StructuredDataKey<Integer> BASE_COLOR = new StructuredDataKey<>("base_color", EnumTypes.DYE_COLOR);
public static final StructuredDataKey<PotDecorations> POT_DECORATIONS = new StructuredDataKey<>("pot_decorations", PotDecorations.TYPE);
public static final StructuredDataKey<Item[]> CONTAINER1_20_5 = new StructuredDataKey<>("container", Types1_20_5.ITEM_ARRAY);
public static final StructuredDataKey<Item[]> CONTAINER1_21 = new StructuredDataKey<>("container", Types1_21.ITEM_ARRAY);
public static final StructuredDataKey<Item[]> CONTAINER1_21_2 = new StructuredDataKey<>("container", new ArrayType<>(Types1_21_2.ITEM, 256));
public static final StructuredDataKey<Item[]> CONTAINER1_21_4 = new StructuredDataKey<>("container", Types1_21_4.ITEM_ARRAY);
public static final StructuredDataKey<BlockStateProperties> BLOCK_STATE = new StructuredDataKey<>("block_state", BlockStateProperties.TYPE);
public static final StructuredDataKey<Bee[]> BEES = new StructuredDataKey<>("bees", Bee.ARRAY_TYPE);
public static final StructuredDataKey<Tag> LOCK = new StructuredDataKey<>("lock", Types.TAG);
public static final StructuredDataKey<Bee[]> BEES1_20_5 = new StructuredDataKey<>("bees", Bee.ARRAY_TYPE1_20_5);
public static final StructuredDataKey<Bee[]> BEES1_21_9 = new StructuredDataKey<>("bees", Bee.ARRAY_TYPE1_21_9);
public static final StructuredDataKey<Tag> LOCK1_20_5 = new StructuredDataKey<>("lock", Types.TAG);
public static final StructuredDataKey<LockCode> LOCK1_21_2 = new StructuredDataKey<>("lock", LockCode.TYPE);
public static final StructuredDataKey<CompoundTag> CONTAINER_LOOT = new StructuredDataKey<>("container_loot", Types.COMPOUND_TAG);
public static final StructuredDataKey<Holder<SoundEvent>> BREAK_SOUND = new StructuredDataKey<>("break_sound", Types.SOUND_EVENT);
public static final StructuredDataKey<Integer> VILLAGER_VARIANT = new StructuredDataKey<>("villager/variant", EnumTypes.VILLAGER_TYPE);
public static final StructuredDataKey<Integer> WOLF_VARIANT = new StructuredDataKey<>("wolf/variant", new SynchronizedRegistryValueType(RegistryKey.of("wolf_variant")));
public static final StructuredDataKey<Integer> WOLF_SOUND_VARIANT = new StructuredDataKey<>("wolf/sound_variant", new SynchronizedRegistryValueType(RegistryKey.of("wolf_sound_variant")));
public static final StructuredDataKey<Integer> WOLF_COLLAR = new StructuredDataKey<>("wolf/collar", EnumTypes.DYE_COLOR);
public static final StructuredDataKey<Integer> FOX_VARIANT = new StructuredDataKey<>("fox/variant", EnumTypes.FOX_VARIANT);
public static final StructuredDataKey<Integer> SALMON_SIZE = new StructuredDataKey<>("salmon/size", EnumTypes.SALMON_VARIANT);
public static final StructuredDataKey<Integer> PARROT_VARIANT = new StructuredDataKey<>("parrot/variant", EnumTypes.PARROT_VARIANT);
public static final StructuredDataKey<TropicalFishPattern> TROPICAL_FISH_PATTERN = new StructuredDataKey<>("tropical_fish/pattern", TropicalFishPattern.TYPE);
public static final StructuredDataKey<Integer> TROPICAL_FISH_BASE_COLOR = new StructuredDataKey<>("tropical_fish/base_color", EnumTypes.DYE_COLOR);
public static final StructuredDataKey<Integer> TROPICAL_FISH_PATTERN_COLOR = new StructuredDataKey<>("tropical_fish/pattern_color", EnumTypes.DYE_COLOR);
public static final StructuredDataKey<Integer> MOOSHROOM_VARIANT = new StructuredDataKey<>("mooshroom/variant", EnumTypes.MUSHROOM_COW_VARIANT);
public static final StructuredDataKey<Integer> RABBIT_VARIANT = new StructuredDataKey<>("rabbit/variant", EnumTypes.RABBIT_VARIANT);
public static final StructuredDataKey<Integer> PIG_VARIANT = new StructuredDataKey<>("pig/variant", new SynchronizedRegistryValueType(RegistryKey.of("pig_variant")));
public static final StructuredDataKey<Integer> COW_VARIANT = new StructuredDataKey<>("cow/variant", new SynchronizedRegistryValueType(RegistryKey.of("cow_variant")));
public static final StructuredDataKey<Either<Integer, String>> CHICKEN_VARIANT = new StructuredDataKey<>("chicken/variant", new SynchronizedRegistryEitherType(RegistryKey.of("chicken_variant")));
public static final StructuredDataKey<Either<Integer, String>> ZOMBIE_NAUTILUS_VARIANT = new StructuredDataKey<>("zombie_nautilus/variant", new SynchronizedRegistryEitherType(RegistryKey.of("zombie_nautilus_variant"))); // ???
public static final StructuredDataKey<Integer> FROG_VARIANT = new StructuredDataKey<>("frog/variant", new SynchronizedRegistryValueType(RegistryKey.of("frog_variant")));
public static final StructuredDataKey<Integer> HORSE_VARIANT = new StructuredDataKey<>("horse/variant", EnumTypes.HORSE_VARIANT);
public static final StructuredDataKey<Holder<PaintingVariant>> PAINTING_VARIANT = new StructuredDataKey<>("painting/variant", PaintingVariant.TYPE1_21_2);
public static final StructuredDataKey<Integer> LLAMA_VARIANT = new StructuredDataKey<>("llama/variant", EnumTypes.LLAMA_VARIANT);
public static final StructuredDataKey<Integer> AXOLOTL_VARIANT = new StructuredDataKey<>("axolotl/variant", EnumTypes.AXOLOTL_VARIANT);
public static final StructuredDataKey<Integer> CAT_VARIANT = new StructuredDataKey<>("cat/variant", new SynchronizedRegistryValueType(RegistryKey.of("cat_variant")));
public static final StructuredDataKey<Integer> CAT_COLLAR = new StructuredDataKey<>("cat/collar", EnumTypes.DYE_COLOR);
public static final StructuredDataKey<Integer> SHEEP_COLOR = new StructuredDataKey<>("sheep/color", EnumTypes.DYE_COLOR);
public static final StructuredDataKey<Integer> SHULKER_COLOR = new StructuredDataKey<>("shulker/color", EnumTypes.DYE_COLOR);
// These are only safe to use after protocol loading
public static final StructuredDataKeys1_20_5 V1_20_5 = VersionedTypes.V1_20_5.structuredDataKeys();
public static final StructuredDataKeys1_20_5 V1_21 = VersionedTypes.V1_21.structuredDataKeys();
public static final StructuredDataKeys1_21_2 V1_21_2 = VersionedTypes.V1_21_2.structuredDataKeys();
public static final StructuredDataKeys1_21_2 V1_21_4 = VersionedTypes.V1_21_4.structuredDataKeys();
public static final StructuredDataKeys1_21_5 V1_21_5 = VersionedTypes.V1_21_5.structuredDataKeys();
public static final StructuredDataKeys1_21_5 V1_21_6 = VersionedTypes.V1_21_6.structuredDataKeys();
public static final StructuredDataKeys1_21_5 V1_21_9 = VersionedTypes.V1_21_9.structuredDataKeys();
public static final StructuredDataKeys1_21_11 V1_21_11 = VersionedTypes.V1_21_11.structuredDataKeys();
@Override
public String toString() {
@@ -0,0 +1,54 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.data.predicate;
import com.viaversion.viaversion.api.minecraft.data.StructuredData;
import com.viaversion.viaversion.api.type.Type;
import io.netty.buffer.ByteBuf;
public record DataComponentMatchers(StructuredData<?>[] exactPredicates, DataComponentPredicate[] predicates) {
public static final class DataComponentMatchersType extends Type<DataComponentMatchers> {
private final Type<StructuredData<?>[]> dataArrayType;
private final Type<DataComponentPredicate[]> predicateArrayType;
public DataComponentMatchersType(final Type<StructuredData<?>[]> dataArrayType, final Type<DataComponentPredicate[]> predicateArrayType) {
super(DataComponentMatchers.class);
this.dataArrayType = dataArrayType;
this.predicateArrayType = predicateArrayType;
}
@Override
public DataComponentMatchers read(final ByteBuf buffer) {
final StructuredData<?>[] exactPredicates = dataArrayType.read(buffer);
final DataComponentPredicate[] partialPredicates = predicateArrayType.read(buffer);
return new DataComponentMatchers(exactPredicates, partialPredicates);
}
@Override
public void write(final ByteBuf buffer, final DataComponentMatchers value) {
dataArrayType.write(buffer, value.exactPredicates());
predicateArrayType.write(buffer, value.predicates());
}
}
}
@@ -0,0 +1,81 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.data.predicate;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.ArrayType;
import io.netty.buffer.ByteBuf;
public record DataComponentPredicate(PredicateType type, Tag predicate) {
public DataComponentPredicate(final int predicateType, final Tag predicate) {
this(PredicateType.ofPredicateType(predicateType), predicate);
}
public static final Type<DataComponentPredicate> TYPE1_21_5 = new Type<>(DataComponentPredicate.class) {
@Override
public DataComponentPredicate read(final ByteBuf buffer) {
final int id = Types.VAR_INT.readPrimitive(buffer);
final Tag predicate = Types.TAG.read(buffer);
return new DataComponentPredicate(id, predicate);
}
@Override
public void write(final ByteBuf buffer, final DataComponentPredicate value) {
Types.VAR_INT.writePrimitive(buffer, value.type().id());
Types.TAG.write(buffer, value.predicate());
}
};
public static final Type<DataComponentPredicate[]> ARRAY_TYPE1_21_5 = new ArrayType<>(TYPE1_21_5, 64);
public static final Type<DataComponentPredicate> TYPE1_21_11 = new Type<>(DataComponentPredicate.class) {
@Override
public DataComponentPredicate read(final ByteBuf buffer) {
final boolean isPredicateType = Types.BOOLEAN.read(buffer);
final PredicateType type = new PredicateType(Types.VAR_INT.readPrimitive(buffer), isPredicateType);
final Tag predicate = Types.TAG.read(buffer);
return new DataComponentPredicate(type, predicate);
}
@Override
public void write(final ByteBuf buffer, final DataComponentPredicate value) {
Types.BOOLEAN.write(buffer, value.type().isPredicateType());
Types.VAR_INT.writePrimitive(buffer, value.type().id());
Types.TAG.write(buffer, value.predicate());
}
};
public static final Type<DataComponentPredicate[]> ARRAY_TYPE1_21_11 = new ArrayType<>(TYPE1_21_11, 64);
public record PredicateType(int id, boolean isPredicateType) {
public static PredicateType ofPredicateType(final int id) {
return new PredicateType(id, true);
}
public static PredicateType ofDataComponentType(final int id) {
return new PredicateType(id, false);
}
}
}
@@ -0,0 +1,40 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.data.version;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
public class StructuredDataKeys1_20_5 extends VersionedStructuredDataKeys {
public final StructuredDataKey<Item[]> container;
public final StructuredDataKey<Item[]> chargedProjectiles;
public final StructuredDataKey<Item[]> bundleContents;
public StructuredDataKeys1_20_5(final VersionedTypesHolder types) {
this.container = add("container", types.itemArray());
this.chargedProjectiles = add("charged_projectiles", types.itemArray());
this.bundleContents = add("bundle_contents", types.itemArray());
}
}
@@ -0,0 +1,44 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.data.version;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.data.predicate.DataComponentPredicate;
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate;
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate.AdventureModePredicateType1_21_5;
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
public class StructuredDataKeys1_21_11 extends StructuredDataKeys1_21_2 {
public final StructuredDataKey<AdventureModePredicate> canPlaceOn;
public final StructuredDataKey<AdventureModePredicate> canBreak;
public StructuredDataKeys1_21_11(final VersionedTypesHolder types) {
super(types);
final AdventureModePredicateType1_21_5 adventureModePredicateType = new AdventureModePredicateType1_21_5(types.structuredDataArray(), DataComponentPredicate.ARRAY_TYPE1_21_11);
this.canPlaceOn = add("can_place_on", adventureModePredicateType);
this.canBreak = add("can_break", adventureModePredicateType);
this.unsupportedForOps.add(this.canPlaceOn);
this.unsupportedForOps.add(this.canBreak);
}
}
@@ -0,0 +1,43 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.data.version;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.item.data.ContainterContents.ContainerContentsType;
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
public class StructuredDataKeys1_21_2 extends VersionedStructuredDataKeys {
public final StructuredDataKey<Item[]> container;
public final StructuredDataKey<Item[]> chargedProjectiles;
public final StructuredDataKey<Item[]> bundleContents;
public final StructuredDataKey<Item> useRemainder;
public StructuredDataKeys1_21_2(final VersionedTypesHolder types) {
this.container = add("container", new ContainerContentsType(types.item()));
this.chargedProjectiles = add("charged_projectiles", types.itemArray());
this.bundleContents = add("bundle_contents", types.itemArray());
this.useRemainder = add("use_remainder", types.item());
}
}
@@ -0,0 +1,44 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.data.version;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.data.predicate.DataComponentPredicate;
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate;
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate.AdventureModePredicateType1_21_5;
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
public class StructuredDataKeys1_21_5 extends StructuredDataKeys1_21_2 {
public final StructuredDataKey<AdventureModePredicate> canPlaceOn;
public final StructuredDataKey<AdventureModePredicate> canBreak;
public StructuredDataKeys1_21_5(final VersionedTypesHolder types) {
super(types);
final AdventureModePredicateType1_21_5 adventureModePredicateType = new AdventureModePredicateType1_21_5(types.structuredDataArray(), DataComponentPredicate.ARRAY_TYPE1_21_5);
this.canPlaceOn = add("can_place_on", adventureModePredicateType);
this.canBreak = add("can_break", adventureModePredicateType);
this.unsupportedForOps.add(this.canPlaceOn);
this.unsupportedForOps.add(this.canBreak);
}
}
@@ -0,0 +1,50 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.data.version;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.type.Type;
import it.unimi.dsi.fastutil.objects.ReferenceArraySet;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public abstract class VersionedStructuredDataKeys {
private final List<StructuredDataKey<?>> keys = new ArrayList<>();
protected final Set<StructuredDataKey<?>> unsupportedForOps = new ReferenceArraySet<>();
protected <T> StructuredDataKey<T> add(final String identifier, final Type<T> type) {
final StructuredDataKey<T> key = new StructuredDataKey<>(identifier, type);
this.keys.add(key);
return key;
}
public List<StructuredDataKey<?>> keys() {
return this.keys;
}
public boolean supportsOps(final StructuredDataKey<?> key) {
return !unsupportedForOps.contains(key);
}
}
@@ -22,22 +22,11 @@
*/
package com.viaversion.viaversion.api.minecraft.entities;
import java.util.HashMap;
import java.util.Map;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class EntityTypes1_10 {
public static EntityType getTypeFromId(final int typeId, final boolean object) {
EntityType type;
if (object) {
type = ObjectType.getEntityType(typeId);
} else {
type = EntityType.findById(typeId);
}
return type;
}
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
ENTITY,
@@ -154,7 +143,7 @@ public class EntityTypes1_10 {
SPIDER(52, ABSTRACT_MONSTER),
CAVE_SPIDER(59, SPIDER);
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
private static final Int2ObjectMap<EntityType> TYPES;
private final int id;
private final EntityType parent;
@@ -195,7 +184,9 @@ public class EntityTypes1_10 {
}
static {
for (EntityType type : EntityType.values()) {
final EntityType[] values = EntityType.values();
TYPES = new Int2ObjectOpenHashMap<>(values.length);
for (EntityType type : values) {
TYPES.put(type.id, type);
}
}
@@ -212,7 +203,13 @@ public class EntityTypes1_10 {
BOAT(1, EntityType.BOAT),
ITEM(2, EntityType.ITEM),
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
MINECART(10, EntityType.MINECART), // There are multiple types, but we don't need them
MINECART(10, EntityType.MINECART),
CHEST_MINECART(10, 1, EntityType.CHEST_MINECART),
FURNACE_MINECART(10, 2, EntityType.FURNACE_MINECART),
TNT_MINECART(10, 3, EntityType.TNT_MINECART),
SPAWNER_MINECART(10, 4, EntityType.SPAWNER_MINECART),
HOPPER_MINECART(10, 5, EntityType.HOPPER_MINECART),
COMMAND_BLOCK_MINECART(10, 6, EntityType.COMMAND_BLOCK_MINECART),
TNT_PRIMED(50, EntityType.TNT),
ENDER_CRYSTAL(51, EntityType.END_CRYSTAL),
TIPPED_ARROW(60, EntityType.ARROW),
@@ -235,19 +232,25 @@ public class EntityTypes1_10 {
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
private static final Map<Integer, ObjectType> TYPES = new HashMap<>();
private static final Int2ObjectMap<Int2ObjectMap<ObjectType>> TYPES = new Int2ObjectOpenHashMap<>();
private final int id;
private final int data;
private final EntityType type;
static {
for (ObjectType type : ObjectType.values()) {
TYPES.put(type.id, type);
TYPES.computeIfAbsent(type.id, k -> new Int2ObjectOpenHashMap<>()).put(type.data, type);
}
}
ObjectType(int id, EntityType type) {
this(id, 0, type);
}
ObjectType(int id, int data, EntityType type) {
this.id = id;
this.data = data;
this.type = type;
}
@@ -256,20 +259,28 @@ public class EntityTypes1_10 {
return id;
}
@Override
public int getData() {
return data;
}
@Override
public EntityType getType() {
return type;
}
public static ObjectType findById(final int id) {
if (id == -1) {
public static ObjectType findById(final int id, final int data) {
final Int2ObjectMap<ObjectType> types = TYPES.get(id);
if (types == null) {
return null;
}
return TYPES.get(id);
final ObjectType type = types.get(data);
return type != null ? type : types.get(0);
}
public static EntityType getEntityType(final int id) {
final ObjectType objectType = findById(id);
public static EntityType getEntityType(final int id, final int data) {
final ObjectType objectType = findById(id, data);
return objectType != null ? objectType.type : null;
}
}
@@ -22,22 +22,11 @@
*/
package com.viaversion.viaversion.api.minecraft.entities;
import java.util.HashMap;
import java.util.Map;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class EntityTypes1_11 {
public static EntityType getTypeFromId(final int typeId, final boolean object) {
EntityType type;
if (object) {
type = ObjectType.getEntityType(typeId);
} else {
type = EntityType.findById(typeId);
}
return type;
}
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
ENTITY,
@@ -179,7 +168,7 @@ public class EntityTypes1_11 {
EVOKER(34, ABSTRACT_MONSTER),
VINDICATOR(36, ABSTRACT_MONSTER);
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
private static final Int2ObjectMap<EntityType> TYPES;
private final int id;
private final EntityType parent;
@@ -220,7 +209,9 @@ public class EntityTypes1_11 {
}
static {
for (EntityType type : EntityType.values()) {
final EntityType[] values = EntityType.values();
TYPES = new Int2ObjectOpenHashMap<>(values.length);
for (EntityType type : values) {
TYPES.put(type.id, type);
}
}
@@ -237,7 +228,13 @@ public class EntityTypes1_11 {
BOAT(1, EntityType.BOAT),
ITEM(2, EntityType.ITEM),
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
MINECART(10, EntityType.MINECART), // There are multiple types, but we don't need them
MINECART(10, EntityType.MINECART),
CHEST_MINECART(10, 1, EntityType.CHEST_MINECART),
FURNACE_MINECART(10, 2, EntityType.FURNACE_MINECART),
TNT_MINECART(10, 3, EntityType.TNT_MINECART),
SPAWNER_MINECART(10, 4, EntityType.SPAWNER_MINECART),
HOPPER_MINECART(10, 5, EntityType.HOPPER_MINECART),
COMMAND_BLOCK_MINECART(10, 6, EntityType.COMMAND_BLOCK_MINECART),
TNT_PRIMED(50, EntityType.TNT),
ENDER_CRYSTAL(51, EntityType.END_CRYSTAL),
TIPPED_ARROW(60, EntityType.ARROW),
@@ -262,19 +259,25 @@ public class EntityTypes1_11 {
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
private static final Map<Integer, ObjectType> TYPES = new HashMap<>();
private static final Int2ObjectMap<Int2ObjectMap<ObjectType>> TYPES = new Int2ObjectOpenHashMap<>();
private final int id;
private final int data;
private final EntityType type;
static {
for (ObjectType type : ObjectType.values()) {
TYPES.put(type.id, type);
TYPES.computeIfAbsent(type.id, k -> new Int2ObjectOpenHashMap<>()).put(type.data, type);
}
}
ObjectType(int id, EntityType type) {
this(id, 0, type);
}
ObjectType(int id, int data, EntityType type) {
this.id = id;
this.data = data;
this.type = type;
}
@@ -283,20 +286,28 @@ public class EntityTypes1_11 {
return id;
}
@Override
public int getData() {
return data;
}
@Override
public EntityType getType() {
return type;
}
public static ObjectType findById(final int id) {
if (id == -1) {
public static ObjectType findById(final int id, final int data) {
final Int2ObjectMap<ObjectType> types = TYPES.get(id);
if (types == null) {
return null;
}
return TYPES.get(id);
final ObjectType type = types.get(data);
return type != null ? type : types.get(0);
}
public static EntityType getEntityType(final int id) {
final ObjectType objectType = findById(id);
public static EntityType getEntityType(final int id, final int data) {
final ObjectType objectType = findById(id, data);
return objectType != null ? objectType.type : null;
}
}
@@ -22,22 +22,11 @@
*/
package com.viaversion.viaversion.api.minecraft.entities;
import java.util.HashMap;
import java.util.Map;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class EntityTypes1_12 {
public static EntityType getTypeFromId(final int typeId, final boolean object) {
EntityType type;
if (object) {
type = ObjectType.getEntityType(typeId);
} else {
type = EntityType.findById(typeId);
}
return type;
}
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
ENTITY,
@@ -185,7 +174,7 @@ public class EntityTypes1_12 {
EVOKER(34, SPELLCASTER_ILLAGER),
ILLUSIONER(37, SPELLCASTER_ILLAGER);
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
private static final Int2ObjectMap<EntityType> TYPES;
private final int id;
private final EntityType parent;
@@ -226,7 +215,9 @@ public class EntityTypes1_12 {
}
static {
for (EntityType type : EntityType.values()) {
final EntityType[] values = EntityType.values();
TYPES = new Int2ObjectOpenHashMap<>(values.length);
for (EntityType type : values) {
TYPES.put(type.id, type);
}
}
@@ -243,7 +234,13 @@ public class EntityTypes1_12 {
BOAT(1, EntityType.BOAT),
ITEM(2, EntityType.ITEM),
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
MINECART(10, EntityType.MINECART), // There are multiple types, but we don't need them
MINECART(10, EntityType.MINECART),
CHEST_MINECART(10, 1, EntityType.CHEST_MINECART),
FURNACE_MINECART(10, 2, EntityType.FURNACE_MINECART),
TNT_MINECART(10, 3, EntityType.TNT_MINECART),
SPAWNER_MINECART(10, 4, EntityType.SPAWNER_MINECART),
HOPPER_MINECART(10, 5, EntityType.HOPPER_MINECART),
COMMAND_BLOCK_MINECART(10, 6, EntityType.COMMAND_BLOCK_MINECART),
TNT_PRIMED(50, EntityType.TNT),
ENDER_CRYSTAL(51, EntityType.END_CRYSTAL),
TIPPED_ARROW(60, EntityType.ARROW),
@@ -268,19 +265,25 @@ public class EntityTypes1_12 {
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
private static final Map<Integer, ObjectType> TYPES = new HashMap<>();
private static final Int2ObjectMap<Int2ObjectMap<ObjectType>> TYPES = new Int2ObjectOpenHashMap<>();
private final int id;
private final int data;
private final EntityType type;
static {
for (ObjectType type : ObjectType.values()) {
TYPES.put(type.id, type);
TYPES.computeIfAbsent(type.id, k -> new Int2ObjectOpenHashMap<>()).put(type.data, type);
}
}
ObjectType(int id, EntityType type) {
this(id, 0, type);
}
ObjectType(int id, int data, EntityType type) {
this.id = id;
this.data = data;
this.type = type;
}
@@ -289,20 +292,28 @@ public class EntityTypes1_12 {
return id;
}
@Override
public int getData() {
return data;
}
@Override
public EntityType getType() {
return type;
}
public static ObjectType findById(final int id) {
if (id == -1) {
public static ObjectType findById(final int id, final int data) {
final Int2ObjectMap<ObjectType> types = TYPES.get(id);
if (types == null) {
return null;
}
return TYPES.get(id);
final ObjectType type = types.get(data);
return type != null ? type : types.get(0);
}
public static EntityType getEntityType(final int id) {
final ObjectType objectType = findById(id);
public static EntityType getEntityType(final int id, final int data) {
final ObjectType objectType = findById(id, data);
return objectType != null ? objectType.type : null;
}
}
@@ -22,22 +22,11 @@
*/
package com.viaversion.viaversion.api.minecraft.entities;
import java.util.HashMap;
import java.util.Map;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class EntityTypes1_13 {
public static EntityType getTypeFromId(final int typeId, final boolean object) {
EntityType type;
if (object) {
type = ObjectType.getEntityType(typeId);
} else {
type = EntityType.findById(typeId);
}
return type;
}
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
ENTITY,
@@ -196,7 +185,7 @@ public class EntityTypes1_13 {
EVOKER(21, SPELLCASTER_ILLAGER),
ILLUSIONER(31, SPELLCASTER_ILLAGER);
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
private static final Int2ObjectMap<EntityType> TYPES;
private final int id;
private final EntityType parent;
@@ -237,7 +226,9 @@ public class EntityTypes1_13 {
}
static {
for (EntityType type : EntityType.values()) {
final EntityType[] values = EntityType.values();
TYPES = new Int2ObjectOpenHashMap<>(values.length);
for (EntityType type : values) {
TYPES.put(type.id, type);
}
}
@@ -254,7 +245,13 @@ public class EntityTypes1_13 {
BOAT(1, EntityType.BOAT),
ITEM(2, EntityType.ITEM),
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
MINECART(10, EntityType.MINECART), // There are multiple types, but we don't need them
MINECART(10, EntityType.MINECART),
CHEST_MINECART(10, 1, EntityType.CHEST_MINECART),
FURNACE_MINECART(10, 2, EntityType.FURNACE_MINECART),
TNT_MINECART(10, 3, EntityType.TNT_MINECART),
SPAWNER_MINECART(10, 4, EntityType.SPAWNER_MINECART),
HOPPER_MINECART(10, 5, EntityType.HOPPER_MINECART),
COMMAND_BLOCK_MINECART(10, 6, EntityType.COMMAND_BLOCK_MINECART),
TNT_PRIMED(50, EntityType.TNT),
ENDER_CRYSTAL(51, EntityType.END_CRYSTAL),
TIPPED_ARROW(60, EntityType.ARROW),
@@ -280,19 +277,25 @@ public class EntityTypes1_13 {
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL),
TRIDENT(94, EntityType.TRIDENT);
private static final Map<Integer, ObjectType> TYPES = new HashMap<>();
private static final Int2ObjectMap<Int2ObjectMap<ObjectType>> TYPES = new Int2ObjectOpenHashMap<>();
private final int id;
private final int data;
private final EntityType type;
static {
for (ObjectType type : ObjectType.values()) {
TYPES.put(type.id, type);
TYPES.computeIfAbsent(type.id, k -> new Int2ObjectOpenHashMap<>()).put(type.data, type);
}
}
ObjectType(int id, EntityType type) {
this(id, 0, type);
}
ObjectType(int id, int data, EntityType type) {
this.id = id;
this.data = data;
this.type = type;
}
@@ -301,20 +304,28 @@ public class EntityTypes1_13 {
return id;
}
@Override
public int getData() {
return data;
}
@Override
public EntityType getType() {
return type;
}
public static ObjectType findById(final int id) {
if (id == -1) {
public static ObjectType findById(final int id, final int data) {
final Int2ObjectMap<ObjectType> types = TYPES.get(id);
if (types == null) {
return null;
}
return TYPES.get(id);
final ObjectType type = types.get(data);
return type != null ? type : types.get(0);
}
public static EntityType getEntityType(final int id) {
final ObjectType objectType = findById(id);
public static EntityType getEntityType(final int id, final int data) {
final ObjectType objectType = findById(id, data);
return objectType != null ? objectType.type : null;
}
}
@@ -213,7 +213,7 @@ public enum EntityTypes1_14 implements EntityType {
EntityTypes1_14(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_14(final EntityType parent, @Nullable final String identifier) {
@@ -214,7 +214,7 @@ public enum EntityTypes1_15 implements EntityType {
EntityTypes1_15(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_15(final EntityType parent, @Nullable final String identifier) {
@@ -218,7 +218,7 @@ public enum EntityTypes1_16 implements EntityType {
EntityTypes1_16(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_16(final EntityType parent, @Nullable final String identifier) {
@@ -221,7 +221,7 @@ public enum EntityTypes1_16_2 implements EntityType {
EntityTypes1_16_2(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_16_2(final EntityType parent, @Nullable final String identifier) {
@@ -227,7 +227,7 @@ public enum EntityTypes1_17 implements EntityType {
EntityTypes1_17(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_17(final EntityType parent, @Nullable final String identifier) {
@@ -232,7 +232,7 @@ public enum EntityTypes1_19 implements EntityType {
EntityTypes1_19(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_19(final EntityType parent, @Nullable final String identifier) {
@@ -233,7 +233,7 @@ public enum EntityTypes1_19_3 implements EntityType {
EntityTypes1_19_3(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_19_3(final EntityType parent, @Nullable final String identifier) {
@@ -240,7 +240,7 @@ public enum EntityTypes1_19_4 implements EntityType {
EntityTypes1_19_4(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_19_4(final EntityType parent, @Nullable final String identifier) {
@@ -242,7 +242,7 @@ public enum EntityTypes1_20_3 implements EntityType {
EntityTypes1_20_3(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_20_3(final EntityType parent, @Nullable final String identifier) {
@@ -248,7 +248,7 @@ public enum EntityTypes1_20_5 implements EntityType {
EntityTypes1_20_5(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_20_5(final EntityType parent, @Nullable final String identifier) {
@@ -0,0 +1,329 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil;
import com.viaversion.viaversion.util.Key;
import java.util.Locale;
import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_21_11 implements EntityType {
ENTITY(null, null),
AREA_EFFECT_CLOUD(ENTITY),
END_CRYSTAL(ENTITY),
EVOKER_FANGS(ENTITY),
EXPERIENCE_ORB(ENTITY),
EYE_OF_ENDER(ENTITY),
FALLING_BLOCK(ENTITY),
ITEM(ENTITY),
TNT(ENTITY),
OMINOUS_ITEM_SPAWNER(ENTITY),
MARKER(ENTITY),
LIGHTNING_BOLT(ENTITY),
INTERACTION(ENTITY),
DISPLAY(ENTITY, null),
BLOCK_DISPLAY(DISPLAY),
ITEM_DISPLAY(DISPLAY),
TEXT_DISPLAY(DISPLAY),
// Hanging entities
HANGING_ENTITY(ENTITY, null),
LEASH_KNOT(HANGING_ENTITY),
PAINTING(HANGING_ENTITY),
ITEM_FRAME(HANGING_ENTITY),
GLOW_ITEM_FRAME(ITEM_FRAME),
// Projectiles
PROJECTILE(ENTITY, null),
ITEM_PROJECTILE(PROJECTILE, null),
SNOWBALL(ITEM_PROJECTILE),
ENDER_PEARL(ITEM_PROJECTILE),
EGG(ITEM_PROJECTILE),
EXPERIENCE_BOTTLE(ITEM_PROJECTILE),
FIREWORK_ROCKET(PROJECTILE),
LLAMA_SPIT(PROJECTILE),
SHULKER_BULLET(PROJECTILE),
FISHING_BOBBER(PROJECTILE),
WITHER_SKULL(PROJECTILE),
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
ABSTRACT_THROWN_POTION(ITEM_PROJECTILE, null),
SPLASH_POTION(ABSTRACT_THROWN_POTION),
LINGERING_POTION(ABSTRACT_THROWN_POTION),
ABSTRACT_ARROW(PROJECTILE, null),
ARROW(ABSTRACT_ARROW),
SPECTRAL_ARROW(ABSTRACT_ARROW),
TRIDENT(ABSTRACT_ARROW),
ABSTRACT_FIREBALL(ENTITY, null),
FIREBALL(ABSTRACT_FIREBALL),
SMALL_FIREBALL(ABSTRACT_FIREBALL),
ABSTRACT_WIND_CHARGE(PROJECTILE, null),
WIND_CHARGE(ABSTRACT_WIND_CHARGE),
BREEZE_WIND_CHARGE(ABSTRACT_WIND_CHARGE),
// Vehicles
VEHICLE(ENTITY, null),
ABSTRACT_MINECART(VEHICLE, null),
MINECART(ABSTRACT_MINECART),
FURNACE_MINECART(ABSTRACT_MINECART),
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
TNT_MINECART(ABSTRACT_MINECART),
SPAWNER_MINECART(ABSTRACT_MINECART),
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
ABSTRACT_BOAT(VEHICLE, null),
ABSTRACT_CHEST_BOAT(ABSTRACT_BOAT, null),
ACACIA_BOAT(ABSTRACT_BOAT),
ACACIA_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
BAMBOO_CHEST_RAFT(ABSTRACT_CHEST_BOAT),
BAMBOO_RAFT(ABSTRACT_BOAT),
BIRCH_BOAT(ABSTRACT_BOAT),
BIRCH_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
CHERRY_BOAT(ABSTRACT_BOAT),
CHERRY_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
DARK_OAK_BOAT(ABSTRACT_BOAT),
DARK_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
JUNGLE_BOAT(ABSTRACT_BOAT),
JUNGLE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
MANGROVE_BOAT(ABSTRACT_BOAT),
MANGROVE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
OAK_BOAT(ABSTRACT_BOAT),
OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
PALE_OAK_BOAT(ABSTRACT_BOAT),
PALE_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
SPRUCE_BOAT(ABSTRACT_BOAT),
SPRUCE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
// Living entities as a larger subclass
LIVING_ENTITY(ENTITY, null),
ARMOR_STAND(LIVING_ENTITY),
// Players
AVATAR(LIVING_ENTITY, null),
MANNEQUIN(AVATAR),
PLAYER(AVATAR),
// Mobs as a larger subclass
MOB(LIVING_ENTITY, null),
ENDER_DRAGON(MOB),
SLIME(MOB),
MAGMA_CUBE(SLIME),
// Ambient mobs
AMBIENT_CREATURE(MOB, null),
BAT(AMBIENT_CREATURE),
// Flying mobs
FLYING_MOB(MOB, null),
GHAST(FLYING_MOB),
PHANTOM(FLYING_MOB),
// Pathfinder mobs and its subclasses
PATHFINDER_MOB(MOB, null),
ALLAY(PATHFINDER_MOB),
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
SNOW_GOLEM(ABSTRACT_GOLEM),
IRON_GOLEM(ABSTRACT_GOLEM),
SHULKER(ABSTRACT_GOLEM),
COPPER_GOLEM(ABSTRACT_GOLEM),
// Ageable mobs and (tamable) animals
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
VILLAGER(ABSTRACT_VILLAGER),
WANDERING_TRADER(ABSTRACT_VILLAGER),
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
AXOLOTL(ABSTRACT_ANIMAL),
CHICKEN(ABSTRACT_ANIMAL),
PANDA(ABSTRACT_ANIMAL),
PIG(ABSTRACT_ANIMAL),
POLAR_BEAR(ABSTRACT_ANIMAL),
RABBIT(ABSTRACT_ANIMAL),
SHEEP(ABSTRACT_ANIMAL),
BEE(ABSTRACT_ANIMAL),
TURTLE(ABSTRACT_ANIMAL),
FOX(ABSTRACT_ANIMAL),
FROG(ABSTRACT_ANIMAL),
GOAT(ABSTRACT_ANIMAL),
HOGLIN(ABSTRACT_ANIMAL),
STRIDER(ABSTRACT_ANIMAL),
SNIFFER(ABSTRACT_ANIMAL),
ARMADILLO(ABSTRACT_ANIMAL),
HAPPY_GHAST(ABSTRACT_ANIMAL),
ABSTRACT_COW(ABSTRACT_ANIMAL, null),
COW(ABSTRACT_COW),
MOOSHROOM(ABSTRACT_COW),
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
CAT(TAMABLE_ANIMAL),
OCELOT(TAMABLE_ANIMAL),
WOLF(TAMABLE_ANIMAL),
PARROT(TAMABLE_ANIMAL),
ABSTRACT_NAUTILUS(TAMABLE_ANIMAL, null),
NAUTILUS(ABSTRACT_NAUTILUS),
ZOMBIE_NAUTILUS(ABSTRACT_NAUTILUS),
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
HORSE(ABSTRACT_HORSE),
SKELETON_HORSE(ABSTRACT_HORSE),
ZOMBIE_HORSE(ABSTRACT_HORSE),
CAMEL(ABSTRACT_HORSE),
CAMEL_HUSK(CAMEL),
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
DONKEY(ABSTRACT_CHESTED_HORSE),
MULE(ABSTRACT_CHESTED_HORSE),
LLAMA(ABSTRACT_CHESTED_HORSE),
TRADER_LLAMA(LLAMA),
// Monsters
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
BLAZE(ABSTRACT_MONSTER),
CREEPER(ABSTRACT_MONSTER),
ENDERMITE(ABSTRACT_MONSTER),
ENDERMAN(ABSTRACT_MONSTER),
GIANT(ABSTRACT_MONSTER),
SILVERFISH(ABSTRACT_MONSTER),
VEX(ABSTRACT_MONSTER),
WITHER(ABSTRACT_MONSTER),
BREEZE(ABSTRACT_MONSTER),
ZOGLIN(ABSTRACT_MONSTER),
WARDEN(ABSTRACT_MONSTER),
CREAKING(ABSTRACT_MONSTER),
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
SKELETON(ABSTRACT_SKELETON),
STRAY(ABSTRACT_SKELETON),
WITHER_SKELETON(ABSTRACT_SKELETON),
BOGGED(ABSTRACT_SKELETON),
PARCHED(ABSTRACT_SKELETON),
ZOMBIE(ABSTRACT_MONSTER),
DROWNED(ZOMBIE),
HUSK(ZOMBIE),
ZOMBIFIED_PIGLIN(ZOMBIE),
ZOMBIE_VILLAGER(ZOMBIE),
GUARDIAN(ABSTRACT_MONSTER),
ELDER_GUARDIAN(GUARDIAN),
SPIDER(ABSTRACT_MONSTER),
CAVE_SPIDER(SPIDER),
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
PIGLIN(ABSTRACT_PIGLIN),
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
// Water mobs
AGEABLE_WATER_CREATURE(ABSTRACT_AGEABLE, null),
DOLPHIN(AGEABLE_WATER_CREATURE),
SQUID(AGEABLE_WATER_CREATURE),
GLOW_SQUID(SQUID),
WATER_ANIMAL(PATHFINDER_MOB, null),
ABSTRACT_FISH(WATER_ANIMAL, null),
PUFFERFISH(ABSTRACT_FISH),
TADPOLE(ABSTRACT_FISH),
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
COD(ABSTRACT_SCHOOLING_FISH),
SALMON(ABSTRACT_SCHOOLING_FISH),
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
// Raiders
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
WITCH(ABSTRACT_RAIDER),
RAVAGER(ABSTRACT_RAIDER),
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
VINDICATOR(ABSTRACT_ILLAGER),
PILLAGER(ABSTRACT_ILLAGER),
EVOKER(SPELLCASTER_ILLAGER),
ILLUSIONER(SPELLCASTER_ILLAGER);
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
private final EntityType parent;
private final String identifier;
private int id = -1;
EntityTypes1_21_11(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_21_11(final EntityType parent, @Nullable final String identifier) {
this.parent = parent;
this.identifier = identifier;
}
@Override
public int getId() {
if (id == -1) {
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
}
return id;
}
@Override
public String identifier() {
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
return identifier;
}
@Override
public @Nullable EntityType getParent() {
return parent;
}
@Override
public boolean isAbstractType() {
return identifier == null;
}
public static EntityType getTypeFromId(final int typeId) {
return EntityTypeUtil.getTypeFromId(TYPES, typeId, PIG);
}
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id);
}
}
@@ -272,7 +272,7 @@ public enum EntityTypes1_21_2 implements EntityType {
EntityTypes1_21_2(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_21_2(final EntityType parent, @Nullable final String identifier) {
@@ -271,7 +271,7 @@ public enum EntityTypes1_21_4 implements EntityType {
EntityTypes1_21_4(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_21_4(final EntityType parent, @Nullable final String identifier) {
@@ -0,0 +1,317 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil;
import com.viaversion.viaversion.util.Key;
import java.util.Locale;
import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_21_5 implements EntityType {
ENTITY(null, null),
AREA_EFFECT_CLOUD(ENTITY),
END_CRYSTAL(ENTITY),
EVOKER_FANGS(ENTITY),
EXPERIENCE_ORB(ENTITY),
EYE_OF_ENDER(ENTITY),
FALLING_BLOCK(ENTITY),
ITEM(ENTITY),
TNT(ENTITY),
OMINOUS_ITEM_SPAWNER(ENTITY),
MARKER(ENTITY),
LIGHTNING_BOLT(ENTITY),
INTERACTION(ENTITY),
DISPLAY(ENTITY, null),
BLOCK_DISPLAY(DISPLAY),
ITEM_DISPLAY(DISPLAY),
TEXT_DISPLAY(DISPLAY),
// Hanging entities
HANGING_ENTITY(ENTITY, null),
LEASH_KNOT(HANGING_ENTITY),
PAINTING(HANGING_ENTITY),
ITEM_FRAME(HANGING_ENTITY),
GLOW_ITEM_FRAME(ITEM_FRAME),
// Projectiles
PROJECTILE(ENTITY, null),
ITEM_PROJECTILE(PROJECTILE, null),
SNOWBALL(ITEM_PROJECTILE),
ENDER_PEARL(ITEM_PROJECTILE),
EGG(ITEM_PROJECTILE),
EXPERIENCE_BOTTLE(ITEM_PROJECTILE),
FIREWORK_ROCKET(PROJECTILE),
LLAMA_SPIT(PROJECTILE),
SHULKER_BULLET(PROJECTILE),
FISHING_BOBBER(PROJECTILE),
WITHER_SKULL(PROJECTILE),
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
ABSTRACT_THROWN_POTION(ITEM_PROJECTILE, null),
SPLASH_POTION(ABSTRACT_THROWN_POTION),
LINGERING_POTION(ABSTRACT_THROWN_POTION),
ABSTRACT_ARROW(PROJECTILE, null),
ARROW(ABSTRACT_ARROW),
SPECTRAL_ARROW(ABSTRACT_ARROW),
TRIDENT(ABSTRACT_ARROW),
ABSTRACT_FIREBALL(ENTITY, null),
FIREBALL(ABSTRACT_FIREBALL),
SMALL_FIREBALL(ABSTRACT_FIREBALL),
ABSTRACT_WIND_CHARGE(PROJECTILE, null),
WIND_CHARGE(ABSTRACT_WIND_CHARGE),
BREEZE_WIND_CHARGE(ABSTRACT_WIND_CHARGE),
// Vehicles
VEHICLE(ENTITY, null),
ABSTRACT_MINECART(VEHICLE, null),
MINECART(ABSTRACT_MINECART),
FURNACE_MINECART(ABSTRACT_MINECART),
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
TNT_MINECART(ABSTRACT_MINECART),
SPAWNER_MINECART(ABSTRACT_MINECART),
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
ABSTRACT_BOAT(VEHICLE, null),
ABSTRACT_CHEST_BOAT(ABSTRACT_BOAT, null),
ACACIA_BOAT(ABSTRACT_BOAT),
ACACIA_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
BAMBOO_CHEST_RAFT(ABSTRACT_CHEST_BOAT),
BAMBOO_RAFT(ABSTRACT_BOAT),
BIRCH_BOAT(ABSTRACT_BOAT),
BIRCH_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
CHERRY_BOAT(ABSTRACT_BOAT),
CHERRY_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
DARK_OAK_BOAT(ABSTRACT_BOAT),
DARK_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
JUNGLE_BOAT(ABSTRACT_BOAT),
JUNGLE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
MANGROVE_BOAT(ABSTRACT_BOAT),
MANGROVE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
OAK_BOAT(ABSTRACT_BOAT),
OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
PALE_OAK_BOAT(ABSTRACT_BOAT),
PALE_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
SPRUCE_BOAT(ABSTRACT_BOAT),
SPRUCE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
// Living entities as a larger subclass
LIVING_ENTITY(ENTITY, null),
ARMOR_STAND(LIVING_ENTITY),
PLAYER(LIVING_ENTITY),
// Mobs as a larger subclass
MOB(LIVING_ENTITY, null),
ENDER_DRAGON(MOB),
SLIME(MOB),
MAGMA_CUBE(SLIME),
// Ambient mobs
AMBIENT_CREATURE(MOB, null),
BAT(AMBIENT_CREATURE),
// Flying mobs
FLYING_MOB(MOB, null),
GHAST(FLYING_MOB),
PHANTOM(FLYING_MOB),
// Pathfinder mobs and its subclasses
PATHFINDER_MOB(MOB, null),
ALLAY(PATHFINDER_MOB),
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
SNOW_GOLEM(ABSTRACT_GOLEM),
IRON_GOLEM(ABSTRACT_GOLEM),
SHULKER(ABSTRACT_GOLEM),
// Ageable mobs and (tamable) animals
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
VILLAGER(ABSTRACT_VILLAGER),
WANDERING_TRADER(ABSTRACT_VILLAGER),
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
AXOLOTL(ABSTRACT_ANIMAL),
CHICKEN(ABSTRACT_ANIMAL),
PANDA(ABSTRACT_ANIMAL),
PIG(ABSTRACT_ANIMAL),
POLAR_BEAR(ABSTRACT_ANIMAL),
RABBIT(ABSTRACT_ANIMAL),
SHEEP(ABSTRACT_ANIMAL),
BEE(ABSTRACT_ANIMAL),
TURTLE(ABSTRACT_ANIMAL),
FOX(ABSTRACT_ANIMAL),
FROG(ABSTRACT_ANIMAL),
GOAT(ABSTRACT_ANIMAL),
HOGLIN(ABSTRACT_ANIMAL),
STRIDER(ABSTRACT_ANIMAL),
SNIFFER(ABSTRACT_ANIMAL),
ARMADILLO(ABSTRACT_ANIMAL),
ABSTRACT_COW(ABSTRACT_ANIMAL, null),
COW(ABSTRACT_COW),
MOOSHROOM(ABSTRACT_COW),
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
CAT(TAMABLE_ANIMAL),
OCELOT(TAMABLE_ANIMAL),
WOLF(TAMABLE_ANIMAL),
PARROT(TAMABLE_ANIMAL),
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
HORSE(ABSTRACT_HORSE),
SKELETON_HORSE(ABSTRACT_HORSE),
ZOMBIE_HORSE(ABSTRACT_HORSE),
CAMEL(ABSTRACT_HORSE),
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
DONKEY(ABSTRACT_CHESTED_HORSE),
MULE(ABSTRACT_CHESTED_HORSE),
LLAMA(ABSTRACT_CHESTED_HORSE),
TRADER_LLAMA(LLAMA),
// Monsters
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
BLAZE(ABSTRACT_MONSTER),
CREEPER(ABSTRACT_MONSTER),
ENDERMITE(ABSTRACT_MONSTER),
ENDERMAN(ABSTRACT_MONSTER),
GIANT(ABSTRACT_MONSTER),
SILVERFISH(ABSTRACT_MONSTER),
VEX(ABSTRACT_MONSTER),
WITHER(ABSTRACT_MONSTER),
BREEZE(ABSTRACT_MONSTER),
ZOGLIN(ABSTRACT_MONSTER),
WARDEN(ABSTRACT_MONSTER),
CREAKING(ABSTRACT_MONSTER),
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
SKELETON(ABSTRACT_SKELETON),
STRAY(ABSTRACT_SKELETON),
WITHER_SKELETON(ABSTRACT_SKELETON),
BOGGED(ABSTRACT_SKELETON),
ZOMBIE(ABSTRACT_MONSTER),
DROWNED(ZOMBIE),
HUSK(ZOMBIE),
ZOMBIFIED_PIGLIN(ZOMBIE),
ZOMBIE_VILLAGER(ZOMBIE),
GUARDIAN(ABSTRACT_MONSTER),
ELDER_GUARDIAN(GUARDIAN),
SPIDER(ABSTRACT_MONSTER),
CAVE_SPIDER(SPIDER),
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
PIGLIN(ABSTRACT_PIGLIN),
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
// Water mobs
AGEABLE_WATER_CREATURE(ABSTRACT_AGEABLE, null),
DOLPHIN(AGEABLE_WATER_CREATURE),
SQUID(AGEABLE_WATER_CREATURE),
GLOW_SQUID(SQUID),
WATER_ANIMAL(PATHFINDER_MOB, null),
ABSTRACT_FISH(WATER_ANIMAL, null),
PUFFERFISH(ABSTRACT_FISH),
TADPOLE(ABSTRACT_FISH),
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
COD(ABSTRACT_SCHOOLING_FISH),
SALMON(ABSTRACT_SCHOOLING_FISH),
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
// Raiders
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
WITCH(ABSTRACT_RAIDER),
RAVAGER(ABSTRACT_RAIDER),
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
VINDICATOR(ABSTRACT_ILLAGER),
PILLAGER(ABSTRACT_ILLAGER),
EVOKER(SPELLCASTER_ILLAGER),
ILLUSIONER(SPELLCASTER_ILLAGER);
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
private final EntityType parent;
private final String identifier;
private int id = -1;
EntityTypes1_21_5(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_21_5(final EntityType parent, @Nullable final String identifier) {
this.parent = parent;
this.identifier = identifier;
}
@Override
public int getId() {
if (id == -1) {
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
}
return id;
}
@Override
public String identifier() {
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
return identifier;
}
@Override
public @Nullable EntityType getParent() {
return parent;
}
@Override
public boolean isAbstractType() {
return identifier == null;
}
public static EntityType getTypeFromId(final int typeId) {
return EntityTypeUtil.getTypeFromId(TYPES, typeId, PIG);
}
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id);
}
}
@@ -0,0 +1,318 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil;
import com.viaversion.viaversion.util.Key;
import java.util.Locale;
import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_21_6 implements EntityType {
ENTITY(null, null),
AREA_EFFECT_CLOUD(ENTITY),
END_CRYSTAL(ENTITY),
EVOKER_FANGS(ENTITY),
EXPERIENCE_ORB(ENTITY),
EYE_OF_ENDER(ENTITY),
FALLING_BLOCK(ENTITY),
ITEM(ENTITY),
TNT(ENTITY),
OMINOUS_ITEM_SPAWNER(ENTITY),
MARKER(ENTITY),
LIGHTNING_BOLT(ENTITY),
INTERACTION(ENTITY),
DISPLAY(ENTITY, null),
BLOCK_DISPLAY(DISPLAY),
ITEM_DISPLAY(DISPLAY),
TEXT_DISPLAY(DISPLAY),
// Hanging entities
HANGING_ENTITY(ENTITY, null),
LEASH_KNOT(HANGING_ENTITY),
PAINTING(HANGING_ENTITY),
ITEM_FRAME(HANGING_ENTITY),
GLOW_ITEM_FRAME(ITEM_FRAME),
// Projectiles
PROJECTILE(ENTITY, null),
ITEM_PROJECTILE(PROJECTILE, null),
SNOWBALL(ITEM_PROJECTILE),
ENDER_PEARL(ITEM_PROJECTILE),
EGG(ITEM_PROJECTILE),
EXPERIENCE_BOTTLE(ITEM_PROJECTILE),
FIREWORK_ROCKET(PROJECTILE),
LLAMA_SPIT(PROJECTILE),
SHULKER_BULLET(PROJECTILE),
FISHING_BOBBER(PROJECTILE),
WITHER_SKULL(PROJECTILE),
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
ABSTRACT_THROWN_POTION(ITEM_PROJECTILE, null),
SPLASH_POTION(ABSTRACT_THROWN_POTION),
LINGERING_POTION(ABSTRACT_THROWN_POTION),
ABSTRACT_ARROW(PROJECTILE, null),
ARROW(ABSTRACT_ARROW),
SPECTRAL_ARROW(ABSTRACT_ARROW),
TRIDENT(ABSTRACT_ARROW),
ABSTRACT_FIREBALL(ENTITY, null),
FIREBALL(ABSTRACT_FIREBALL),
SMALL_FIREBALL(ABSTRACT_FIREBALL),
ABSTRACT_WIND_CHARGE(PROJECTILE, null),
WIND_CHARGE(ABSTRACT_WIND_CHARGE),
BREEZE_WIND_CHARGE(ABSTRACT_WIND_CHARGE),
// Vehicles
VEHICLE(ENTITY, null),
ABSTRACT_MINECART(VEHICLE, null),
MINECART(ABSTRACT_MINECART),
FURNACE_MINECART(ABSTRACT_MINECART),
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
TNT_MINECART(ABSTRACT_MINECART),
SPAWNER_MINECART(ABSTRACT_MINECART),
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
ABSTRACT_BOAT(VEHICLE, null),
ABSTRACT_CHEST_BOAT(ABSTRACT_BOAT, null),
ACACIA_BOAT(ABSTRACT_BOAT),
ACACIA_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
BAMBOO_CHEST_RAFT(ABSTRACT_CHEST_BOAT),
BAMBOO_RAFT(ABSTRACT_BOAT),
BIRCH_BOAT(ABSTRACT_BOAT),
BIRCH_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
CHERRY_BOAT(ABSTRACT_BOAT),
CHERRY_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
DARK_OAK_BOAT(ABSTRACT_BOAT),
DARK_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
JUNGLE_BOAT(ABSTRACT_BOAT),
JUNGLE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
MANGROVE_BOAT(ABSTRACT_BOAT),
MANGROVE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
OAK_BOAT(ABSTRACT_BOAT),
OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
PALE_OAK_BOAT(ABSTRACT_BOAT),
PALE_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
SPRUCE_BOAT(ABSTRACT_BOAT),
SPRUCE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
// Living entities as a larger subclass
LIVING_ENTITY(ENTITY, null),
ARMOR_STAND(LIVING_ENTITY),
PLAYER(LIVING_ENTITY),
// Mobs as a larger subclass
MOB(LIVING_ENTITY, null),
ENDER_DRAGON(MOB),
SLIME(MOB),
MAGMA_CUBE(SLIME),
// Ambient mobs
AMBIENT_CREATURE(MOB, null),
BAT(AMBIENT_CREATURE),
// Flying mobs
FLYING_MOB(MOB, null),
GHAST(FLYING_MOB),
PHANTOM(FLYING_MOB),
// Pathfinder mobs and its subclasses
PATHFINDER_MOB(MOB, null),
ALLAY(PATHFINDER_MOB),
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
SNOW_GOLEM(ABSTRACT_GOLEM),
IRON_GOLEM(ABSTRACT_GOLEM),
SHULKER(ABSTRACT_GOLEM),
// Ageable mobs and (tamable) animals
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
VILLAGER(ABSTRACT_VILLAGER),
WANDERING_TRADER(ABSTRACT_VILLAGER),
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
AXOLOTL(ABSTRACT_ANIMAL),
CHICKEN(ABSTRACT_ANIMAL),
PANDA(ABSTRACT_ANIMAL),
PIG(ABSTRACT_ANIMAL),
POLAR_BEAR(ABSTRACT_ANIMAL),
RABBIT(ABSTRACT_ANIMAL),
SHEEP(ABSTRACT_ANIMAL),
BEE(ABSTRACT_ANIMAL),
TURTLE(ABSTRACT_ANIMAL),
FOX(ABSTRACT_ANIMAL),
FROG(ABSTRACT_ANIMAL),
GOAT(ABSTRACT_ANIMAL),
HOGLIN(ABSTRACT_ANIMAL),
STRIDER(ABSTRACT_ANIMAL),
SNIFFER(ABSTRACT_ANIMAL),
ARMADILLO(ABSTRACT_ANIMAL),
HAPPY_GHAST(ABSTRACT_ANIMAL),
ABSTRACT_COW(ABSTRACT_ANIMAL, null),
COW(ABSTRACT_COW),
MOOSHROOM(ABSTRACT_COW),
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
CAT(TAMABLE_ANIMAL),
OCELOT(TAMABLE_ANIMAL),
WOLF(TAMABLE_ANIMAL),
PARROT(TAMABLE_ANIMAL),
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
HORSE(ABSTRACT_HORSE),
SKELETON_HORSE(ABSTRACT_HORSE),
ZOMBIE_HORSE(ABSTRACT_HORSE),
CAMEL(ABSTRACT_HORSE),
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
DONKEY(ABSTRACT_CHESTED_HORSE),
MULE(ABSTRACT_CHESTED_HORSE),
LLAMA(ABSTRACT_CHESTED_HORSE),
TRADER_LLAMA(LLAMA),
// Monsters
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
BLAZE(ABSTRACT_MONSTER),
CREEPER(ABSTRACT_MONSTER),
ENDERMITE(ABSTRACT_MONSTER),
ENDERMAN(ABSTRACT_MONSTER),
GIANT(ABSTRACT_MONSTER),
SILVERFISH(ABSTRACT_MONSTER),
VEX(ABSTRACT_MONSTER),
WITHER(ABSTRACT_MONSTER),
BREEZE(ABSTRACT_MONSTER),
ZOGLIN(ABSTRACT_MONSTER),
WARDEN(ABSTRACT_MONSTER),
CREAKING(ABSTRACT_MONSTER),
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
SKELETON(ABSTRACT_SKELETON),
STRAY(ABSTRACT_SKELETON),
WITHER_SKELETON(ABSTRACT_SKELETON),
BOGGED(ABSTRACT_SKELETON),
ZOMBIE(ABSTRACT_MONSTER),
DROWNED(ZOMBIE),
HUSK(ZOMBIE),
ZOMBIFIED_PIGLIN(ZOMBIE),
ZOMBIE_VILLAGER(ZOMBIE),
GUARDIAN(ABSTRACT_MONSTER),
ELDER_GUARDIAN(GUARDIAN),
SPIDER(ABSTRACT_MONSTER),
CAVE_SPIDER(SPIDER),
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
PIGLIN(ABSTRACT_PIGLIN),
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
// Water mobs
AGEABLE_WATER_CREATURE(ABSTRACT_AGEABLE, null),
DOLPHIN(AGEABLE_WATER_CREATURE),
SQUID(AGEABLE_WATER_CREATURE),
GLOW_SQUID(SQUID),
WATER_ANIMAL(PATHFINDER_MOB, null),
ABSTRACT_FISH(WATER_ANIMAL, null),
PUFFERFISH(ABSTRACT_FISH),
TADPOLE(ABSTRACT_FISH),
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
COD(ABSTRACT_SCHOOLING_FISH),
SALMON(ABSTRACT_SCHOOLING_FISH),
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
// Raiders
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
WITCH(ABSTRACT_RAIDER),
RAVAGER(ABSTRACT_RAIDER),
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
VINDICATOR(ABSTRACT_ILLAGER),
PILLAGER(ABSTRACT_ILLAGER),
EVOKER(SPELLCASTER_ILLAGER),
ILLUSIONER(SPELLCASTER_ILLAGER);
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
private final EntityType parent;
private final String identifier;
private int id = -1;
EntityTypes1_21_6(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_21_6(final EntityType parent, @Nullable final String identifier) {
this.parent = parent;
this.identifier = identifier;
}
@Override
public int getId() {
if (id == -1) {
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
}
return id;
}
@Override
public String identifier() {
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
return identifier;
}
@Override
public @Nullable EntityType getParent() {
return parent;
}
@Override
public boolean isAbstractType() {
return identifier == null;
}
public static EntityType getTypeFromId(final int typeId) {
return EntityTypeUtil.getTypeFromId(TYPES, typeId, PIG);
}
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id);
}
}
@@ -0,0 +1,323 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entities;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.util.EntityTypeUtil;
import com.viaversion.viaversion.util.Key;
import java.util.Locale;
import org.checkerframework.checker.nullness.qual.Nullable;
public enum EntityTypes1_21_9 implements EntityType {
ENTITY(null, null),
AREA_EFFECT_CLOUD(ENTITY),
END_CRYSTAL(ENTITY),
EVOKER_FANGS(ENTITY),
EXPERIENCE_ORB(ENTITY),
EYE_OF_ENDER(ENTITY),
FALLING_BLOCK(ENTITY),
ITEM(ENTITY),
TNT(ENTITY),
OMINOUS_ITEM_SPAWNER(ENTITY),
MARKER(ENTITY),
LIGHTNING_BOLT(ENTITY),
INTERACTION(ENTITY),
DISPLAY(ENTITY, null),
BLOCK_DISPLAY(DISPLAY),
ITEM_DISPLAY(DISPLAY),
TEXT_DISPLAY(DISPLAY),
// Hanging entities
HANGING_ENTITY(ENTITY, null),
LEASH_KNOT(HANGING_ENTITY),
PAINTING(HANGING_ENTITY),
ITEM_FRAME(HANGING_ENTITY),
GLOW_ITEM_FRAME(ITEM_FRAME),
// Projectiles
PROJECTILE(ENTITY, null),
ITEM_PROJECTILE(PROJECTILE, null),
SNOWBALL(ITEM_PROJECTILE),
ENDER_PEARL(ITEM_PROJECTILE),
EGG(ITEM_PROJECTILE),
EXPERIENCE_BOTTLE(ITEM_PROJECTILE),
FIREWORK_ROCKET(PROJECTILE),
LLAMA_SPIT(PROJECTILE),
SHULKER_BULLET(PROJECTILE),
FISHING_BOBBER(PROJECTILE),
WITHER_SKULL(PROJECTILE),
DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball
ABSTRACT_THROWN_POTION(ITEM_PROJECTILE, null),
SPLASH_POTION(ABSTRACT_THROWN_POTION),
LINGERING_POTION(ABSTRACT_THROWN_POTION),
ABSTRACT_ARROW(PROJECTILE, null),
ARROW(ABSTRACT_ARROW),
SPECTRAL_ARROW(ABSTRACT_ARROW),
TRIDENT(ABSTRACT_ARROW),
ABSTRACT_FIREBALL(ENTITY, null),
FIREBALL(ABSTRACT_FIREBALL),
SMALL_FIREBALL(ABSTRACT_FIREBALL),
ABSTRACT_WIND_CHARGE(PROJECTILE, null),
WIND_CHARGE(ABSTRACT_WIND_CHARGE),
BREEZE_WIND_CHARGE(ABSTRACT_WIND_CHARGE),
// Vehicles
VEHICLE(ENTITY, null),
ABSTRACT_MINECART(VEHICLE, null),
MINECART(ABSTRACT_MINECART),
FURNACE_MINECART(ABSTRACT_MINECART),
COMMAND_BLOCK_MINECART(ABSTRACT_MINECART),
TNT_MINECART(ABSTRACT_MINECART),
SPAWNER_MINECART(ABSTRACT_MINECART),
ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null),
CHEST_MINECART(ABSTRACT_MINECART_CONTAINER),
HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER),
ABSTRACT_BOAT(VEHICLE, null),
ABSTRACT_CHEST_BOAT(ABSTRACT_BOAT, null),
ACACIA_BOAT(ABSTRACT_BOAT),
ACACIA_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
BAMBOO_CHEST_RAFT(ABSTRACT_CHEST_BOAT),
BAMBOO_RAFT(ABSTRACT_BOAT),
BIRCH_BOAT(ABSTRACT_BOAT),
BIRCH_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
CHERRY_BOAT(ABSTRACT_BOAT),
CHERRY_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
DARK_OAK_BOAT(ABSTRACT_BOAT),
DARK_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
JUNGLE_BOAT(ABSTRACT_BOAT),
JUNGLE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
MANGROVE_BOAT(ABSTRACT_BOAT),
MANGROVE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
OAK_BOAT(ABSTRACT_BOAT),
OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
PALE_OAK_BOAT(ABSTRACT_BOAT),
PALE_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
SPRUCE_BOAT(ABSTRACT_BOAT),
SPRUCE_CHEST_BOAT(ABSTRACT_CHEST_BOAT),
// Living entities as a larger subclass
LIVING_ENTITY(ENTITY, null),
ARMOR_STAND(LIVING_ENTITY),
// Players
AVATAR(LIVING_ENTITY, null),
MANNEQUIN(AVATAR),
PLAYER(AVATAR),
// Mobs as a larger subclass
MOB(LIVING_ENTITY, null),
ENDER_DRAGON(MOB),
SLIME(MOB),
MAGMA_CUBE(SLIME),
// Ambient mobs
AMBIENT_CREATURE(MOB, null),
BAT(AMBIENT_CREATURE),
// Flying mobs
FLYING_MOB(MOB, null),
GHAST(FLYING_MOB),
PHANTOM(FLYING_MOB),
// Pathfinder mobs and its subclasses
PATHFINDER_MOB(MOB, null),
ALLAY(PATHFINDER_MOB),
ABSTRACT_GOLEM(PATHFINDER_MOB, null),
SNOW_GOLEM(ABSTRACT_GOLEM),
IRON_GOLEM(ABSTRACT_GOLEM),
SHULKER(ABSTRACT_GOLEM),
COPPER_GOLEM(ABSTRACT_GOLEM),
// Ageable mobs and (tamable) animals
ABSTRACT_AGEABLE(PATHFINDER_MOB, null),
ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null),
VILLAGER(ABSTRACT_VILLAGER),
WANDERING_TRADER(ABSTRACT_VILLAGER),
ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null),
AXOLOTL(ABSTRACT_ANIMAL),
CHICKEN(ABSTRACT_ANIMAL),
PANDA(ABSTRACT_ANIMAL),
PIG(ABSTRACT_ANIMAL),
POLAR_BEAR(ABSTRACT_ANIMAL),
RABBIT(ABSTRACT_ANIMAL),
SHEEP(ABSTRACT_ANIMAL),
BEE(ABSTRACT_ANIMAL),
TURTLE(ABSTRACT_ANIMAL),
FOX(ABSTRACT_ANIMAL),
FROG(ABSTRACT_ANIMAL),
GOAT(ABSTRACT_ANIMAL),
HOGLIN(ABSTRACT_ANIMAL),
STRIDER(ABSTRACT_ANIMAL),
SNIFFER(ABSTRACT_ANIMAL),
ARMADILLO(ABSTRACT_ANIMAL),
HAPPY_GHAST(ABSTRACT_ANIMAL),
ABSTRACT_COW(ABSTRACT_ANIMAL, null),
COW(ABSTRACT_COW),
MOOSHROOM(ABSTRACT_COW),
TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null),
CAT(TAMABLE_ANIMAL),
OCELOT(TAMABLE_ANIMAL),
WOLF(TAMABLE_ANIMAL),
PARROT(TAMABLE_ANIMAL),
ABSTRACT_HORSE(ABSTRACT_ANIMAL, null),
HORSE(ABSTRACT_HORSE),
SKELETON_HORSE(ABSTRACT_HORSE),
ZOMBIE_HORSE(ABSTRACT_HORSE),
CAMEL(ABSTRACT_HORSE),
ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null),
DONKEY(ABSTRACT_CHESTED_HORSE),
MULE(ABSTRACT_CHESTED_HORSE),
LLAMA(ABSTRACT_CHESTED_HORSE),
TRADER_LLAMA(LLAMA),
// Monsters
ABSTRACT_MONSTER(PATHFINDER_MOB, null),
BLAZE(ABSTRACT_MONSTER),
CREEPER(ABSTRACT_MONSTER),
ENDERMITE(ABSTRACT_MONSTER),
ENDERMAN(ABSTRACT_MONSTER),
GIANT(ABSTRACT_MONSTER),
SILVERFISH(ABSTRACT_MONSTER),
VEX(ABSTRACT_MONSTER),
WITHER(ABSTRACT_MONSTER),
BREEZE(ABSTRACT_MONSTER),
ZOGLIN(ABSTRACT_MONSTER),
WARDEN(ABSTRACT_MONSTER),
CREAKING(ABSTRACT_MONSTER),
ABSTRACT_SKELETON(ABSTRACT_MONSTER, null),
SKELETON(ABSTRACT_SKELETON),
STRAY(ABSTRACT_SKELETON),
WITHER_SKELETON(ABSTRACT_SKELETON),
BOGGED(ABSTRACT_SKELETON),
ZOMBIE(ABSTRACT_MONSTER),
DROWNED(ZOMBIE),
HUSK(ZOMBIE),
ZOMBIFIED_PIGLIN(ZOMBIE),
ZOMBIE_VILLAGER(ZOMBIE),
GUARDIAN(ABSTRACT_MONSTER),
ELDER_GUARDIAN(GUARDIAN),
SPIDER(ABSTRACT_MONSTER),
CAVE_SPIDER(SPIDER),
ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null),
PIGLIN(ABSTRACT_PIGLIN),
PIGLIN_BRUTE(ABSTRACT_PIGLIN),
// Water mobs
AGEABLE_WATER_CREATURE(ABSTRACT_AGEABLE, null),
DOLPHIN(AGEABLE_WATER_CREATURE),
SQUID(AGEABLE_WATER_CREATURE),
GLOW_SQUID(SQUID),
WATER_ANIMAL(PATHFINDER_MOB, null),
ABSTRACT_FISH(WATER_ANIMAL, null),
PUFFERFISH(ABSTRACT_FISH),
TADPOLE(ABSTRACT_FISH),
ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null),
COD(ABSTRACT_SCHOOLING_FISH),
SALMON(ABSTRACT_SCHOOLING_FISH),
TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH),
// Raiders
ABSTRACT_RAIDER(ABSTRACT_MONSTER, null),
WITCH(ABSTRACT_RAIDER),
RAVAGER(ABSTRACT_RAIDER),
ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null),
SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null),
VINDICATOR(ABSTRACT_ILLAGER),
PILLAGER(ABSTRACT_ILLAGER),
EVOKER(SPELLCASTER_ILLAGER),
ILLUSIONER(SPELLCASTER_ILLAGER);
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
private final EntityType parent;
private final String identifier;
private int id = -1;
EntityTypes1_21_9(final EntityType parent) {
this.parent = parent;
this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT));
}
EntityTypes1_21_9(final EntityType parent, @Nullable final String identifier) {
this.parent = parent;
this.identifier = identifier;
}
@Override
public int getId() {
if (id == -1) {
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
}
return id;
}
@Override
public String identifier() {
Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type");
return identifier;
}
@Override
public @Nullable EntityType getParent() {
return parent;
}
@Override
public boolean isAbstractType() {
return identifier == null;
}
public static EntityType getTypeFromId(final int typeId) {
return EntityTypeUtil.getTypeFromId(TYPES, typeId, PIG);
}
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id);
}
}
@@ -22,22 +22,11 @@
*/
package com.viaversion.viaversion.api.minecraft.entities;
import java.util.HashMap;
import java.util.Map;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class EntityTypes1_8 {
public static EntityType getTypeFromId(final int typeId, final boolean object) {
EntityType type;
if (object) {
type = ObjectType.getEntityType(typeId);
} else {
type = EntityType.findById(typeId);
}
return type;
}
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
ENTITY,
@@ -146,7 +135,7 @@ public class EntityTypes1_8 {
SPIDER(52, ABSTRACT_MONSTER),
CAVE_SPIDER(59, SPIDER);
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
private static final Int2ObjectMap<EntityType> TYPES;
private final int id;
private final EntityType parent;
@@ -187,7 +176,9 @@ public class EntityTypes1_8 {
}
static {
for (EntityType type : EntityType.values()) {
final EntityType[] values = EntityType.values();
TYPES = new Int2ObjectOpenHashMap<>(values.length);
for (EntityType type : values) {
TYPES.put(type.id, type);
}
}
@@ -203,7 +194,13 @@ public class EntityTypes1_8 {
public enum ObjectType implements com.viaversion.viaversion.api.minecraft.entities.ObjectType {
BOAT(1, EntityType.BOAT),
ITEM(2, EntityType.ITEM),
MINECART(10, EntityType.MINECART), // There are multiple types, but we don't need them
MINECART(10, EntityType.MINECART),
CHEST_MINECART(10, 1, EntityType.CHEST_MINECART),
FURNACE_MINECART(10, 2, EntityType.FURNACE_MINECART),
TNT_MINECART(10, 3, EntityType.TNT_MINECART),
SPAWNER_MINECART(10, 4, EntityType.SPAWNER_MINECART),
HOPPER_MINECART(10, 5, EntityType.HOPPER_MINECART),
COMMAND_BLOCK_MINECART(10, 6, EntityType.COMMAND_BLOCK_MINECART),
TNT_PRIMED(50, EntityType.TNT),
ENDER_CRYSTAL(51, EntityType.END_CRYSTAL),
TIPPED_ARROW(60, EntityType.ARROW),
@@ -223,19 +220,25 @@ public class EntityTypes1_8 {
ARMOR_STAND(78, EntityType.ARMOR_STAND),
FISHIHNG_HOOK(90, EntityType.FISHING_HOOK);
private static final Map<Integer, ObjectType> TYPES = new HashMap<>();
private static final Int2ObjectMap<Int2ObjectMap<ObjectType>> TYPES = new Int2ObjectOpenHashMap<>();
private final int id;
private final int data;
private final EntityType type;
static {
for (ObjectType type : ObjectType.values()) {
TYPES.put(type.id, type);
TYPES.computeIfAbsent(type.id, k -> new Int2ObjectOpenHashMap<>()).put(type.data, type);
}
}
ObjectType(int id, EntityType type) {
this(id, 0, type);
}
ObjectType(int id, int data, EntityType type) {
this.id = id;
this.data = data;
this.type = type;
}
@@ -244,20 +247,28 @@ public class EntityTypes1_8 {
return id;
}
@Override
public int getData() {
return data;
}
@Override
public EntityType getType() {
return type;
}
public static ObjectType findById(final int id) {
if (id == -1) {
public static ObjectType findById(final int id, final int data) {
final Int2ObjectMap<ObjectType> types = TYPES.get(id);
if (types == null) {
return null;
}
return TYPES.get(id);
final ObjectType type = types.get(data);
return type != null ? type : types.get(0);
}
public static EntityType getEntityType(final int id) {
final ObjectType objectType = findById(id);
public static EntityType getEntityType(final int id, final int data) {
final ObjectType objectType = findById(id, data);
return objectType != null ? objectType.type : null;
}
}
@@ -22,22 +22,11 @@
*/
package com.viaversion.viaversion.api.minecraft.entities;
import java.util.HashMap;
import java.util.Map;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class EntityTypes1_9 {
public static EntityType getTypeFromId(final int typeId, final boolean object) {
EntityType type;
if (object) {
type = ObjectType.getEntityType(typeId);
} else {
type = EntityType.findById(typeId);
}
return type;
}
public enum EntityType implements com.viaversion.viaversion.api.minecraft.entities.EntityType {
ENTITY,
@@ -153,7 +142,7 @@ public class EntityTypes1_9 {
SPIDER(52, ABSTRACT_MONSTER),
CAVE_SPIDER(59, SPIDER);
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
private static final Int2ObjectMap<EntityType> TYPES;
private final int id;
private final EntityType parent;
@@ -194,7 +183,9 @@ public class EntityTypes1_9 {
}
static {
for (EntityType type : EntityType.values()) {
final EntityType[] values = EntityType.values();
TYPES = new Int2ObjectOpenHashMap<>(values.length);
for (EntityType type : values) {
TYPES.put(type.id, type);
}
}
@@ -211,7 +202,13 @@ public class EntityTypes1_9 {
BOAT(1, EntityType.BOAT),
ITEM(2, EntityType.ITEM),
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
MINECART(10, EntityType.MINECART), // There are multiple types, but we don't need them
MINECART(10, EntityType.MINECART),
CHEST_MINECART(10, 1, EntityType.CHEST_MINECART),
FURNACE_MINECART(10, 2, EntityType.FURNACE_MINECART),
TNT_MINECART(10, 3, EntityType.TNT_MINECART),
SPAWNER_MINECART(10, 4, EntityType.SPAWNER_MINECART),
HOPPER_MINECART(10, 5, EntityType.HOPPER_MINECART),
COMMAND_BLOCK_MINECART(10, 6, EntityType.COMMAND_BLOCK_MINECART),
TNT_PRIMED(50, EntityType.TNT),
ENDER_CRYSTAL(51, EntityType.END_CRYSTAL),
TIPPED_ARROW(60, EntityType.ARROW),
@@ -234,19 +231,25 @@ public class EntityTypes1_9 {
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
private static final Map<Integer, ObjectType> TYPES = new HashMap<>();
private static final Int2ObjectMap<Int2ObjectMap<ObjectType>> TYPES = new Int2ObjectOpenHashMap<>();
private final int id;
private final int data;
private final EntityType type;
static {
for (ObjectType type : ObjectType.values()) {
TYPES.put(type.id, type);
TYPES.computeIfAbsent(type.id, k -> new Int2ObjectOpenHashMap<>()).put(type.data, type);
}
}
ObjectType(int id, EntityType type) {
this(id, 0, type);
}
ObjectType(int id, int data, EntityType type) {
this.id = id;
this.data = data;
this.type = type;
}
@@ -255,20 +258,28 @@ public class EntityTypes1_9 {
return id;
}
@Override
public int getData() {
return data;
}
@Override
public EntityType getType() {
return type;
}
public static ObjectType findById(final int id) {
if (id == -1) {
public static ObjectType findById(final int id, final int data) {
final Int2ObjectMap<ObjectType> types = TYPES.get(id);
if (types == null) {
return null;
}
return TYPES.get(id);
final ObjectType type = types.get(data);
return type != null ? type : types.get(0);
}
public static EntityType getEntityType(final int id) {
final ObjectType objectType = findById(id);
public static EntityType getEntityType(final int id, final int data) {
final ObjectType objectType = findById(id, data);
return objectType != null ? objectType.type : null;
}
}
@@ -29,5 +29,7 @@ public interface ObjectType {
int getId();
int getData();
EntityType getType();
}
@@ -44,6 +44,10 @@ public abstract class AbstractEntityDataTypes implements EntityDataTypes {
}
protected EntityDataType add(final int typeId, final Type<?> type) {
if (values[typeId] != null) {
throw new IllegalArgumentException("Entity data type ID " + typeId + " is already registered as " + values[typeId]);
}
final EntityDataType dataType = EntityDataType.create(typeId, type);
values[typeId] = dataType;
return dataType;
@@ -44,7 +44,7 @@ public final class EntityDataTypes1_14 extends AbstractEntityDataTypes {
public final EntityDataType optionalBlockStateType = add(13, Types.VAR_INT);
public final EntityDataType compoundTagType = add(14, Types.NAMED_COMPOUND_TAG);
public final EntityDataType particleType;
public final EntityDataType villagerDatatType = add(16, Types.VILLAGER_DATA);
public final EntityDataType villagerDataType = add(16, Types.VILLAGER_DATA);
public final EntityDataType optionalVarIntType = add(17, Types.OPTIONAL_VAR_INT);
public final EntityDataType poseType = add(18, Types.VAR_INT);
@@ -44,7 +44,7 @@ public final class EntityDataTypes1_19 extends AbstractEntityDataTypes {
public final EntityDataType optionalBlockStateType = add(13, Types.VAR_INT);
public final EntityDataType compoundTagType = add(14, Types.NAMED_COMPOUND_TAG);
public final EntityDataType particleType;
public final EntityDataType villagerDatatType = add(16, Types.VILLAGER_DATA);
public final EntityDataType villagerDataType = add(16, Types.VILLAGER_DATA);
public final EntityDataType optionalVarIntType = add(17, Types.OPTIONAL_VAR_INT);
public final EntityDataType poseType = add(18, Types.VAR_INT);
public final EntityDataType catVariantType = add(19, Types.VAR_INT);
@@ -45,7 +45,7 @@ public final class EntityDataTypes1_19_3 extends AbstractEntityDataTypes {
public final EntityDataType optionalBlockStateType = add(14, Types.VAR_INT);
public final EntityDataType compoundTagType = add(15, Types.NAMED_COMPOUND_TAG);
public final EntityDataType particleType;
public final EntityDataType villagerDatatType = add(17, Types.VILLAGER_DATA);
public final EntityDataType villagerDataType = add(17, Types.VILLAGER_DATA);
public final EntityDataType optionalVarIntType = add(18, Types.OPTIONAL_VAR_INT);
public final EntityDataType poseType = add(19, Types.VAR_INT);
public final EntityDataType catVariantType = add(20, Types.VAR_INT);
@@ -46,7 +46,7 @@ public final class EntityDataTypes1_19_4 extends AbstractEntityDataTypes {
public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT);
public final EntityDataType compoundTagType = add(16, Types.NAMED_COMPOUND_TAG);
public final EntityDataType particleType;
public final EntityDataType villagerDatatType = add(18, Types.VILLAGER_DATA);
public final EntityDataType villagerDataType = add(18, Types.VILLAGER_DATA);
public final EntityDataType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT);
public final EntityDataType poseType = add(20, Types.VAR_INT);
public final EntityDataType catVariantType = add(21, Types.VAR_INT);
@@ -46,7 +46,7 @@ public final class EntityDataTypes1_20_2 extends AbstractEntityDataTypes {
public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT);
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
public final EntityDataType particleType;
public final EntityDataType villagerDatatType = add(18, Types.VILLAGER_DATA);
public final EntityDataType villagerDataType = add(18, Types.VILLAGER_DATA);
public final EntityDataType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT);
public final EntityDataType poseType = add(20, Types.VAR_INT);
public final EntityDataType catVariantType = add(21, Types.VAR_INT);
@@ -46,7 +46,7 @@ public final class EntityDataTypes1_20_3 extends AbstractEntityDataTypes {
public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT);
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
public final EntityDataType particleType;
public final EntityDataType villagerDatatType = add(18, Types.VILLAGER_DATA);
public final EntityDataType villagerDataType = add(18, Types.VILLAGER_DATA);
public final EntityDataType optionalVarIntType = add(19, Types.OPTIONAL_VAR_INT);
public final EntityDataType poseType = add(20, Types.VAR_INT);
public final EntityDataType catVariantType = add(21, Types.VAR_INT);
@@ -22,12 +22,9 @@
*/
package com.viaversion.viaversion.api.minecraft.entitydata.types;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.ArrayType;
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
public final class EntityDataTypes1_20_5 extends AbstractEntityDataTypes {
@@ -38,7 +35,7 @@ public final class EntityDataTypes1_20_5 extends AbstractEntityDataTypes {
public final EntityDataType stringType = add(4, Types.STRING);
public final EntityDataType componentType = add(5, Types.TAG);
public final EntityDataType optionalComponentType = add(6, Types.OPTIONAL_TAG);
public final EntityDataType itemType = add(7, Types1_20_5.ITEM);
public final EntityDataType itemType;
public final EntityDataType booleanType = add(8, Types.BOOLEAN);
public final EntityDataType rotationsType = add(9, Types.ROTATIONS);
public final EntityDataType blockPositionType = add(10, Types.BLOCK_POSITION1_14);
@@ -50,7 +47,7 @@ public final class EntityDataTypes1_20_5 extends AbstractEntityDataTypes {
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
public final EntityDataType particleType;
public final EntityDataType particlesType;
public final EntityDataType villagerDatatType = add(19, Types.VILLAGER_DATA);
public final EntityDataType villagerDataType = add(19, Types.VILLAGER_DATA);
public final EntityDataType optionalVarIntType = add(20, Types.OPTIONAL_VAR_INT);
public final EntityDataType poseType = add(21, Types.VAR_INT);
public final EntityDataType catVariantType = add(22, Types.VAR_INT);
@@ -63,9 +60,10 @@ public final class EntityDataTypes1_20_5 extends AbstractEntityDataTypes {
public final EntityDataType vector3FType = add(29, Types.VECTOR3F);
public final EntityDataType quaternionType = add(30, Types.QUATERNION);
public EntityDataTypes1_20_5(final ParticleType particleType, final ArrayType<Particle> particlesType) {
public EntityDataTypes1_20_5(final VersionedTypesHolder types) {
super(31);
this.particleType = add(17, particleType);
this.particlesType = add(18, particlesType);
this.itemType = add(7, types.item());
this.particleType = add(17, types.particle());
this.particlesType = add(18, types.particles());
}
}
@@ -23,14 +23,10 @@
package com.viaversion.viaversion.api.minecraft.entitydata.types;
import com.viaversion.viaversion.api.minecraft.PaintingVariant;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.WolfVariant;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
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.api.type.types.ArrayType;
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
public final class EntityDataTypes1_21 extends AbstractEntityDataTypes {
@@ -53,7 +49,7 @@ public final class EntityDataTypes1_21 extends AbstractEntityDataTypes {
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
public final EntityDataType particleType;
public final EntityDataType particlesType;
public final EntityDataType villagerDatatType = add(19, Types.VILLAGER_DATA);
public final EntityDataType villagerDataType = add(19, Types.VILLAGER_DATA);
public final EntityDataType optionalVarIntType = add(20, Types.OPTIONAL_VAR_INT);
public final EntityDataType poseType = add(21, Types.VAR_INT);
public final EntityDataType catVariantType = add(22, Types.VAR_INT);
@@ -66,10 +62,10 @@ public final class EntityDataTypes1_21 extends AbstractEntityDataTypes {
public final EntityDataType vector3FType = add(29, Types.VECTOR3F);
public final EntityDataType quaternionType = add(30, Types.QUATERNION);
public EntityDataTypes1_21(final Type<Item> itemType, final ParticleType particleType, final ArrayType<Particle> particlesType) {
public EntityDataTypes1_21(final VersionedTypesHolder types) {
super(31);
this.itemType = add(7, itemType);
this.particleType = add(17, particleType);
this.particlesType = add(18, particlesType);
this.itemType = add(7, types.item());
this.particleType = add(17, types.particle());
this.particlesType = add(18, types.particles());
}
}
Loaded 100 of 569 files, more files were not shown because too many files have changed in this diff. Show more