Skip to content

Commit 456893f

Browse files
authored
Add most new Copper Age blocks (#103)
* Fix rendering of waterlogged ladders and glow lichen Change-Id: I801243817f2930fcac0f04c67f51a83a5a0e07ef * Extend spawn detection to account for other spawn points in other dimensions Change-Id: I4f380dcdb533d1784bf6d4544771cae0064b4e8a * Add copper generation function to aid in attribute compacting Change-Id: Ic47c474ec7b988df0f2c67bc714f26894959a324 * Fix iron chain, add copper chain varieties Change-Id: I21c336f93f64e2355ce233bed4edeab8679ea71b * Add copper bars Change-Id: I672f2820706afd847e47ca0ac6327a316cabafc6 * Add variants of lightning rod Change-Id: I22f16e8fa2bcac2b9a295a9a3e4f0a966eaedbf5 * Add copper lanterns Change-Id: I62f7c79a78071410162dfc924f2b8cefb39563a1 * Add copper torch Change-Id: I649bb631884e85b291228f109caf96086f063816 * Add copper chests Change-Id: Ia3e151946de2e7d4886523a8123f65f62e60dab5 * Add wooden shelves Change-Id: Ia0d0491ebd0a8d11f9d3175cf589ef2514c253c4 # Conflicts: # overviewer_core/textures.py # overviewer_core/world.py * Bump requests version Change-Id: Ie06bb609008e8a8997da5c0c1160849056c3c9e6
1 parent c38a598 commit 456893f

File tree

7 files changed

+305
-55
lines changed

7 files changed

+305
-55
lines changed

overviewer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ def set_renderchecks(checkname, num):
610610
"imgquality", "imglossless", "optimizeimg", "rendermode", "worldname_orig", "title",
611611
"dimension", "changelist", "showspawn", "overlay", "base", "poititle", "maxzoom",
612612
"showlocationmarker", "minzoom", "center"])
613-
tileSetOpts.update({"spawn": w.find_true_spawn()}) # TODO find a better way to do this
613+
tileSetOpts.update({"spawn": w.find_true_spawn(render['dimension'])})
614614
for rset in rsets:
615615
tset = tileset.TileSet(w, rset, assetMrg, tex, tileSetOpts, tileset_dir)
616616
tilesets.append(tset)

overviewer_core/settingsValidators.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -230,30 +230,15 @@ def validateStr(s):
230230

231231
def validateDimension(d):
232232
"""Validates the dimension setting"""
233-
valid_dimensions = {
234-
'overworld': 'DIM0',
235-
'nether': 'DIM-1',
236-
'end': 'DIM1'
237-
}
238233

234+
dimension_data = util.get_dimension_data(d)
239235

240-
241-
if d is None:
236+
if dimension_data is None:
242237
raise ValidationException(
243238
"Required key 'dimension' was not specified. Must be one of: 'overworld', 'nether', or 'end'"
244239
)
245-
246-
# Convert to lowercase for case-insensitive comparison
247-
if isinstance(d, str):
248-
d = d.lower()
249-
250-
if d not in valid_dimensions:
251-
raise ValidationException(
252-
"The dimension value must be one of: 'overworld', 'nether', or 'end'. "
253-
f"Got '{d}' instead."
254-
)
255-
256-
return (d, valid_dimensions[d])
240+
241+
return d, dimension_data[0], dimension_data[1], dimension_data[2]
257242

258243
def validateOutputDir(d):
259244
checkBadEscape(d)

overviewer_core/textures.py

Lines changed: 152 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,8 +1927,8 @@ def slabs(self, blockid, data):
19271927

19281928
return self.build_slab_block(top, side, data & 8 == 8);
19291929

1930-
# torch, redstone torch (off), redstone torch(on), soul_torch
1931-
@material(blockid=[50, 75, 76, 1039], data=[1, 2, 3, 4, 5], transparent=True)
1930+
# torch, redstone torch (off), redstone torch(on), soul_torch, copper_torch
1931+
@material(blockid=[50, 75, 76, 1039, 264], data=[1, 2, 3, 4, 5], transparent=True)
19321932
def torches(self, blockid, data):
19331933
# first, rotations
19341934
if self.rotation == 1:
@@ -1956,6 +1956,9 @@ def torches(self, blockid, data):
19561956
small = self.load_image_texture(BLOCKTEXTURE + "redstone_torch.png")
19571957
elif blockid == 1039: # soul torch
19581958
small= self.load_image_texture(BLOCKTEXTURE + "soul_torch.png")
1959+
elif blockid == 264: # soul torch
1960+
small= self.load_image_texture(BLOCKTEXTURE + "copper_torch.png")
1961+
19591962
# compose a torch bigger than the normal
19601963
# (better for doing transformations)
19611964
torch = Image.new("RGBA", (16,16), self.bgcolor)
@@ -1999,13 +2002,19 @@ def torches(self, blockid, data):
19992002
return img
20002003

