Skip to content

Commit

Permalink
added example datapack and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
aws404 committed Jun 7, 2021
1 parent 880e4d5 commit 8c9cd2d
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 34 deletions.
32 changes: 12 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,16 @@
**Easy painter** is a server-side mod for improving paintings!

## Features
* The easy painting selection GUI opens when you place/shift click a painting, showing you all the paintings that could go in that position.
* Add custom paintings to your server, no resource packs required. Just place the image and a small JSON file in the config directory ([see here](#Custom Paintings))
* Easy painting selection GUI opens when you place/shift click a painting, showing you all the paintings that could go in that position.
* Add custom paintings to your server, no resource packs required. Just place create a simple datapack, [see here](/example).
* Painting locking, add the `locked:true` tag to a painting entity to lock it. This will make it unbreakable, unchangeable, ect.
* Painting block/entity tags, customise the blocks which can support paintings/sit informant of paintings without breaking them.
* `easy_painter/tags/blocks/cannot_support_paiting.json` - Blocks which cannot be behind paintings without them breaking
* `easy_painter/tags/blocks/paiting_ignored.json` - Blocks which can sit in-front of paintings without them breaking
* `easy_painter/tags/entity_types/painting_interact.json` - Entities which cannot share a space with paintings

## Custom Paintings
Custom paintings require 2 files to be placed in the `config/easy_painter` dirrecory (see the [example here](/example/config)).
1. The JSON file. This simply tells the mod how big the painting should be. For Example:
```json5
{
"blockWidth": 2,
"blockHeight": 2,
"image": "tater" //<- (optional, will assume the same as the file name if not supplied)
}
```
2. The image file. This is the `png` image that the painting should display, it can be either named the same as the JSON file or defined in the `image` field.
The dimensions of the image need to be in the same ratio as `blockWidth` to `blockHeight` (Note: this is not a technical limitation but rather imposed as stretching images to fit dimensions looks terrible).

### Removing Custom Paintings
To properly remove a custom painting follow the steps bellow:
1. From the console or as an op run `/easy_painter clear <painting_name>`
2. Run the command again to confirm.
3. Once the server has stopped, delete the relevant files from `config/easy_painter`
## Libraries Used
* [Image2Map](https://github.com/TheEssem/Image2Map) - TheEssem
* [sgui](https://github.com/Patbox/sgui) - Patbox
* [Server Translations](https://github.com/arthurbambou/Server-Translations) - Arthurbambou
* [FabricAPI](https://github.com/FabricMC/fabric) - FabricMC
5 changes: 0 additions & 5 deletions example/config/easy_painter/big_tater.json

This file was deleted.

4 changes: 0 additions & 4 deletions example/config/easy_painter/landscape.json

This file was deleted.

Binary file removed example/config/easy_painter/landscape.png
Binary file not shown.
5 changes: 0 additions & 5 deletions example/config/easy_painter/mega_tater.json

This file was deleted.

5 changes: 5 additions & 0 deletions example/datapacks/my_data_pack/data/my_mod_id/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"painting.my_mod_id.tater": "The Tater",
"painting.my_mod_id.big_tater": "The BIG Tater",
"painting.my_mod_id.esher": "Waterfall"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"blockWidth": 2,
"blockHeight": 2,
"image": "tater_image",
"ditherMode": "FLOYD"
}
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
6 changes: 6 additions & 0 deletions example/datapacks/my_data_pack/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pack":{
"pack_format":3,
"description":"A example datapack for adding paintings with Easy Painter!"
}
}
69 changes: 69 additions & 0 deletions example/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Adding Custom Painting Motives
You can add your own custom painting motives by simply adding a data pack. Follow along with the example data pack here!

1. In your datapack add a `painting` directory. For example:
```
my_data_pack
├───pack.mcmeta
└───data
└───my_mod_id <─ Your mod/datapack id (any valid Identifier)
├───painting <─ The painting directory
└───lang
```
2. Inside the `painting` place your `.png` image and a new `.json` file. The name of your json file will be the motive's identifier.
By default, the image name should be the same as the `.json` but with `_image` on the end.
```
my_data_pack
├───pack.mcmeta
└───data
└───my_mod_id
├───painting
│ ├───my_painting.json
│ └───my_painting_image.png
└───lang
```
3. Edit the contents of the `.json` file to match the following template:
```json5
{
"blockWidth": 2, // <─ This is the paintings width in blocks
"blockHeight": 2, // <─ This is the paintings height in blocks
"image": "my_painting_image", // <─ OPTIONAL: By default the mod will look for an image of the same name with `_image`.
"ditherMode": "FLOYD" // <─ OPTIONAL: By default this will be NONE
}
```
The image dimensions need to have the same aspect ratio as `blockWidth` and `blockHeight` (`imageWidth/imageHeight == blockWidth/blockHeight`), this is to prevent strange resizing issues.

3.5. You can also add a translation key for your paining inside the `lang` directory, if not supplied it will use the motive's identifier.
```
my_data_pack
├───pack.mcmeta
└───data
└───my_mod_id
├───painting
│ ├───my_painting.json
│ └───my_painting_image.png
└───lang
└───en_us.json
```
The translation key uses the format `painting.<mod_id>.<painting_identifier>`, for example the contents of `en_us.json` would be:
```json
{
"painting.my_mod_id.my_painting": "My Custom Painting"
}
```

4. Add the datapack to your world/mod and restart the server/use `/reload` (can cause some small issues).

# Clearing the Cache
When the server detects a new motive, the maps are created and cached. This means the maps do not need to be re-generated each time, saving space and time.
This also means if you change an image you will need to clear this cache for the change to take effect.

## The Automatic Easy Way
This will clear all the entire motive cache and required a server restart.
1. From the console/an operator run `/easy_painter clearcache` then again to confirm. This will save the server and then shutdown, clearing the cache in the process.
2. Restart the server, you should see in the logs that the mod regenerates the motives.

## The Manual Technical Way
The cache is stored in the overworld's `data/custom_motives.dat` file. You can open this file with an nbt editor and manually remove a cached motive.
You can also safely delete the `map_<id>` values contained in the motives `mapIds` lists.
**Do not touch the `currentMapId` value! It will overwrite other motives maps!**

0 comments on commit 8c9cd2d

Please sign in to comment.