-
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.
Added eggs & other resource pack stuff
- Loading branch information
Showing
25 changed files
with
330 additions
and
5 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.
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,23 @@ | ||
from pathlib import Path | ||
from noxpack import json | ||
|
||
BRILLIANCE_PATH = Path(__file__).resolve().parents[5] / "trackedout/Brilliance/Brilliance Resourcepack/assets" | ||
|
||
def paper_list(): | ||
path = "do2/textures/item/artifacts" | ||
glob = (BRILLIANCE_PATH / path).glob("*.png") | ||
return ["skull"] + [path.stem for path in glob] | ||
|
||
|
||
def _create_model(name): | ||
@json(path=f"do2/models/item/dungeon_log/paper_{name}") | ||
def _(): | ||
return { | ||
"parent": "item/generated", | ||
"textures": { | ||
"layer0": f"do2:item/dungeon_log/paper_{name}", | ||
} | ||
} | ||
|
||
for name in paper_list(): | ||
_create_model(name) |
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,23 @@ | ||
from noxpack import json | ||
from .dungeon_logs import paper_list | ||
|
||
|
||
@json(path="minecraft/models/item/paper") | ||
def _(): | ||
overrides = [] | ||
|
||
for idx, name in enumerate(paper_list()): | ||
overrides.append( | ||
{ | ||
"predicate": {"custom_model_data": idx + 1}, | ||
"model": f"do2:item/dungeon_log/paper_{name}", | ||
} | ||
) | ||
|
||
return { | ||
"parent": "item/generated", | ||
"textures": { | ||
"layer0": "item/paper", | ||
}, | ||
"overrides": overrides, | ||
} |
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,73 @@ | ||
from pathlib import Path | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import cv2 | ||
|
||
from noxpack import png | ||
from .dungeon_logs import paper_list | ||
|
||
|
||
BRILLIANCE_PATH = Path(__file__).resolve().parents[5] / "trackedout/Brilliance/Brilliance Resourcepack/assets" | ||
MINECRAFT_PATH = Path(__file__).resolve().parents[6] / "Minecraft/Data/Versions/1.20.1/assets" | ||
SELF = Path(__file__).resolve().parent | ||
|
||
|
||
def imread(name): | ||
if name == "do2:item/paper": | ||
name = name.replace("do2:", "minecraft:") | ||
root = MINECRAFT_PATH | ||
else: | ||
root = BRILLIANCE_PATH | ||
|
||
image = plt.imread((root / name.replace(":", "/textures/")).with_suffix(".png")) | ||
image = (255 * image).astype("u1") | ||
|
||
if name == "do2:item/artifacts/tntslab": | ||
assert image.shape == (64, 256, 4), f"Invalid shape: {image.shape}" | ||
image = image[:, 128:][:, :64] | ||
image[32:] = 0 | ||
|
||
return image | ||
|
||
|
||
PAPER = imread("do2:item/paper") | ||
|
||
|
||
def _create_texture(name): | ||
@png(name=f"item/dungeon_log/paper_{name}") | ||
def _(): | ||
if name == "skull": | ||
icon = plt.imread(SELF / "_skull.png") | ||
icon = 255 * icon | ||
icon = (icon - 20) * 255 / (175 - 20) | ||
icon = icon.clip(0, 255).astype("u1") | ||
icon = np.concatenate([icon, 255 - icon[..., 0:1]], axis=-1) | ||
else: | ||
icon = imread(f"do2:item/artifacts/{name}") | ||
|
||
size = 48 | ||
k2 = size / 128 | ||
x1, x2, y1, y2 = -16, 48, -24, 56 | ||
k1 = icon.shape[0] / 32 | ||
paper = cv2.resize(PAPER, (size, size), interpolation=cv2.INTER_NEAREST) | ||
P = cv2.getPerspectiveTransform( | ||
k1 * np.array([x1, y1, x2, y1, x2, y2, x1, y2]).astype('f4').reshape(4, 1, 2), | ||
k2 * np.array([80, 14.7, 125, 59.8, 54.3, 111.7, 8.6, 64.7]).astype('f4').reshape(4, 1, 2), | ||
) | ||
# icon2 = cv2.warpPerspective(icon, P, (size, size), flags=cv2.INTER_NEAREST) | ||
icon2 = cv2.warpPerspective(icon, P, (size, size), flags=cv2.INTER_CUBIC) | ||
canvas = paper.copy() | ||
|
||
a1 = icon2[..., -1].astype('f4') / 255 | ||
a2 = (1 - a1) * canvas[..., -1].astype('f4') / 255 | ||
a = a1 + a2 | ||
a = a.clip(0.001, None) | ||
|
||
canvas = icon2 * (a1 / a)[..., np.newaxis] + canvas * (a2 / a)[..., np.newaxis] | ||
canvas[..., -1] = 255 * a | ||
canvas = canvas.clip(0, 255).astype("u1") | ||
return canvas | ||
|
||
for name in paper_list(): | ||
_create_texture(name) |
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,75 @@ | ||
from pathlib import Path | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
from noxpack import png | ||
|
||
|
||
BRILLIANCE_PATH = Path(__file__).resolve().parents[6] / "trackedout/Brilliance/Brilliance Resourcepack/assets" | ||
MINECRAFT_PATH = Path(__file__).resolve().parents[7] / "Minecraft/Data/Versions/1.20.1/assets" | ||
|
||
|
||
def image_list(path): | ||
glob = (BRILLIANCE_PATH / path.replace(":", "/textures/")).glob("*.png") | ||
return [path.stem for path in glob] | ||
|
||
|
||
def imread(name): | ||
if name == "do2:item/sweet_berries": | ||
name = name.replace("do2:", "minecraft:") | ||
root = MINECRAFT_PATH | ||
else: | ||
root = BRILLIANCE_PATH | ||
|
||
image = plt.imread((root / name.replace(":", "/textures/")).with_suffix(".png")) | ||
image = (255 * image).astype("u1") | ||
|
||
if name == "do2:item/artifacts/tntslab": | ||
assert image.shape == (64, 256, 4), f"Invalid shape: {image.shape}" | ||
image = image[:, 128:][:, :64] | ||
image[32:] = 0 | ||
|
||
return image | ||
|
||
|
||
def png_array(call): | ||
@png(name=call.__name__) | ||
def _(): | ||
names = [] | ||
|
||
for item in call(): | ||
if isinstance(item, str): | ||
names.append(item) | ||
elif isinstance(item, tuple) and len(item) == 2 and isinstance(item[1], list): | ||
prefix, item = item | ||
names.extend(prefix + name for name in item) | ||
else: | ||
names.extend(item) | ||
|
||
textures = [ | ||
imread(f"do2:item/{name}") for name in names | ||
] | ||
|
||
for texture in textures: | ||
texture[-1, -1] = (60, 60, 60, 1) | ||
|
||
return np.concatenate(textures, axis=1) | ||
|
||
|
||
@png_array | ||
def icons16(): | ||
yield "do_coin", "do_crown", "do_ember", "do_tome" | ||
yield "sweet_berries" | ||
|
||
@png_array | ||
def icons32(): | ||
artifacts = image_list("do2:/item/artifacts") | ||
artifacts = [a for a in artifacts if a != "tntslab"] | ||
print(f":: Got {len(artifacts)} artifacts.") | ||
yield "artifacts/", artifacts | ||
|
||
@png_array | ||
def icons64(): | ||
yield "keys/", ["do_key1_64", "do_key4_64", "do_key6_64", "toolbox", "do_key3_64"] | ||
yield "artifacts/tntslab" |
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,43 @@ | ||
from noxpack import json | ||
import numpy as np | ||
|
||
|
||
def _space(code, size): | ||
return { | ||
"type": "bitmap", | ||
"file": "do2:gui/empty.png", | ||
"ascent": -65535, | ||
"height": size - (1 if size > 0 else 2), | ||
"chars": [chr(code)], | ||
} | ||
|
||
|
||
def _bitmap(name, ascent, height, chars): | ||
return { | ||
"type": "bitmap", | ||
"file": f"{name}.png", | ||
"ascent": ascent, | ||
"height": height, | ||
"chars": [chars], | ||
} | ||
|
||
@json | ||
def _(): | ||
space_left = [] | ||
space_right = [] | ||
|
||
implemented = list(range(1, 33)) + [64, 128, 255] | ||
space_left = [_space(0xEB00 + size, -size) for size in implemented] | ||
space_right = [_space(0xEA00 + size, size) for size in implemented] | ||
|
||
artifacts = "".join(chr(0xe100 + i) for i in range(1, 30)) | ||
|
||
return { | ||
"providers": [ | ||
_bitmap("do2:font_icons/icons16", 16, 16, "\ue001\ue002\ue003\ue004\ue023"), | ||
_bitmap("do2:font_icons/icons32", 16, 16, artifacts), | ||
_bitmap("do2:font_icons/icons64", 16, 16, "\ue011\ue012\ue013\ue021\ue022\ue11e"), | ||
*space_left, | ||
*space_right, | ||
] | ||
} |
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,25 @@ | ||
from pathlib import Path | ||
|
||
from noxpack import json | ||
|
||
|
||
TEXTURES = Path(__file__).parents[2] / "textures/item/eggs" | ||
|
||
def _create_egg(name): | ||
@json(name=name) | ||
def _(): | ||
return { | ||
"parent": "custom:item/egg/gold", | ||
"textures": { | ||
"2": f"do2:item/eggs/{name}", | ||
"particle": f"do2:item/eggs/{name}" | ||
} | ||
} | ||
|
||
|
||
for name in TEXTURES.glob("*.png"): | ||
name = name.stem | ||
if name.startswith("_"): | ||
continue | ||
|
||
_create_egg(name) |
Binary file added
BIN
+293 Bytes
Components/Resource/More Eggs/do2/textures/item/eggs/_egg_template.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
+8.88 KB
Components/Resource/More Eggs/do2/textures/item/eggs/chrono_trigger.png
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.
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.
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.
Binary file added
BIN
+7.96 KB
Components/Resource/More Eggs/do2/textures/item/eggs/smallish_beans.png
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.
Binary file added
BIN
+1.32 KB
Components/Resource/More Eggs/do2/textures/item/eggs/tango_dungeon_master.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
+687 Bytes
Components/Resource/More Eggs/do2/textures/item/eggs/tinfoil_chef.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions
20
Components/Resource/More Eggs/minecraft/models/item/pumpkin.py
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,20 @@ | ||
from noxpack import json | ||
import data | ||
|
||
|
||
@json | ||
def _(): | ||
overrides = [] | ||
|
||
for name, model in data.CUSTOM_MODIFICATIONS.MORE_EGGS.MODELS.items(): | ||
overrides.append( | ||
{ | ||
"predicate": {"custom_model_data": model}, | ||
"model": f"do2:item/eggs/{name}", | ||
} | ||
) | ||
|
||
return { | ||
"parent": "minecraft:block/pumpkin", | ||
"overrides": overrides, | ||
} |
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,24 @@ | ||
[ | ||
{ | ||
"type": "datapack", | ||
"name": "Dev Server Datapack", | ||
"description": "DO2 Experimental Datapack", | ||
"components": [ | ||
"-Deck Validation", | ||
"-Ethereal Cards", | ||
"-GUI", | ||
"-Run Summary", | ||
"-Training" | ||
] | ||
}, | ||
{ | ||
"type": "resource_pack", | ||
"name": "Dev Server Resource Pack", | ||
"description": "DO2 Experimental Datapack", | ||
"components": [ | ||
"-Ethereal Cards", | ||
"Font Icons", | ||
"GUI" | ||
] | ||
} | ||
] |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
def text_button(text, color, scoreboard, trigger, hint): | ||
return f"""{{ | ||
"color": "{color}", | ||
"text": "[{text}]", | ||
"clickEvent": {{"action": "run_command", "value": "/trigger {scoreboard} set {trigger}"}}, | ||
"hoverEvent": {{"action": "show_text", "contents": "{hint}"}} | ||
}}""" |
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