Skip to content

Commit 0776bf0

Browse files
committed
textures: fix various small nitpicks
- don't redundantly declare a side image when it's the same as top - change wood blocks to get textures from a dict
1 parent ba17369 commit 0776bf0

File tree

1 file changed

+65
-124
lines changed

1 file changed

+65
-124
lines changed

overviewer_core/textures.py

Lines changed: 65 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
from . import util
3131

3232

33+
BLOCKTEX = "assets/minecraft/textures/block/"
34+
3335
# global variables to collate information in @material decorators
3436
blockmap_generators = {}
3537

@@ -1090,125 +1092,67 @@ def wood(self, blockid, data):
10901092
if wood_orientation == 4: wood_orientation = 8
10911093
elif wood_orientation == 8: wood_orientation = 4
10921094

1093-
# choose textures
1094-
if blockid == 17: # regular wood:
1095-
if wood_type == 0: # normal
1096-
top = self.load_image_texture("assets/minecraft/textures/block/oak_log_top.png")
1097-
side = self.load_image_texture("assets/minecraft/textures/block/oak_log.png")
1098-
if wood_type == 1: # spruce
1099-
top = self.load_image_texture("assets/minecraft/textures/block/spruce_log_top.png")
1100-
side = self.load_image_texture("assets/minecraft/textures/block/spruce_log.png")
1101-
if wood_type == 2: # birch
1102-
top = self.load_image_texture("assets/minecraft/textures/block/birch_log_top.png")
1103-
side = self.load_image_texture("assets/minecraft/textures/block/birch_log.png")
1104-
if wood_type == 3: # jungle wood
1105-
top = self.load_image_texture("assets/minecraft/textures/block/jungle_log_top.png")
1106-
side = self.load_image_texture("assets/minecraft/textures/block/jungle_log.png")
1107-
elif blockid == 162: # acacia/dark wood:
1108-
if wood_type == 0: # acacia
1109-
top = self.load_image_texture("assets/minecraft/textures/block/acacia_log_top.png")
1110-
side = self.load_image_texture("assets/minecraft/textures/block/acacia_log.png")
1111-
elif wood_type == 1: # dark oak
1112-
top = self.load_image_texture("assets/minecraft/textures/block/dark_oak_log_top.png")
1113-
side = self.load_image_texture("assets/minecraft/textures/block/dark_oak_log.png")
1114-
else:
1115-
top = self.load_image_texture("assets/minecraft/textures/block/acacia_log_top.png")
1116-
side = self.load_image_texture("assets/minecraft/textures/block/acacia_log.png")
1117-
if blockid == 11306: # stripped regular wood:
1118-
if wood_type == 0: # normal
1119-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_oak_log_top.png")
1120-
side = self.load_image_texture("assets/minecraft/textures/block/stripped_oak_log.png")
1121-
if wood_type == 1: # spruce
1122-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_spruce_log_top.png")
1123-
side = self.load_image_texture("assets/minecraft/textures/block/stripped_spruce_log.png")
1124-
if wood_type == 2: # birch
1125-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_birch_log_top.png")
1126-
side = self.load_image_texture("assets/minecraft/textures/block/stripped_birch_log.png")
1127-
if wood_type == 3: # jungle wood
1128-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_jungle_log_top.png")
1129-
side = self.load_image_texture("assets/minecraft/textures/block/stripped_jungle_log.png")
1130-
elif blockid == 11307: # stripped acacia/dark wood:
1131-
if wood_type == 0: # acacia
1132-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_acacia_log_top.png")
1133-
side = self.load_image_texture("assets/minecraft/textures/block/stripped_acacia_log.png")
1134-
elif wood_type == 1: # dark oak
1135-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_dark_oak_log_top.png")
1136-
side = self.load_image_texture("assets/minecraft/textures/block/stripped_dark_oak_log.png")
1137-
else:
1138-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_acacia_log_top.png")
1139-
side = self.load_image_texture("assets/minecraft/textures/block/stripped_acacia_log.png")
1140-
if blockid == 11308: # regular bark:
1141-
if wood_type == 0: # normal
1142-
top = self.load_image_texture("assets/minecraft/textures/block/oak_log.png")
1143-
side = top
1144-
if wood_type == 1: # spruce
1145-
top = self.load_image_texture("assets/minecraft/textures/block/spruce_log.png")
1146-
side = top
1147-
if wood_type == 2: # birch
1148-
top = self.load_image_texture("assets/minecraft/textures/block/birch_log.png")
1149-
side = top
1150-
if wood_type == 3: # jungle wood
1151-
top = self.load_image_texture("assets/minecraft/textures/block/jungle_log.png")
1152-
side = top
1153-
elif blockid == 11309: # acacia/dark bark:
1154-
if wood_type == 0: # acacia
1155-
top = self.load_image_texture("assets/minecraft/textures/block/acacia_log.png")
1156-
side = top
1157-
elif wood_type == 1: # dark oak
1158-
top = self.load_image_texture("assets/minecraft/textures/block/dark_oak_log.png")
1159-
side = top
1160-
else:
1161-
top = self.load_image_texture("assets/minecraft/textures/block/acacia_log.png")
1162-
side = top
1163-
if blockid == 11310: # stripped regular wood:
1164-
if wood_type == 0: # normal
1165-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_oak_log.png")
1166-
side = top
1167-
if wood_type == 1: # spruce
1168-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_spruce_log.png")
1169-
side = top
1170-
if wood_type == 2: # birch
1171-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_birch_log.png")
1172-
side = top
1173-
if wood_type == 3: # jungle wood
1174-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_jungle_log.png")
1175-
side = top
1176-
if blockid == 1008: # nether logs aka stem
1177-
if wood_type == 0: # warped_stem
1178-
top = self.load_image_texture("assets/minecraft/textures/block/warped_stem_top.png")
1179-
side = self.load_image_texture("assets/minecraft/textures/block/warped_stem.png")
1180-
if wood_type == 1: # stripped_warped_stem
1181-
top = self.load_image_texture("assets/minecraft/textures/block/warped_stem_top.png")
1182-
side = self.load_image_texture("assets/minecraft/textures/block/stripped_warped_stem.png")
1183-
if wood_type == 2: # crimson_stem
1184-
top = self.load_image_texture("assets/minecraft/textures/block/crimson_stem_top.png")
1185-
side = self.load_image_texture("assets/minecraft/textures/block/crimson_stem.png")
1186-
if wood_type == 3: # crimson_stem
1187-
top = self.load_image_texture("assets/minecraft/textures/block/crimson_stem_top.png")
1188-
side = self.load_image_texture("assets/minecraft/textures/block/stripped_crimson_stem.png")
1189-
if blockid == 1009: # nether hyphae
1190-
if wood_type == 0: # warped_hyphae
1191-
top = self.load_image_texture("assets/minecraft/textures/block/warped_stem.png")
1192-
side = top
1193-
if wood_type == 1: # stripped_warped_hyphae
1194-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_warped_stem.png")
1195-
side = top
1196-
if wood_type == 2: # crimson_hyphae
1197-
top = self.load_image_texture("assets/minecraft/textures/block/crimson_stem.png")
1198-
side = top
1199-
if wood_type == 3: # stripped_crimson_hyphae
1200-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_crimson_stem.png")
1201-
side = top
1202-
elif blockid == 11311: # stripped acacia/dark wood:
1203-
if wood_type == 0: # acacia
1204-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_acacia_log.png")
1205-
side = top
1206-
elif wood_type == 1: # dark oak
1207-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_dark_oak_log.png")
1208-
side = top
1209-
else:
1210-
top = self.load_image_texture("assets/minecraft/textures/block/stripped_acacia_log.png")
1211-
side = top
1095+
# dictionary of blockid : { wood_type : (top, side) }
1096+
wood_tex = {
1097+
17: {
1098+
0: ("oak_log_top.png", "oak_log.png"),
1099+
1: ("spruce_log_top.png", "spruce_log.png"),
1100+
2: ("birch_log_top.png", "birch_log.png"),
1101+
3: ("jungle_log_top.png", "jungle_log.png"),
1102+
},
1103+
162: {
1104+
0: ("acacia_log_top.png", "acacia_log.png"),
1105+
1: ("dark_oak_log_top.png", "dark_oak_log.png"),
1106+
},
1107+
11306: {
1108+
0: ("stripped_oak_log_top.png", "stripped_oak_log.png"),
1109+
1: ("stripped_spruce_log_top.png", "stripped_spruce_log.png"),
1110+
2: ("stripped_birch_log_top.png", "stripped_birch_log.png"),
1111+
3: ("stripped_jungle_log_top.png", "stripped_jungle_log.png"),
1112+
},
1113+
11307: {
1114+
0: ("stripped_acacia_log_top.png", "stripped_acacia_log.png"),
1115+
1: ("stripped_dark_oak_log_top.png", "stripped_dark_oak_log.png"),
1116+
},
1117+
11308: {
1118+
0: ("oak_log.png", None),
1119+
1: ("spruce_log.png", None),
1120+
2: ("birch_log.png", None),
1121+
3: ("jungle_log.png", None),
1122+
},
1123+
11309: {
1124+
0: ("acacia_log.png", None),
1125+
1: ("dark_oak_log.png", None),
1126+
},
1127+
11310: {
1128+
0: ("stripped_oak_log.png", None),
1129+
1: ("stripped_spruce_log.png", None),
1130+
2: ("stripped_birch_log.png", None),
1131+
3: ("stripped_jungle_log.png", None),
1132+
},
1133+
11311: {
1134+
0: ("stripped_acacia_log.png", None),
1135+
1: ("stripped_dark_oak_log.png", None),
1136+
},
1137+
1008: {
1138+
0: ("warped_stem_top.png", "warped_stem.png"),
1139+
1: ("warped_stem_top.png", "stripped_warped_stem.png"),
1140+
2: ("crimson_stem_top.png", "crimson_stem.png"),
1141+
3: ("crimson_stem_top.png", "stripped_crimson_stem.png"),
1142+
},
1143+
1009: {
1144+
0: ("warped_stem.png", None),
1145+
1: ("stripped_warped_stem.png", None),
1146+
2: ("crimson_stem.png", None),
1147+
3: ("stripped_crimson_stem.png", None),
1148+
}
1149+
}
1150+
1151+
top_f, side_f = wood_tex[blockid].get(wood_type, wood_tex[blockid][0])
1152+
if not side_f:
1153+
side_f = top_f
1154+
top = self.load_image_texture(BLOCKTEX + top_f)
1155+
side = self.load_image_texture(BLOCKTEX + side_f)
12121156

