Skip to content

Commit

Permalink
ooh, look, documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dries007 committed Aug 3, 2015
1 parent c84ecf0 commit 8216b9f
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 9 deletions.
78 changes: 76 additions & 2 deletions README.md
Expand Up @@ -26,10 +26,84 @@ A note on the amount of slots: When filling a chest, Minecraft picks a random sl
Json format
-----------

Per lootbag, you make 1 json file. The extension needs to be .json! The name of the file doesn't matter.

*** Everything is always CASE SENSITIVE unless specifically stated otherwise. ***

### Json template
```javascript
{
"itemname": String,
"color": Color Object,
"invSlotsMin": Integer,
"invSlotsMax": Integer,
"amountOfItemsMin": Integer,
"amountOfItemsMax": Integer,
"rarity": String,
"items": [
Item Objects here
]
}
```

TODO: write documentation about the json format.
For both `invSlots` and `amountOfItems` actual amount is randomly picked between min & max

Property | Type | Explanation
-----------------|---------|----------------------------------------------------------
itemname | String | The displayname of the itemstack.
color | Various | See later on in this document.
invSlotsMin | Integer | Minimum amount of slots in the inventory.
invSlotsMax | Integer | Maximum amount of slots in the inventory.
amountOfItemsMin | Integer | Minimum amount of items to be distributed over the slots.
amountOfItemsMax | Integer | Maximum amount of items to be distributed over the slots.
rarity | String | Determines formatting of the itemname, see later.
items | Objects | The itemstack objects, see later.

#### Color

Color can be represented in a couple of ways:
- A number (known as the java color code)
- A hexadecimal number (same as CSS color codes, but the `#` is needs to be replaced by `0x`
- An array of RGB(A) values. Eater 0.0 trough 1.0 or 0 trough 255.
- An object with values r(ed), g(reen), b(lue) and or a(lpha).
- A string withe the standard colors known by java, as seen [here](http://docs.oracle.com/javase/7/docs/api/java/awt/Color.html).

For now, look at the examples as generated by the
#### Rarity

The following rarities are possible in Minecraft:
- Common: White name, like normal items.
- Uncommon: Yellow name, like enchanted books.
- Rare: Aqua name, like enchanted items.
- Epic: Light purple name, like Notch apple.

#### Item Objects

Fist of all, an example:
```javascript
{
"min": 1,
"max": 3,
"weight": 10,
"itemstack": {
"item": "minecraft:stick",
"stacksize": 1,
"damage": 0,
"nbt":
}
}
```
Property | Type | Explanation
----------|---------|----------------------------------------------------------
min | Integer | The minimum number of these items.
max | Integer | The maximum number of these items.
weight | Integer | How often the item is chosen. (Higher is more)
itemstack | Object | The itemstack object

##### Itemstack objects

Property | Type | Explanation
----------|---------|----------------------------------------------------------
item | String | Item name, in `modid:item` format
stacksize | Integer | Actually not used in this case (random value between min & max is used)
damage | Integer | The damage value / metadata value
nbt | Object | Optional, nbt value for the itemstack. You can obtain this trough the jsonlootbags command.
10 changes: 3 additions & 7 deletions src/main/java/net/doubledoordev/jsonlootbags/util/BagType.java
Expand Up @@ -32,6 +32,7 @@

package net.doubledoordev.jsonlootbags.util;

import com.google.gson.annotations.Expose;
import net.doubledoordev.jsonlootbags.JsonLootBags;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.item.EnumRarity;
Expand All @@ -50,15 +51,15 @@ public class BagType
{
private static final Map<String, BagType> bagTypeMap = new HashMap<>();

private String name;
public String itemname;
public Color color;
public int invSlotsMin = 36;
public int invSlotsMax = 36;
public int amountOfItemsMin = 1;
public int amountOfItemsMax = 10;
public WeightedRandomChestContent[] items;
public EnumRarity rarity = EnumRarity.common;
private String name;
public WeightedRandomChestContent[] items;

public static BagType getFromStack(ItemStack stack)
{
Expand Down Expand Up @@ -103,9 +104,4 @@ public List<ItemStack> getRandomItems(Random rand)
}
return list;
}

public static class MinMaxWeight
{
public int min, max, weight;
}
}

0 comments on commit 8216b9f

Please sign in to comment.