Skip to content

Commit a423ac4

Browse files
blocks: add end_portal_frame block and ss override
1 parent 1b8d5d6 commit a423ac4

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

crates/blocks/src/blocks/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,28 @@ blocks! {
13421342
solid: true,
13431343
cube: true,
13441344
},
1345+
EndPortalFrame {
1346+
props: {
1347+
eye: bool,
1348+
facing: BlockDirection
1349+
},
1350+
get_id: (!eye as u32) * 4
1351+
+ facing.get_id()
1352+
+ 7407,
1353+
from_id_offset: 7407,
1354+
from_id(id): 7407..=7414 => {
1355+
eye: (id >> 2) == 0,
1356+
facing: BlockDirection::from_id(id % 4)
1357+
},
1358+
from_names(_name): {
1359+
"end_portal_frame" => {
1360+
eye: false,
1361+
facing: BlockDirection::West
1362+
}
1363+
},
1364+
get_name: "end_portal_frame",
1365+
transparent: true,
1366+
},
13451367
Unknown {
13461368
props: {
13471369
id: u32

crates/blocks/src/items.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,17 @@ items! {
431431
from_id(_id): 339 => {},
432432
block: true,
433433
},
434+
EndPortalFrame {
435+
props: {},
436+
get_id: 375,
437+
from_id(_id): 375 => {},
438+
block: true,
439+
},
440+
EnderEye {
441+
props: {},
442+
get_id: 1003,
443+
from_id(_id): 1003 => {},
444+
},
434445
Unknown {
435446
props: {
436447
id: u32

crates/core/src/interaction.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ pub fn on_use(
3535
}
3636
ActionResult::Success
3737
}
38+
Block::EndPortalFrame { eye, facing } => {
39+
if let Some(Item::EnderEye {}) = item_in_hand {
40+
if !eye {
41+
world.set_block(pos, Block::EndPortalFrame { eye: true, facing });
42+
redstone::update_surrounding_blocks(world, pos);
43+
return ActionResult::Success;
44+
}
45+
}
46+
ActionResult::Pass
47+
}
3848
b if b.has_block_entity() => {
3949
// Open container
4050
let block_entity = world.get_block_entity(pos);
@@ -183,6 +193,10 @@ pub fn get_state_for_placement(
183193
Item::HayBlock {} => Block::HayBlock {},
184194
Item::Sand {} => Block::Sand {},
185195
Item::StoneBricks {} => Block::StoneBricks {},
196+
Item::EndPortalFrame {} => Block::EndPortalFrame {
197+
eye: false,
198+
facing: context.player.get_direction().opposite(),
199+
},
186200
_ => Block::Air {},
187201
};
188202
if is_valid_position(block, world, pos) {

crates/redstone/src/comparator.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub fn has_override(block: Block) -> bool {
3434
| Block::Cauldron { .. }
3535
| Block::Composter { .. }
3636
| Block::Cake { .. }
37+
| Block::EndPortalFrame { eye: true, .. }
3738
)
3839
}
3940

@@ -56,6 +57,7 @@ pub fn get_override(block: Block, world: &impl World, pos: BlockPos) -> u8 {
5657
Block::Cauldron { level } => level,
5758
Block::Composter { level } => level,
5859
Block::Cake { bites } => 14 - 2 * bites,
60+
Block::EndPortalFrame { eye: true, .. } => 15,
5961
_ => unreachable!("Block does not override comparators"),
6062
}
6163
}

0 commit comments

Comments
 (0)