mirror of
https://github.com/zyllian/classics.git
synced 2025-01-18 11:47:14 -08:00
add support for CustomBlocks, closes #19
This commit is contained in:
parent
61e27247b7
commit
d53f37d664
2 changed files with 50 additions and 0 deletions
|
@ -98,6 +98,43 @@ pub static BLOCK_INFO: LazyLock<BTreeMap<u8, BlockInfo>> = LazyLock::new(|| {
|
||||||
(0x2f, BlockInfo::new("bookshelf")),
|
(0x2f, BlockInfo::new("bookshelf")),
|
||||||
(0x30, BlockInfo::new("mossy_cobblestone")),
|
(0x30, BlockInfo::new("mossy_cobblestone")),
|
||||||
(0x31, BlockInfo::new("obsidian")),
|
(0x31, BlockInfo::new("obsidian")),
|
||||||
|
// CustomBlocks blocks
|
||||||
|
(
|
||||||
|
0x32,
|
||||||
|
BlockInfo::new("cobblestone_slab")
|
||||||
|
.block_type(BlockType::Slab)
|
||||||
|
.fallback(0x2c),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
0x33,
|
||||||
|
BlockInfo::new("rope")
|
||||||
|
.block_type(BlockType::Rope)
|
||||||
|
.fallback(0x27),
|
||||||
|
),
|
||||||
|
(0x34, BlockInfo::new("sandstone").fallback(0x0c)),
|
||||||
|
(
|
||||||
|
0x35,
|
||||||
|
BlockInfo::new("snow")
|
||||||
|
.block_type(BlockType::NonSolid)
|
||||||
|
.fallback(0x00),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
0x36,
|
||||||
|
BlockInfo::new("fire")
|
||||||
|
.block_type(BlockType::NonSolid)
|
||||||
|
.fallback(0x0a),
|
||||||
|
),
|
||||||
|
(0x37, BlockInfo::new("cloth_light_pink").fallback(0x21)),
|
||||||
|
(0x38, BlockInfo::new("cloth_forest_green").fallback(0x19)),
|
||||||
|
(0x39, BlockInfo::new("cloth_brown").fallback(0x03)),
|
||||||
|
(0x3a, BlockInfo::new("cloth_deep_blue").fallback(0x1d)),
|
||||||
|
(0x3b, BlockInfo::new("cloth_turquoise").fallback(0x1c)),
|
||||||
|
(0x3c, BlockInfo::new("ice").fallback(0x14)),
|
||||||
|
(0x3d, BlockInfo::new("ceramic_tile").fallback(0x2a)),
|
||||||
|
(0x3e, BlockInfo::new("magma").fallback(0x31)),
|
||||||
|
(0x3f, BlockInfo::new("pillar").fallback(0x24)),
|
||||||
|
(0x40, BlockInfo::new("crate").fallback(0x05)),
|
||||||
|
(0x41, BlockInfo::new("stone_brick").fallback(0x01)),
|
||||||
]
|
]
|
||||||
.into()
|
.into()
|
||||||
});
|
});
|
||||||
|
@ -121,6 +158,8 @@ pub struct BlockInfo {
|
||||||
pub place_permissions: PlayerType,
|
pub place_permissions: PlayerType,
|
||||||
/// permissions needed to break this block (includes replacing fluids)
|
/// permissions needed to break this block (includes replacing fluids)
|
||||||
pub break_permissions: PlayerType,
|
pub break_permissions: PlayerType,
|
||||||
|
/// the block used as fallback if the client doesn't support it
|
||||||
|
pub fallback: Option<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockInfo {
|
impl BlockInfo {
|
||||||
|
@ -131,6 +170,7 @@ impl BlockInfo {
|
||||||
block_type: BlockType::Solid,
|
block_type: BlockType::Solid,
|
||||||
place_permissions: PlayerType::Normal,
|
place_permissions: PlayerType::Normal,
|
||||||
break_permissions: PlayerType::Normal,
|
break_permissions: PlayerType::Normal,
|
||||||
|
fallback: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +186,13 @@ impl BlockInfo {
|
||||||
self.break_permissions = brk;
|
self.break_permissions = brk;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// sets the block's fallback block
|
||||||
|
pub const fn fallback(mut self, fallback: u8) -> Self {
|
||||||
|
assert!(fallback <= 0x31, "fallback must be under 0x31!");
|
||||||
|
self.fallback = Some(fallback);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// types of blocks
|
/// types of blocks
|
||||||
|
@ -164,6 +211,8 @@ pub enum BlockType {
|
||||||
},
|
},
|
||||||
/// fluid which is stationary
|
/// fluid which is stationary
|
||||||
FluidStationary { moving: u8 },
|
FluidStationary { moving: u8 },
|
||||||
|
/// a block which is climbable like the rope block
|
||||||
|
Rope,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockType {
|
impl BlockType {
|
||||||
|
|
|
@ -196,6 +196,7 @@ impl ExtBitmask {
|
||||||
fn info(self) -> Option<ExtInfo> {
|
fn info(self) -> Option<ExtInfo> {
|
||||||
// TODO: add entries as extensions are supported
|
// TODO: add entries as extensions are supported
|
||||||
Some(match self {
|
Some(match self {
|
||||||
|
Self::CustomBlocks => ExtInfo::new("CustomBlocks".to_string(), 1, Self::CustomBlocks),
|
||||||
// this isn't actually used by the server at all, but it technically sort of implements it
|
// this isn't actually used by the server at all, but it technically sort of implements it
|
||||||
Self::HeldBlock => ExtInfo::new("HeldBlock".to_string(), 1, Self::HeldBlock),
|
Self::HeldBlock => ExtInfo::new("HeldBlock".to_string(), 1, Self::HeldBlock),
|
||||||
Self::EmoteFix => ExtInfo::new("EmoteFix".to_string(), 1, Self::EmoteFix),
|
Self::EmoteFix => ExtInfo::new("EmoteFix".to_string(), 1, Self::EmoteFix),
|
||||||
|
|
Loading…
Add table
Reference in a new issue