From fd3bb110a90135aca5040f54373c090af2fdd6b3 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Mon, 13 May 2019 19:05:59 -0700 Subject: [PATCH 01/24] Add hardcoded rockwool -> wool conversion --- blocks/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index bdbc9ccc..12d2c4bc 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -137,6 +137,12 @@ macro_rules! define_blocks { if protocol_version >= 404 { VANILLA_ID_MAP.flat.get(id).and_then(|v| *v).unwrap_or(Block::Missing{}) } else { + // rockwool -> wool + // TODO: avoid hardcoding ids, lookup from ModIdData + if id >> 4 == 3731 { + return VANILLA_ID_MAP.hier.get((35 << 4) | (id & 0xf)).and_then(|v| *v).unwrap() + } + VANILLA_ID_MAP.hier.get(id).and_then(|v| *v).unwrap_or(Block::Missing{}) } } From e7866912fd53426df6aeee67b5e1f1d84484c7a6 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Tue, 14 May 2019 18:23:54 -0700 Subject: [PATCH 02/24] Add modid macro token, skipped from vanilla, and Rockwool with modid --- blocks/src/lib.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index 12d2c4bc..89fb7163 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -50,6 +50,7 @@ macro_rules! define_blocks { ( $( $name:ident { + $(modid $modid:expr,)* props { $( $fname:ident : $ftype:ty = [$($val:expr),+], @@ -102,6 +103,10 @@ macro_rules! define_blocks { Block::$name { $($fname,)* } => { + $( + $modid; + return None; + )* $( let data: Option = ($datafunc).map(|v| v); return data; @@ -119,6 +124,10 @@ macro_rules! define_blocks { Block::$name { $($fname,)* } => { + $( + $modid; + return None; + )* $( let offset: Option = ($offsetfunc).map(|v| v); return offset; @@ -1020,6 +1029,32 @@ define_blocks! { data Some(color.data()), model { ("minecraft", format!("{}_wool", color.as_string()) ) }, } + Rockwool { + modid "\u{1}ThermalExpansion:Rockwool", + props { + color: ColoredVariant = [ + ColoredVariant::White, + ColoredVariant::Orange, + ColoredVariant::Magenta, + ColoredVariant::LightBlue, + ColoredVariant::Yellow, + ColoredVariant::Lime, + ColoredVariant::Pink, + ColoredVariant::Gray, + ColoredVariant::Silver, + ColoredVariant::Cyan, + ColoredVariant::Purple, + ColoredVariant::Blue, + ColoredVariant::Brown, + ColoredVariant::Green, + ColoredVariant::Red, + ColoredVariant::Black + ], + }, + data Some(color.data()), + model { ("minecraft", format!("{}_wool", color.as_string()) ) }, + } + PistonExtension { props { facing: Direction = [ From 9dd51dd9ef6f0f1ce6650b69df587f96e3f5b920 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Tue, 14 May 2019 18:30:23 -0700 Subject: [PATCH 03/24] Add get_modid() accessor for modid macro token --- blocks/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index 89fb7163..be4da39e 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -142,6 +142,22 @@ macro_rules! define_blocks { } } + #[allow(unused_variables, unreachable_code)] + pub fn get_modid(&self) -> Option<&str> { + match *self { + $( + Block::$name { + $($fname,)* + } => { + $( + return Some($modid); + )* + None + } + )+ + } + } + pub fn by_vanilla_id(id: usize, protocol_version: i32) -> Block { if protocol_version >= 404 { VANILLA_ID_MAP.flat.get(id).and_then(|v| *v).unwrap_or(Block::Missing{}) From 12034c339e40070396be8adc422896bf1c5428dd Mon Sep 17 00:00:00 2001 From: ice_iix Date: Tue, 14 May 2019 18:36:51 -0700 Subject: [PATCH 04/24] Change to skip modid in vanilla block iter, instead of offset/data accessors --- blocks/src/lib.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index be4da39e..867876bb 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -103,10 +103,6 @@ macro_rules! define_blocks { Block::$name { $($fname,)* } => { - $( - $modid; - return None; - )* $( let data: Option = ($datafunc).map(|v| v); return data; @@ -124,10 +120,6 @@ macro_rules! define_blocks { Block::$name { $($fname,)* } => { - $( - $modid; - return None; - )* $( let offset: Option = ($offsetfunc).map(|v| v); return offset; @@ -384,6 +376,10 @@ macro_rules! define_blocks { for block in iter { let internal_id = block.get_internal_id(); let hier_data: Option = block.get_hierarchical_data(); + if let Some(_modid) = block.get_modid() { + continue + } + let vanilla_id = if let Some(hier_data) = hier_data { if internal_id != last_internal_id { From b8881b9c8ccada44d04809596791d1c7ae3f19a9 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Tue, 14 May 2019 18:44:35 -0700 Subject: [PATCH 05/24] Return the new Rockwool block for modded id instead of vanilla Wool --- blocks/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index 867876bb..004563a1 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -157,7 +157,8 @@ macro_rules! define_blocks { // rockwool -> wool // TODO: avoid hardcoding ids, lookup from ModIdData if id >> 4 == 3731 { - return VANILLA_ID_MAP.hier.get((35 << 4) | (id & 0xf)).and_then(|v| *v).unwrap() + // TODO: correct variant from id & 0xf + return Block::Rockwool { color: ColoredVariant::Orange } } VANILLA_ID_MAP.hier.get(id).and_then(|v| *v).unwrap_or(Block::Missing{}) From 6d838efb80eaa64fa9b5b138c66bd55675c452c0 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Tue, 14 May 2019 19:28:30 -0700 Subject: [PATCH 06/24] Register modded blocks by modid->[data], and lookup correct rockwool data --- blocks/src/lib.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index 004563a1..dc7e3b6d 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -7,6 +7,7 @@ use crate::shared::{Axis, Direction, Position}; use collision::Aabb3; use cgmath::Point3; use lazy_static::lazy_static; +use std::collections::HashMap; pub mod material; pub use self::material::Material; @@ -44,6 +45,8 @@ macro_rules! create_ids { struct VanillaIDMap { flat: Vec>, hier: Vec>, + //modded: HashMap<&'static str, [Option; 16]>, // TODO: fixed-size array? + modded: HashMap>>, } macro_rules! define_blocks { @@ -157,8 +160,11 @@ macro_rules! define_blocks { // rockwool -> wool // TODO: avoid hardcoding ids, lookup from ModIdData if id >> 4 == 3731 { - // TODO: correct variant from id & 0xf - return Block::Rockwool { color: ColoredVariant::Orange } + let data = id & 0xf; + return VANILLA_ID_MAP.modded + .get("\u{1}ThermalExpansion:Rockwool") + .unwrap()[data] + .unwrap_or(Block::Missing{}) } VANILLA_ID_MAP.hier.get(id).and_then(|v| *v).unwrap_or(Block::Missing{}) @@ -281,6 +287,7 @@ macro_rules! define_blocks { static ref VANILLA_ID_MAP: VanillaIDMap = { let mut blocks_flat = vec![]; let mut blocks_hier = vec![]; + let mut blocks_modded: HashMap>> = HashMap::new(); let mut flat_id = 0; let mut last_internal_id = 0; let mut hier_block_id = 0; @@ -377,7 +384,14 @@ macro_rules! define_blocks { for block in iter { let internal_id = block.get_internal_id(); let hier_data: Option = block.get_hierarchical_data(); - if let Some(_modid) = block.get_modid() { + if let Some(modid) = block.get_modid() { + println!("Mod id: {}, hier_data {:?}", modid, hier_data); + let hier_data = hier_data.unwrap(); + if !blocks_modded.contains_key(modid) { + blocks_modded.insert(modid.to_string(), vec![None; 16]); + } + let block_from_data = blocks_modded.get_mut(modid).unwrap(); + block_from_data[hier_data] = Some(block); continue } @@ -450,7 +464,7 @@ macro_rules! define_blocks { } })+ - VanillaIDMap { flat: blocks_flat, hier: blocks_hier } + VanillaIDMap { flat: blocks_flat, hier: blocks_hier, modded: blocks_modded } }; } ); From 1f38e35b2739f08dbc40394ceee80f7a66766686 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Tue, 14 May 2019 19:45:03 -0700 Subject: [PATCH 07/24] Lookup modded after vanilla --- blocks/src/lib.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index dc7e3b6d..b2f4dd93 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -156,18 +156,23 @@ macro_rules! define_blocks { pub fn by_vanilla_id(id: usize, protocol_version: i32) -> Block { if protocol_version >= 404 { VANILLA_ID_MAP.flat.get(id).and_then(|v| *v).unwrap_or(Block::Missing{}) + // TODO: support modded 1.13.2+ blocks after https://github.com/iceiix/stevenarella/pull/145 } else { - // rockwool -> wool - // TODO: avoid hardcoding ids, lookup from ModIdData - if id >> 4 == 3731 { - let data = id & 0xf; - return VANILLA_ID_MAP.modded - .get("\u{1}ThermalExpansion:Rockwool") - .unwrap()[data] - .unwrap_or(Block::Missing{}) + if let Some(block) = VANILLA_ID_MAP.hier.get(id).and_then(|v| *v) { + block + } else { + // rockwool -> wool + // TODO: avoid hardcoding ids, lookup from ModIdData + if id >> 4 == 3731 { + let data = id & 0xf; + return VANILLA_ID_MAP.modded + .get("\u{1}ThermalExpansion:Rockwool") + .unwrap()[data] + .unwrap_or(Block::Missing{}) + } else { + Block::Missing{} + } } - - VANILLA_ID_MAP.hier.get(id).and_then(|v| *v).unwrap_or(Block::Missing{}) } } From 8435ac7f931eaf37e4a97d3a8aeddc95253761eb Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 05:59:34 -0700 Subject: [PATCH 08/24] Save block IDs from ModIdData/RegistryData to self.modded_block_ids --- src/server/mod.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 9be139ac..4f968de4 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -43,6 +43,7 @@ pub struct Server { conn: Option, protocol_version: i32, forge_mods: Vec, + modded_block_ids: HashMap, read_queue: Option>>, pub disconnect_reason: Option, just_disconnected: bool, @@ -283,6 +284,7 @@ impl Server { conn, protocol_version, forge_mods, + modded_block_ids: HashMap::new(), read_queue, disconnect_reason: None, just_disconnected: false, @@ -711,17 +713,24 @@ impl Server { self.write_fmlhs_plugin_message(&HandshakeAck { phase: WaitingServerData }); }, - ModIdData { mappings: _, block_substitutions: _, item_substitutions: _ } => { + ModIdData { mappings, block_substitutions: _, item_substitutions: _ } => { println!("Received FML|HS ModIdData"); + for m in mappings.data { + self.modded_block_ids.insert(m.id.0, m.name); + } self.write_fmlhs_plugin_message(&HandshakeAck { phase: WaitingServerComplete }); // TODO: dynamically register mod blocks }, - RegistryData { has_more, name, ids: _, substitutions: _, dummies: _ } => { + RegistryData { has_more, name, ids, substitutions: _, dummies: _ } => { println!("Received FML|HS RegistryData for {}", name); + if name == "minecraft:blocks" { + for m in ids.data { + self.modded_block_ids.insert(m.id.0, m.name); + } + } if !has_more { self.write_fmlhs_plugin_message(&HandshakeAck { phase: WaitingServerComplete }); } - // TODO: dynamically register mod blocks }, HandshakeAck { phase } => { match phase { From cd1684011d83afaec85e9700147867996adb6eea Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 06:33:15 -0700 Subject: [PATCH 09/24] Attempt to add by_vanilla_id protocol-specific accessor in World Fails due to Rust's mutability rules: error[E0502]: cannot borrow `*self` as immutable because it is also borrowed as mutable --> src/world/mod.rs:626:44 | 600 | self.chunks.get_mut(&cpos).unwrap() | ----------- mutable borrow occurs here ... 626 | section.blocks.set(bi, self.by_vanilla_id(id as usize)); | ^^^^ immutable borrow occurs here ... 635 | ) + (chunk.position.0 << 4, (i << 4) as i32, chunk.position.1 << 4); | ---------------- mutable borrow later used here --- src/server/mod.rs | 6 +++--- src/world/mod.rs | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 4f968de4..072567ee 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -1294,7 +1294,7 @@ impl Server { } fn on_block_change(&mut self, location: Position, id: i32) { - self.world.set_block(location, block::Block::by_vanilla_id(id as usize, self.protocol_version)) + self.world.set_block(location, self.world.by_vanilla_id(id as usize)) } fn on_block_change_varint(&mut self, block_change: packet::play::clientbound::BlockChange_VarInt) { @@ -1318,7 +1318,7 @@ impl Server { record.y as i32, oz + (record.xz & 0xF) as i32 ), - block::Block::by_vanilla_id(record.block_id.0 as usize, self.protocol_version) + self.world.by_vanilla_id(record.block_id.0 as usize) ); } } @@ -1341,7 +1341,7 @@ impl Server { self.world.set_block( Position::new(x, y, z), - block::Block::by_vanilla_id(id as usize, self.protocol_version) + self.world.by_vanilla_id(id as usize) ); } } diff --git a/src/world/mod.rs b/src/world/mod.rs index 87f4c28c..734445e6 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -88,6 +88,10 @@ impl World { } } + pub fn by_vanilla_id(&self, id: usize) -> block::Block { + block::Block::by_vanilla_id(id, self.protocol_version) + } + pub fn is_chunk_loaded(&self, x: i32, z: i32) -> bool { self.chunks.contains_key(&CPos(x, z)) } @@ -619,7 +623,7 @@ impl World { for bi in 0 .. 4096 { let id = data.read_u16::()?; - section.blocks.set(bi, block::Block::by_vanilla_id(id as usize, self.protocol_version)); + section.blocks.set(bi, self.by_vanilla_id(id as usize)); // Spawn block entities let b = section.blocks.get(bi); @@ -805,7 +809,7 @@ impl World { for bi in 0 .. 4096 { let id = ((block_add[i].get(bi) as u16) << 12) | ((block_types[i][bi] as u16) << 4) | (block_meta[i].get(bi) as u16); - section.blocks.set(bi, block::Block::by_vanilla_id(id as usize, self.protocol_version)); + section.blocks.set(bi, self.by_vanilla_id(id as usize)); // Spawn block entities let b = section.blocks.get(bi); @@ -882,7 +886,7 @@ impl World { let count = VarInt::read_from(&mut data)?.0; for i in 0 .. count { let id = VarInt::read_from(&mut data)?.0; - let bl = block::Block::by_vanilla_id(id as usize, self.protocol_version); + let bl = self.by_vanilla_id(id as usize); mappings.insert(i as usize, bl); } } @@ -892,7 +896,7 @@ impl World { for bi in 0 .. 4096 { let id = m.get(bi); - section.blocks.set(bi, mappings.get(&id).cloned().unwrap_or(block::Block::by_vanilla_id(id, self.protocol_version))); + section.blocks.set(bi, mappings.get(&id).cloned().unwrap_or(self.by_vanilla_id(id))); // Spawn block entities let b = section.blocks.get(bi); if block_entity::BlockEntityType::get_block_entity(b).is_some() { From 588a74a1c607e6a9961e80631e211347c3b36cb8 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 06:40:48 -0700 Subject: [PATCH 10/24] Revert "Attempt to add by_vanilla_id protocol-specific accessor in World" This reverts commit cd1684011d83afaec85e9700147867996adb6eea. --- src/server/mod.rs | 6 +++--- src/world/mod.rs | 12 ++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 072567ee..4f968de4 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -1294,7 +1294,7 @@ impl Server { } fn on_block_change(&mut self, location: Position, id: i32) { - self.world.set_block(location, self.world.by_vanilla_id(id as usize)) + self.world.set_block(location, block::Block::by_vanilla_id(id as usize, self.protocol_version)) } fn on_block_change_varint(&mut self, block_change: packet::play::clientbound::BlockChange_VarInt) { @@ -1318,7 +1318,7 @@ impl Server { record.y as i32, oz + (record.xz & 0xF) as i32 ), - self.world.by_vanilla_id(record.block_id.0 as usize) + block::Block::by_vanilla_id(record.block_id.0 as usize, self.protocol_version) ); } } @@ -1341,7 +1341,7 @@ impl Server { self.world.set_block( Position::new(x, y, z), - self.world.by_vanilla_id(id as usize) + block::Block::by_vanilla_id(id as usize, self.protocol_version) ); } } diff --git a/src/world/mod.rs b/src/world/mod.rs index 734445e6..87f4c28c 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -88,10 +88,6 @@ impl World { } } - pub fn by_vanilla_id(&self, id: usize) -> block::Block { - block::Block::by_vanilla_id(id, self.protocol_version) - } - pub fn is_chunk_loaded(&self, x: i32, z: i32) -> bool { self.chunks.contains_key(&CPos(x, z)) } @@ -623,7 +619,7 @@ impl World { for bi in 0 .. 4096 { let id = data.read_u16::()?; - section.blocks.set(bi, self.by_vanilla_id(id as usize)); + section.blocks.set(bi, block::Block::by_vanilla_id(id as usize, self.protocol_version)); // Spawn block entities let b = section.blocks.get(bi); @@ -809,7 +805,7 @@ impl World { for bi in 0 .. 4096 { let id = ((block_add[i].get(bi) as u16) << 12) | ((block_types[i][bi] as u16) << 4) | (block_meta[i].get(bi) as u16); - section.blocks.set(bi, self.by_vanilla_id(id as usize)); + section.blocks.set(bi, block::Block::by_vanilla_id(id as usize, self.protocol_version)); // Spawn block entities let b = section.blocks.get(bi); @@ -886,7 +882,7 @@ impl World { let count = VarInt::read_from(&mut data)?.0; for i in 0 .. count { let id = VarInt::read_from(&mut data)?.0; - let bl = self.by_vanilla_id(id as usize); + let bl = block::Block::by_vanilla_id(id as usize, self.protocol_version); mappings.insert(i as usize, bl); } } @@ -896,7 +892,7 @@ impl World { for bi in 0 .. 4096 { let id = m.get(bi); - section.blocks.set(bi, mappings.get(&id).cloned().unwrap_or(self.by_vanilla_id(id))); + section.blocks.set(bi, mappings.get(&id).cloned().unwrap_or(block::Block::by_vanilla_id(id, self.protocol_version))); // Spawn block entities let b = section.blocks.get(bi); if block_entity::BlockEntityType::get_block_entity(b).is_some() { From 19230b19898aba2a1a5abb8606487f907a99d676 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 06:59:12 -0700 Subject: [PATCH 11/24] Pass and lookup modded_block_ids in by_vanilla_id --- blocks/src/lib.rs | 15 ++++++++------- src/server/mod.rs | 12 ++++++------ src/world/mod.rs | 9 +++++---- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index b2f4dd93..d05cc87d 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -153,7 +153,7 @@ macro_rules! define_blocks { } } - pub fn by_vanilla_id(id: usize, protocol_version: i32) -> Block { + pub fn by_vanilla_id(id: usize, protocol_version: i32, modded_block_ids: &HashMap) -> Block { if protocol_version >= 404 { VANILLA_ID_MAP.flat.get(id).and_then(|v| *v).unwrap_or(Block::Missing{}) // TODO: support modded 1.13.2+ blocks after https://github.com/iceiix/stevenarella/pull/145 @@ -161,12 +161,13 @@ macro_rules! define_blocks { if let Some(block) = VANILLA_ID_MAP.hier.get(id).and_then(|v| *v) { block } else { - // rockwool -> wool - // TODO: avoid hardcoding ids, lookup from ModIdData - if id >> 4 == 3731 { - let data = id & 0xf; - return VANILLA_ID_MAP.modded - .get("\u{1}ThermalExpansion:Rockwool") + let data = id & 0xf; + println!("Looking up custom block id {}:{}", id >> 4, data); + + if let Some(name) = modded_block_ids.get(&(id >> 4)) { + println!("Resolved modded block id {}:{} -> {}", id >> 4, data, name); + VANILLA_ID_MAP.modded + .get(name) .unwrap()[data] .unwrap_or(Block::Missing{}) } else { diff --git a/src/server/mod.rs b/src/server/mod.rs index 4f968de4..128ca2ba 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -43,7 +43,7 @@ pub struct Server { conn: Option, protocol_version: i32, forge_mods: Vec, - modded_block_ids: HashMap, + modded_block_ids: HashMap, read_queue: Option>>, pub disconnect_reason: Option, just_disconnected: bool, @@ -716,7 +716,7 @@ impl Server { ModIdData { mappings, block_substitutions: _, item_substitutions: _ } => { println!("Received FML|HS ModIdData"); for m in mappings.data { - self.modded_block_ids.insert(m.id.0, m.name); + self.modded_block_ids.insert(m.id.0 as usize, m.name); } self.write_fmlhs_plugin_message(&HandshakeAck { phase: WaitingServerComplete }); // TODO: dynamically register mod blocks @@ -725,7 +725,7 @@ impl Server { println!("Received FML|HS RegistryData for {}", name); if name == "minecraft:blocks" { for m in ids.data { - self.modded_block_ids.insert(m.id.0, m.name); + self.modded_block_ids.insert(m.id.0 as usize, m.name); } } if !has_more { @@ -1294,7 +1294,7 @@ impl Server { } fn on_block_change(&mut self, location: Position, id: i32) { - self.world.set_block(location, block::Block::by_vanilla_id(id as usize, self.protocol_version)) + self.world.set_block(location, block::Block::by_vanilla_id(id as usize, self.protocol_version, &self.modded_block_ids)) } fn on_block_change_varint(&mut self, block_change: packet::play::clientbound::BlockChange_VarInt) { @@ -1318,7 +1318,7 @@ impl Server { record.y as i32, oz + (record.xz & 0xF) as i32 ), - block::Block::by_vanilla_id(record.block_id.0 as usize, self.protocol_version) + block::Block::by_vanilla_id(record.block_id.0 as usize, self.protocol_version, &self.modded_block_ids) ); } } @@ -1341,7 +1341,7 @@ impl Server { self.world.set_block( Position::new(x, y, z), - block::Block::by_vanilla_id(id as usize, self.protocol_version) + block::Block::by_vanilla_id(id as usize, self.protocol_version, &self.modded_block_ids) ); } } diff --git a/src/world/mod.rs b/src/world/mod.rs index 87f4c28c..4b81bfd2 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -45,6 +45,7 @@ pub struct World { block_entity_actions: VecDeque, protocol_version: i32, + modded_block_ids: HashMap, } #[derive(Clone, Debug)] @@ -619,7 +620,7 @@ impl World { for bi in 0 .. 4096 { let id = data.read_u16::()?; - section.blocks.set(bi, block::Block::by_vanilla_id(id as usize, self.protocol_version)); + section.blocks.set(bi, block::Block::by_vanilla_id(id as usize, self.protocol_version, &self.modded_block_ids)); // Spawn block entities let b = section.blocks.get(bi); @@ -805,7 +806,7 @@ impl World { for bi in 0 .. 4096 { let id = ((block_add[i].get(bi) as u16) << 12) | ((block_types[i][bi] as u16) << 4) | (block_meta[i].get(bi) as u16); - section.blocks.set(bi, block::Block::by_vanilla_id(id as usize, self.protocol_version)); + section.blocks.set(bi, block::Block::by_vanilla_id(id as usize, self.protocol_version, &self.modded_block_ids)); // Spawn block entities let b = section.blocks.get(bi); @@ -882,7 +883,7 @@ impl World { let count = VarInt::read_from(&mut data)?.0; for i in 0 .. count { let id = VarInt::read_from(&mut data)?.0; - let bl = block::Block::by_vanilla_id(id as usize, self.protocol_version); + let bl = block::Block::by_vanilla_id(id as usize, self.protocol_version, &self.modded_block_ids); mappings.insert(i as usize, bl); } } @@ -892,7 +893,7 @@ impl World { for bi in 0 .. 4096 { let id = m.get(bi); - section.blocks.set(bi, mappings.get(&id).cloned().unwrap_or(block::Block::by_vanilla_id(id, self.protocol_version))); + section.blocks.set(bi, mappings.get(&id).cloned().unwrap_or(block::Block::by_vanilla_id(id, self.protocol_version, &self.modded_block_ids))); // Spawn block entities let b = section.blocks.get(bi); if block_entity::BlockEntityType::get_block_entity(b).is_some() { From e8636ba60e6e70234c87a85bcba4148a94e31c64 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 07:07:14 -0700 Subject: [PATCH 12/24] Fix crashing on unsupported but known modded blocks --- blocks/src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index d05cc87d..45524afb 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -162,14 +162,16 @@ macro_rules! define_blocks { block } else { let data = id & 0xf; - println!("Looking up custom block id {}:{}", id >> 4, data); + //println!("Looking up custom block id {}:{}", id >> 4, data); // could be unimplemented vanilla if let Some(name) = modded_block_ids.get(&(id >> 4)) { println!("Resolved modded block id {}:{} -> {}", id >> 4, data, name); - VANILLA_ID_MAP.modded - .get(name) - .unwrap()[data] - .unwrap_or(Block::Missing{}) + if let Some(blocks_by_data) = VANILLA_ID_MAP.modded.get(name) { + blocks_by_data[data].unwrap_or(Block::Missing{}) + } else { + println!("Modded block not supported yet: {}:{} -> {}", id >> 4, data, name); + Block::Missing{} + } } else { Block::Missing{} } From f6d4d3a8c97c514722a25efbea49fb909b17115d Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 07:34:14 -0700 Subject: [PATCH 13/24] Less logging --- blocks/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index 45524afb..08f74b9c 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -165,7 +165,7 @@ macro_rules! define_blocks { //println!("Looking up custom block id {}:{}", id >> 4, data); // could be unimplemented vanilla if let Some(name) = modded_block_ids.get(&(id >> 4)) { - println!("Resolved modded block id {}:{} -> {}", id >> 4, data, name); + //println!("Resolved modded block id {}:{} -> {}", id >> 4, data, name); if let Some(blocks_by_data) = VANILLA_ID_MAP.modded.get(name) { blocks_by_data[data].unwrap_or(Block::Missing{}) } else { From 573bceedae58328d1f89a98c7fca2cebd2b2b2c3 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 07:34:28 -0700 Subject: [PATCH 14/24] Register modded blocks in World instance as well --- src/server/mod.rs | 9 ++++++--- src/world/mod.rs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 128ca2ba..125cd1a3 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -279,12 +279,13 @@ impl Server { entities.add_component(world_entity, game_info, entity::GameInfo::new()); let version = resources.read().unwrap().version(); + let modded_block_ids = HashMap::new(); Server { uuid, conn, protocol_version, forge_mods, - modded_block_ids: HashMap::new(), + modded_block_ids, read_queue, disconnect_reason: None, just_disconnected: false, @@ -716,7 +717,8 @@ impl Server { ModIdData { mappings, block_substitutions: _, item_substitutions: _ } => { println!("Received FML|HS ModIdData"); for m in mappings.data { - self.modded_block_ids.insert(m.id.0 as usize, m.name); + self.modded_block_ids.insert(m.id.0 as usize, m.name.clone()); // TODO: avoid unnecessary clone + self.world.modded_block_ids.insert(m.id.0 as usize, m.name); } self.write_fmlhs_plugin_message(&HandshakeAck { phase: WaitingServerComplete }); // TODO: dynamically register mod blocks @@ -725,7 +727,8 @@ impl Server { println!("Received FML|HS RegistryData for {}", name); if name == "minecraft:blocks" { for m in ids.data { - self.modded_block_ids.insert(m.id.0 as usize, m.name); + self.modded_block_ids.insert(m.id.0 as usize, m.name.clone()); + self.world.modded_block_ids.insert(m.id.0 as usize, m.name); } } if !has_more { diff --git a/src/world/mod.rs b/src/world/mod.rs index 4b81bfd2..f3baecf7 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -45,7 +45,7 @@ pub struct World { block_entity_actions: VecDeque, protocol_version: i32, - modded_block_ids: HashMap, + pub modded_block_ids: HashMap, // TODO: reference with lifetime parameter to avoid copying from server module } #[derive(Clone, Debug)] From b1f976b6e9e738e4ad12f6160e2b50efaf5c5c80 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 07:55:29 -0700 Subject: [PATCH 15/24] Fix rockwool block modid name, has a \u{2} prefix for some reason --- blocks/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index 08f74b9c..b9fcbb0d 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -165,7 +165,8 @@ macro_rules! define_blocks { //println!("Looking up custom block id {}:{}", id >> 4, data); // could be unimplemented vanilla if let Some(name) = modded_block_ids.get(&(id >> 4)) { - //println!("Resolved modded block id {}:{} -> {}", id >> 4, data, name); + //println!("Resolved modded block id {}:{} -> {:?}", id >> 4, data, name); + //println!("modded = {:?}", VANILLA_ID_MAP.modded); if let Some(blocks_by_data) = VANILLA_ID_MAP.modded.get(name) { blocks_by_data[data].unwrap_or(Block::Missing{}) } else { @@ -1065,7 +1066,7 @@ define_blocks! { model { ("minecraft", format!("{}_wool", color.as_string()) ) }, } Rockwool { - modid "\u{1}ThermalExpansion:Rockwool", + modid "\u{2}ThermalExpansion:Rockwool", props { color: ColoredVariant = [ ColoredVariant::White, From c2256b06be86f468c753d134cb87edffaf194c26 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 08:04:57 -0700 Subject: [PATCH 16/24] Remove modded block ID logging since they are always registered --- blocks/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index b9fcbb0d..1c2a9e02 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -394,7 +394,6 @@ macro_rules! define_blocks { let internal_id = block.get_internal_id(); let hier_data: Option = block.get_hierarchical_data(); if let Some(modid) = block.get_modid() { - println!("Mod id: {}, hier_data {:?}", modid, hier_data); let hier_data = hier_data.unwrap(); if !blocks_modded.contains_key(modid) { blocks_modded.insert(modid.to_string(), vec![None; 16]); From 27dd400fc25102c3c17a3e5d1ca96e6306e6bf26 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 08:12:52 -0700 Subject: [PATCH 17/24] Switch to using fixed-size 16-element array for modded block data map instead of Vec --- blocks/src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index 1c2a9e02..aa8fb7f7 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -45,8 +45,7 @@ macro_rules! create_ids { struct VanillaIDMap { flat: Vec>, hier: Vec>, - //modded: HashMap<&'static str, [Option; 16]>, // TODO: fixed-size array? - modded: HashMap>>, + modded: HashMap; 16]>, } macro_rules! define_blocks { @@ -296,7 +295,7 @@ macro_rules! define_blocks { static ref VANILLA_ID_MAP: VanillaIDMap = { let mut blocks_flat = vec![]; let mut blocks_hier = vec![]; - let mut blocks_modded: HashMap>> = HashMap::new(); + let mut blocks_modded: HashMap; 16]> = HashMap::new(); let mut flat_id = 0; let mut last_internal_id = 0; let mut hier_block_id = 0; @@ -396,7 +395,7 @@ macro_rules! define_blocks { if let Some(modid) = block.get_modid() { let hier_data = hier_data.unwrap(); if !blocks_modded.contains_key(modid) { - blocks_modded.insert(modid.to_string(), vec![None; 16]); + blocks_modded.insert(modid.to_string(), [None; 16]); } let block_from_data = blocks_modded.get_mut(modid).unwrap(); block_from_data[hier_data] = Some(block); From 5d85080a4a57275b4f74fa0e2ecf82d7bd9220fa Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 08:15:29 -0700 Subject: [PATCH 18/24] Remove modded block logging as it is too noisy, uncomment and recompile if you need it --- blocks/src/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index aa8fb7f7..b4414703 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -161,15 +161,12 @@ macro_rules! define_blocks { block } else { let data = id & 0xf; - //println!("Looking up custom block id {}:{}", id >> 4, data); // could be unimplemented vanilla if let Some(name) = modded_block_ids.get(&(id >> 4)) { - //println!("Resolved modded block id {}:{} -> {:?}", id >> 4, data, name); - //println!("modded = {:?}", VANILLA_ID_MAP.modded); if let Some(blocks_by_data) = VANILLA_ID_MAP.modded.get(name) { blocks_by_data[data].unwrap_or(Block::Missing{}) } else { - println!("Modded block not supported yet: {}:{} -> {}", id >> 4, data, name); + //println!("Modded block not supported yet: {}:{} -> {}", id >> 4, data, name); Block::Missing{} } } else { From dbfd188574ea49e25f970a79019ccd7fd65cdacf Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 08:36:41 -0700 Subject: [PATCH 19/24] Remove obsolete comment --- src/server/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 125cd1a3..1b69d475 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -721,7 +721,6 @@ impl Server { self.world.modded_block_ids.insert(m.id.0 as usize, m.name); } self.write_fmlhs_plugin_message(&HandshakeAck { phase: WaitingServerComplete }); - // TODO: dynamically register mod blocks }, RegistryData { has_more, name, ids, substitutions: _, dummies: _ } => { println!("Received FML|HS RegistryData for {}", name); From aa7efab44d315337e3c36f7f01a776eb036130c1 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 09:33:55 -0700 Subject: [PATCH 20/24] Broken attempt at namespaced id mappings (length is wrong) --- src/protocol/forge.rs | 28 +++++++++++++++++++++++++++- src/server/mod.rs | 6 ++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/protocol/forge.rs b/src/protocol/forge.rs index 841df927..29d685a5 100644 --- a/src/protocol/forge.rs +++ b/src/protocol/forge.rs @@ -85,6 +85,32 @@ impl Serializable for ModIdMapping { } } +pub static BLOCK_NAMESPACE: u8 = 1; +pub static ITEM_NAMESPACE: u8 = 2; + +#[derive(Debug)] +pub struct NamespacedModIdMapping { + pub namespace: u8, + pub name: String, + pub id: VarInt, +} + +impl Serializable for NamespacedModIdMapping { + fn read_from(buf: &mut R) -> Result { + Ok(NamespacedModIdMapping { + namespace: Serializable::read_from(buf)?, + name: Serializable::read_from(buf)?, + id: Serializable::read_from(buf)?, + }) + } + + fn write_to(&self, buf: &mut W) -> Result<(), Error> { + self.namespace.write_to(buf)?; + self.name.write_to(buf)?; + self.id.write_to(buf) + } +} + #[derive(Debug)] pub enum FmlHs { ServerHello { @@ -105,7 +131,7 @@ pub enum FmlHs { dummies: LenPrefixed, }, ModIdData { - mappings: LenPrefixed, + mappings: LenPrefixed, block_substitutions: LenPrefixed, item_substitutions: LenPrefixed, }, diff --git a/src/server/mod.rs b/src/server/mod.rs index 1b69d475..e8f3b08f 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -717,8 +717,10 @@ impl Server { ModIdData { mappings, block_substitutions: _, item_substitutions: _ } => { println!("Received FML|HS ModIdData"); for m in mappings.data { - self.modded_block_ids.insert(m.id.0 as usize, m.name.clone()); // TODO: avoid unnecessary clone - self.world.modded_block_ids.insert(m.id.0 as usize, m.name); + if m.namespace == protocol::forge::BLOCK_NAMESPACE { + self.modded_block_ids.insert(m.id.0 as usize, m.name.clone()); // TODO: avoid unnecessary clone + self.world.modded_block_ids.insert(m.id.0 as usize, m.name); + } } self.write_fmlhs_plugin_message(&HandshakeAck { phase: WaitingServerComplete }); }, From d2c6de0c5baf4524daa76c21bdfcacb261dcf7b4 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 09:51:05 -0700 Subject: [PATCH 21/24] Add namespaced mod ids, working, \u{1}=block \u{2}=item --- blocks/src/lib.rs | 2 +- src/protocol/forge.rs | 29 +++-------------------------- src/server/mod.rs | 8 +++++--- 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index b4414703..c645a97f 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -1061,7 +1061,7 @@ define_blocks! { model { ("minecraft", format!("{}_wool", color.as_string()) ) }, } Rockwool { - modid "\u{2}ThermalExpansion:Rockwool", + modid "ThermalExpansion:Rockwool", props { color: ColoredVariant = [ ColoredVariant::White, diff --git a/src/protocol/forge.rs b/src/protocol/forge.rs index 29d685a5..005a887d 100644 --- a/src/protocol/forge.rs +++ b/src/protocol/forge.rs @@ -85,31 +85,8 @@ impl Serializable for ModIdMapping { } } -pub static BLOCK_NAMESPACE: u8 = 1; -pub static ITEM_NAMESPACE: u8 = 2; - -#[derive(Debug)] -pub struct NamespacedModIdMapping { - pub namespace: u8, - pub name: String, - pub id: VarInt, -} - -impl Serializable for NamespacedModIdMapping { - fn read_from(buf: &mut R) -> Result { - Ok(NamespacedModIdMapping { - namespace: Serializable::read_from(buf)?, - name: Serializable::read_from(buf)?, - id: Serializable::read_from(buf)?, - }) - } - - fn write_to(&self, buf: &mut W) -> Result<(), Error> { - self.namespace.write_to(buf)?; - self.name.write_to(buf)?; - self.id.write_to(buf) - } -} +pub static BLOCK_NAMESPACE: &'static str = "\u{1}"; +pub static ITEM_NAMESPACE: &'static str = "\u{2}"; #[derive(Debug)] pub enum FmlHs { @@ -131,7 +108,7 @@ pub enum FmlHs { dummies: LenPrefixed, }, ModIdData { - mappings: LenPrefixed, + mappings: LenPrefixed, block_substitutions: LenPrefixed, item_substitutions: LenPrefixed, }, diff --git a/src/server/mod.rs b/src/server/mod.rs index e8f3b08f..f4a53f82 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -717,9 +717,11 @@ impl Server { ModIdData { mappings, block_substitutions: _, item_substitutions: _ } => { println!("Received FML|HS ModIdData"); for m in mappings.data { - if m.namespace == protocol::forge::BLOCK_NAMESPACE { - self.modded_block_ids.insert(m.id.0 as usize, m.name.clone()); // TODO: avoid unnecessary clone - self.world.modded_block_ids.insert(m.id.0 as usize, m.name); + let (namespace, name) = m.name.split_at(1); + if namespace == protocol::forge::BLOCK_NAMESPACE { + // TODO: avoid unnecessary clone() + self.modded_block_ids.insert(m.id.0 as usize, name.to_string().clone()); + self.world.modded_block_ids.insert(m.id.0 as usize, name.to_string()); } } self.write_fmlhs_plugin_message(&HandshakeAck { phase: WaitingServerComplete }); From b8fa00f405d6323a2a670d9bf34bef6ba985fee5 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 10:02:20 -0700 Subject: [PATCH 22/24] Remove duplicate modded_block_ids in Server, use in World --- src/server/mod.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index f4a53f82..dcc623ac 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -43,7 +43,6 @@ pub struct Server { conn: Option, protocol_version: i32, forge_mods: Vec, - modded_block_ids: HashMap, read_queue: Option>>, pub disconnect_reason: Option, just_disconnected: bool, @@ -279,13 +278,11 @@ impl Server { entities.add_component(world_entity, game_info, entity::GameInfo::new()); let version = resources.read().unwrap().version(); - let modded_block_ids = HashMap::new(); Server { uuid, conn, protocol_version, forge_mods, - modded_block_ids, read_queue, disconnect_reason: None, just_disconnected: false, @@ -719,8 +716,6 @@ impl Server { for m in mappings.data { let (namespace, name) = m.name.split_at(1); if namespace == protocol::forge::BLOCK_NAMESPACE { - // TODO: avoid unnecessary clone() - self.modded_block_ids.insert(m.id.0 as usize, name.to_string().clone()); self.world.modded_block_ids.insert(m.id.0 as usize, name.to_string()); } } @@ -730,7 +725,6 @@ impl Server { println!("Received FML|HS RegistryData for {}", name); if name == "minecraft:blocks" { for m in ids.data { - self.modded_block_ids.insert(m.id.0 as usize, m.name.clone()); self.world.modded_block_ids.insert(m.id.0 as usize, m.name); } } @@ -1300,7 +1294,7 @@ impl Server { } fn on_block_change(&mut self, location: Position, id: i32) { - self.world.set_block(location, block::Block::by_vanilla_id(id as usize, self.protocol_version, &self.modded_block_ids)) + self.world.set_block(location, block::Block::by_vanilla_id(id as usize, self.protocol_version, &self.world.modded_block_ids)) } fn on_block_change_varint(&mut self, block_change: packet::play::clientbound::BlockChange_VarInt) { @@ -1324,7 +1318,7 @@ impl Server { record.y as i32, oz + (record.xz & 0xF) as i32 ), - block::Block::by_vanilla_id(record.block_id.0 as usize, self.protocol_version, &self.modded_block_ids) + block::Block::by_vanilla_id(record.block_id.0 as usize, self.protocol_version, &self.world.modded_block_ids) ); } } @@ -1347,7 +1341,7 @@ impl Server { self.world.set_block( Position::new(x, y, z), - block::Block::by_vanilla_id(id as usize, self.protocol_version, &self.modded_block_ids) + block::Block::by_vanilla_id(id as usize, self.protocol_version, &self.world.modded_block_ids) ); } } From b68be792b1b9d3b420e2a600a9427b3e407ac13b Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 10:04:20 -0700 Subject: [PATCH 23/24] Another outdated comment --- src/world/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/world/mod.rs b/src/world/mod.rs index f3baecf7..6087d160 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -45,7 +45,7 @@ pub struct World { block_entity_actions: VecDeque, protocol_version: i32, - pub modded_block_ids: HashMap, // TODO: reference with lifetime parameter to avoid copying from server module + pub modded_block_ids: HashMap, } #[derive(Clone, Debug)] From b4be0bc95a4a84b41457dfbeadb4f4f302628241 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 15 May 2019 10:36:29 -0700 Subject: [PATCH 24/24] Add ThermalFoundation's Rockwool (1.12.2) --- blocks/src/lib.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index c645a97f..1231b5c2 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -1060,7 +1060,7 @@ define_blocks! { data Some(color.data()), model { ("minecraft", format!("{}_wool", color.as_string()) ) }, } - Rockwool { + ThermalExpansionRockwool { modid "ThermalExpansion:Rockwool", props { color: ColoredVariant = [ @@ -1085,7 +1085,31 @@ define_blocks! { data Some(color.data()), model { ("minecraft", format!("{}_wool", color.as_string()) ) }, } - + ThermalFoundationRockwool { + modid "thermalfoundation:rockwool", + props { + color: ColoredVariant = [ + ColoredVariant::White, + ColoredVariant::Orange, + ColoredVariant::Magenta, + ColoredVariant::LightBlue, + ColoredVariant::Yellow, + ColoredVariant::Lime, + ColoredVariant::Pink, + ColoredVariant::Gray, + ColoredVariant::Silver, + ColoredVariant::Cyan, + ColoredVariant::Purple, + ColoredVariant::Blue, + ColoredVariant::Brown, + ColoredVariant::Green, + ColoredVariant::Red, + ColoredVariant::Black + ], + }, + data Some(color.data()), + model { ("minecraft", format!("{}_wool", color.as_string()) ) }, + } PistonExtension { props { facing: Direction = [