diff --git a/crates/horizon-client/examples/block_entity_anim_fixture.rs b/crates/horizon-client/examples/block_entity_anim_fixture.rs index 3347a8104..e108c53b3 100644 --- a/crates/horizon-client/examples/block_entity_anim_fixture.rs +++ b/crates/horizon-client/examples/block_entity_anim_fixture.rs @@ -8,9 +8,10 @@ use horizon_client::{ assets::Assets, block_entity_anim::{ Bell, BellEntity, BlockEntityAnims, ChestLid, Conduit, ConduitTarget, DIRECTIONS, - PotWobble, Shulker, ShulkerStatus, Skull, WobbleStyle, chest_lid_x_rot, direction_index, + EndGateway, PotWobble, Shulker, ShulkerStatus, Skull, WobbleStyle, chest_lid_x_rot, + direction_index, }, - block_entity_render::BlockEntityRenderer, + block_entity_render::{BlockEntityRenderer, gateway_beam}, blocks::{BlockFacts, Fluid}, items::Items, }; @@ -188,6 +189,14 @@ fn main() -> Result<()> { let facing = prop(&block, "facing") .and_then(direction_index) .unwrap_or(1); + // End gateways: the saved age, the level's height range and the + // integrated server's copy. + let initial = EndGateway { + age: case["age"].as_i64().unwrap_or(0), + teleport_cooldown: 0, + }; + let max_y = int(&case["level"][0]) + int(&case["level"][1]) - 1; + let mut server = initial; let mut text = String::new(); for step in case["steps"].as_array().into_iter().flatten() { let time = step["time"].as_i64().unwrap_or(0); @@ -445,6 +454,36 @@ fn main() -> Result<()> { f(progress), style ); + } else if name == "minecraft:end_gateway" { + let client = anims.gateways.entry(pos).or_insert(initial); + if step["enter"].as_bool() == Some(true) && server.enter() { + log.push_str(" blockEvent 1 0"); + client.trigger_event(1, 0); + } + if server.portal_tick() { + log.push_str(" blockEvent 1 0"); + client.trigger_event(1, 0); + } + if let Some((e0, e1)) = event { + let handled = client.trigger_event(e0, e1); + let _ = write!(log, " event {handled}"); + } + client.tick(); + let g = *client; + let a = anims.block_anim(pos, time, partial, Default::default()); + let b = gateway_beam(a.gateway, partial, max_y, time); + let _ = write!( + text, + "{} {} server {} {} render {} {} {:x} {}", + g.age, + g.teleport_cooldown, + server.age, + server.teleport_cooldown, + b.height, + f(b.scale), + b.color, + f(b.animation_time) + ); } else { text = format!("unsupported {block}"); } diff --git a/crates/horizon-client/src/block_entity_anim.rs b/crates/horizon-client/src/block_entity_anim.rs index 70a57cc64..eefd1ba63 100644 --- a/crates/horizon-client/src/block_entity_anim.rs +++ b/crates/horizon-client/src/block_entity_anim.rs @@ -725,6 +725,55 @@ impl PotWobble { } } +/// `TheEndGatewayBlockEntity` fields the beam reads. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub struct EndGateway { + pub age: i64, + pub teleport_cooldown: i32, +} +impl EndGateway { + /// `beamAnimationTick` (the client ticker). + pub fn tick(&mut self) { + self.age = self.age.wrapping_add(1); + if self.teleport_cooldown > 0 { + self.teleport_cooldown -= 1; + } + } + /// `portalTick` on the server copy: whether it called `triggerCooldown`, + /// whose block event 1 reaches the client copy. + pub fn portal_tick(&mut self) -> bool { + let cooling = self.teleport_cooldown > 0; + self.age = self.age.wrapping_add(1); + if cooling { + self.teleport_cooldown -= 1; + false + } else if self.age % 2400 == 0 { + self.teleport_cooldown = 40; + true + } else { + false + } + } + /// `EndGatewayBlock.entityInside` on the server copy: an entity that can + /// use the portal starts the cooldown unless it is already running. + pub fn enter(&mut self) -> bool { + if self.teleport_cooldown > 0 { + return false; + } + self.teleport_cooldown = 40; + true + } + /// `triggerEvent`: event 1 starts the 40 tick cooldown. + pub fn trigger_event(&mut self, event: i32, _data: i32) -> bool { + if event == 1 { + self.teleport_cooldown = 40; + true + } else { + false + } + } +} + /// The client ticker a block entity runs (`getTicker` on a client level), /// or [`Ticker::Pot`] for decorated pots, which keep wobble state unticked. #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -746,6 +795,8 @@ pub enum Ticker { powered: bool, }, Pot, + /// `TheEndGatewayBlockEntity.beamAnimationTick`. + Gateway, } /// The [`Ticker`] of a block state, by block name and property lookup. @@ -764,6 +815,7 @@ pub fn ticker(name: &str, prop: impl Fn(&str) -> Option) -> Option Ticker::Bell, "conduit" => Ticker::Conduit, "decorated_pot" => Ticker::Pot, + "end_gateway" => Ticker::Gateway, "dragon_head" | "dragon_wall_head" | "piglin_head" | "piglin_wall_head" => Ticker::Skull { powered: prop("powered").as_deref() == Some("true"), }, @@ -789,6 +841,9 @@ pub struct BlockEntityAnims { pub conduits: HashMap<[i32; 3], Conduit>, pub skulls: HashMap<[i32; 3], Skull>, pub pots: HashMap<[i32; 3], PotWobble>, + pub gateways: HashMap<[i32; 3], EndGateway>, + /// The integrated server's copies of the gateways (`portalTick`). + pub gateway_servers: HashMap<[i32; 3], EndGateway>, /// The client level's random (conduit particles). pub random: LegacyRandom, /// [`Ticker`] by block state id (see [`BlockEntityAnims::classify`]). @@ -805,6 +860,8 @@ impl Default for BlockEntityAnims { conduits: HashMap::new(), skulls: HashMap::new(), pots: HashMap::new(), + gateways: HashMap::new(), + gateway_servers: HashMap::new(), random: LegacyRandom::new(0x6c6576656c), kinds: Vec::new(), } @@ -839,6 +896,8 @@ impl BlockEntityAnims { self.skulls .retain(|p, _| is(p, |t| matches!(t, Ticker::Skull { .. }))); self.pots.retain(|p, _| is(p, |t| *t == Ticker::Pot)); + self.gateways + .retain(|p, _| is(p, |t| *t == Ticker::Gateway)); } /// Drops the state of positions whose block entity is gone. pub fn retain(&mut self, keep: impl Fn([i32; 3]) -> bool) { @@ -849,6 +908,8 @@ impl BlockEntityAnims { self.conduits.retain(|p, _| keep(*p)); self.skulls.retain(|p, _| keep(*p)); self.pots.retain(|p, _| keep(*p)); + self.gateways.retain(|p, _| keep(*p)); + self.gateway_servers.retain(|p, _| keep(*p)); } /// `getOpenNess(partial)` of the chest or ender chest at `pos`. pub fn lid(&self, pos: [i32; 3], partial: f32) -> f32 { @@ -867,9 +928,11 @@ impl BlockEntityAnims { ) -> BlockAnim { let mut anim = BlockAnim { sherds, - // End gateway ages and cooldowns are not tracked on the client yet: - // gateways render settled (no beam). - gateway: (i64::MAX, 0), + // Gateways not ticked yet render settled (no beam). + gateway: self + .gateways + .get(&pos) + .map_or((i64::MAX, 0), |g| (g.age, g.teleport_cooldown)), ..BlockAnim::default() }; if let Some(b) = self.books.get(&pos) { diff --git a/crates/horizon-client/src/block_entity_render.rs b/crates/horizon-client/src/block_entity_render.rs index 7380bb75e..399527b78 100644 --- a/crates/horizon-client/src/block_entity_render.rs +++ b/crates/horizon-client/src/block_entity_render.rs @@ -1292,44 +1292,24 @@ impl BlockEntityRenderer { } Kind::EndGateway { state } => { let anim = (scene.anim)(pos); - let (age, cooldown) = anim.gateway; - // TheEndGatewayRenderer.extractRenderState. - let spawning = age < 200; - if spawning || cooldown > 0 { - let a = scene.partial; - let percent = if spawning { - ((age as f32 + a) / 200.0).clamp(0.0, 1.0) - } else { - 1.0 - ((cooldown as f32 - a) / 40.0).clamp(0.0, 1.0) - }; - let distance = if spawning { - f64::from(scene.max_y) - } else { - 50.0 - }; - let scale = trig::sin(f64::from(percent * PI)); - let height = (f64::from(scale) * distance).floor() as i32; - // DyeColor.MAGENTA / PURPLE getTextureDiffuseColor. - let color = if spawning { 0xC7_4EBD } else { 0x89_32B8 }; - let time = scene.game_time.rem_euclid(40) as f32 + a; - if height > 0 - && let Some(s) = sprite("entity/end_portal/end_gateway_beam") - { - beam( - base, - BeamShape { - scale, - time, - start: -height, - height: height * 2, - color, - solid_radius: 0.15, - glow_radius: 0.175, - }, - s, - out, - ); - } + let b = gateway_beam(anim.gateway, scene.partial, scene.max_y, scene.game_time); + if b.height > 0 + && let Some(s) = sprite("entity/end_portal/end_gateway_beam") + { + beam( + base, + BeamShape { + scale: b.scale, + time: b.animation_time, + start: -b.height, + height: b.height * 2, + color: b.color, + solid_radius: 0.15, + glow_radius: 0.175, + }, + s, + out, + ); } // AbstractEndPortalRenderer.extractRenderState: TheEndGatewayBlockEntity.shouldRenderFace. let faces: Vec = Direction::ALL @@ -1618,6 +1598,43 @@ impl BeamPart { } } +/// `EndGatewayRenderState`'s beam fields (zero when there is no beam). +#[derive(Clone, Copy, Debug, Default, PartialEq)] +pub struct GatewayBeam { + pub height: i32, + pub scale: f32, + pub color: u32, + pub animation_time: f32, +} + +/// `TheEndGatewayRenderer.extractRenderState` from the block entity's age and +/// teleport cooldown, at `partial`, for a level whose top is `max_y`. +pub fn gateway_beam( + (age, cooldown): (i64, i32), + partial: f32, + max_y: i32, + game_time: i64, +) -> GatewayBeam { + let spawning = age < 200; + if !spawning && cooldown <= 0 { + return GatewayBeam::default(); + } + let percent = if spawning { + ((age as f32 + partial) / 200.0).clamp(0.0, 1.0) + } else { + 1.0 - ((cooldown as f32 - partial) / 40.0).clamp(0.0, 1.0) + }; + let distance = if spawning { f64::from(max_y) } else { 50.0 }; + let scale = trig::sin(f64::from(percent * PI)); + GatewayBeam { + height: (f64::from(scale) * distance).floor() as i32, + scale, + // DyeColor.MAGENTA / PURPLE getTextureDiffuseColor. + color: if spawning { 0xFFC7_4EBD } else { 0xFF89_32B8 }, + animation_time: game_time.rem_euclid(40) as f32 + partial, + } +} + /// Entity-shader layers for `rendertype_end_portal`: end portals draw 15 /// layers of `end_portal.png` over `end_sky.png`, End gateways 16. pub const END_PORTAL_LAYER: u32 = 9; diff --git a/crates/horizon-client/src/game/block_entity_anims.rs b/crates/horizon-client/src/game/block_entity_anims.rs index d1597a7a3..5444ea2fd 100644 --- a/crates/horizon-client/src/game/block_entity_anims.rs +++ b/crates/horizon-client/src/game/block_entity_anims.rs @@ -5,10 +5,11 @@ //! [`Game::block_anim`] and [`Game::chest_lid`]. use super::Game; use horizon_client::{ - block_entity_anim::{BellEntity, Shulker, ShulkerStatus, Ticker}, + block_entity_anim::{BellEntity, EndGateway, Shulker, ShulkerStatus, Ticker}, block_entity_render::BlockAnim, collisions::{SceneCollisions, no_collision_empty}, particles::{ParticleOptions, ParticleType}, + save::number, }; use horizon_core::geometry::{Aabb, Vec3}; use std::collections::HashMap; @@ -44,6 +45,14 @@ impl Game<'_> { .or_default() .trigger_event(a, b, time, || gathered); } + Some(Ticker::Gateway) => { + let initial = self.gateway_loaded(pos); + self.be_anims + .gateways + .entry(pos) + .or_insert(initial) + .trigger_event(a, b); + } Some(Ticker::Pot) => { self.be_anims .pots @@ -276,9 +285,58 @@ impl Game<'_> { } } Ticker::Pot => {} + Ticker::Gateway => { + // The server copy's portalTick runs first; its block event + // reaches the client copy before the client ticks it. + let initial = self.gateway_loaded(pos); + let anims = &mut self.be_anims; + let server = anims.gateway_servers.entry(pos).or_insert(initial); + let triggered = server.portal_tick(); + let client = anims.gateways.entry(pos).or_insert(initial); + if triggered { + client.trigger_event(1, 0); + } + client.tick(); + } } } } + /// `EndGatewayBlock.entityInside` on the server: whether the gateway at + /// `pos` let the entity in (`triggerCooldown`, with its block event). + pub(super) fn gateway_enter(&mut self, pos: [i32; 3]) -> bool { + let initial = self.gateway_loaded(pos); + let entered = self + .be_anims + .gateway_servers + .entry(pos) + .or_insert(initial) + .enter(); + if entered { + self.block_entity_event(pos, 1, 0); + } + entered + } + /// The End gateway at `pos` as its chunk was loaded: `Age` from the saved + /// block entity (`getUpdateTag`), or a new gateway. + fn gateway_loaded(&self, pos: [i32; 3]) -> EndGateway { + let age = self + .world + .chunks + .get(&(pos[0] >> 4, pos[2] >> 4)) + .and_then(|c| c.saved.as_deref()) + .and_then(|saved| { + saved.block_entities.iter().find(|t| { + [t.get("x"), t.get("y"), t.get("z")] + .map(number) + .eq(&pos.map(|v| Some(i64::from(v)))) + }) + }) + .and_then(|t| number(t.get("Age"))); + EndGateway { + age: age.unwrap_or(0), + teleport_cooldown: 0, + } + } /// The renderer's view of the block entity at `pos`. pub(super) fn block_anim(&self, pos: [i32; 3], partial: f32) -> BlockAnim { self.be_anims diff --git a/crates/horizon-client/src/game/end.rs b/crates/horizon-client/src/game/end.rs index e1a848a25..163c76e73 100644 --- a/crates/horizon-client/src/game/end.rs +++ b/crates/horizon-client/src/game/end.rs @@ -405,6 +405,7 @@ impl Game<'_> { } } else if let Some(g) = gateway && self.end.gateway_cooldown == 0 + && self.gateway_enter(g) { self.enter_gateway(g)?; } diff --git a/crates/horizon-client/src/game/persist.rs b/crates/horizon-client/src/game/persist.rs index a72530e6a..659a87ce0 100644 --- a/crates/horizon-client/src/game/persist.rs +++ b/crates/horizon-client/src/game/persist.rs @@ -95,6 +95,16 @@ impl Game<'_> { extras.fluid_ticks.clear(); } extras.last_update = time; + // TheEndGatewayBlockEntity saves its Age (the server copy's). + for tag in &mut extras.block_entities { + let pos = [tag.get("x"), tag.get("y"), tag.get("z")] + .map(|v| horizon_client::save::number(v).unwrap_or(0) as i32); + if let Some(g) = self.be_anims.gateway_servers.get(&pos) + && let Some(age) = tag.get_mut("Age") + { + *age = horizon_world::nbt::Tag::Long(g.age); + } + } if let Some(t) = self.world.inhabited.get(&(chunk.x, chunk.z)) { extras .root diff --git a/crates/horizon-client/src/save.rs b/crates/horizon-client/src/save.rs index a9c538362..96965431f 100644 --- a/crates/horizon-client/src/save.rs +++ b/crates/horizon-client/src/save.rs @@ -53,7 +53,7 @@ pub(crate) fn text(tag: Option<&Tag>) -> Option { } } /// Any numeric tag as i64 (vanilla's `getIntOr` etc. accept every number type). -pub(crate) fn number(tag: Option<&Tag>) -> Option { +pub fn number(tag: Option<&Tag>) -> Option { Some(match tag? { Tag::Byte(v) => i64::from(*v), Tag::Short(v) => i64::from(*v), diff --git a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockEntityAnimOracle.java b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockEntityAnimOracle.java index 5c8c899db..a85bce1b4 100644 --- a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockEntityAnimOracle.java +++ b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockEntityAnimOracle.java @@ -33,13 +33,15 @@ import net.minecraft.world.phys.*; /** * Original oracle for the client-ticked animation state of chests and ender * chests (ChestLidController), enchanting table books, shulker boxes, bells, - * conduits, skulls and decorated pots. Each case builds the real + * conduits, skulls, decorated pots and End gateways. Each case builds the real * vanilla block entity on a stand-in client level (scripted blocks, entities, * game time and a seeded LegacyRandomSource), then per step applies the * scripted block event (triggerEvent), runs the block entity's own client * ticker (lidAnimateTick, bookAnimationTick with the class's static RANDOM * reseeded, ShulkerBoxBlockEntity.tick, BellBlockEntity.clientTick, - * ConduitBlockEntity.clientTick, SkullBlockEntity.animation; pots have none) + * ConduitBlockEntity.clientTick, SkullBlockEntity.animation, + * TheEndGatewayBlockEntity.beamAnimationTick after the server copy's portalTick + * on a server-side stand-in; pots have none) * and runs the real renderer's extractRenderState at the step's partial tick. * It prints the block entity's fields, the level calls the tick made * (neighbour updates, entity queries, sounds, particles) and the render state. @@ -100,6 +102,9 @@ public final class VanillaBlockEntityAnimOracle { static final class World extends Level { World() { super(null, null, null, null, false, false, 0L, 0); } long time; + boolean server; + int minY, height; + BlockEntity serverCopyOf; Map blocks = new HashMap<>(); List mobs = new ArrayList<>(); List gamers = new ArrayList<>(); @@ -108,7 +113,16 @@ public final class VanillaBlockEntityAnimOracle { StringBuilder log = new StringBuilder(); @Override public long getGameTime() { return time; } - @Override public boolean isClientSide() { return true; } + @Override public boolean isClientSide() { return !server; } + @Override public int getMinY() { return minY; } + @Override public int getHeight() { return height; } + @Override public void blockEvent(BlockPos p, Block block, int b0, int b1) { + // The integrated server's block event reaching the client copy. + log.append(" blockEvent ").append(b0).append(' ').append(b1); + serverCopyOf.triggerEvent(b0, b1); + } + @Override public void blockEntityChanged(BlockPos p) {} + @Override public void updateNeighbourForOutputSignal(BlockPos p, Block block) {} @Override public BlockState getBlockState(BlockPos p) { return blocks.getOrDefault(p.immutable(), Blocks.AIR.defaultBlockState()); } @Override public FluidState getFluidState(BlockPos p) { return getBlockState(p).getFluidState(); } @Override public int getBrightness(LightLayer layer, BlockPos p) { return 0; } @@ -236,6 +250,22 @@ public final class VanillaBlockEntityAnimOracle { if (c.has("target") && be instanceof ConduitBlockEntity) { put(be, ConduitBlockEntity.class, "destroyTarget", EntityReference.of(mob(c.getAsJsonObject("target"), world))); } + World serverWorld = null; + TheEndGatewayBlockEntity serverGateway = null; + if (be instanceof TheEndGatewayBlockEntity g) { + var level = c.getAsJsonArray("level"); + world.minY = level.get(0).getAsInt(); + world.height = level.get(1).getAsInt(); + field(TheEndGatewayBlockEntity.class, "age").setLong(g, c.get("age").getAsLong()); + serverWorld = make(World.class); + serverWorld.server = true; + serverWorld.blocks = world.blocks; + serverWorld.log = world.log; + serverWorld.serverCopyOf = g; + serverGateway = (TheEndGatewayBlockEntity) ((EntityBlock) state.getBlock()).newBlockEntity(pos, state); + serverGateway.setLevel(serverWorld); + field(TheEndGatewayBlockEntity.class, "age").setLong(serverGateway, c.get("age").getAsLong()); + } StringBuilder out = new StringBuilder(); for (var stepElement : c.getAsJsonArray("steps")) { var step = stepElement.getAsJsonObject(); @@ -251,6 +281,14 @@ public final class VanillaBlockEntityAnimOracle { world.gamers.clear(); for (var e : step.getAsJsonArray("players")) world.gamers.add(gamer(e.getAsJsonObject())); } + if (serverGateway != null) { + serverWorld.time = world.time; + // ServerLevel.tick: entities (EndGatewayBlock.entityInside), then block entities. + if (step.has("enter") && !serverGateway.isCoolingDown()) { + TheEndGatewayBlockEntity.triggerCooldown(serverWorld, pos, state, serverGateway); + } + TheEndGatewayBlockEntity.portalTick(serverWorld, pos, state, serverGateway); + } if (step.has("event")) { var ev = step.getAsJsonArray("event"); boolean handled = be.triggerEvent(ev.get(0).getAsInt(), ev.get(1).getAsInt()); @@ -327,6 +365,15 @@ public final class VanillaBlockEntityAnimOracle { make(DecoratedPotRenderer.class).extractRenderState(p, r, partial, Vec3.ZERO, null); fields = p.wobbleStartedAtTick + " " + p.lastWobbleStyle + " render " + f(r.wobbleProgress) + " " + r.wobbleStyle; + } else if (be instanceof TheEndGatewayBlockEntity g) { + TheEndGatewayBlockEntity.beamAnimationTick(world, pos, state, g); + var r = make(TheEndGatewayRenderer.class).createRenderState(); + make(TheEndGatewayRenderer.class).extractRenderState(g, r, partial, Vec3.ZERO, null); + fields = field(TheEndGatewayBlockEntity.class, "age").getLong(g) + + " " + field(TheEndGatewayBlockEntity.class, "teleportCooldown").getInt(g) + + " server " + field(TheEndGatewayBlockEntity.class, "age").getLong(serverGateway) + + " " + field(TheEndGatewayBlockEntity.class, "teleportCooldown").getInt(serverGateway) + + " render " + r.height + " " + f(r.scale) + " " + Integer.toHexString(r.color) + " " + f(r.animationTime); } else { throw new IllegalArgumentException("no animation for " + be); } diff --git a/tools/test_block_entity_anim_parity.py b/tools/test_block_entity_anim_parity.py index 0e85d978a..eb47285d8 100755 --- a/tools/test_block_entity_anim_parity.py +++ b/tools/test_block_entity_anim_parity.py @@ -4,7 +4,7 @@ The Java oracle (VanillaBlockEntityAnimOracle) builds each case's real vanilla block entity (chest, trapped/copper chest and the other half of a double chest, ender chest, enchanting table, shulker box, bell, conduit, dragon/piglin head, -decorated pot) +decorated pot, End gateway with the integrated server's copy ticking beside it) on a stand-in client level, then per scripted step applies the block event (triggerEvent), runs the entity's own client ticker and the renderer's extractRenderState, printing the fields, the level calls the tick made @@ -162,6 +162,21 @@ def cases(): step['event'] = [rng.choice([1, 1, 1, 2]), rng.choice([0, 1, 0, 1, 2, -1])] steps.append(step) add('pot', f'minecraft:decorated_pot[facing={rng.choice(HORIZONTAL)}]', steps) + # End gateways: the server copy's portalTick (triggerCooldown every 2400 + # ticks, entities entering) sends block event 1 to the client copy, whose + # beamAnimationTick and TheEndGatewayRenderer draw the beam; saved ages + # from new to long settled, both level heights. + for i in range(40): + age = rng.choice([0, 0, 150, 2390, 4790, rng.randint(200, 10 ** 6), 2399 + 2400 * rng.randint(1, 50)]) + steps = [] + for t in times(rng.randint(20, 90), gaps=(1, 1, 1, 2)): + step = {'time': t, 'partial': round(rng.random(), 4)} + if rng.random() < 0.06: + step['enter'] = True + if rng.random() < 0.04: + step['event'] = [rng.choice([1, 2, 0]), rng.choice([0, 3])] + steps.append(step) + add('gateway', 'minecraft:end_gateway', steps, age=age, level=rng.choice([[0, 256], [-64, 384]])) # Chests and ender chests: open counts from block event 1 (both halves of # a double chest), other events ignored; the neighbour a double half # connects to may be its other half or not (wrong block, type, facing).