20012004
# lantern
2002-
@material(blockid=[11373, 1038], data=[0, 1], transparent=True)
2005+
@material(blockid=[11373, 1038, 1156,1157,1158,1159], data=[0, 1], transparent=True)
20032006
def lantern(self, blockid, data):
20042007
# get the multipart texture of the lantern
2005-
if blockid == 11373:
2006-
inputtexture = self.load_image_texture(BLOCKTEXTURE + "lantern.png")
2007-
if blockid == 1038:
2008-
inputtexture = self.load_image_texture(BLOCKTEXTURE + "soul_lantern.png")
2008+
texmap = {
2009+
11373: "lantern.png",
2010+
1038: "soul_lantern.png",
2011+
1156: "copper_lantern.png",
2012+
1157: "exposed_copper_lantern.png",
2013+
1158: "weathered_copper_lantern.png",
2014+
1159: "oxidized_copper_lantern.png",
2015+
}
2016+
2017+
inputtexture = self.load_image_texture(BLOCKTEXTURE + texmap[blockid])
20092018

20102019

20112020
# # now create a textures, using the parts defined in lantern.json
@@ -2349,7 +2358,7 @@ def rect(tex,coords):
23492358

23502359
# normal, locked (used in april's fool day), ender and trapped chest
23512360
# NOTE: locked chest used to be id95 (which is now stained glass)
2352-
@material(blockid=[54, 130, 146], data=list(range(30)), transparent = True)
2361+
@material(blockid=[54, 130, 146, 11425, 11426, 11427, 11428], data=list(range(30)), transparent = True)
23532362
def chests(self, blockid, data):
23542363
# the first 3 bits are the orientation as stored in minecraft,
23552364
# bits 0x8 and 0x10 indicate which half of the double chest is it.
@@ -2376,12 +2385,20 @@ def chests(self, blockid, data):
23762385
# iterate.c will only return the ancil data (without pseudo
23772386
# ancil data) for locked and ender chests, so only
23782387
# ancilData = 2,3,4,5 are used for this blockids
2379-
2388+
2389+
texture_base_name = {
2390+
11425: "copper",
2391+
11426: "copper_exposed",
2392+
11427: "copper_weathered",
2393+
11428: "copper_oxidized",
2394+
}.get(blockid, "normal")
2395+
23802396
if data & 24 == 0:
2381-
if blockid == 130: t = self.load_image("assets/minecraft/textures/entity/chest/ender.png")
2397+
if blockid == 130:
2398+
t = self.load_image("assets/minecraft/textures/entity/chest/ender.png")
23822399
else:
23832400
try:
2384-
t = self.load_image("assets/minecraft/textures/entity/chest/normal.png")
2401+
t = self.load_image(f"assets/minecraft/textures/entity/chest/{texture_base_name}.png")
23852402
except (TextureException, IOError):
23862403
t = self.load_image("assets/minecraft/textures/entity/chest/chest.png")
23872404

@@ -2440,8 +2457,8 @@ def chests(self, blockid, data):
24402457
# large chest
24412458
# the textures is no longer in terrain.png, get it from
24422459
# item/chest.png and get all the needed stuff
2443-
t_left = self.load_image("assets/minecraft/textures/entity/chest/normal_left.png")
2444-
t_right = self.load_image("assets/minecraft/textures/entity/chest/normal_right.png")
2460+
t_left = self.load_image(f"assets/minecraft/textures/entity/chest/{texture_base_name}_left.png")
2461+
t_right = self.load_image(f"assets/minecraft/textures/entity/chest/{texture_base_name}_right.png")
24452462
# for some reason the 1.15 images are upside down
24462463
t_left = ImageOps.flip(t_left)
24472464
t_right = ImageOps.flip(t_right)
@@ -4852,12 +4869,20 @@ def huge_mushroom(self, blockid, data):
48524869
# iron bars and glass pane
48534870
# TODO glass pane is not a sprite, it has a texture for the side,
48544871
# at the moment is not used
4855-
@material(blockid=[101,102, 160], data=list(range(256)), transparent=True, nospawn=True)
4872+
@material(blockid=[101,102, 160,260,261,262,263], data=list(range(256)), transparent=True, nospawn=True)
48564873
def panes(self, blockid, data):
48574874
# no rotation, uses pseudo data
48584875
if blockid == 101:
48594876
# iron bars
48604877
t = self.load_image_texture(BLOCKTEXTURE + "iron_bars.png")
4878+
elif blockid == 260:
4879+
t = self.load_image_texture(BLOCKTEXTURE + "copper_bars.png")
4880+
elif blockid == 261:
4881+
t = self.load_image_texture(BLOCKTEXTURE + "exposed_copper_bars.png")
4882+
elif blockid == 262:
4883+
t = self.load_image_texture(BLOCKTEXTURE + "weathered_copper_bars.png")
4884+
elif blockid == 263:
4885+
t = self.load_image_texture(BLOCKTEXTURE + "oxidized_copper_bars.png")
48614886
elif blockid == 160:
48624887
t = self.load_image_texture(BLOCKTEXTURE + "%s_stained_glass.png" % color_map[data & 0xf])
48634888
else:
@@ -6772,14 +6797,26 @@ def froglight(self, blockid, data):
67726797
return self.build_axis_block(top, side, data)
67736798

