Skip to content

Commit 770f908

Browse files
committed
Update README a little
1 parent 3bb89e5 commit 770f908

File tree

1 file changed

+16
-87
lines changed

1 file changed

+16
-87
lines changed

README.md

Lines changed: 16 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,49 @@
11
# trove
22

3-
[![license](https://img.shields.io/github/license/GoldenStack/trove?style=for-the-badge&color=dd2233)](LICENSE)
4-
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=for-the-badge)](https://github.com/RichardLitt/standard-readme)
5-
[![javadocs](https://img.shields.io/badge/documentation-javadocs-4d7a97?style=for-the-badge)](https://javadoc.jitpack.io/com/github/GoldenStack/trove/master-SNAPSHOT/javadoc/)
6-
7-
Trove is a versatile loot table library. Although a lot of the base concepts here are similar to Minecraft's loot table
8-
system, Trove is much more flexible, permitting the usage of multiple different loot types (e.g. items and experience).
9-
Plus, it has a convenient API, emphasizes immutable data structures, and supports full serialization and deserialization
10-
of all formats supported by Configurate, including JSON and YAML.
11-
12-
The two modules are `core` and `minestom`. The `core` module contains the basic functioning pieces of the library, while
13-
`minestom` contains a nearly full implementation for Minecraft's loot tables for Minestom.
14-
15-
---
16-
17-
## Table of Contents
18-
- [Install](#install)
19-
- [Usage](#usage)
20-
- [Contributing](#contributing)
21-
- [License](#license)
3+
Trove is a loot table library for [Minestom](https://github.com/Minestom/Minestom/). It implements
4+
[nearly every](#completeness) feature from vanilla Minecraft.
225

236
---
247

258
## Install
269

27-
To install, simply add the library via [JitPack](https://jitpack.io/#GoldenStack/trove/):
10+
To install, simply add the library via Maven Central:
2811

29-
Details for how to add this library with other build tools (such as Maven) can be found on the page linked above.
3012
``` kts
3113
repositories {
32-
...
33-
maven(url = "https://jitpack.io")
14+
mavenCentral()
3415
}
3516

3617
dependencies {
37-
...
38-
// Minestom and Configurate versions
39-
// (you can replace Minestom with Minestom-ce if you want)
40-
implementation("com.github.minestom.minestom:Minestom:VERSION")
41-
implementation("org.spongepowered:configurate-gson:VERSION")
18+
implementation 'net.minestom:minestom-snapshots:<version>'
4219

43-
implementation("com.github.GoldenStack.trove:MODULE:VERSION")
20+
implementation 'net.goldenstack.trove:<version>'
4421
}
4522
```
46-
Trove relies on Minestom and Configurate, so make sure to add them.
47-
48-
Just replace `MODULE` with the desired module of Trove, and replace `VERSION` with the desired version or commit hash.
49-
50-
Trove currently uses
23+
Make sure to include Minestom, or else Trove won't work.
5124

5225
---
5326

5427
## Usage
5528

5629
### Setup
5730

58-
This setup currently only explains how to set up the Minestom module.
59-
60-
You can use the TroveMinestom class for a very easy setup. Just provide a folder path, and it will recursively parse
61-
every JSON file inside it.
62-
63-
``` java
64-
Path lootTableFolder = ...; // Replace with the path to the folder of loot tables
65-
66-
var tableRegistry = TroveMinestom.readTables(lootTableFolder,
67-
() -> GsonConfigurationLoader.builder().defaultOptions(options -> options.serializers(builder -> builder.registerAll(TroveMinestom.DEFAULT_COLLECTION))));
68-
```
69-
Each table will be stored via a NamespaceID in the tables object. For example, if the parsed loot table has the path
70-
"blocks/barrel.json" relative to the loot table folder, its ID will be `minecraft:blocks/barrel`.
31+
Trove is designed to be extremely simple to use.
7132

33+
To obtain a `Map<NamespaceID, LootTable>`, simply call `Trove.readTables(Path.of("path_to_loot_tables"))`. Trove will
34+
automatically parse out the loot table hierarchy and include it in the table IDs.
7235

7336
### Generation
74-
Actual loot generation is fairly simple - you just need to call `LootTable#generate(LootContext, Consumer<Object>)`.
75-
The consumer can be a `LootProcessor` if that makes it easier.
76-
77-
Importantly, if you want some of the vanilla features that aren't implemented here, you should implement the
78-
`VanillaInterface` interface and pass it in as a key to your context. A partial implementation of it that doesn't throw
79-
any exceptions is `FallbackVanillaInterface`. You may also have to implement some type serializers.
80-
81-
Here's an example that uses the `tableRegistry` variable from the last code snippet:
82-
``` java
83-
LootTable table = tableRegistry.getTable(NamespaceID.from("minecraft:blocks/stone"));
37+
Loot generation is very simple as well. Calling `LootTable#generate(LootContext)` returns a list of items.
8438

85-
// You can use the LootContext class to provide important information during generation.
86-
LootContext context = LootContext.builder()
87-
.random(...) // Random instance here
88-
.with(..., ...) // Loot context keys and values added with Builder#with
89-
.build();
90-
91-
// Generate the loot
92-
table.generate(context, loot -> ...); // Do something with the loot
93-
```
39+
If you're implementing block drops, just call `LootTable#blockDrop(LootContext, Instance, Point)`. If you're
40+
implementing entity drops, call `LootTable#drop(LootContext, Instance, Point)`.
9441

95-
You can also use a `LootProcessor` to make this processing easier. For example:
96-
``` java
97-
var processor = LootProcessor.processClass(ItemStack.class, item -> {
98-
// Perform some arbitrary action with the item
99-
});
100-
```
42+
---
10143

102-
You can also handle multiple classes at once, or even use a custom predicate:
103-
``` java
104-
var processor = LootProcessor.builder()
105-
.processClass(ItemStack.class, item -> {
106-
// Perform some calculation
107-
}).processClass(String.class, string -> {
108-
// Perform another calculation
109-
}).process(object -> true, object -> {
110-
// Perform some calculation with the object
111-
}).build();
112-
```
44+
## Completeness
11345

114-
Then, you can just provide the processor to the generator:
115-
``` java
116-
table.generate(context, processor);
117-
```
46+
TODO
11847

11948
---
12049

0 commit comments

Comments
 (0)