Skip to content

Commit

Permalink
icons and clean-up and readme!
Browse files Browse the repository at this point in the history
  • Loading branch information
LemmaEOF committed Feb 15, 2020
1 parent 2cbbc0e commit 22a7940
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 16 deletions.
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
<img src="icon.png" align="right" width="180px"/>

# Fabric Starter
# Obligatory Loot Bag Mod


[>> Downloads <<](https://github.com/CottonMC/FabricStarter/releases)
[>> Downloads <<](https://github.com/AllOfFabric/OLBM/releases)

*Get set up!*

**This mod is open source and under a permissive license.** As such, it can be included in any modpack on any platform without prior permission. We appreciate hearing about people using our mods, but you do not need to ask to use them. See the [LICENSE file](LICENSE) for more details.

This is a template mod for creating Fabric projects. I'll be adding to it over time. Currently, it comes with a build.gradle set up to provide access to Cotton's maven and publish to Artifactory.
OLBM adds loot bags created through static data and driven by loot tables for pack devs to add into their modpacks.

## JSON format

Loot bags are defined in `.minecraft/config/olbm.json5` file, or in any static data directory as `olbm.json5`. A typical file should look like this:
```JSON
{
"bags": {
"olbm:test_bag": {
"loot": "minecraft:chests/simple_dungeon",
"color": "#FF7253",
"rarity": "epic",
"glint": true
},
}
}
```
The JSON should have one primary object, named `bags`, which all bags are defined in. Each bag should be an object, and its in-game ID will be defined by its key in the `bags` object.

Each bag configuration can store the following properties:
- `"loot"` - The loot table this bag will roll from when opened. Required
- `"color"` - The color of the bag item. Required.
- `"rarity"` - The rarity of the bag item (determines the item's name color). Optional; defaults to `"common"`.
- `"glint"` - Whether the item should have an enchantment glint. Optional; defaults to `false`.
- `"make_item"` - Whether an item should be created by OLBM for this loot bag. Optional; defaults to `true`.
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 16 additions & 13 deletions src/main/java/io/github/alloffabric/olbm/OLBData.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,21 @@ public static void loadData() {
}

private static void loadEntries(String from, JsonObject json) {
List<String> keys = new ArrayList<>(json.keySet());
Collections.sort(keys);
for (String key : keys) {
if (OLBM.LOOT_BAG_TYPES.containsId(new Identifier(key))) {
OLBM.logger.error("[OLBM] Table type named {} already exists, skipping it in {}", key, from);
continue;
}
JsonElement elem = json.get(key);
if (elem instanceof JsonObject) {
JsonObject config = (JsonObject)elem;
LootBagType type = getType(key, config);
OLBM.registerBag(type);
JsonObject bagObj = json.getObject("bags");
if (bagObj != null) {
List<String> keys = new ArrayList<>(bagObj.keySet());
Collections.sort(keys);
for (String key : keys) {
if (OLBM.LOOT_BAG_TYPES.containsId(new Identifier(key))) {
OLBM.logger.error("[OLBM] Table type named {} already exists, skipping it in {}", key, from);
continue;
}
JsonElement elem = bagObj.get(key);
if (elem instanceof JsonObject) {
JsonObject config = (JsonObject) elem;
LootBagType type = getType(key, config);
OLBM.registerBag(type);
}
}
}
}
Expand All @@ -77,7 +80,7 @@ static LootBagType getType(String key, JsonObject json) {
boolean makeItem = json.getBoolean("make_item", true);
if (makeItem) {
Rarity rarity = json.containsKey("rarity")? getRarity(json.get(String.class, "rarity")) : Rarity.COMMON;
boolean hasGlint = json.containsKey("glint")? json.get(Boolean.class, "glint") : false;
boolean hasGlint = json.getBoolean("glint", false);
return new LootBagType(id, tableId, color, hasGlint, Optional.of(new Item.Settings().maxCount(1).group(OLBM.OLBM_GROUP).rarity(rarity)));
} else {
return new LootBagType(id, tableId, color, false, Optional.empty());
Expand Down
Binary file modified src/main/resources/assets/olbm/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 22a7940

Please sign in to comment.