mirror of
https://github.com/italicsjenga/valence.git
synced 2024-12-23 14:31:30 +11:00
Provide API for getting the wall variant of blocks (#255)
<!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description This adds an API for getting the wall / attachable variant of a block. Unlike #117 it does not add convenience methods for orientation, and it does not modify the example to use this code. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> The extractor is not tested. The API has some tests in the test module. #### Related <!-- Link to any issues that have context for this or that this PR fixes. --> #115 - it does not fix this, as it doesn't modify the example, but it could lead to it. --------- Co-authored-by: EmperialDev <saroke.dev@gmail.com>
This commit is contained in:
parent
7cd059b9b3
commit
9931c8a80b
|
@ -18,6 +18,7 @@ struct TopLevel {
|
||||||
struct Block {
|
struct Block {
|
||||||
id: u16,
|
id: u16,
|
||||||
item_id: u16,
|
item_id: u16,
|
||||||
|
wall_variant_id: Option<u16>,
|
||||||
translation_key: String,
|
translation_key: String,
|
||||||
name: String,
|
name: String,
|
||||||
properties: Vec<Property>,
|
properties: Vec<Property>,
|
||||||
|
@ -297,6 +298,22 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
})
|
})
|
||||||
.collect::<TokenStream>();
|
.collect::<TokenStream>();
|
||||||
|
|
||||||
|
let state_to_wall_variant_arms = blocks
|
||||||
|
.iter()
|
||||||
|
.filter(|b| b.wall_variant_id.is_some())
|
||||||
|
.map(|b| {
|
||||||
|
let block_name = ident(b.name.to_shouty_snake_case());
|
||||||
|
let wall_block_name = ident(
|
||||||
|
blocks[b.wall_variant_id.unwrap() as usize]
|
||||||
|
.name
|
||||||
|
.to_shouty_snake_case(),
|
||||||
|
);
|
||||||
|
quote! {
|
||||||
|
BlockState::#block_name => Some(BlockState::#wall_block_name),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<TokenStream>();
|
||||||
|
|
||||||
let state_to_block_entity_type_arms = blocks
|
let state_to_block_entity_type_arms = blocks
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|b| {
|
.flat_map(|b| {
|
||||||
|
@ -595,6 +612,16 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
#max_state_id
|
#max_state_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the wall variant of the block state.
|
||||||
|
///
|
||||||
|
/// If the given block state doesn't have a wall variant, `None` is returned.
|
||||||
|
pub const fn wall_block_id(self) -> Option<Self> {
|
||||||
|
match self {
|
||||||
|
#state_to_wall_variant_arms
|
||||||
|
_ => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Gets the value of the property with the given name from this block.
|
/// Gets the value of the property with the given name from this block.
|
||||||
///
|
///
|
||||||
/// If this block does not have the property, then `None` is returned.
|
/// If this block does not have the property, then `None` is returned.
|
||||||
|
|
|
@ -124,4 +124,21 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn blockstate_to_wall() {
|
||||||
|
assert_eq!(BlockState::STONE.wall_block_id(), None);
|
||||||
|
assert_eq!(
|
||||||
|
BlockState::OAK_SIGN.wall_block_id(),
|
||||||
|
Some(BlockState::OAK_WALL_SIGN)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
BlockState::GREEN_BANNER.wall_block_id(),
|
||||||
|
Some(BlockState::GREEN_WALL_BANNER)
|
||||||
|
);
|
||||||
|
assert_ne!(
|
||||||
|
BlockState::GREEN_BANNER.wall_block_id(),
|
||||||
|
Some(BlockState::GREEN_BANNER)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,6 +441,11 @@ impl PacketDecoder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "compression")]
|
||||||
|
pub fn compression(&self) -> bool {
|
||||||
|
self.compression_enabled
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "compression")]
|
#[cfg(feature = "compression")]
|
||||||
pub fn set_compression(&mut self, enabled: bool) {
|
pub fn set_compression(&mut self, enabled: bool) {
|
||||||
self.compression_enabled = enabled;
|
self.compression_enabled = enabled;
|
||||||
|
|
|
@ -271,7 +271,7 @@ pub trait Decode<'a>: Sized {
|
||||||
/// ```
|
/// ```
|
||||||
/// use valence_protocol::{Encode, EncodePacket};
|
/// use valence_protocol::{Encode, EncodePacket};
|
||||||
///
|
///
|
||||||
/// #[derive(Encode, EncodePacket)]
|
/// #[derive(Encode, EncodePacket, Debug)]
|
||||||
/// #[packet_id = 42]
|
/// #[packet_id = 42]
|
||||||
/// struct MyStruct {
|
/// struct MyStruct {
|
||||||
/// first: i32,
|
/// first: i32,
|
||||||
|
@ -308,7 +308,7 @@ pub trait EncodePacket: fmt::Debug {
|
||||||
/// ```
|
/// ```
|
||||||
/// use valence_protocol::{Decode, DecodePacket};
|
/// use valence_protocol::{Decode, DecodePacket};
|
||||||
///
|
///
|
||||||
/// #[derive(Decode, DecodePacket)]
|
/// #[derive(Decode, DecodePacket, Debug)]
|
||||||
/// #[packet_id = 42]
|
/// #[packet_id = 42]
|
||||||
/// struct MyStruct {
|
/// struct MyStruct {
|
||||||
/// first: i32,
|
/// first: i32,
|
||||||
|
|
|
@ -27676,6 +27676,7 @@
|
||||||
"name": "torch",
|
"name": "torch",
|
||||||
"translation_key": "block.minecraft.torch",
|
"translation_key": "block.minecraft.torch",
|
||||||
"item_id": 255,
|
"item_id": 255,
|
||||||
|
"wall_variant_id": 162,
|
||||||
"properties": [],
|
"properties": [],
|
||||||
"default_state_id": 2303,
|
"default_state_id": 2303,
|
||||||
"states": [
|
"states": [
|
||||||
|
@ -42091,6 +42092,7 @@
|
||||||
"name": "oak_sign",
|
"name": "oak_sign",
|
||||||
"translation_key": "block.minecraft.oak_sign",
|
"translation_key": "block.minecraft.oak_sign",
|
||||||
"item_id": 821,
|
"item_id": 821,
|
||||||
|
"wall_variant_id": 188,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -42386,6 +42388,7 @@
|
||||||
"name": "spruce_sign",
|
"name": "spruce_sign",
|
||||||
"translation_key": "block.minecraft.spruce_sign",
|
"translation_key": "block.minecraft.spruce_sign",
|
||||||
"item_id": 822,
|
"item_id": 822,
|
||||||
|
"wall_variant_id": 189,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -42681,6 +42684,7 @@
|
||||||
"name": "birch_sign",
|
"name": "birch_sign",
|
||||||
"translation_key": "block.minecraft.birch_sign",
|
"translation_key": "block.minecraft.birch_sign",
|
||||||
"item_id": 823,
|
"item_id": 823,
|
||||||
|
"wall_variant_id": 190,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -42976,6 +42980,7 @@
|
||||||
"name": "acacia_sign",
|
"name": "acacia_sign",
|
||||||
"translation_key": "block.minecraft.acacia_sign",
|
"translation_key": "block.minecraft.acacia_sign",
|
||||||
"item_id": 825,
|
"item_id": 825,
|
||||||
|
"wall_variant_id": 191,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -43271,6 +43276,7 @@
|
||||||
"name": "jungle_sign",
|
"name": "jungle_sign",
|
||||||
"translation_key": "block.minecraft.jungle_sign",
|
"translation_key": "block.minecraft.jungle_sign",
|
||||||
"item_id": 824,
|
"item_id": 824,
|
||||||
|
"wall_variant_id": 192,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -43566,6 +43572,7 @@
|
||||||
"name": "dark_oak_sign",
|
"name": "dark_oak_sign",
|
||||||
"translation_key": "block.minecraft.dark_oak_sign",
|
"translation_key": "block.minecraft.dark_oak_sign",
|
||||||
"item_id": 826,
|
"item_id": 826,
|
||||||
|
"wall_variant_id": 193,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -43861,6 +43868,7 @@
|
||||||
"name": "mangrove_sign",
|
"name": "mangrove_sign",
|
||||||
"translation_key": "block.minecraft.mangrove_sign",
|
"translation_key": "block.minecraft.mangrove_sign",
|
||||||
"item_id": 827,
|
"item_id": 827,
|
||||||
|
"wall_variant_id": 194,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -44156,6 +44164,7 @@
|
||||||
"name": "bamboo_sign",
|
"name": "bamboo_sign",
|
||||||
"translation_key": "block.minecraft.bamboo_sign",
|
"translation_key": "block.minecraft.bamboo_sign",
|
||||||
"item_id": 828,
|
"item_id": 828,
|
||||||
|
"wall_variant_id": 195,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -46967,6 +46976,7 @@
|
||||||
"name": "oak_hanging_sign",
|
"name": "oak_hanging_sign",
|
||||||
"translation_key": "block.minecraft.oak_hanging_sign",
|
"translation_key": "block.minecraft.oak_hanging_sign",
|
||||||
"item_id": 831,
|
"item_id": 831,
|
||||||
|
"wall_variant_id": 206,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "attached",
|
"name": "attached",
|
||||||
|
@ -47525,6 +47535,7 @@
|
||||||
"name": "spruce_hanging_sign",
|
"name": "spruce_hanging_sign",
|
||||||
"translation_key": "block.minecraft.spruce_hanging_sign",
|
"translation_key": "block.minecraft.spruce_hanging_sign",
|
||||||
"item_id": 832,
|
"item_id": 832,
|
||||||
|
"wall_variant_id": 207,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "attached",
|
"name": "attached",
|
||||||
|
@ -48083,6 +48094,7 @@
|
||||||
"name": "birch_hanging_sign",
|
"name": "birch_hanging_sign",
|
||||||
"translation_key": "block.minecraft.birch_hanging_sign",
|
"translation_key": "block.minecraft.birch_hanging_sign",
|
||||||
"item_id": 833,
|
"item_id": 833,
|
||||||
|
"wall_variant_id": 208,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "attached",
|
"name": "attached",
|
||||||
|
@ -48641,6 +48653,7 @@
|
||||||
"name": "acacia_hanging_sign",
|
"name": "acacia_hanging_sign",
|
||||||
"translation_key": "block.minecraft.acacia_hanging_sign",
|
"translation_key": "block.minecraft.acacia_hanging_sign",
|
||||||
"item_id": 835,
|
"item_id": 835,
|
||||||
|
"wall_variant_id": 209,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "attached",
|
"name": "attached",
|
||||||
|
@ -49199,6 +49212,7 @@
|
||||||
"name": "jungle_hanging_sign",
|
"name": "jungle_hanging_sign",
|
||||||
"translation_key": "block.minecraft.jungle_hanging_sign",
|
"translation_key": "block.minecraft.jungle_hanging_sign",
|
||||||
"item_id": 834,
|
"item_id": 834,
|
||||||
|
"wall_variant_id": 210,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "attached",
|
"name": "attached",
|
||||||
|
@ -49757,6 +49771,7 @@
|
||||||
"name": "dark_oak_hanging_sign",
|
"name": "dark_oak_hanging_sign",
|
||||||
"translation_key": "block.minecraft.dark_oak_hanging_sign",
|
"translation_key": "block.minecraft.dark_oak_hanging_sign",
|
||||||
"item_id": 836,
|
"item_id": 836,
|
||||||
|
"wall_variant_id": 211,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "attached",
|
"name": "attached",
|
||||||
|
@ -50315,6 +50330,7 @@
|
||||||
"name": "crimson_hanging_sign",
|
"name": "crimson_hanging_sign",
|
||||||
"translation_key": "block.minecraft.crimson_hanging_sign",
|
"translation_key": "block.minecraft.crimson_hanging_sign",
|
||||||
"item_id": 839,
|
"item_id": 839,
|
||||||
|
"wall_variant_id": 213,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "attached",
|
"name": "attached",
|
||||||
|
@ -50873,6 +50889,7 @@
|
||||||
"name": "warped_hanging_sign",
|
"name": "warped_hanging_sign",
|
||||||
"translation_key": "block.minecraft.warped_hanging_sign",
|
"translation_key": "block.minecraft.warped_hanging_sign",
|
||||||
"item_id": 840,
|
"item_id": 840,
|
||||||
|
"wall_variant_id": 214,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "attached",
|
"name": "attached",
|
||||||
|
@ -51431,6 +51448,7 @@
|
||||||
"name": "mangrove_hanging_sign",
|
"name": "mangrove_hanging_sign",
|
||||||
"translation_key": "block.minecraft.mangrove_hanging_sign",
|
"translation_key": "block.minecraft.mangrove_hanging_sign",
|
||||||
"item_id": 837,
|
"item_id": 837,
|
||||||
|
"wall_variant_id": 212,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "attached",
|
"name": "attached",
|
||||||
|
@ -51989,6 +52007,7 @@
|
||||||
"name": "bamboo_hanging_sign",
|
"name": "bamboo_hanging_sign",
|
||||||
"translation_key": "block.minecraft.bamboo_hanging_sign",
|
"translation_key": "block.minecraft.bamboo_hanging_sign",
|
||||||
"item_id": 838,
|
"item_id": 838,
|
||||||
|
"wall_variant_id": 215,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "attached",
|
"name": "attached",
|
||||||
|
@ -54804,6 +54823,7 @@
|
||||||
"name": "redstone_torch",
|
"name": "redstone_torch",
|
||||||
"translation_key": "block.minecraft.redstone_torch",
|
"translation_key": "block.minecraft.redstone_torch",
|
||||||
"item_id": 619,
|
"item_id": 619,
|
||||||
|
"wall_variant_id": 230,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "lit",
|
"name": "lit",
|
||||||
|
@ -56155,6 +56175,7 @@
|
||||||
"name": "soul_torch",
|
"name": "soul_torch",
|
||||||
"translation_key": "block.minecraft.soul_torch",
|
"translation_key": "block.minecraft.soul_torch",
|
||||||
"item_id": 294,
|
"item_id": 294,
|
||||||
|
"wall_variant_id": 247,
|
||||||
"properties": [],
|
"properties": [],
|
||||||
"default_state_id": 5693,
|
"default_state_id": 5693,
|
||||||
"states": [
|
"states": [
|
||||||
|
@ -86355,6 +86376,7 @@
|
||||||
"name": "skeleton_skull",
|
"name": "skeleton_skull",
|
||||||
"translation_key": "block.minecraft.skeleton_skull",
|
"translation_key": "block.minecraft.skeleton_skull",
|
||||||
"item_id": 1029,
|
"item_id": 1029,
|
||||||
|
"wall_variant_id": 376,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -86607,6 +86629,7 @@
|
||||||
"name": "wither_skeleton_skull",
|
"name": "wither_skeleton_skull",
|
||||||
"translation_key": "block.minecraft.wither_skeleton_skull",
|
"translation_key": "block.minecraft.wither_skeleton_skull",
|
||||||
"item_id": 1030,
|
"item_id": 1030,
|
||||||
|
"wall_variant_id": 378,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -86859,6 +86882,7 @@
|
||||||
"name": "zombie_head",
|
"name": "zombie_head",
|
||||||
"translation_key": "block.minecraft.zombie_head",
|
"translation_key": "block.minecraft.zombie_head",
|
||||||
"item_id": 1032,
|
"item_id": 1032,
|
||||||
|
"wall_variant_id": 380,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -87111,6 +87135,7 @@
|
||||||
"name": "player_head",
|
"name": "player_head",
|
||||||
"translation_key": "block.minecraft.player_head",
|
"translation_key": "block.minecraft.player_head",
|
||||||
"item_id": 1031,
|
"item_id": 1031,
|
||||||
|
"wall_variant_id": 382,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -87363,6 +87388,7 @@
|
||||||
"name": "creeper_head",
|
"name": "creeper_head",
|
||||||
"translation_key": "block.minecraft.creeper_head",
|
"translation_key": "block.minecraft.creeper_head",
|
||||||
"item_id": 1033,
|
"item_id": 1033,
|
||||||
|
"wall_variant_id": 384,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -87615,6 +87641,7 @@
|
||||||
"name": "dragon_head",
|
"name": "dragon_head",
|
||||||
"translation_key": "block.minecraft.dragon_head",
|
"translation_key": "block.minecraft.dragon_head",
|
||||||
"item_id": 1034,
|
"item_id": 1034,
|
||||||
|
"wall_variant_id": 386,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -87867,6 +87894,7 @@
|
||||||
"name": "piglin_head",
|
"name": "piglin_head",
|
||||||
"translation_key": "block.minecraft.piglin_head",
|
"translation_key": "block.minecraft.piglin_head",
|
||||||
"item_id": 1035,
|
"item_id": 1035,
|
||||||
|
"wall_variant_id": 388,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -106046,6 +106074,7 @@
|
||||||
"name": "white_banner",
|
"name": "white_banner",
|
||||||
"translation_key": "block.minecraft.white_banner",
|
"translation_key": "block.minecraft.white_banner",
|
||||||
"item_id": 1059,
|
"item_id": 1059,
|
||||||
|
"wall_variant_id": 499,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -106206,6 +106235,7 @@
|
||||||
"name": "orange_banner",
|
"name": "orange_banner",
|
||||||
"translation_key": "block.minecraft.orange_banner",
|
"translation_key": "block.minecraft.orange_banner",
|
||||||
"item_id": 1060,
|
"item_id": 1060,
|
||||||
|
"wall_variant_id": 500,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -106366,6 +106396,7 @@
|
||||||
"name": "magenta_banner",
|
"name": "magenta_banner",
|
||||||
"translation_key": "block.minecraft.magenta_banner",
|
"translation_key": "block.minecraft.magenta_banner",
|
||||||
"item_id": 1061,
|
"item_id": 1061,
|
||||||
|
"wall_variant_id": 501,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -106526,6 +106557,7 @@
|
||||||
"name": "light_blue_banner",
|
"name": "light_blue_banner",
|
||||||
"translation_key": "block.minecraft.light_blue_banner",
|
"translation_key": "block.minecraft.light_blue_banner",
|
||||||
"item_id": 1062,
|
"item_id": 1062,
|
||||||
|
"wall_variant_id": 502,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -106686,6 +106718,7 @@
|
||||||
"name": "yellow_banner",
|
"name": "yellow_banner",
|
||||||
"translation_key": "block.minecraft.yellow_banner",
|
"translation_key": "block.minecraft.yellow_banner",
|
||||||
"item_id": 1063,
|
"item_id": 1063,
|
||||||
|
"wall_variant_id": 503,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -106846,6 +106879,7 @@
|
||||||
"name": "lime_banner",
|
"name": "lime_banner",
|
||||||
"translation_key": "block.minecraft.lime_banner",
|
"translation_key": "block.minecraft.lime_banner",
|
||||||
"item_id": 1064,
|
"item_id": 1064,
|
||||||
|
"wall_variant_id": 504,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -107006,6 +107040,7 @@
|
||||||
"name": "pink_banner",
|
"name": "pink_banner",
|
||||||
"translation_key": "block.minecraft.pink_banner",
|
"translation_key": "block.minecraft.pink_banner",
|
||||||
"item_id": 1065,
|
"item_id": 1065,
|
||||||
|
"wall_variant_id": 505,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -107166,6 +107201,7 @@
|
||||||
"name": "gray_banner",
|
"name": "gray_banner",
|
||||||
"translation_key": "block.minecraft.gray_banner",
|
"translation_key": "block.minecraft.gray_banner",
|
||||||
"item_id": 1066,
|
"item_id": 1066,
|
||||||
|
"wall_variant_id": 506,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -107326,6 +107362,7 @@
|
||||||
"name": "light_gray_banner",
|
"name": "light_gray_banner",
|
||||||
"translation_key": "block.minecraft.light_gray_banner",
|
"translation_key": "block.minecraft.light_gray_banner",
|
||||||
"item_id": 1067,
|
"item_id": 1067,
|
||||||
|
"wall_variant_id": 507,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -107486,6 +107523,7 @@
|
||||||
"name": "cyan_banner",
|
"name": "cyan_banner",
|
||||||
"translation_key": "block.minecraft.cyan_banner",
|
"translation_key": "block.minecraft.cyan_banner",
|
||||||
"item_id": 1068,
|
"item_id": 1068,
|
||||||
|
"wall_variant_id": 508,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -107646,6 +107684,7 @@
|
||||||
"name": "purple_banner",
|
"name": "purple_banner",
|
||||||
"translation_key": "block.minecraft.purple_banner",
|
"translation_key": "block.minecraft.purple_banner",
|
||||||
"item_id": 1069,
|
"item_id": 1069,
|
||||||
|
"wall_variant_id": 509,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -107806,6 +107845,7 @@
|
||||||
"name": "blue_banner",
|
"name": "blue_banner",
|
||||||
"translation_key": "block.minecraft.blue_banner",
|
"translation_key": "block.minecraft.blue_banner",
|
||||||
"item_id": 1070,
|
"item_id": 1070,
|
||||||
|
"wall_variant_id": 510,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -107966,6 +108006,7 @@
|
||||||
"name": "brown_banner",
|
"name": "brown_banner",
|
||||||
"translation_key": "block.minecraft.brown_banner",
|
"translation_key": "block.minecraft.brown_banner",
|
||||||
"item_id": 1071,
|
"item_id": 1071,
|
||||||
|
"wall_variant_id": 511,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -108126,6 +108167,7 @@
|
||||||
"name": "green_banner",
|
"name": "green_banner",
|
||||||
"translation_key": "block.minecraft.green_banner",
|
"translation_key": "block.minecraft.green_banner",
|
||||||
"item_id": 1072,
|
"item_id": 1072,
|
||||||
|
"wall_variant_id": 512,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -108286,6 +108328,7 @@
|
||||||
"name": "red_banner",
|
"name": "red_banner",
|
||||||
"translation_key": "block.minecraft.red_banner",
|
"translation_key": "block.minecraft.red_banner",
|
||||||
"item_id": 1073,
|
"item_id": 1073,
|
||||||
|
"wall_variant_id": 513,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -108446,6 +108489,7 @@
|
||||||
"name": "black_banner",
|
"name": "black_banner",
|
||||||
"translation_key": "block.minecraft.black_banner",
|
"translation_key": "block.minecraft.black_banner",
|
||||||
"item_id": 1074,
|
"item_id": 1074,
|
||||||
|
"wall_variant_id": 514,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -127600,6 +127644,7 @@
|
||||||
"name": "dead_tube_coral_fan",
|
"name": "dead_tube_coral_fan",
|
||||||
"translation_key": "block.minecraft.dead_tube_coral_fan",
|
"translation_key": "block.minecraft.dead_tube_coral_fan",
|
||||||
"item_id": 575,
|
"item_id": 575,
|
||||||
|
"wall_variant_id": 685,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "waterlogged",
|
"name": "waterlogged",
|
||||||
|
@ -127632,6 +127677,7 @@
|
||||||
"name": "dead_brain_coral_fan",
|
"name": "dead_brain_coral_fan",
|
||||||
"translation_key": "block.minecraft.dead_brain_coral_fan",
|
"translation_key": "block.minecraft.dead_brain_coral_fan",
|
||||||
"item_id": 576,
|
"item_id": 576,
|
||||||
|
"wall_variant_id": 686,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "waterlogged",
|
"name": "waterlogged",
|
||||||
|
@ -127664,6 +127710,7 @@
|
||||||
"name": "dead_bubble_coral_fan",
|
"name": "dead_bubble_coral_fan",
|
||||||
"translation_key": "block.minecraft.dead_bubble_coral_fan",
|
"translation_key": "block.minecraft.dead_bubble_coral_fan",
|
||||||
"item_id": 577,
|
"item_id": 577,
|
||||||
|
"wall_variant_id": 687,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "waterlogged",
|
"name": "waterlogged",
|
||||||
|
@ -127696,6 +127743,7 @@
|
||||||
"name": "dead_fire_coral_fan",
|
"name": "dead_fire_coral_fan",
|
||||||
"translation_key": "block.minecraft.dead_fire_coral_fan",
|
"translation_key": "block.minecraft.dead_fire_coral_fan",
|
||||||
"item_id": 578,
|
"item_id": 578,
|
||||||
|
"wall_variant_id": 688,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "waterlogged",
|
"name": "waterlogged",
|
||||||
|
@ -127728,6 +127776,7 @@
|
||||||
"name": "dead_horn_coral_fan",
|
"name": "dead_horn_coral_fan",
|
||||||
"translation_key": "block.minecraft.dead_horn_coral_fan",
|
"translation_key": "block.minecraft.dead_horn_coral_fan",
|
||||||
"item_id": 579,
|
"item_id": 579,
|
||||||
|
"wall_variant_id": 689,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "waterlogged",
|
"name": "waterlogged",
|
||||||
|
@ -127760,6 +127809,7 @@
|
||||||
"name": "tube_coral_fan",
|
"name": "tube_coral_fan",
|
||||||
"translation_key": "block.minecraft.tube_coral_fan",
|
"translation_key": "block.minecraft.tube_coral_fan",
|
||||||
"item_id": 570,
|
"item_id": 570,
|
||||||
|
"wall_variant_id": 690,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "waterlogged",
|
"name": "waterlogged",
|
||||||
|
@ -127792,6 +127842,7 @@
|
||||||
"name": "brain_coral_fan",
|
"name": "brain_coral_fan",
|
||||||
"translation_key": "block.minecraft.brain_coral_fan",
|
"translation_key": "block.minecraft.brain_coral_fan",
|
||||||
"item_id": 571,
|
"item_id": 571,
|
||||||
|
"wall_variant_id": 691,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "waterlogged",
|
"name": "waterlogged",
|
||||||
|
@ -127824,6 +127875,7 @@
|
||||||
"name": "bubble_coral_fan",
|
"name": "bubble_coral_fan",
|
||||||
"translation_key": "block.minecraft.bubble_coral_fan",
|
"translation_key": "block.minecraft.bubble_coral_fan",
|
||||||
"item_id": 572,
|
"item_id": 572,
|
||||||
|
"wall_variant_id": 692,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "waterlogged",
|
"name": "waterlogged",
|
||||||
|
@ -127856,6 +127908,7 @@
|
||||||
"name": "fire_coral_fan",
|
"name": "fire_coral_fan",
|
||||||
"translation_key": "block.minecraft.fire_coral_fan",
|
"translation_key": "block.minecraft.fire_coral_fan",
|
||||||
"item_id": 573,
|
"item_id": 573,
|
||||||
|
"wall_variant_id": 693,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "waterlogged",
|
"name": "waterlogged",
|
||||||
|
@ -127888,6 +127941,7 @@
|
||||||
"name": "horn_coral_fan",
|
"name": "horn_coral_fan",
|
||||||
"translation_key": "block.minecraft.horn_coral_fan",
|
"translation_key": "block.minecraft.horn_coral_fan",
|
||||||
"item_id": 574,
|
"item_id": 574,
|
||||||
|
"wall_variant_id": 694,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "waterlogged",
|
"name": "waterlogged",
|
||||||
|
@ -199667,6 +199721,7 @@
|
||||||
"name": "crimson_sign",
|
"name": "crimson_sign",
|
||||||
"translation_key": "block.minecraft.crimson_sign",
|
"translation_key": "block.minecraft.crimson_sign",
|
||||||
"item_id": 829,
|
"item_id": 829,
|
||||||
|
"wall_variant_id": 802,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
@ -199962,6 +200017,7 @@
|
||||||
"name": "warped_sign",
|
"name": "warped_sign",
|
||||||
"translation_key": "block.minecraft.warped_sign",
|
"translation_key": "block.minecraft.warped_sign",
|
||||||
"item_id": 830,
|
"item_id": 830,
|
||||||
|
"wall_variant_id": 803,
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"name": "rotation",
|
"name": "rotation",
|
||||||
|
|
|
@ -4,9 +4,11 @@ import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
|
import net.minecraft.item.VerticallyAttachableBlockItem;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.EmptyBlockView;
|
import net.minecraft.world.EmptyBlockView;
|
||||||
import rs.valence.extractor.Main;
|
import rs.valence.extractor.Main;
|
||||||
|
import rs.valence.extractor.mixin.ExposeWallBlock;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -37,6 +39,13 @@ public class Blocks implements Main.Extractor {
|
||||||
blockJson.addProperty("translation_key", block.getTranslationKey());
|
blockJson.addProperty("translation_key", block.getTranslationKey());
|
||||||
blockJson.addProperty("item_id", Registries.ITEM.getRawId(block.asItem()));
|
blockJson.addProperty("item_id", Registries.ITEM.getRawId(block.asItem()));
|
||||||
|
|
||||||
|
if (block.asItem() instanceof VerticallyAttachableBlockItem wsbItem) {
|
||||||
|
if (wsbItem.getBlock() == block) {
|
||||||
|
var wallBlock = ((ExposeWallBlock) wsbItem).getWallBlock();
|
||||||
|
blockJson.addProperty("wall_variant_id", Registries.BLOCK.getRawId(wallBlock));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var propsJson = new JsonArray();
|
var propsJson = new JsonArray();
|
||||||
for (var prop : block.getStateManager().getProperties()) {
|
for (var prop : block.getStateManager().getProperties()) {
|
||||||
var propJson = new JsonObject();
|
var propJson = new JsonObject();
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package rs.valence.extractor.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.item.VerticallyAttachableBlockItem;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
@Mixin(VerticallyAttachableBlockItem.class)
|
||||||
|
public interface ExposeWallBlock {
|
||||||
|
@Accessor
|
||||||
|
Block getWallBlock();
|
||||||
|
}
|
9
extractor/src/main/resources/extractor.mixins.json
Normal file
9
extractor/src/main/resources/extractor.mixins.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"package": "rs.valence.extractor.mixin",
|
||||||
|
"compatibilityLevel": "JAVA_17",
|
||||||
|
"mixins": [
|
||||||
|
"ExposeWallBlock"
|
||||||
|
]
|
||||||
|
}
|
|
@ -17,7 +17,9 @@
|
||||||
"rs.valence.extractor.Main"
|
"rs.valence.extractor.Main"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [],
|
"mixins": [
|
||||||
|
"extractor.mixins.json"
|
||||||
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.6",
|
"fabricloader": ">=0.14.6",
|
||||||
"minecraft": "~1.19",
|
"minecraft": "~1.19",
|
||||||
|
|
Loading…
Reference in a new issue