Skip to content

Commit

Permalink
docs: add docs on resource-pack merging
Browse files Browse the repository at this point in the history
  • Loading branch information
yusshu committed Nov 28, 2023
1 parent 3b17c7f commit 346c74d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public interface MergeStrategy {
/**
* Gets a merge strategy that merges the resources of the
* first container with the resources of the second container,
* resulting in a exception if there are duplicates that can't
* resulting in an exception if there are duplicates that can't
* be merged.
*
* @return The merge and fail on error merge strategy
Expand Down
1 change: 1 addition & 0 deletions docs/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ fonts.md
language.md
sounds.md
putting-all-together.md
merging.md
examples
serialization
server
29 changes: 29 additions & 0 deletions docs/merging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Merging

Developers can merge two resource-packs together using the
`ResourcePack#merge(ResourcePack, MergeStrategy)` method.

<!--@formatter:off-->
```java
// get our resource packs
ResourcePack base = ...;
ResourcePack other = ...;

// merge
base.merge(other, MergeStrategy.override());

// now base contains all the resources from other
```
<!--@formatter:on-->

There are three built-in merge strategies:

- `override()`: overrides the resources of the base resource-pack with the resources
of the second one if there are duplicates.
- `mergeAndFailOnError()`: merges the resources of the base resource-pack with the
resources of the second one, resulting in a `MergeException` if there are duplicates that
can't be merged.
- `mergeAndKeepFirstOnError()`: merges the resources of the
base resource-pack with the resources of the second one,
keeping only the resources of the first resource-pack if there
are duplicates that can't be merged.

0 comments on commit 346c74d

Please sign in to comment.