67746799
# Chain
6775-
@material(blockid=11419, data=list(range(3)), solid=True, transparent=True, nospawn=True)
6800+
@material(blockid=[11419,11420,11421,11422,11423,11424], data=list(range(3)), solid=True, transparent=True, nospawn=True)
67766801
def chain(self, blockid, data):
6777-
# In versions prior to 1.21.10 chain was adequate, versions after 1.21.10 chain may be iron
6802+
# Updated in 1.21.9: chain -> iron_chain
6803+
# Most people are probably going to have newer versions, so let's try new first.
6804+
6805+
texture_dict = {
6806+
11419: "chain",
6807+
11420: "iron_chain",
6808+
11421: "copper_chain",
6809+
11422: "exposed_copper_chain",
6810+
11423: "weathered_copper_chain",
6811+
11424: "oxidized_copper_chain",
6812+
}
6813+
67786814
try:
6779-
tex = self.load_image_texture(BLOCKTEXTURE + "chain.png")
6780-
except:
6781-
tex = self.load_image_texture(BLOCKTEXTURE + "iron_chain.png")
6782-
6815+
tex = self.load_image_texture(BLOCKTEXTURE + texture_dict[blockid] + ".png")
6816+
except (TextureException, IOError):
6817+
# Texture load failed, assume texture doesn't exist.
6818+
return None
6819+
67836820
sidetex = Image.new(tex.mode, tex.size, self.bgcolor)
67846821
mask = tex.crop((0, 0, 6, 16))
67856822
alpha_over(sidetex, mask, (5, 0), mask)
@@ -6936,9 +6973,17 @@ def cave_vines(self, blockid, data):
69366973
tex = self.load_image_texture(BLOCKTEXTURE + "cave_vines.png")
69376974
return self.build_sprite(tex)
69386975

6939-
@material(blockid=1118, data=list(range(6)), transparent=True, solid=True)
6976+
@material(blockid=[1118,1153,1154,1155], data=list(range(6)), transparent=True, solid=True)
69406977
def lightning_rod(self, blockid, data):
6941-
tex = self.load_image_texture(BLOCKTEXTURE + "lightning_rod.png")
6978+
texmap = {
6979+
1118: "lightning_rod",
6980+
1153: "exposed_lightning_rod",
6981+
1154: "weathered_lightning_rod",
6982+
1155: "oxidized_lightning_rod",
6983+
}
6984+
6985+
6986+
tex = self.load_image_texture(BLOCKTEXTURE + texmap[blockid] + '.png')
69426987
img = Image.new("RGBA", (24, 24), self.bgcolor)
69436988

69446989
mask = tex.crop((0, 4, 2, 16))
@@ -7600,6 +7645,91 @@ def test_block(self, _, data):
76007645
tex = self.load_image_texture(BLOCKTEXTURE + 'test_block_' + ['start','accept','fail','log'][data] + '.png')
76017646
return self.build_block(tex, tex)
76027647

