-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: version 1.21 rc1 + item showcase build automation
- Loading branch information
1 parent
0bc0dfd
commit 153aff1
Showing
89 changed files
with
228 additions
and
48 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import glob | ||
import math | ||
|
||
from PIL import Image | ||
|
||
|
||
UI_HEADER = Image.open("../_media/assets/ui_displayer_header.png", "RGBA") | ||
UI_SLOTS = Image.open("../_media/assets/ui_displayer_slots.png", "RGBA") | ||
UI_FOOTER = Image.open("../_media/assets/ui_displayer_footer.png", "RGBA") | ||
ITEMS_LOCATION = "../../tasty_supplies/src/assets/tasty_supplies/textures/item/*.png" | ||
|
||
item_textures = [] | ||
|
||
|
||
def main(): | ||
_load_item_textures() | ||
im = _build_displayer() | ||
im = _append_items(im) | ||
|
||
new_size = tuple(i * 3 for i in im.size) | ||
im = im.resize(new_size, Image.Resampling.NEAREST) | ||
|
||
im.save("../_media/showcase/item_showcase.png") | ||
|
||
|
||
def _load_item_textures(): | ||
paths = glob.glob(ITEMS_LOCATION) | ||
paths.sort() | ||
|
||
for path in paths: | ||
texture = Image.open(path) | ||
item_textures.append(texture) | ||
|
||
|
||
def _build_displayer(): | ||
col = 9 | ||
raw = math.ceil(len(item_textures)/col) | ||
|
||
header_size = UI_HEADER.size | ||
slots_size = UI_SLOTS.size | ||
footer_size = UI_FOOTER.size | ||
|
||
im_height = header_size[1] + (slots_size[1]*raw) + footer_size[1] | ||
im = Image.new("RGBA", (header_size[0], im_height), (0, 0, 0)) | ||
|
||
Image.Image.paste(im, UI_HEADER, (0, 0)) | ||
|
||
for r in range(raw): | ||
Image.Image.paste(im, UI_SLOTS, ( | ||
0, header_size[1] + slots_size[1]*r | ||
)) | ||
|
||
Image.Image.paste(im, UI_FOOTER, (0, im_height-footer_size[1])) | ||
|
||
return im | ||
|
||
|
||
def _append_items(im): | ||
padding = (7, UI_HEADER.size[1]) | ||
|
||
for texture in item_textures: | ||
index = item_textures.index(texture) | ||
raw = math.floor(index/9) | ||
col = index - raw*9 | ||
|
||
mask = _create_a_mask(texture) | ||
|
||
im.paste(texture, ( | ||
padding[0] + col*(16+1) + col+1, | ||
padding[1] + raw*(16+1) + raw+1 | ||
), mask) | ||
|
||
return im | ||
|
||
|
||
def _create_a_mask(im: Image): | ||
return im.convert('LA') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import glob | ||
import io | ||
import math | ||
import json | ||
import requests | ||
|
||
from PIL import Image | ||
|
||
|
||
CRAFTING_TABLE_BG = Image.open("../_media/recipes/blank_recipes/blank_crafting_table_recipe.png").convert("RGBA") | ||
FURNACE_TABLE_BG = Image.open("../_media/recipes/blank_recipes/blank_furnace_recipe.png").convert("RGBA") | ||
CUTTING_BOARD_BG = Image.open("../_media/recipes/blank_recipes/blank_cutting_board_recipe.png").convert("RGBA") | ||
RECIPES_LOCATION = "../../tasty_supplies/src/data/tasty_supplies/recipes/*.json" | ||
ITEMS_LOCATION = "../../tasty_supplies/src/assets/tasty_supplies/textures/item" | ||
|
||
MC_TEXTURES_URL = "https://minecraft.wiki/images/Invicon_" | ||
|
||
recipes_data = [] | ||
|
||
|
||
def main(): | ||
_load_recipes_data() | ||
|
||
for recipe in recipes_data: | ||
match _get_recipe_type(recipe): | ||
case "crafting_shapeless": | ||
im = _build_crafting_shapeless(recipe) | ||
im.show() | ||
case "crafting_shaped": | ||
# _build_crafting_shaped(recipe) | ||
pass | ||
|
||
|
||
def _upscale(im, factor): | ||
return im.resize(tuple(i * factor for i in im.size), Image.Resampling.NEAREST) | ||
|
||
def _build_crafting_shapeless(recipe): | ||
im = _upscale(CRAFTING_TABLE_BG.copy(), 2) | ||
padding = (58, 32) | ||
|
||
ingredients = recipe["ingredients"] | ||
is_2x2 = len(ingredients) <= 4 | ||
|
||
index = 0 | ||
for item in ingredients: | ||
raw = math.floor(index/(2 if is_2x2 else 3)) | ||
col = index - raw*(2 if is_2x2 else 3) | ||
|
||
if not item.get("item"): | ||
texture = _get_item_texture("minecraft:barrier") | ||
else: | ||
texture = _get_item_texture(item["item"]) | ||
mask = _create_a_mask(texture) | ||
|
||
im.paste(texture, ( | ||
padding[0] + col*(32+2) + col+2, | ||
padding[1] + raw*(32+2) + raw+2 | ||
), mask) | ||
|
||
index += 1 | ||
|
||
custom_model_data = _get_custom_model_data(recipe["result"]) | ||
result_texture = _get_item_texture(recipe["result"]["id"], custom_model_data) | ||
mask = _create_a_mask(result_texture) | ||
im.paste(texture, (124, 35), mask) | ||
|
||
return im.convert("RGBA") | ||
|
||
|
||
def _get_item_texture(item: str, custom_model_data: int = -1): | ||
if custom_model_data == -1: | ||
im = _get_minecraft_texture(item) | ||
else: | ||
item_name = item.removeprefix("tasty_supplies:") | ||
im = Image.open(f"{ITEMS_LOCATION}/{item_name}.png") | ||
|
||
im = im.resize((32, 32), Image.Resampling.NEAREST) | ||
return im | ||
|
||
|
||
def _get_custom_texture(custom_model_data: int): | ||
pass | ||
|
||
|
||
def _get_minecraft_texture(item: str): | ||
item_name = item.removeprefix("minecraft:") | ||
item_name = item_name.replace("_", " ") | ||
item_name = item_name.title() | ||
item_name = item_name.replace(" ", "_") | ||
|
||
url = f"{MC_TEXTURES_URL}{item_name}.png" | ||
|
||
res = requests.get(url, stream=True) | ||
if not res.ok: | ||
return | ||
|
||
im = Image.open(res.raw) | ||
im = im.convert("RGBA") | ||
|
||
return im | ||
|
||
|
||
def _get_custom_model_data(recipe): | ||
if recipe.get("components"): | ||
return recipe["components"]["custom_model_data"] | ||
|
||
return -1 | ||
|
||
|
||
def _load_recipes_data(): | ||
paths = glob.glob(RECIPES_LOCATION) | ||
|
||
for recipe in paths: | ||
if recipe.endswith("reversed.json"): | ||
continue | ||
|
||
f = open(recipe) | ||
data = json.load(f) | ||
|
||
recipes_data.append(data) | ||
|
||
|
||
def _get_recipe_type(recipe): | ||
return recipe["type"].removeprefix("minecraft:") | ||
|
||
|
||
def _create_a_mask(im: Image): | ||
return im.convert('LA') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
beet[image] >= 0.104.1 | ||
mecha >= 0.92.0 | ||
# beet[image] >= 0.107.0 | ||
git+https://github.com/atomic-junky/beet.git | ||
mecha >= 0.94.2 | ||
requests >= 2.31.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+495 Bytes
tasty_supplies/src/assets/tasty_supplies/textures/item/cherry_blossom_pie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+381 Bytes
...y_supplies/src/assets/tasty_supplies/textures/item/cherry_blossom_pie_slice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 0 additions & 38 deletions
38
tasty_supplies/src/data/tasty_supplies/advancements/_consume_bucket_drink.json
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions
2
tasty_supplies/src/data/tasty_supplies/functions/bucket_drink.mcfunction
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
tasty_supplies/src/data/tasty_supplies/functions/bucket_drink_core.mcfunction
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.