Skip to content

Commit

Permalink
slight clarifications for BlockCapabilityCache usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Dec 7, 2023
1 parent e209770 commit 3053abf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions content/news/20.3capability-rework.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ if (handler != null) {
```

### Block capability caching
For efficient queries and automatic caching, use `BlockCapabilityCache`.
For efficient queries and automatic caching, use `BlockCapabilityCache` instead of directly calling `level.getCapability`.
This is a more powerful replacement for the old `LazyOptional` invalidation system.

When a capability is looked up, the system will perform the following steps under the hood:
Expand All @@ -238,7 +238,8 @@ The implementation is rather efficient, but for queries that are performed frequ
for example every game tick, these steps can take a significant amount of server time.
The `BlockCapabilityCache` system provides a dramatic speedup for capabilities that are frequently queried at a given position.

Generally, a `BlockCapabilityCache` will be created once and then stored in a field.
Generally, a `BlockCapabilityCache` will be created once and then stored in a field of the object performing frequent capability queries.
When exactly you store the cache is up to you.
The cache must be provided with the capability to query, the level, the position, and the query context.

```java
Expand Down

0 comments on commit 3053abf

Please sign in to comment.