Skip to content

Commit

Permalink
Added custom textures resource pack
Browse files Browse the repository at this point in the history
  • Loading branch information
Noxitu committed Jan 12, 2024
1 parent 28cad0e commit cd08a8e
Show file tree
Hide file tree
Showing 26 changed files with 581 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
/Decked Out 2 Datapack
5 changes: 5 additions & 0 deletions Decked Out 2 Sprites Resource Pack/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# _ prefix used for untracked files
_*

# Dont push assets for now
assets/
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 Decked Out 2 Sprites Resource Pack/Data/gui_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions Decked Out 2 Sprites Resource Pack/Data/orig_clock.json
Original file line number Diff line number Diff line change
@@ -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" }
]
}
41 changes: 41 additions & 0 deletions Decked Out 2 Sprites Resource Pack/Data/orig_compass.json
Original file line number Diff line number Diff line change
@@ -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" }
]
}
60 changes: 60 additions & 0 deletions Decked Out 2 Sprites Resource Pack/Python/common.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from resource_pack import json


@json
def _():
return {
"parent": "item/generated",
"textures": {
"layer0": "do2:item/gui_map",
},
}
Original file line number Diff line number Diff line change
@@ -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)
Loading

0 comments on commit cd08a8e

Please sign in to comment.