summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-03-28 15:40:57 +0200
committerGitHub <noreply@github.com>2021-03-28 15:40:57 +0200
commit748b121703fa28b10933f4432c09391e66179118 (patch)
tree58a39b6a75c3e9127507bf3c185a99e546147276 /src/Items
parentFix Windows XP to 7 compatibility (#5167) (diff)
downloadcuberite-748b121703fa28b10933f4432c09391e66179118.tar
cuberite-748b121703fa28b10933f4432c09391e66179118.tar.gz
cuberite-748b121703fa28b10933f4432c09391e66179118.tar.bz2
cuberite-748b121703fa28b10933f4432c09391e66179118.tar.lz
cuberite-748b121703fa28b10933f4432c09391e66179118.tar.xz
cuberite-748b121703fa28b10933f4432c09391e66179118.tar.zst
cuberite-748b121703fa28b10933f4432c09391e66179118.zip
Diffstat (limited to 'src/Items')
-rw-r--r--src/Items/ItemBanner.h6
-rw-r--r--src/Items/ItemEnchantingTable.h12
-rw-r--r--src/Items/ItemMobHead.h58
3 files changed, 35 insertions, 41 deletions
diff --git a/src/Items/ItemBanner.h b/src/Items/ItemBanner.h
index 7b9e6d05b..3f082c5a5 100644
--- a/src/Items/ItemBanner.h
+++ b/src/Items/ItemBanner.h
@@ -203,13 +203,15 @@ public:
}
const auto BannerPos = AddFaceDirection(a_ClickedBlockPos, a_ClickedBlockFace);
- return a_World.DoWithBlockEntityAt(BannerPos.x, BannerPos.y, BannerPos.z, [Color](cBlockEntity & a_BlockEntity)
+ a_World.DoWithBlockEntityAt(BannerPos, [Color](cBlockEntity & a_BlockEntity)
{
ASSERT((a_BlockEntity.GetBlockType() == E_BLOCK_STANDING_BANNER) || (a_BlockEntity.GetBlockType() == E_BLOCK_WALL_BANNER));
auto & Banner = static_cast<cBannerEntity &>(a_BlockEntity);
Banner.SetBaseColor(Color);
- return true;
+ return false;
});
+
+ return true;
}
};
diff --git a/src/Items/ItemEnchantingTable.h b/src/Items/ItemEnchantingTable.h
index c8eb42cac..12835cb4a 100644
--- a/src/Items/ItemEnchantingTable.h
+++ b/src/Items/ItemEnchantingTable.h
@@ -46,16 +46,12 @@ private:
}
const auto PlacePos = AddFaceDirection(a_ClickedBlockPos, a_ClickedBlockFace);
- a_World.DoWithBlockEntityAt(PlacePos.x, PlacePos.y, PlacePos.z, [&a_EquippedItem](cBlockEntity & a_Entity)
+ a_World.DoWithBlockEntityAt(PlacePos, [&a_EquippedItem](cBlockEntity & a_Entity)
{
- if (a_Entity.GetBlockType() != E_BLOCK_ENCHANTMENT_TABLE)
- {
- return true;
- }
+ ASSERT(a_Entity.GetBlockType() == E_BLOCK_ENCHANTMENT_TABLE);
- auto & EnchantingTable = static_cast<cEnchantingTableEntity &>(a_Entity);
- EnchantingTable.SetCustomName(a_EquippedItem.m_CustomName);
- return true;
+ static_cast<cEnchantingTableEntity &>(a_Entity).SetCustomName(a_EquippedItem.m_CustomName);
+ return false;
});
return true;
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