Tidy up block defining
This commit is contained in:
parent
302466a518
commit
e149a7eca5
|
@ -31,10 +31,11 @@ macro_rules! define_blocks {
|
||||||
$fname:ident : $ftype:ty = [$($val:expr),+],
|
$fname:ident : $ftype:ty = [$($val:expr),+],
|
||||||
)*
|
)*
|
||||||
},
|
},
|
||||||
data $datafunc:expr,
|
$(data $datafunc:expr,)*
|
||||||
material $mat:expr,
|
material $mat:expr,
|
||||||
model $model:expr,
|
model $model:expr,
|
||||||
variant $variant:expr,
|
$(variant $variant:expr,)*
|
||||||
|
$(tint $tint:expr,)*
|
||||||
}
|
}
|
||||||
)+
|
)+
|
||||||
) => (
|
) => (
|
||||||
|
@ -112,14 +113,18 @@ macro_rules! define_blocks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables, unreachable_code)]
|
||||||
pub fn get_vanilla_id(&self) -> Option<usize> {
|
pub fn get_vanilla_id(&self) -> Option<usize> {
|
||||||
match *self {
|
match *self {
|
||||||
$(
|
$(
|
||||||
Block::$name {
|
Block::$name {
|
||||||
$($fname,)*
|
$($fname,)*
|
||||||
} => {
|
} => {
|
||||||
($datafunc).map(|v| v + (internal_ids::$name << 4))
|
$(
|
||||||
|
let data: Option<usize> = ($datafunc).map(|v| v + (internal_ids::$name << 4));
|
||||||
|
return data;
|
||||||
|
)*
|
||||||
|
return Some(0);
|
||||||
}
|
}
|
||||||
)+
|
)+
|
||||||
}
|
}
|
||||||
|
@ -156,14 +161,29 @@ macro_rules! define_blocks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables, unreachable_code)]
|
||||||
pub fn get_model_variant(&self) -> String {
|
pub fn get_model_variant(&self) -> String {
|
||||||
match *self {
|
match *self {
|
||||||
$(
|
$(
|
||||||
Block::$name {
|
Block::$name {
|
||||||
$($fname,)*
|
$($fname,)*
|
||||||
} => {
|
} => {
|
||||||
String::from($variant)
|
$(return String::from($variant);)*
|
||||||
|
return "normal";
|
||||||
|
}
|
||||||
|
)+
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables, unreachable_code)]
|
||||||
|
pub fn get_tint(&self) -> TintType {
|
||||||
|
match *self {
|
||||||
|
$(
|
||||||
|
Block::$name {
|
||||||
|
$($fname,)*
|
||||||
|
} => {
|
||||||
|
$(return $tint;)*
|
||||||
|
return TintType::Default;
|
||||||
}
|
}
|
||||||
)+
|
)+
|
||||||
}
|
}
|
||||||
|
@ -194,17 +214,22 @@ pub struct Material {
|
||||||
pub force_shade: bool,
|
pub force_shade: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum TintType {
|
||||||
|
Default,
|
||||||
|
Color{r: u8, g: u8, b: u8},
|
||||||
|
Grass,
|
||||||
|
Foliage,
|
||||||
|
}
|
||||||
|
|
||||||
define_blocks! {
|
define_blocks! {
|
||||||
Air {
|
Air {
|
||||||
props {},
|
props {},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: false,
|
renderable: false,
|
||||||
should_cull_against: false,
|
should_cull_against: false,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "air" ) },
|
model { ("minecraft", "air" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
Stone {
|
Stone {
|
||||||
props {
|
props {
|
||||||
|
@ -222,7 +247,6 @@ define_blocks! {
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", variant.as_string() ) },
|
model { ("minecraft", variant.as_string() ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
Grass {
|
Grass {
|
||||||
props {
|
props {
|
||||||
|
@ -240,170 +264,142 @@ define_blocks! {
|
||||||
Dirt {
|
Dirt {
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: true,
|
should_cull_against: true,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "dirt" ) },
|
model { ("minecraft", "dirt" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
Cobblestone {
|
Cobblestone {
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: true,
|
should_cull_against: true,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "cobblestone" ) },
|
model { ("minecraft", "cobblestone" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
Planks { // TODO
|
Planks { // TODO
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: true,
|
should_cull_against: true,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "planks" ) },
|
model { ("minecraft", "planks" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
Sapling { // TODO
|
Sapling { // TODO
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: false,
|
should_cull_against: false,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "sapling" ) },
|
model { ("minecraft", "sapling" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
Bedrock {
|
Bedrock {
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: true,
|
should_cull_against: true,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "bedrock" ) },
|
model { ("minecraft", "bedrock" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
FlowingWater { // TODO
|
FlowingWater { // TODO
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: true,
|
should_cull_against: true,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "water" ) },
|
model { ("minecraft", "water" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
Water { // TODO
|
Water { // TODO
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: true,
|
should_cull_against: true,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "water" ) },
|
model { ("minecraft", "water" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
FlowingLava { // TODO
|
FlowingLava { // TODO
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: true,
|
should_cull_against: true,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "lava" ) },
|
model { ("minecraft", "lava" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
Lava {
|
Lava {
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: true,
|
should_cull_against: true,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "lava" ) },
|
model { ("minecraft", "lava" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
Sand { // TODO
|
Sand { // TODO
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: true,
|
should_cull_against: true,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "sand" ) },
|
model { ("minecraft", "sand" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
Gravel {
|
Gravel {
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: true,
|
should_cull_against: true,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "gravel" ) },
|
model { ("minecraft", "gravel" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
GoldOre {
|
GoldOre {
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: true,
|
should_cull_against: true,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "gold_ore" ) },
|
model { ("minecraft", "gold_ore" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
IronOre {
|
IronOre {
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: true,
|
should_cull_against: true,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "iron_ore" ) },
|
model { ("minecraft", "iron_ore" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
CoalOre {
|
CoalOre {
|
||||||
props {
|
props {
|
||||||
},
|
},
|
||||||
data { Some(0) },
|
|
||||||
material Material {
|
material Material {
|
||||||
renderable: true,
|
renderable: true,
|
||||||
should_cull_against: true,
|
should_cull_against: true,
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("minecraft", "coal_ore" ) },
|
model { ("minecraft", "coal_ore" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
Log {
|
Log {
|
||||||
props {
|
props {
|
||||||
|
@ -441,7 +437,6 @@ define_blocks! {
|
||||||
force_shade: true,
|
force_shade: true,
|
||||||
},
|
},
|
||||||
model { ("minecraft", format!("{}_leaves", variant.as_string()) ) },
|
model { ("minecraft", format!("{}_leaves", variant.as_string()) ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
Missing {
|
Missing {
|
||||||
props {},
|
props {},
|
||||||
|
@ -452,7 +447,6 @@ define_blocks! {
|
||||||
force_shade: false,
|
force_shade: false,
|
||||||
},
|
},
|
||||||
model { ("steven", "missing_block" ) },
|
model { ("steven", "missing_block" ) },
|
||||||
variant "normal",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue