From cd08a8ec9313a7b7a3fa44d653785e240c872412 Mon Sep 17 00:00:00 2001 From: Noxitu <4777470+Noxitu@users.noreply.github.com> Date: Fri, 12 Jan 2024 21:22:50 +0100 Subject: [PATCH] Added custom textures resource pack --- .gitignore | 3 +- Decked Out 2 Sprites Resource Pack/.gitignore | 5 + .../Data/Compass/compass_frame_blackrock.png | Bin 0 -> 328 bytes .../Data/Compass/compass_frame_frozen.png | Bin 0 -> 475 bytes .../Data/Compass/compass_frame_warped.png | Bin 0 -> 430 bytes .../Data/Compass/compass_frame_wooden.png | Bin 0 -> 541 bytes .../Data/Compass/compass_mask.png | Bin 0 -> 117 bytes .../Data/Watch/watch.png | Bin 0 -> 1836 bytes .../Data/Watch/watch_face.png | Bin 0 -> 1784 bytes .../Data/Watch/watch_mask.png | Bin 0 -> 191 bytes .../Data/gui_map.png | Bin 0 -> 470 bytes .../Data/orig_clock.json | 73 +++++++++ .../Data/orig_compass.json | 41 +++++ .../Python/common.py | 60 ++++++++ .../item/artifacts/pocketwatchofshreep.py | 17 +++ .../Python/do2/models/item/compass.py | 20 +++ .../Python/do2/models/item/gui_map.py | 11 ++ .../item/artifacts/pocketwatchofshreep.py | 45 ++++++ .../Python/do2/textures/item/compass.py | 144 ++++++++++++++++++ .../Python/do2/textures/item/gui_map.py | 5 + .../Python/main.py | 15 ++ .../Python/minecraft/models/item/clock.py | 14 ++ .../Python/minecraft/models/item/compass.py | 19 +++ .../minecraft/models/item/filled_map.py | 18 +++ .../Python/resource_pack.py | 87 +++++++++++ .../pack.mcmeta | 6 + 26 files changed, 581 insertions(+), 2 deletions(-) create mode 100644 Decked Out 2 Sprites Resource Pack/.gitignore create mode 100644 Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_blackrock.png create mode 100644 Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_frozen.png create mode 100644 Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_warped.png create mode 100644 Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_wooden.png create mode 100644 Decked Out 2 Sprites Resource Pack/Data/Compass/compass_mask.png create mode 100644 Decked Out 2 Sprites Resource Pack/Data/Watch/watch.png create mode 100644 Decked Out 2 Sprites Resource Pack/Data/Watch/watch_face.png create mode 100644 Decked Out 2 Sprites Resource Pack/Data/Watch/watch_mask.png create mode 100644 Decked Out 2 Sprites Resource Pack/Data/gui_map.png create mode 100644 Decked Out 2 Sprites Resource Pack/Data/orig_clock.json create mode 100644 Decked Out 2 Sprites Resource Pack/Data/orig_compass.json create mode 100644 Decked Out 2 Sprites Resource Pack/Python/common.py create mode 100644 Decked Out 2 Sprites Resource Pack/Python/do2/models/item/artifacts/pocketwatchofshreep.py create mode 100644 Decked Out 2 Sprites Resource Pack/Python/do2/models/item/compass.py create mode 100644 Decked Out 2 Sprites Resource Pack/Python/do2/models/item/gui_map.py create mode 100644 Decked Out 2 Sprites Resource Pack/Python/do2/textures/item/artifacts/pocketwatchofshreep.py create mode 100644 Decked Out 2 Sprites Resource Pack/Python/do2/textures/item/compass.py create mode 100644 Decked Out 2 Sprites Resource Pack/Python/do2/textures/item/gui_map.py create mode 100644 Decked Out 2 Sprites Resource Pack/Python/main.py create mode 100644 Decked Out 2 Sprites Resource Pack/Python/minecraft/models/item/clock.py create mode 100644 Decked Out 2 Sprites Resource Pack/Python/minecraft/models/item/compass.py create mode 100644 Decked Out 2 Sprites Resource Pack/Python/minecraft/models/item/filled_map.py create mode 100644 Decked Out 2 Sprites Resource Pack/Python/resource_pack.py create mode 100644 Decked Out 2 Sprites Resource Pack/pack.mcmeta diff --git a/.gitignore b/.gitignore index c3b46ea..ca916c2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,4 @@ _*.py /Decked Out 2 Audio Resource Pack /Decked Out 2 Catacombs /Decked Out 2 Egg Hunt/Advancements Datapack -/Decked Out 2 Datapack -/Decked Out 2 Sprites Resource Pack \ No newline at end of file +/Decked Out 2 Datapack \ No newline at end of file diff --git a/Decked Out 2 Sprites Resource Pack/.gitignore b/Decked Out 2 Sprites Resource Pack/.gitignore new file mode 100644 index 0000000..f61c7d3 --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/.gitignore @@ -0,0 +1,5 @@ +# _ prefix used for untracked files +_* + +# Dont push assets for now +assets/ \ No newline at end of file diff --git a/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_blackrock.png b/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_blackrock.png new file mode 100644 index 0000000000000000000000000000000000000000..1ed433e84bf3dbfb44fc97a87fb2e083b2f4af79 GIT binary patch literal 328 zcmV-O0k{5%P)5xLcslnFN9U&I2uT3u7h3iPt^4CKK)xPEZg3;>gGOc;0U-2#%I=+~Q1 zPw5qah|%v2^gVN@)y*Yj0gdJ>=F?#*q|@qZlY~*l9F&p(fa5`--y7)pbZEg!No?1l zjWOFnE=EcjTtC2e9p;QiW_i(Wm5(tC0f6?~JB|m1<>C{rAJ`>FyA=Rf^UbepK$prI a|Buey9F2tj6tl4a00005y^& literal 0 HcmV?d00001 diff --git a/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_frozen.png b/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_frozen.png new file mode 100644 index 0000000000000000000000000000000000000000..e8dc3153c56885d5a2816c62612309ca34ca5cb6 GIT binary patch literal 475 zcmV<10VMv3P)$=`77K`;tr83-R zz8#Cj#-6^;hJXJ##mel+|L}+qY?|gN5$)Y}GZ8gR({v+3aI1kwM7!M8it_(;6kAgQc67>j4uQM;Mbw|&tR?OTi@%R z-DrH9{It`Dx8o-v$8mZ9KuUR$u9U)~k$KdQe8`52mlLD51t9P)5tsr1YthhF-@m}C zcpTMg^~(Cs5?S;-_VHwZVJ#Y$3tubwR_h!Qg4^HHdX2C9+ciFZxuftl`~|Q`rp=`} RXEy)<002ovPDHLkV1mKz+64dr literal 0 HcmV?d00001 diff --git a/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_warped.png b/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_warped.png new file mode 100644 index 0000000000000000000000000000000000000000..a190f0116e5b41647843c912495809ad6bca9138 GIT binary patch literal 430 zcmV;f0a5;mP)^aLj`&+FC@o?vb@3p!C1lz@i#!WiHGM0 zm8!Y|0RH(Y`619US)np2Fgxe7di~BjJ4yA*!};9{*>l!;bW)`a2d!d(bOl-_D^yM? zZ+9Nu(xo|UW+T0JkEz5AZ8&nPSRm48&Y5o9j)DQeEnOy2v7RL74FI47JAxTq`t9a< zbb|7Bi+_NDAqIrEc1ojQeRI34#A3;S?Fz^ZfstNK#gC592f>lO{cAEGO|pg)blx2S z0Ki;Vm8;gq?7?9T0Q0#})K-(Q__XM}SRwBFnlwKKUheY;S|%%u$T(mwqOCvS^Zp1m zJ+R3s&{`D$AQ%Pn{jX>2l>oq)xd1s5LC1QAq=zBDR?x9+wB?V619;#o2cqxQ3;v&a Y2Y4Nt=`dBhp8x;=07*qoM6N<$f;2_HbpQYW literal 0 HcmV?d00001 diff --git a/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_wooden.png b/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_wooden.png new file mode 100644 index 0000000000000000000000000000000000000000..e04f74ee0efc10e5bdc6d6ac1de27dbefd46bedd GIT binary patch literal 541 zcmV+&0^{yA1w2CT$FY^(;fP)0B9NJ5#Uxm)aV`qn@dkug@#(g3P zfH0FM*JI@FlUJXIza6-BVc|qkg%3t6$r7zWK$;kGE)3#QH)@-i7?bPc48fG$Jl%nQr(i&Bvdh~LG_cAO^Oy9Dc z+uo^qV=fva+&D8Qjm+Y4ca#2>#=R?xYE=2SRn*XgqiWKyR^#sFMfub6{i`QUV2MTP z#|aS4PZ2_37y~@Gxx~imQ_TFSs)MOr2*Gp0g2P4WK5`TxnxY7-qnohc^A3z4zTkYXZ= zX)|gP9I&AYHCCLOF~*7+(+^}iqDcv)Gm?Qw@P-TJvagvaR7j?>bKErH~QiBcwo}A2m}UE(bzRf=&iqXJn&;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GbN=0Lb$KIWx}var^dd_V@Rx>lzWk`-Wgj%%)@S-~(cx(uSM|`A1xt zT<2(Um*H|79ruav_qcrTAub#E^2*FKgA`FZeCy1#*5bYY3dpCQe#(s-H+cX3_j%`? zcX;^lAz3e@s0xnf2h>GDT~v(O;UBzBA}Nc#Te#4&o4&*_xy)cNAwD{)qBvvp<-Sp) zA@$Ym^Hp%}S=l6AK+q-w%7bBmqv zQ>3!(dhuBL*&s@K19UdYzmbGrJFjU?9LG54aL!Q_U3emEdH%+;e0=v`7-JZXhB)VF z+IC$_9w8ujS_%%rT^^NRKqFeYKnPB^O+mXV!($mZE3@gCvaD#GM-a5uMAk4J_W5Fe z{+KV-nJ!})t7}}>KV>u7MTJN%4B&qw9T-E*W%WFp>N-C#fb(!H`XVnrwLRq0xOX9? zFI=Bp7=Ylo(9w0=@6n4a<9?6Ds-kXBt3yO+oRG$v%Ucuv{@J4vNH5I7|1$*N`g8h2 a%YOj5QbU3zBwP*v0000sIP~dRZ{l5S6 zx6S;?n>wAl+^QIUv9Ne~E-kzKH6zR>!?&H8c?MHLZ7x5{yk}Az6|=u995DFbBrt8~ zDi)s4X52!y;V&3+r#Tx1I4dmr`O3~>J^Q(TtgAdd^f|MI_US7BEOyzE+OW4v^LxWf prASF(|T|gHxc)I$ztaD0e0sz|E+_s0nMFy9lYc<=jE=#r*qT8{%+$gFVO0pkXyR_Se;sqB+yzy_UbuA*CDE7$8=(b@L=Ty z&)+^mP~?(2+szg~_CM38SJdeVcUGUs#f4i)*T=q`C2mJZm>S1^NH`7{3;Z1T_`mvi z-#*Z&SJY&PN*V3F4P;Jd*z6GmAqPhzg0Wzk2EG1({V(ei@E;-GU3(fChoj)aVgc0| zk+|Y8^nHB)i0 0.5 +WATCH_FACE = read_image("Watch/watch_face.png") + +WATCH_CENTER = 15, 16 +WATCH_SIZE = 32, 32 + + +def _rotate(image, angle, center=(16, 16)): + rotation_matrix = cv2.getRotationMatrix2D(center, angle, 1.0) + return cv2.warpAffine(image, rotation_matrix, WATCH_SIZE, flags=cv2.INTER_LANCZOS4) + + +def _create_clock(index): + texture_name = f"clock_{index:02d}" + + @image(name=texture_name) + def _(): + angle = 57.5 - index * 360 / 64 + + face = _rotate(WATCH_FACE, angle, WATCH_CENTER) + + alpha = WATCH[..., -1].copy() + output_alpha = alpha.copy() + + alpha[~WATCH_MASK] = 1.0 + alpha = alpha[..., np.newaxis] + output_alpha[WATCH_MASK] = 1.0 + + output = alpha * WATCH + (1 - alpha) * face + output[..., -1] = output_alpha + output = output.clip(0, 1) + + return output + + +for index in range(64): + _create_clock(index) diff --git a/Decked Out 2 Sprites Resource Pack/Python/do2/textures/item/compass.py b/Decked Out 2 Sprites Resource Pack/Python/do2/textures/item/compass.py new file mode 100644 index 0000000..fc7d45a --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Python/do2/textures/item/compass.py @@ -0,0 +1,144 @@ +import cv2 +import numpy as np + +import common +from resource_pack import mcmeta, image + + +SETTINGS = { + "blue_ice": {"size": (11, 11), "offset": (4, 8)}, + "magma": { + "size": (11, 11), + "offset": (12, 10), + # "update": {"frametime": 5}, + }, + "sculk": { + "size": (11, 11), + "offset": (9, 5), + "update": {"frametime": 15}, + }, + "soul_fire_0": { + "size": (10, 10), + "offset": (7, 0), + "update": {"frametime": 3, "interpolate": True}, + }, +} + + +COMPASS_MASK = common.read_image("Compass/compass_mask.png")[..., 3] > 0.5 + + +def _needle(): + needle = [] + + for index in range(32): + needle.append(common.read_item_texture(f"compass_{index:02d}.png")) + + needle = np.stack(needle, axis=0) + median_needle = np.median(needle, axis=0) + + mask = np.any(needle != median_needle, axis=-1) + needle[..., -1] = 0.33 * mask + mask = (needle[..., 0] > 0.7) & (needle[..., 1] < 0.1) & (needle[..., 2] < 0.1) + needle[mask, -1] = 1.0 + return needle + + +def _yellow(needle): + return needle[..., [0, 0, 1, 3]] + + +COMPASS_NEEDLE = _needle() +COMPASS_NEEDLE_YELLOW = _yellow(COMPASS_NEEDLE) + + +def _animate_ice(face): + face = np.concatenate([face, face], axis=1) + face = np.concatenate([face, face], axis=0) + + face = np.concatenate( + [ + face[:, :][:16, :16], + face[15:, :][:16, :16], + face[15:, 1:][:16, :16], + ], + axis=0, + ) + + return face + + +def _blend(top, bottom, mask=None): + alpha = top[..., -1][..., np.newaxis] + + ret = alpha * top + (1 - alpha) * bottom + if mask is not None: + ret[~mask] = 0.0 + ret[mask, -1] = 1.0 + return ret.clip(0, 1) + + +def _create_compass_level(level): + FACE_NAME = {1: "blue_ice", 2: "magma", 3: "sculk", 4: "soul_fire_0"}[level] + FACE_PATH = f"{FACE_NAME}.png" + + COMPASS_FRAME_NAME = { + 1: "frozen", + 2: "blackrock", + 3: "wooden", + 4: "warped", + }[level] + + COMPASS_FRAME = common.read_image(f"Compass/compass_frame_{COMPASS_FRAME_NAME}.png") + COMPASS_FACE = common.read_block_texture(FACE_PATH) + + if level == 1: + COMPASS_FACE = _animate_ice(COMPASS_FACE) + MCMETA = {"animation": {"frametime": 80, "interpolate": True}} + else: + MCMETA = common.read_block_texture_mcmeta(FACE_PATH) + + def _create_compass(index): + texture_name = f"level{level}/compass_{index:02d}" + + @image(name=texture_name) + def _(): + settings = SETTINGS[FACE_NAME] + frames = [] + n_frames = COMPASS_FACE.shape[0] // 16 + + w, h = settings["size"] + x, y = settings["offset"] + + for i in range(n_frames): + face = COMPASS_FACE[16 * i :][:16, :16] + face = np.concatenate([face, face, face], axis=1) + face = np.concatenate([face, face, face], axis=0) + face = cv2.resize(face, (3 * w, 3 * h), interpolation=cv2.INTER_CUBIC) + face = face[y:, x:][:16, :16] + + canvas = np.zeros((16, 16, 4), dtype="f4") + canvas = _blend(face, canvas, COMPASS_MASK) + canvas = _blend(COMPASS_FRAME, canvas, None) + + if level == 2: + needle = COMPASS_NEEDLE_YELLOW[index] + else: + needle = COMPASS_NEEDLE[index] + + canvas = _blend(needle, canvas, None) + frames.append(canvas) + + output = np.concatenate(frames, axis=0) + return output.clip(0, 1) + + @mcmeta(name=texture_name) + def _(): + return MCMETA + + for index in range(32): + _create_compass(index) + + +for level in [1, 2, 3, 4]: + _create_compass_level(level) diff --git a/Decked Out 2 Sprites Resource Pack/Python/do2/textures/item/gui_map.py b/Decked Out 2 Sprites Resource Pack/Python/do2/textures/item/gui_map.py new file mode 100644 index 0000000..140dbc5 --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Python/do2/textures/item/gui_map.py @@ -0,0 +1,5 @@ +from resource_pack import image + +@image +def _(): + return "gui_map.png" \ No newline at end of file diff --git a/Decked Out 2 Sprites Resource Pack/Python/main.py b/Decked Out 2 Sprites Resource Pack/Python/main.py new file mode 100644 index 0000000..bf00a5e --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Python/main.py @@ -0,0 +1,15 @@ +# import do2.models.item.artifacts.pocketwatchofshreep +# import do2.models.item.compass +import do2.models.item.gui_map +# import do2.textures.item.artifacts.pocketwatchofshreep +import do2.textures.item.compass +import do2.textures.item.gui_map +import minecraft.models.item.clock +import minecraft.models.item.compass +import minecraft.models.item.filled_map + +import resource_pack + + +if __name__ == "__main__": + resource_pack.save(verbose=True) diff --git a/Decked Out 2 Sprites Resource Pack/Python/minecraft/models/item/clock.py b/Decked Out 2 Sprites Resource Pack/Python/minecraft/models/item/clock.py new file mode 100644 index 0000000..707af09 --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Python/minecraft/models/item/clock.py @@ -0,0 +1,14 @@ +from common import read_json, extend_overrides +from resource_pack import json + + +@json +def _(): + clock = read_json("orig_clock.json") + + clock["overrides"] = extend_overrides( + clock["overrides"], + {1: lambda m: m.replace("item/", f"do2:item/artifacts/pocketwatchofshreep/")}, + ) + + return clock diff --git a/Decked Out 2 Sprites Resource Pack/Python/minecraft/models/item/compass.py b/Decked Out 2 Sprites Resource Pack/Python/minecraft/models/item/compass.py new file mode 100644 index 0000000..8fca599 --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Python/minecraft/models/item/compass.py @@ -0,0 +1,19 @@ +from common import read_json, extend_overrides +from resource_pack import json + + +@json +def _(): + compass = read_json("orig_compass.json") + + compass["overrides"] = extend_overrides( + compass["overrides"], + { + 1: lambda m: m.replace("item/", f"do2:item/compass/level1/"), + 2: lambda m: m.replace("item/", f"do2:item/compass/level2/"), + 3: lambda m: m.replace("item/", f"do2:item/compass/level3/"), + 4: lambda m: m.replace("item/", f"do2:item/compass/level4/"), + }, + ) + + return compass diff --git a/Decked Out 2 Sprites Resource Pack/Python/minecraft/models/item/filled_map.py b/Decked Out 2 Sprites Resource Pack/Python/minecraft/models/item/filled_map.py new file mode 100644 index 0000000..1e36a47 --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Python/minecraft/models/item/filled_map.py @@ -0,0 +1,18 @@ +from resource_pack import json + + +@json +def _(): + return { + "parent": "item/generated", + "textures": { + "layer0": "item/filled_map", + "layer1": "item/filled_map_markings", + }, + "overrides": [ + { + "predicate": {"custom_model_data": 201}, + "model": "do2:item/gui_map", + } + ], + } diff --git a/Decked Out 2 Sprites Resource Pack/Python/resource_pack.py b/Decked Out 2 Sprites Resource Pack/Python/resource_pack.py new file mode 100644 index 0000000..75d4db9 --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Python/resource_pack.py @@ -0,0 +1,87 @@ +import functools as _functools +import json as _json +import matplotlib.pyplot as plt +from pathlib import Path as _Path +import shutil + +import common + + +_ROOT = _Path(__file__).parents[1] / "assets" +_ASSETS = [] + + +def _get_asset_desc(call, *, name): + if name is None: + name = call.__qualname__.split(".") + else: + name = name.split("/") + + parts = call.__module__.split(".") + name + parts = [p for p in parts if p != "_"] + + asset_type = parts[1] + assert asset_type in {"models", "textures"} + return parts[0] + ":" + "/".join(parts[2:]), asset_type + + +def _get_asset_path(asset_name, asset_type, ext): + return _ROOT / (asset_name.replace(":", f"/{asset_type}/") + f".{ext}") + + +def _create_func(save_func, ext): + def _decorator(call=None, *, skip=False, name=None): + if call is None: + return _functools.partial(_decorator, skip=skip, name=name) + + asset_name, asset_type = _get_asset_desc(call, name=name) + + class Call: + SAVE = staticmethod(save_func) + EXT = ext + + def __call__(self): + return call() + + def __str__(self): + return asset_name + + ret = Call() + + if not skip: + _ASSETS.append((asset_name, asset_type, ret)) + + return ret + + return _decorator + + +def _save_json(path, call): + with open(path, "wt", encoding="utf-8") as fd: + value = call() + _json.dump(value, fd) + + +def _save_image(path, call): + image = call() + + if isinstance(image, str): + shutil.copy2(common.get_path(image), path) + else: + plt.imsave(path, image) + + +json = _create_func(_save_json, "json") +mcmeta = _create_func(_save_json, "png.mcmeta") +image = _create_func(_save_image, "png") + + +def save(verbose=False): + for asset_name, asset_type, asset_call in _ASSETS: + path = _get_asset_path(asset_name, asset_type, asset_call.EXT) + path.parent.mkdir(exist_ok=True, parents=True) + + if verbose: + print(path.relative_to(_ROOT)) + + asset_call.SAVE(path, asset_call) diff --git a/Decked Out 2 Sprites Resource Pack/pack.mcmeta b/Decked Out 2 Sprites Resource Pack/pack.mcmeta new file mode 100644 index 0000000..27d453b --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "pack_format": 15, + "description": "Decked Out 2 Additions Resource Pack" + } +} \ No newline at end of file