12131157
# choose orientation and paste textures
12141158
if wood_orientation == 0:
@@ -4278,7 +4222,6 @@ def vines(self, blockid, data):
42784222
# 1 UNWSE
42794223
# 2 UWSEN
42804224
# 3 USENW
4281-
42824225
if self.rotation in [1, 2, 3]:
42834226
bit_map = {1: [5, 3, 2, 1, 4],
42844227
2: [5, 2, 1, 4, 3],
@@ -4408,11 +4351,9 @@ def fence_gate(self, blockid, data):
44084351
block(blockid=1006, top_image="assets/minecraft/textures/block/warped_nylium.png", side_image="assets/minecraft/textures/block/warped_nylium_side.png")
44094352
block(blockid=1007, top_image="assets/minecraft/textures/block/crimson_nylium.png", side_image="assets/minecraft/textures/block/crimson_nylium_side.png")
44104353
# soul soil
4411-
soul_soil_texture="assets/minecraft/textures/block/soul_soil.png"
4412-
block(blockid=1020, top_image=soul_soil_texture, side_image=soul_soil_texture)
4354+
block(blockid=1020, top_image="assets/minecraft/textures/block/soul_soil.png")
44134355
# nether gold ore
4414-
nether_gold_texture="assets/minecraft/textures/block/nether_gold_ore.png"
4415-
block(blockid=1021, top_image=nether_gold_texture, side_image=nether_gold_texture)
4356+
block(blockid=1021, top_image="assets/minecraft/textures/block/nether_gold_ore.png")
44164357

44174358
# lilypad
44184359
# At the moment of writing this lilypads has no ancil data and their

0 commit comments

Comments
 (0)