Commit Graph

1529 Commits

Author SHA1 Message Date
KennyTV
2b8c5082ed
Make Item an interface, more OOP for the ItemRewriter 2021-06-04 12:15:14 +02:00
KennyTV
fc1450fe38
Slightly more OOP, move registerPackets out of Protocol constructor
registerPackets being called within the constructor made it impossible to create instance objects then used in registerPackets (vs. having to then create the objects in registerPackets).
2021-06-03 17:28:02 +02:00
KennyTV
b2855c2cd4
F 2021-06-02 23:22:09 +02:00
KennyTV
fec777b349
Don't wrap direct type mappers 2021-06-02 23:22:00 +02:00
KennyTV
7b1f9c199a
Produce less overhead in packet handler registering
Instead of creating a void type reader for every single PacketHandler registered, this just directly uses the consumer-like PacketHandler.

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

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

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

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

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

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

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

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

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

* Bump setup-java action to v2, specify AdoptOpenJDK distribution
2021-04-14 14:16:48 +02:00
KennyTV
c7e5b4a297
Update to Gradle 7.0 2021-04-13 12:37:29 +02:00
LabyStudio
76e739e4f0
fix ghost shield issue and delayed interaction when switching to another item (#2432) 2021-04-12 16:56:53 +02:00
KennyTV
0ee80dc41f
Don't throw an exception on hover parse failure 2021-04-11 13:35:53 +02:00
KennyTV
4473f863c6
Update ComponentRewriter 2021-04-10 17:03:43 +02:00
creeper123123321
9f380a7598
Handle minecart block data (#2424) 2021-04-09 17:09:30 +02:00
KennyTV
3c7d481a39
Fix namespaced 1.12->1.13 sound conversion 2021-04-09 14:56:44 +02:00
KennyTV
00b8289c61
Handle new entity pose from 21w13a 2021-04-07 17:27:51 +02:00
KennyTV
e9fa5b49ca
21w14a 2021-04-07 16:55:22 +02:00
LabyStudio
e83686d6fc
Implement showShieldWhenSwordInHand option (#2417) 2021-04-05 18:53:57 +02:00
KennyTV
26bbc92f94
Warn about potentially unstable plugins/server software 2021-04-03 17:01:57 +02:00
KennyTV
1251d43709
Fix invalid enchantment parsing
Fixes #2418
2021-04-02 18:22:18 +02:00
KennyTV
070c7f5808
Move to checker qual nullability annotations 2021-04-02 14:15:30 +02:00
KennyTV
d79bd00f58
Minor log changes 2021-04-02 10:21:31 +02:00
R0bbyYT
956492bca6
Add option to fix delayed shield blocking (#2415) 2021-04-01 20:03:13 +02:00
KennyTV
ab376dc562
21w13a 2021-03-31 19:18:16 +02:00
KennyTV
fd9442b077
Minor jd changes in ViaAPI, fix typo 2021-03-30 22:10:57 +02:00
KennyTV
a63f2ab6fe
Improve server version API 2021-03-26 12:51:38 +01:00
KennyTV
d918fd27b6
Reduce boxing in protocol path getting
More of its implementation should probably be cleaned up later
2021-03-25 22:34:30 +01:00
KennyTV
63356207a3
ProtocolRegistry -> ProtocolManager interface 2021-03-24 15:30:03 +01:00
KennyTV
0ab2c626aa
Split parts of common into api; We are now GPL, api is MIT
This does not affect any previous states of this project; only future modifications as well as the project as a whole will be under the GNU General Public License from now on. The newly introduced api directory, partly split from common, is an exception to this, still being licensed under the MIT license.

See the README for details.
2021-03-24 14:02:37 +01:00
KennyTV
bfcfb4340e
Add missing doc 2021-03-22 13:47:40 +01:00