|
@@ -185,7 +185,8 @@ void Block::onUnloaded()
|
|
|
|
|
|
Framework::Text Block::getTargetUIML()
|
|
|
{
|
|
|
- return StaticRegistry<BlockType>::INSTANCE.zElement(typeId)->getTargetUIML();
|
|
|
+ return StaticRegistry<BlockType>::INSTANCE.zElement(typeId)
|
|
|
+ ->getTargetUIML();
|
|
|
}
|
|
|
|
|
|
void api(Framework::StreamReader* zRequest, NetworkMessage* zResponse)
|
|
@@ -330,6 +331,30 @@ BasicBlockItem::BasicBlockItem(
|
|
|
{
|
|
|
this->blockTypeId = blockTypeId;
|
|
|
placeable = 1;
|
|
|
+ placableProof = [this](const Item* self,
|
|
|
+ int dimensionId,
|
|
|
+ Framework::Vec3<int> worldPos) {
|
|
|
+ return Item::canBePlacedAt(dimensionId, worldPos);
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+void BasicBlockItem::setPlacableProof(
|
|
|
+ std::function<bool(const Item*, int, Framework::Vec3<int>)> condition,
|
|
|
+ bool andDefault)
|
|
|
+{
|
|
|
+ if (andDefault)
|
|
|
+ {
|
|
|
+ placableProof = [this, condition](const Item* self,
|
|
|
+ int dimensionId,
|
|
|
+ Framework::Vec3<int> worldPos) {
|
|
|
+ return Item::canBePlacedAt(dimensionId, worldPos)
|
|
|
+ && condition(self, dimensionId, worldPos);
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ placableProof = condition;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
bool BasicBlockItem::canBeStackedWith(const Item* zItem) const
|
|
@@ -345,6 +370,12 @@ bool BasicBlockItem::canBeStackedWith(const Item* zItem) const
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+bool BasicBlockItem::canBePlacedAt(
|
|
|
+ int dimensionId, Framework::Vec3<int> worldPos) const
|
|
|
+{
|
|
|
+ return placableProof(this, dimensionId, worldPos);
|
|
|
+}
|
|
|
+
|
|
|
BasicBlockItemType::BasicBlockItemType(int id,
|
|
|
const char* name,
|
|
|
ItemSkillLevelUpRule* levelUpRule,
|
|
@@ -401,6 +432,10 @@ Item* BasicBlockItemType::createItem() const
|
|
|
item->toolId = toolId;
|
|
|
item->speedModifier = speedModifier;
|
|
|
item->interactable = 1;
|
|
|
+ if (placableProofState)
|
|
|
+ {
|
|
|
+ item->setPlacableProof(placableProof, placableProofState > 1);
|
|
|
+ }
|
|
|
return item;
|
|
|
}
|
|
|
|
|
@@ -408,4 +443,13 @@ BasicBlockItemType* BasicBlockItemType::setHardness(float hardness)
|
|
|
{
|
|
|
this->hardness = hardness;
|
|
|
return this;
|
|
|
+}
|
|
|
+
|
|
|
+BasicBlockItemType* BasicBlockItemType::setPlacableProof(
|
|
|
+ std::function<bool(const Item*, int, Framework::Vec3<int>)> condition,
|
|
|
+ bool andDefault)
|
|
|
+{
|
|
|
+ placableProofState = 1 + (andDefault ? 1 : 0);
|
|
|
+ placableProof = condition;
|
|
|
+ return this;
|
|
|
}
|