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 0000000..1ed433e Binary files /dev/null and b/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_blackrock.png differ 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 0000000..e8dc315 Binary files /dev/null and b/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_frozen.png differ 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 0000000..a190f01 Binary files /dev/null and b/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_warped.png differ 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 0000000..e04f74e Binary files /dev/null and b/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_frame_wooden.png differ diff --git a/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_mask.png b/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_mask.png new file mode 100644 index 0000000..7966d35 Binary files /dev/null and b/Decked Out 2 Sprites Resource Pack/Data/Compass/compass_mask.png differ diff --git a/Decked Out 2 Sprites Resource Pack/Data/Watch/watch.png b/Decked Out 2 Sprites Resource Pack/Data/Watch/watch.png new file mode 100644 index 0000000..2e6a9dd Binary files /dev/null and b/Decked Out 2 Sprites Resource Pack/Data/Watch/watch.png differ diff --git a/Decked Out 2 Sprites Resource Pack/Data/Watch/watch_face.png b/Decked Out 2 Sprites Resource Pack/Data/Watch/watch_face.png new file mode 100644 index 0000000..aa60b06 Binary files /dev/null and b/Decked Out 2 Sprites Resource Pack/Data/Watch/watch_face.png differ diff --git a/Decked Out 2 Sprites Resource Pack/Data/Watch/watch_mask.png b/Decked Out 2 Sprites Resource Pack/Data/Watch/watch_mask.png new file mode 100644 index 0000000..b0736de Binary files /dev/null and b/Decked Out 2 Sprites Resource Pack/Data/Watch/watch_mask.png differ diff --git a/Decked Out 2 Sprites Resource Pack/Data/gui_map.png b/Decked Out 2 Sprites Resource Pack/Data/gui_map.png new file mode 100644 index 0000000..2e16595 Binary files /dev/null and b/Decked Out 2 Sprites Resource Pack/Data/gui_map.png differ diff --git a/Decked Out 2 Sprites Resource Pack/Data/orig_clock.json b/Decked Out 2 Sprites Resource Pack/Data/orig_clock.json new file mode 100644 index 0000000..407b8aa --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Data/orig_clock.json @@ -0,0 +1,73 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "item/clock_00" + }, + "overrides": [ + { "predicate": { "time": 0.0000000 }, "model": "item/clock" }, + { "predicate": { "time": 0.0078125 }, "model": "item/clock_01" }, + { "predicate": { "time": 0.0234375 }, "model": "item/clock_02" }, + { "predicate": { "time": 0.0390625 }, "model": "item/clock_03" }, + { "predicate": { "time": 0.0546875 }, "model": "item/clock_04" }, + { "predicate": { "time": 0.0703125 }, "model": "item/clock_05" }, + { "predicate": { "time": 0.0859375 }, "model": "item/clock_06" }, + { "predicate": { "time": 0.1015625 }, "model": "item/clock_07" }, + { "predicate": { "time": 0.1171875 }, "model": "item/clock_08" }, + { "predicate": { "time": 0.1328125 }, "model": "item/clock_09" }, + { "predicate": { "time": 0.1484375 }, "model": "item/clock_10" }, + { "predicate": { "time": 0.1640625 }, "model": "item/clock_11" }, + { "predicate": { "time": 0.1796875 }, "model": "item/clock_12" }, + { "predicate": { "time": 0.1953125 }, "model": "item/clock_13" }, + { "predicate": { "time": 0.2109375 }, "model": "item/clock_14" }, + { "predicate": { "time": 0.2265625 }, "model": "item/clock_15" }, + { "predicate": { "time": 0.2421875 }, "model": "item/clock_16" }, + { "predicate": { "time": 0.2578125 }, "model": "item/clock_17" }, + { "predicate": { "time": 0.2734375 }, "model": "item/clock_18" }, + { "predicate": { "time": 0.2890625 }, "model": "item/clock_19" }, + { "predicate": { "time": 0.3046875 }, "model": "item/clock_20" }, + { "predicate": { "time": 0.3203125 }, "model": "item/clock_21" }, + { "predicate": { "time": 0.3359375 }, "model": "item/clock_22" }, + { "predicate": { "time": 0.3515625 }, "model": "item/clock_23" }, + { "predicate": { "time": 0.3671875 }, "model": "item/clock_24" }, + { "predicate": { "time": 0.3828125 }, "model": "item/clock_25" }, + { "predicate": { "time": 0.3984375 }, "model": "item/clock_26" }, + { "predicate": { "time": 0.4140625 }, "model": "item/clock_27" }, + { "predicate": { "time": 0.4296875 }, "model": "item/clock_28" }, + { "predicate": { "time": 0.4453125 }, "model": "item/clock_29" }, + { "predicate": { "time": 0.4609375 }, "model": "item/clock_30" }, + { "predicate": { "time": 0.4765625 }, "model": "item/clock_31" }, + { "predicate": { "time": 0.4921875 }, "model": "item/clock_32" }, + { "predicate": { "time": 0.5078125 }, "model": "item/clock_33" }, + { "predicate": { "time": 0.5234375 }, "model": "item/clock_34" }, + { "predicate": { "time": 0.5390625 }, "model": "item/clock_35" }, + { "predicate": { "time": 0.5546875 }, "model": "item/clock_36" }, + { "predicate": { "time": 0.5703125 }, "model": "item/clock_37" }, + { "predicate": { "time": 0.5859375 }, "model": "item/clock_38" }, + { "predicate": { "time": 0.6015625 }, "model": "item/clock_39" }, + { "predicate": { "time": 0.6171875 }, "model": "item/clock_40" }, + { "predicate": { "time": 0.6328125 }, "model": "item/clock_41" }, + { "predicate": { "time": 0.6484375 }, "model": "item/clock_42" }, + { "predicate": { "time": 0.6640625 }, "model": "item/clock_43" }, + { "predicate": { "time": 0.6796875 }, "model": "item/clock_44" }, + { "predicate": { "time": 0.6953125 }, "model": "item/clock_45" }, + { "predicate": { "time": 0.7109375 }, "model": "item/clock_46" }, + { "predicate": { "time": 0.7265625 }, "model": "item/clock_47" }, + { "predicate": { "time": 0.7421875 }, "model": "item/clock_48" }, + { "predicate": { "time": 0.7578125 }, "model": "item/clock_49" }, + { "predicate": { "time": 0.7734375 }, "model": "item/clock_50" }, + { "predicate": { "time": 0.7890625 }, "model": "item/clock_51" }, + { "predicate": { "time": 0.8046875 }, "model": "item/clock_52" }, + { "predicate": { "time": 0.8203125 }, "model": "item/clock_53" }, + { "predicate": { "time": 0.8359375 }, "model": "item/clock_54" }, + { "predicate": { "time": 0.8515625 }, "model": "item/clock_55" }, + { "predicate": { "time": 0.8671875 }, "model": "item/clock_56" }, + { "predicate": { "time": 0.8828125 }, "model": "item/clock_57" }, + { "predicate": { "time": 0.8984375 }, "model": "item/clock_58" }, + { "predicate": { "time": 0.9140625 }, "model": "item/clock_59" }, + { "predicate": { "time": 0.9296875 }, "model": "item/clock_60" }, + { "predicate": { "time": 0.9453125 }, "model": "item/clock_61" }, + { "predicate": { "time": 0.9609375 }, "model": "item/clock_62" }, + { "predicate": { "time": 0.9765625 }, "model": "item/clock_63" }, + { "predicate": { "time": 0.9921875 }, "model": "item/clock" } + ] +} diff --git a/Decked Out 2 Sprites Resource Pack/Data/orig_compass.json b/Decked Out 2 Sprites Resource Pack/Data/orig_compass.json new file mode 100644 index 0000000..ec66bb1 --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Data/orig_compass.json @@ -0,0 +1,41 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "item/compass_16" + }, + "overrides": [ + { "predicate": { "angle": 0.000000 }, "model": "item/compass" }, + { "predicate": { "angle": 0.015625 }, "model": "item/compass_17" }, + { "predicate": { "angle": 0.046875 }, "model": "item/compass_18" }, + { "predicate": { "angle": 0.078125 }, "model": "item/compass_19" }, + { "predicate": { "angle": 0.109375 }, "model": "item/compass_20" }, + { "predicate": { "angle": 0.140625 }, "model": "item/compass_21" }, + { "predicate": { "angle": 0.171875 }, "model": "item/compass_22" }, + { "predicate": { "angle": 0.203125 }, "model": "item/compass_23" }, + { "predicate": { "angle": 0.234375 }, "model": "item/compass_24" }, + { "predicate": { "angle": 0.265625 }, "model": "item/compass_25" }, + { "predicate": { "angle": 0.296875 }, "model": "item/compass_26" }, + { "predicate": { "angle": 0.328125 }, "model": "item/compass_27" }, + { "predicate": { "angle": 0.359375 }, "model": "item/compass_28" }, + { "predicate": { "angle": 0.390625 }, "model": "item/compass_29" }, + { "predicate": { "angle": 0.421875 }, "model": "item/compass_30" }, + { "predicate": { "angle": 0.453125 }, "model": "item/compass_31" }, + { "predicate": { "angle": 0.484375 }, "model": "item/compass_00" }, + { "predicate": { "angle": 0.515625 }, "model": "item/compass_01" }, + { "predicate": { "angle": 0.546875 }, "model": "item/compass_02" }, + { "predicate": { "angle": 0.578125 }, "model": "item/compass_03" }, + { "predicate": { "angle": 0.609375 }, "model": "item/compass_04" }, + { "predicate": { "angle": 0.640625 }, "model": "item/compass_05" }, + { "predicate": { "angle": 0.671875 }, "model": "item/compass_06" }, + { "predicate": { "angle": 0.703125 }, "model": "item/compass_07" }, + { "predicate": { "angle": 0.734375 }, "model": "item/compass_08" }, + { "predicate": { "angle": 0.765625 }, "model": "item/compass_09" }, + { "predicate": { "angle": 0.796875 }, "model": "item/compass_10" }, + { "predicate": { "angle": 0.828125 }, "model": "item/compass_11" }, + { "predicate": { "angle": 0.859375 }, "model": "item/compass_12" }, + { "predicate": { "angle": 0.890625 }, "model": "item/compass_13" }, + { "predicate": { "angle": 0.921875 }, "model": "item/compass_14" }, + { "predicate": { "angle": 0.953125 }, "model": "item/compass_15" }, + { "predicate": { "angle": 0.984375 }, "model": "item/compass" } + ] +} diff --git a/Decked Out 2 Sprites Resource Pack/Python/common.py b/Decked Out 2 Sprites Resource Pack/Python/common.py new file mode 100644 index 0000000..350c359 --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Python/common.py @@ -0,0 +1,60 @@ +import copy +import json +from pathlib import Path + +import matplotlib.pyplot as plt + + +_DATA_PATH = Path(__file__).parents[1] / "Data" +_SOURCES_ROOT = _DATA_PATH.parents[3] +_ITEM_TEXTURES = ( + _SOURCES_ROOT / "Minecraft/Data/Versions/1.20.1/assets/minecraft/textures/item" +) +_BLOCK_TEXTURES = ( + _SOURCES_ROOT / "Minecraft/Data/Versions/1.20.1/assets/minecraft/textures/block" +) + + +def get_path(path): + return _DATA_PATH / path + + +def read_image(path): + return plt.imread(get_path(path)) + + +def read_item_texture(path): + return plt.imread(_ITEM_TEXTURES / path) + + +def read_block_texture(path): + return plt.imread(_BLOCK_TEXTURES / path) + + +def read_block_texture_mcmeta(path): + try: + with open(_BLOCK_TEXTURES / (path + ".mcmeta"), "rt", encoding="utf-8") as fd: + return json.load(fd) + + except FileNotFoundError: + return None + + +def read_json(path): + with open(get_path(path), "rt", encoding="utf-8") as fd: + return json.load(fd) + + +def extend_overrides(overrides, replace): + ret = [] + + for override in overrides: + ret.append(override) + + for model, func in replace.items(): + new_override = copy.deepcopy(override) + new_override["predicate"]["custom_model_data"] = model + new_override["model"] = func(override["model"]) + ret.append(new_override) + + return ret diff --git a/Decked Out 2 Sprites Resource Pack/Python/do2/models/item/artifacts/pocketwatchofshreep.py b/Decked Out 2 Sprites Resource Pack/Python/do2/models/item/artifacts/pocketwatchofshreep.py new file mode 100644 index 0000000..afba955 --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Python/do2/models/item/artifacts/pocketwatchofshreep.py @@ -0,0 +1,17 @@ +from resource_pack import json + + +def _create_clock(index): + model_name = "clock" if index == 0 else f"clock_{index:02d}" + texture_name = f"do2:item/artifacts/pocketwatchofshreep/clock_{index:02d}" + + @json(name=model_name) + def _(): + return { + "parent": "minecraft:item/generated", + "textures": {"layer0": texture_name}, + } + + +for index in range(64): + _create_clock(index) diff --git a/Decked Out 2 Sprites Resource Pack/Python/do2/models/item/compass.py b/Decked Out 2 Sprites Resource Pack/Python/do2/models/item/compass.py new file mode 100644 index 0000000..ddcb090 --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Python/do2/models/item/compass.py @@ -0,0 +1,20 @@ +from resource_pack import json + + +def _create_compass(level, index): + model_name = ( + f"level{level}/compass" if index == 16 else f"level{level}/compass_{index:02d}" + ) + texture_name = f"do2:item/compass/level{level}/compass_{index:02d}" + + @json(name=model_name) + def _(): + return { + "parent": "minecraft:item/generated", + "textures": {"layer0": texture_name}, + } + + +for level in [1, 2, 3, 4]: + for index in range(32): + _create_compass(level, index) diff --git a/Decked Out 2 Sprites Resource Pack/Python/do2/models/item/gui_map.py b/Decked Out 2 Sprites Resource Pack/Python/do2/models/item/gui_map.py new file mode 100644 index 0000000..4b18d9d --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Python/do2/models/item/gui_map.py @@ -0,0 +1,11 @@ +from resource_pack import json + + +@json +def _(): + return { + "parent": "item/generated", + "textures": { + "layer0": "do2:item/gui_map", + }, + } diff --git a/Decked Out 2 Sprites Resource Pack/Python/do2/textures/item/artifacts/pocketwatchofshreep.py b/Decked Out 2 Sprites Resource Pack/Python/do2/textures/item/artifacts/pocketwatchofshreep.py new file mode 100644 index 0000000..748fce1 --- /dev/null +++ b/Decked Out 2 Sprites Resource Pack/Python/do2/textures/item/artifacts/pocketwatchofshreep.py @@ -0,0 +1,45 @@ +import cv2 +import numpy as np + +from resource_pack import image +from common import read_image + + +WATCH = read_image("Watch/watch.png") +WATCH_MASK = read_image("Watch/watch_mask.png")[..., 3] > 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