You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: public/wiki/cardinal-components-api/modules/level.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,8 @@ breadcrumb: Level Properties
6
6
7
7
This module allows mods to attach components to WorldProperties objects. Those properties are shared by every world and thus can be used as global data. Level components can be semi-automatically synchronized by implementing `AutoSyncedComponent`. **Note that you must call `LevelComponents#sync(MinecraftServer)` instead of `ComponentKey#sync()`**.
Scoreboard components are available starting from version 2.5.0 of the API (MC 1.16.2) and offer the same functionality as level components while being easier to synchronize.
9
+
## CCA Alternative: [Scoreboard Components](./scoreboard)
10
+
[Scoreboard components](./scoreboard) are available starting from version 2.5.0 of the API (MC 1.16.2) and offer the same functionality as level components while being easier to synchronize.
Copy file name to clipboardExpand all lines: public/wiki/cardinal-components-api/modules/scoreboard.md
+115-3Lines changed: 115 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,19 +4,131 @@ layout: cca_wiki
4
4
breadcrumb: Scoreboards and Teams
5
5
---
6
6
7
-
This module allows mods to attach components to `Scoreboard` and `Team` objects. The former can be used for storing global data, while the latter can be especially useful for implementing multiplayer systems like minigames and factions.
7
+
This module allows mods to attach components to `Scoreboard` and `Team` objects.
8
+
The former can be used for storing global data, while the latter can be especially useful for implementing multiplayer systems like minigames and factions.
9
+
10
+
By default, the scoreboard itself is not affected in any way by the data that is attached to it through Cardinal Components API.
11
+
It is only used as a convenient provider that can easily be accessed by mods.
12
+
{:.admonition.admonition-important}
8
13
9
14
## Usage
10
15
### Registration
11
16
12
-
Scoreboard components are registered by a [`ScoreboardComponentInitializer`](https://github.com/Ladysnake/Cardinal-Components-API/blob/master/cardinal-components-scoreboard/src/main/java/org/ladysnake/cca/api/v3/scoreboard/ScoreboardComponentInitializer.java), exposed as `cardinal-components-scoreboard` in the mod json (more information on the [component registration page](../registration#2-attaching-your-component)).
17
+
Scoreboard components are registered by a [`ScoreboardComponentInitializer`](https://github.com/Ladysnake/Cardinal-Components-API/blob/master/cardinal-components-scoreboard/src/main/java/org/ladysnake/cca/api/v3/scoreboard/ScoreboardComponentInitializer.java), exposed as either `cardinal-components-scoreboard`
18
+
or simply `cardinal-components` in the mod json (more information on the [component registration page](../registration#2-attaching-your-component)).
13
19
Once a component factory is registered for either scoreboards or teams, its associated component will be available on every relevant instance, on both clients and servers.
14
20
21
+
Scoreboard and team component factories are passed a `MinecraftServer` instance, which allows for advanced behaviour during *e.g.* component ticking.
22
+
This server instance will be `null` on the logical client.
Scoreboard components can be automatically synchronized from the server to the client by implementing [`AutoSyncedComponent`](https://github.com/Ladysnake/Cardinal-Components-API/blob/master/cardinal-components-base/src/main/java/org/ladysnake/cca/api/v3/component/sync/AutoSyncedComponent.java) - more information is available on [the component synchronization page](../synchronization.md).
41
+
BothScoreboard and Team components can be automatically synchronized from the server to the client by implementing
42
+
[`AutoSyncedComponent`](https://github.com/Ladysnake/Cardinal-Components-API/blob/master/cardinal-components-base/src/main/java/org/ladysnake/cca/api/v3/component/sync/AutoSyncedComponent.java) - more information is available on [the component synchronization page](../synchronization.md).
43
+
A scoreboard component should call `KEY.sync(scoreboard)` to trigger server-to-client synchronization, while a team
44
+
component should call `KEY.sync(team)`.
18
45
19
46
### Ticking
20
47
21
48
Scoreboard components support both [server](https://github.com/Ladysnake/Cardinal-Components-API/blob/main/cardinal-components-base/src/main/java/org/ladysnake/cca/api/v3/component/tick/ServerTickingComponent.java) and [client](https://github.com/Ladysnake/Cardinal-Components-API/blob/main/cardinal-components-base/src/main/java/org/ladysnake/cca/api/v3/component/tick/ClientTickingComponent.java) ticking.
22
49
They get ticked at the end of the server/client tick.
50
+
51
+
## GlobalComponentExample
52
+
53
+
Here is an example of a global component that can be used to track modded player data even when the players are offline:
0 commit comments