7648+
@material(blockid=list(range(12700, 12712)), data=list(range(0b111)), transparent=True)
7649+
def shelf(self, block_id, data):
7650+
texmap = {
7651+
12700: 'oak_shelf',
7652+
12701: 'spruce_shelf',
7653+
12702: 'birch_shelf',
7654+
12703: 'jungle_shelf',
7655+
12704: 'acacia_shelf',
7656+
12705: 'dark_oak_shelf',
7657+
12706: 'crimson_shelf',
7658+
12707: 'warped_shelf',
7659+
12708: 'mangrove_shelf',
7660+
12709: 'cherry_shelf',
7661+
12710: 'bamboo_shelf',
7662+
12711: 'pale_oak_shelf',
7663+
}
7664+
7665+
tex = self.load_image(BLOCKTEXTURE + texmap[block_id] + '.png')
7666+
7667+
powered = (data & 0b100) == 0b100
7668+
direction = data & 0b011
7669+
7670+
direction = (direction + self.rotation) % 4
7671+
7672+
front = Image.new("RGBA", (16, 16), self.bgcolor)
7673+
alpha_over(front, tex.crop((0, 0, 16, 16)), (0, 0))
7674+
7675+
if powered:
7676+
# fake this for now
7677+
chain = 'center'
7678+
7679+
if chain == 'left':
7680+
alpha_over(front, tex.crop((0, 16, 16, 23)), (0, 4))
7681+
pass
7682+
elif chain == 'right':
7683+
alpha_over(front, tex.crop((16, 16, 32, 24)), (0, 4))
7684+
pass
7685+
elif chain == 'center':
7686+
alpha_over(front, tex.crop((0, 24, 16, 34)), (0, 4))
7687+
pass
7688+
elif chain == 'none':
7689+
alpha_over(front, tex.crop((16, 24, 32, 32)), (0, 4))
7690+
pass
7691+
7692+
rear = Image.new("RGBA", (16, 16), self.bgcolor)
7693+
alpha_over(rear, tex.crop((16, 0, 32, 16)), (0, 0))
7694+
7695+
right = Image.new("RGBA", (16, 16), self.bgcolor)
7696+
alpha_over(right, tex.crop((28, 0, 32, 16)), (0, 0))
7697+
7698+
left = Image.new("RGBA", (16, 16), self.bgcolor)
7699+
alpha_over(left, tex.crop((16, 0, 20, 16)), (0, 0))
7700+
7701+
top = Image.new("RGBA", (16, 16), self.bgcolor)
7702+
alpha_over(top, tex.crop((16, 7, 32, 12)), (0, 0))
7703+
7704+
# None == front; we handle this later
7705+
sides = [left, None, right, rear]
7706+
7707+
for i in range(direction):
7708+
sides = sides[1:] + sides[:1]
7709+
top = top.rotate(270)
7710+
7711+
# Make the sides line up properly
7712+
if sides[2] is None:
7713+
sides[1] = sides[1].transpose(Image.FLIP_LEFT_RIGHT)
7714+
sides[3] = sides[3].transpose(Image.FLIP_LEFT_RIGHT)
7715+
7716+
if sides[3] is None:
7717+
sides[0] = sides[0].transpose(Image.FLIP_LEFT_RIGHT)
7718+
sides[2] = sides[2].transpose(Image.FLIP_LEFT_RIGHT)
7719+
7720+
block = self.build_full_block(top, sides[3], sides[2], sides[0], sides[1])
7721+
7722+
# stitch on the front in the correct place
7723+
if sides[0] is None:
7724+
front = self.transform_image_side(front)
7725+
alpha_over(block, front, (9, 2), front)
7726+
7727+
if sides[1] is None:
7728+
front = self.transform_image_side(front.transpose(Image.FLIP_LEFT_RIGHT)).transpose(Image.FLIP_LEFT_RIGHT)
7729+
alpha_over(block, front, (3, 2), front)
7730+
7731+
return block
7732+
76037733

76047734
sprite(blockid=11385, imagename=BLOCKTEXTURE + "oak_sapling.png")
76057735
sprite(blockid=11386, imagename=BLOCKTEXTURE + "spruce_sapling.png")

overviewer_core/tileset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,7 @@ def bgcolorformat(color):
620620
if isOverlay:
621621
d.update({"tilesets": self.options.get("overlay")})
622622

623-
# DIM0 means overworld
624-
if self.regionset.get_type() == "DIM0" and self.options.get("showspawn", True):
623+
if self.options.get("showspawn", True):
625624
d.update({"spawn": self.options.get("spawn")})
626625
else:
627626
d.update({"spawn": False})

overviewer_core/util.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,30 @@
2525
from string import hexdigits
2626
from subprocess import PIPE, Popen
2727

28+
DIMENSION_INFO = {
29+
"minecraft:overworld": ("DIM0", 0, "minecraft:overworld"),
30+
"minecraft:the_end": ("DIM1", 1, "minecraft:the_end"),
31+
"minecraft:the_nether": ("DIM-1", -1, "minecraft:the_nether"),
32+
}
33+
34+
35+
def get_dimension_data(dimension):
36+
if isinstance(dimension, int):
37+
for dim_name, (folder, dim_id, _) in DIMENSION_INFO.items():
38+
if dim_id == dimension:
39+
return DIMENSION_INFO[dim_name]
40+
elif isinstance(dimension, str):
41+
if dimension in DIMENSION_INFO:
42+
return DIMENSION_INFO[dimension]
43+
elif dimension in ("overworld"):
44+
return DIMENSION_INFO["minecraft:overworld"]
45+
elif dimension in ("the_end", "end"):
46+
return DIMENSION_INFO["minecraft:the_end"]
47+
elif dimension in ("the_nether", "nether"):
48+
return DIMENSION_INFO["minecraft:the_nether"]
49+
50+
return None
51+
2852

2953
def get_program_path():
3054
# Check if running as a frozen executable (e.g., created with PyInstaller)

0 commit comments

Comments
 (0)