Commit Graph

35 Commits

Author SHA1 Message Date
Nassim Jahnke 9dd3348510
Move appendClientbound/Serverbound methods to Protocol interface 2024-04-24 20:11:05 +02:00
Nassim Jahnke a99273db2e
Always call onMappingDataLoaded in TagRewriter
In case they are needed in the future, so that we don't also have to check whether the different methods are actually called
2024-04-18 16:12:57 +02:00
Nassim Jahnke 56b82b049a
Move a few methods out of AbstractProtocol 2024-02-27 17:21:27 +01:00
Nassim Jahnke 1dafa7d273
Cleanup config packet registration in newer protocols 2024-01-26 15:48:10 +01:00
Nassim Jahnke ce8fab7c44
Cleanup config packet registering in AbstractProtocol 2024-01-26 14:35:19 +01:00
Nassim Jahnke 5d5c98acc6
24w03a (maybe, and it's a bit ugly) 2024-01-17 22:55:16 +01:00
Nassim Jahnke ef78fcd478
Update API license headers and scope 2024-01-12 10:21:45 +01:00
Nassim Jahnke e7d0b01eee
23w42a 2023-10-19 10:53:14 +10:00
Nassim Jahnke cb1b33b3e7
Start working on 23w40a 2023-10-05 18:22:13 +10:00
Nassim Jahnke 854696abff
Add separate client and server protocol state 2023-09-25 16:44:41 +10:00
Nassim Jahnke 9c92ccea77 Finish up state switching 2023-08-06 15:40:15 +10:00
Nassim Jahnke 6586fc1436 More work on the snapshot 2023-08-03 18:36:30 +10:00
Nassim Jahnke 5cad29c754
Expose PacketTypesProvider in Protocol 2023-02-24 10:07:25 +01:00
Nassim Jahnke 3e2ee37829
Allow custom PacketMappings implementation in AbstractProtocol 2023-02-22 16:54:54 +01:00
Nassim Jahnke 7b5cb92982
Small refactor 2023-02-20 13:19:03 +01:00
Nassim Jahnke 45fcc9ef7d
Rename Protocol generics to be clearer 2023-02-12 21:14:10 +01:00
Nassim Jahnke f5ddc6550d
Optimize/improve Protocol packet mapping
Also makes it possible to work with packet types of different states in a Protocol
2023-02-12 17:27:36 +01:00
Nassim Jahnke cb2165eb93
Greatly reduce the number of (anonymous) inner classes
Reduces code complexity, and much more importantly, reduces the number of classes loaded at runtime by *hundreds*
2023-02-12 11:46:48 +01:00
Nassim Jahnke de5b7bf828
Allow registration of simple packet handlers over extending an abstract class 2023-02-12 10:54:47 +01:00
Nassim Jahnke 088f654159
Remove some deprecated api usage, small cleanup 2023-02-04 19:42:26 +01:00
Nassim Jahnke 4fb95581ce
Update copyright headers 2023-01-12 12:45:53 +01:00
Nassim Jahnke 4067107b52
Improve exception handling 2023-01-06 20:51:21 +01:00
Nassim Jahnke 90feac8c83
Update DebugHandler 2022-05-20 14:10:23 +02:00
Nassim Jahnke d5a568b3fc
Update copyright header 2022-01-09 22:36:07 +01:00
Nassim Jahnke dbe8b6551a
Readd flare
Issues were addressed in 2.0.0
2021-10-19 09:10:17 +02:00
Nassim Jahnke 68e4146f3b
Deprecate cancelClientbound/Serverbound with new id parameter 2021-09-05 14:02:33 +02:00
kennytv 2094397bca
Allow bypassing of packet type restriction in Protocol, amend packet creator 2021-08-01 12:05:04 +02:00
kennytv b81109f512
Semi force packet types in PacketWrapper at creation and transformation 2021-07-31 15:08:45 +02:00
KennyTV 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 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
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
KennyTV 8bcd8fd995
Add apiVersion to ViaAPI, some jd 2021-05-22 19:39:26 +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 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 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