resource: add sign material to block types

This commit is contained in:
Matthias Schiffer 2023-12-29 20:54:26 +01:00
parent 8814dcff89
commit abf87e75ee
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
5 changed files with 2207 additions and 1050 deletions

File diff suppressed because it is too large Load diff

View file

@ -57,11 +57,31 @@ impl BlockColor {
}
}
/// A block type specification (for use in constants)
#[derive(Debug, Clone)]
struct ConstBlockType {
/// Determines the rendered color of the block type
pub block_color: BlockColor,
/// Material of a sign block
pub sign_material: Option<&'static str>,
}
/// A block type specification
#[derive(Debug, Clone)]
pub struct BlockType {
/// Determines the rendered color of the block type
pub block_color: BlockColor,
/// Material of a sign block
pub sign_material: Option<String>,
}
impl From<&ConstBlockType> for BlockType {
fn from(value: &ConstBlockType) -> Self {
BlockType {
block_color: value.block_color,
sign_material: value.sign_material.map(String::from),
}
}
}
/// Used to look up standard Minecraft block types
@ -77,7 +97,7 @@ impl Default for BlockTypes {
fn default() -> Self {
let block_type_map: HashMap<_, _> = block_types::BLOCK_TYPES
.iter()
.map(|(k, v)| (String::from(*k), v.clone()))
.map(|(k, v)| (String::from(*k), BlockType::from(v)))
.collect();
let legacy_block_types = Box::new(legacy_block_types::LEGACY_BLOCK_TYPES.map(|inner| {
inner.map(|id| {

View file

@ -9,7 +9,10 @@
"acacia_fence_gate": {
"texture": "acacia_planks"
},
"acacia_hanging_sign": null,
"acacia_hanging_sign": {
"sign_material": "acacia",
"texture": null
},
"acacia_leaves": {
"foliage": true
},
@ -22,6 +25,7 @@
},
"acacia_sapling": {},
"acacia_sign": {
"sign_material": "acacia",
"texture": "acacia_planks"
},
"acacia_slab": {
@ -31,8 +35,14 @@
"texture": "acacia_planks"
},
"acacia_trapdoor": {},
"acacia_wall_hanging_sign": null,
"acacia_wall_sign": null,
"acacia_wall_hanging_sign": {
"sign_material": "acacia",
"texture": null
},
"acacia_wall_sign": {
"sign_material": "acacia",
"texture": null
},
"acacia_wood": {
"texture": "acacia_log"
},
@ -84,7 +94,10 @@
"bamboo_fence_gate": {
"texture": "bamboo_planks"
},
"bamboo_hanging_sign": null,
"bamboo_hanging_sign": {
"sign_material": "bamboo",
"texture": null
},
"bamboo_mosaic": {},
"bamboo_mosaic_slab": {
"texture": "bamboo_mosaic"
@ -98,6 +111,7 @@
},
"bamboo_sapling": null,
"bamboo_sign": {
"sign_material": "bamboo",
"texture": "bamboo_planks"
},
"bamboo_slab": {
@ -107,8 +121,14 @@
"texture": "bamboo_planks"
},
"bamboo_trapdoor": {},
"bamboo_wall_hanging_sign": null,
"bamboo_wall_sign": null,
"bamboo_wall_hanging_sign": {
"sign_material": "bamboo",
"texture": null
},
"bamboo_wall_sign": {
"sign_material": "bamboo",
"texture": null
},
"barrel": {
"texture": "barrel_top"
},
@ -144,7 +164,10 @@
"birch_fence_gate": {
"texture": "birch_planks"
},
"birch_hanging_sign": null,
"birch_hanging_sign": {
"sign_material": "birch",
"texture": null
},
"birch_leaves": {
"birch": true
},
@ -157,6 +180,7 @@
},
"birch_sapling": {},
"birch_sign": {
"sign_material": "birch",
"texture": "birch_planks"
},
"birch_slab": {
@ -166,8 +190,14 @@
"texture": "birch_planks"
},
"birch_trapdoor": {},
"birch_wall_hanging_sign": null,
"birch_wall_sign": null,
"birch_wall_hanging_sign": {
"sign_material": "birch",
"texture": null
},
"birch_wall_sign": {
"sign_material": "birch",
"texture": null
},
"birch_wood": {
"texture": "birch_log"
},
@ -326,7 +356,10 @@
"cherry_fence_gate": {
"texture": "cherry_planks"
},
"cherry_hanging_sign": null,
"cherry_hanging_sign": {
"sign_material": "cherry",
"texture": null
},
"cherry_leaves": {},
"cherry_log": {
"texture": "cherry_log_top"
@ -337,6 +370,7 @@
},
"cherry_sapling": null,
"cherry_sign": {
"sign_material": "cherry",
"texture": "cherry_planks"
},
"cherry_slab": {
@ -346,8 +380,14 @@
"texture": "cherry_planks"
},
"cherry_trapdoor": {},
"cherry_wall_hanging_sign": null,
"cherry_wall_sign": null,
"cherry_wall_hanging_sign": {
"sign_material": "cherry",
"texture": null
},
"cherry_wall_sign": {
"sign_material": "cherry",
"texture": null
},
"cherry_wood": {
"texture": "cherry_log"
},
@ -433,7 +473,10 @@
"texture": "crimson_planks"
},
"crimson_fungus": null,
"crimson_hanging_sign": null,
"crimson_hanging_sign": {
"sign_material": "crimson",
"texture": null
},
"crimson_hyphae": {
"texture": "crimson_stem"
},
@ -444,6 +487,7 @@
},
"crimson_roots": {},
"crimson_sign": {
"sign_material": "crimson",
"texture": "crimson_planks"
},
"crimson_slab": {
@ -456,8 +500,14 @@
"texture": "crimson_stem_top"
},
"crimson_trapdoor": {},
"crimson_wall_hanging_sign": null,
"crimson_wall_sign": null,
"crimson_wall_hanging_sign": {
"sign_material": "crimson",
"texture": null
},
"crimson_wall_sign": {
"sign_material": "crimson",
"texture": null
},
"crying_obsidian": {},
"cut_copper": {},
"cut_copper_slab": {
@ -512,7 +562,10 @@
"dark_oak_fence_gate": {
"texture": "dark_oak_planks"
},
"dark_oak_hanging_sign": null,
"dark_oak_hanging_sign": {
"sign_material": "dark_oak",
"texture": null
},
"dark_oak_leaves": {
"foliage": true
},
@ -525,6 +578,7 @@
},
"dark_oak_sapling": {},
"dark_oak_sign": {
"sign_material": "dark_oak",
"texture": "dark_oak_planks"
},
"dark_oak_slab": {
@ -534,8 +588,14 @@
"texture": "dark_oak_planks"
},
"dark_oak_trapdoor": {},
"dark_oak_wall_hanging_sign": null,
"dark_oak_wall_sign": null,
"dark_oak_wall_hanging_sign": {
"sign_material": "dark_oak",
"texture": null
},
"dark_oak_wall_sign": {
"sign_material": "dark_oak",
"texture": null
},
"dark_oak_wood": {
"texture": "dark_oak_log"
},
@ -832,7 +892,10 @@
"jungle_fence_gate": {
"texture": "jungle_planks"
},
"jungle_hanging_sign": null,
"jungle_hanging_sign": {
"sign_material": "jungle",
"texture": null
},
"jungle_leaves": {
"foliage": true
},
@ -845,6 +908,7 @@
},
"jungle_sapling": {},
"jungle_sign": {
"sign_material": "jungle",
"texture": "jungle_planks"
},
"jungle_slab": {
@ -854,8 +918,14 @@
"texture": "jungle_planks"
},
"jungle_trapdoor": {},
"jungle_wall_hanging_sign": null,
"jungle_wall_sign": null,
"jungle_wall_hanging_sign": {
"sign_material": "jungle",
"texture": null
},
"jungle_wall_sign": {
"sign_material": "jungle",
"texture": null
},
"jungle_wood": {
"texture": "jungle_log"
},
@ -991,7 +1061,10 @@
"mangrove_fence_gate": {
"texture": "mangrove_planks"
},
"mangrove_hanging_sign": null,
"mangrove_hanging_sign": {
"sign_material": "mangrove",
"texture": null
},
"mangrove_leaves": {
"foliage": true
},
@ -1007,6 +1080,7 @@
"texture": "mangrove_roots_top"
},
"mangrove_sign": {
"sign_material": "mangrove",
"texture": "mangrove_planks"
},
"mangrove_slab": {
@ -1016,8 +1090,14 @@
"texture": "mangrove_planks"
},
"mangrove_trapdoor": {},
"mangrove_wall_hanging_sign": null,
"mangrove_wall_sign": null,
"mangrove_wall_hanging_sign": {
"sign_material": "mangrove",
"texture": null
},
"mangrove_wall_sign": {
"sign_material": "mangrove",
"texture": null
},
"mangrove_wood": {
"texture": "mangrove_log"
},
@ -1105,7 +1185,10 @@
"oak_fence_gate": {
"texture": "oak_planks"
},
"oak_hanging_sign": null,
"oak_hanging_sign": {
"sign_material": "oak",
"texture": null
},
"oak_leaves": {
"foliage": true
},
@ -1118,6 +1201,7 @@
},
"oak_sapling": {},
"oak_sign": {
"sign_material": "oak",
"texture": "oak_planks"
},
"oak_slab": {
@ -1127,8 +1211,14 @@
"texture": "oak_planks"
},
"oak_trapdoor": {},
"oak_wall_hanging_sign": null,
"oak_wall_sign": null,
"oak_wall_hanging_sign": {
"sign_material": "oak",
"texture": null
},
"oak_wall_sign": {
"sign_material": "oak",
"texture": null
},
"oak_wood": {
"texture": "oak_log"
},
@ -1562,6 +1652,7 @@
"shroomlight": {},
"shulker_box": {},
"sign": {
"sign_material": "oak",
"texture": "oak_planks"
},
"skeleton_skull": null,
@ -1638,7 +1729,10 @@
"spruce_fence_gate": {
"texture": "spruce_planks"
},
"spruce_hanging_sign": null,
"spruce_hanging_sign": {
"sign_material": "spruce",
"texture": null
},
"spruce_leaves": {
"spruce": true
},
@ -1651,6 +1745,7 @@
},
"spruce_sapling": {},
"spruce_sign": {
"sign_material": "spruce",
"texture": "spruce_planks"
},
"spruce_slab": {
@ -1660,8 +1755,14 @@
"texture": "spruce_planks"
},
"spruce_trapdoor": {},
"spruce_wall_hanging_sign": null,
"spruce_wall_sign": null,
"spruce_wall_hanging_sign": {
"sign_material": "spruce",
"texture": null
},
"spruce_wall_sign": {
"sign_material": "spruce",
"texture": null
},
"spruce_wood": {
"texture": "spruce_log"
},
@ -1808,7 +1909,10 @@
"grass": true
},
"void_air": null,
"wall_sign": null,
"wall_sign": {
"sign_material": "oak",
"texture": null
},
"wall_torch": null,
"warped_button": null,
"warped_door": {
@ -1821,7 +1925,10 @@
"texture": "warped_planks"
},
"warped_fungus": null,
"warped_hanging_sign": null,
"warped_hanging_sign": {
"sign_material": "warped",
"texture": null
},
"warped_hyphae": {
"texture": "warped_stem"
},
@ -1832,6 +1939,7 @@
},
"warped_roots": {},
"warped_sign": {
"sign_material": "warped",
"texture": "warped_planks"
},
"warped_slab": {
@ -1844,8 +1952,14 @@
"texture": "warped_stem_top"
},
"warped_trapdoor": {},
"warped_wall_hanging_sign": null,
"warped_wall_sign": null,
"warped_wall_hanging_sign": {
"sign_material": "warped",
"texture": null
},
"warped_wall_sign": {
"sign_material": "warped",
"texture": null
},
"warped_wart_block": {},
"water": {
"texture": "water_still",

View file

@ -45,12 +45,17 @@ for name, info in blocks.items():
'birch': False,
'spruce': False,
'water': False,
'sign_material': None,
}
if info is None:
continue
color = mean_color(info.get('texture', name))
texture = info.get('texture', name)
color = None
if texture:
color = mean_color(texture)
if color:
output[id]['color'] = color
output[id]['opaque'] = True
@ -60,5 +65,7 @@ for name, info in blocks.items():
output[id]['spruce'] = info.get('spruce', False)
output[id]['water'] = info.get('water', False)
output[id]['sign_material'] = info.get('sign_material')
with open(sys.argv[3], 'w') as f:
json.dump(output, f)

View file

@ -18,7 +18,7 @@ with open(sys.argv[2], 'w') as f:
print('', file=f)
print('use super::*;', file=f)
print('', file=f)
print('pub const BLOCK_TYPES: &[(&str, BlockType)] = &[', file=f)
print('pub const BLOCK_TYPES: &[(&str, ConstBlockType)] = &[', file=f)
for name, info in colors.items():
flags = []
@ -36,13 +36,18 @@ with open(sys.argv[2], 'w') as f:
flags.append('Water')
flags = 'make_bitflags!(BlockFlag::{' + '|'.join(flags) + '})'
print('\t("%s", BlockType { ' % name, file=f)
sign_material = 'None'
if info['sign_material']:
sign_material = 'Some("%s")' % info['sign_material']
print('\t("%s", ConstBlockType { ' % name, file=f)
print('\t\tblock_color: BlockColor { flags: %s, color: Color([%u, %u, %u]) },' % (
flags,
info['color']['r'],
info['color']['g'],
info['color']['b'],
), file=f)
print('\t\tsign_material: %s,' % sign_material, file=f)
print('}),', file=f)
print('];', file=f)