* Provide a RegistryByteBuf for attachment syncing
* None breaking?
* Slight improvement
* Test syncing an item stack
* Jdoc fix
* Jdoc fix
(cherry picked from commit 9aea556b88)
(cherry picked from commit dbad41f1cb)
Completes the data attachment API with client-server syncing capabilities.
## Motivation
The existing API works great for attaching data to game objects, be they serverside or clientside, but lacks any ability to synchronize between the two.
A mod that wants to add a "thirst" mechanic can easily do so on the server side by attaching an integer to every player. However, the mod may also want to use this information to render additional HUD elements on the client. Currently, informing the client of this data can only be done manually, which is cumbersome, error-prone, and is much better-suited as an API feature.
## API Changes
The API doesn't change a lot (at least compared to the implementation), with a few new methods and one new class.
One new method has been added to `AttachmentRegistry.Builder`, namely `syncWith`. It declares that an attachment type may be synchronized with some clients, and takes a `PacketCodec` to encode attachment data over the network, as well as an element of the new `AttachmentSyncPredicate` interface.
This interface extends `BiPredicate<AttachmentTarget, ServerPlayerEntity>` to allow for user-defined predicates, and provides some common presets:
* `all()`: attachment data will be synchronized with all clients (that track the target).
* `targetOnly()`: attachment data will only be synchronized with the target it is attached to, when it is a player. If the target is not a player, it won't be synchronized with any client.
* `allButTarget()`: reverse of the above. For non-player targets, attachment data will be synchronized with all clients.
**NOTE**: for a user-defined condition, whether attachment data is synchronized with a client can change at runtime (e.g. "sync only with operators" when a player changes operator status). A specialized method to "refresh" data was considered, but in the end discarded due to complexity. It falls to individual mods to handle these edge cases.
AttachmentType also gets one new `isSynced` method to know whether a given attachment type can be synced.
## Usage
Here is how one could register an attachment for a "thirst" meter like mentioned above.
```java
public static final AttachmentType<Integer> THIRST = AttachmentRegistry.<Integer>builder()
.initializer(() -> 20) // start with a default value like hunger
.persistent(Codec.INT) // persist across restarts
.syncWith(PacketCodecs.VAR_INT.cast(), AttachmentSyncPredicate.targetOnly()) // only the player's own client needs the value for rendering
.buildAndRegister(Identifier.of("modid", "thirst"));
```
* Add a new chunk generate event, fired alongside the chunk load event when a chunk is first upgraded to full status
* fix style
* Add logging test for generate event
After creating an SP world and waiting for all nearby chunks to generate (logging to stop), closing the SP world and opening it again should not log any fresh generation. Moving to an unexplored area will start logging again.
(cherry picked from commit 4402f4ee73)
* New translations en_us.json (German)
* New translations en_us.json (Italian)
* New translations en_us.json (Russian)
* New translations en_us.json (Polish)
* New translations en_us.json (Russian)
* New translations en_us.json (Korean)
* - Add new method AttachmentRegistry#create that allows configuration of the registered attachment type with a builder.
- Migrate existing creation methods to use the new one under the hood for consistency.
- Moves all null checking from AttachmentRegistry to AttachmentRegistryImpl.BuilderImpl (most of them happened there as well already and were thus redundant).
* - Adds the ability to initialize an AttachmentType with only a path, substituting the mod ID of the registrant via an entrypoint.
* - Add registration safety checks
* - Add missing copyright header
* - Remove lazy entrypoint initialization of attachment types.
* - Import fixes
* - Update javadoc.
* - Use expression lambdas.
* - Fix style checks
* - More style fixes
* - Fix line endings
* - Move WheelInfo and initialization to test package
- Deprecate AttachmentRegistry#builder
- Update existing tests to use #create rather than #builder
* New translations en_us.json (Polish)
* New translations en_us.json (Italian)
* New translations en_us.json (German)
* New translations en_us.json (Japanese)
* Add `c:animal_foods` tag
* checkstyle
* Spotless
* Add to lang generator
* Actually use the generated lang file
---------
Co-authored-by: modmuss50 <modmuss50@gmail.com>
* after damage event
* add after damage event to testmod
* remove amount > 0 check to capture shield blocking
* add javadoc
* dont fire event if killed
* clarify javadoc a bit more
* fix checkstyle issue
* fix other checkstyle issues lol
* rename damageDealt to baseDamageTaken
* Add #c:nuggets/iron and #c:nuggets/gold
Closes#4005.
* Add crop item tags
Everything but c:crops/cocoa_bean is already in NeoForge.
* Add more crop tags and documentation for #c:crops
* Add an API to add additional supported blocks to block entity types. (#4009)
(cherry picked from commit 40875a9333)
* Bump version
* Add chorus fruit to 1c:foods/fruit` tag
---------
Co-authored-by: modmuss <modmuss50@gmail.com>