summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemMobHead.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Items/ItemMobHead.h')
-rw-r--r--src/Items/ItemMobHead.h58
1 files changed, 27 insertions, 31 deletions
diff --git a/src/Items/ItemMobHead.h b/src/Items/ItemMobHead.h
index ef16f6c96..f1e963e1f 100644
--- a/src/Items/ItemMobHead.h
+++ b/src/Items/ItemMobHead.h
@@ -75,26 +75,22 @@ public:
auto BlockMeta = static_cast<NIBBLETYPE>(a_ClickedBlockFace);
// Use a callback to set the properties of the mob head block entity:
- a_World.DoWithBlockEntityAt(a_PlacePos.x, a_PlacePos.y, a_PlacePos.z, [&](cBlockEntity & a_BlockEntity)
- {
- if (a_BlockEntity.GetBlockType() != E_BLOCK_HEAD)
- {
- return false;
- }
- auto & MobHeadEntity = static_cast<cMobHeadEntity &>(a_BlockEntity);
+ a_World.DoWithBlockEntityAt(a_PlacePos, [&](cBlockEntity & a_BlockEntity)
+ {
+ ASSERT(a_BlockEntity.GetBlockType() == E_BLOCK_HEAD);
- int Rotation = 0;
- if (BlockMeta == 1)
- {
- Rotation = FloorC(a_Player.GetYaw() * 16.0f / 360.0f + 0.5f) & 0x0f;
- }
+ auto & MobHeadEntity = static_cast<cMobHeadEntity &>(a_BlockEntity);
- MobHeadEntity.SetType(HeadType);
- MobHeadEntity.SetRotation(static_cast<eMobHeadRotation>(Rotation));
- MobHeadEntity.GetWorld()->BroadcastBlockEntity(MobHeadEntity.GetPos());
- return false;
+ int Rotation = 0;
+ if (BlockMeta == 1)
+ {
+ Rotation = FloorC(a_Player.GetYaw() * 16.0f / 360.0f + 0.5f) & 0x0f;
}
- );
+
+ MobHeadEntity.SetType(HeadType);
+ MobHeadEntity.SetRotation(static_cast<eMobHeadRotation>(Rotation));
+ return false;
+ });
}
@@ -243,23 +239,23 @@ public:
return false;
}
- // If it is a mob head, check the correct head type using the block entity:
- if (BlockType == E_BLOCK_HEAD)
- {
- bool IsWitherHead = false;
- a_World.DoWithBlockEntityAt(BlockX, BlockY, BlockZ, [&](cBlockEntity & a_Entity)
+ // If it is a mob head, check it's a wither skull using the block entity:
+ if (
+ (BlockType == E_BLOCK_HEAD) &&
+ !a_World.DoWithBlockEntityAt({ BlockX, BlockY, BlockZ }, [&](cBlockEntity & a_BlockEntity)
+ {
+ if (a_BlockEntity.GetBlockType() != E_BLOCK_HEAD)
{
- ASSERT(a_Entity.GetBlockType() == E_BLOCK_HEAD);
- auto & MobHead = static_cast<cMobHeadEntity &>(a_Entity);
- IsWitherHead = (MobHead.GetType() == SKULL_TYPE_WITHER);
- return true;
+ return false;
}
- );
- if (!IsWitherHead)
- {
- return false;
- }
+
+ return static_cast<cMobHeadEntity &>(a_BlockEntity).GetType() == SKULL_TYPE_WITHER;
+ })
+ )
+ {
+ return false;
}
+
// Matched, continue checking
AirBlocks.emplace_back(BlockX, BlockY, BlockZ, E_BLOCK_AIR, 0);
} // for i - a_Image