Browse Source

fix block items are not stackable when they are spawned without harvesting it from a block

Kolja Strohm 2 years ago
parent
commit
ac180ce718
2 changed files with 9 additions and 2 deletions
  1. 8 1
      FactoryCraft/Block.cpp
  2. 1 1
      FactoryCraft/Item.cpp

+ 8 - 1
FactoryCraft/Block.cpp

@@ -320,7 +320,13 @@ void Block::updateModel(ModelInfo info) const
 
 BasicBlockItem::BasicBlockItem(
     int itemTypeId, int blockTypeId, const char* name)
-    : Item(itemTypeId, name)
+    : Item(itemTypeId, name),
+      transparent(0),
+      passable(0),
+      hardness(1.f),
+      toolId(0),
+      speedModifier(1.f),
+      interactable(1)
 {
     this->blockTypeId = blockTypeId;
     placeable = 1;
@@ -394,6 +400,7 @@ Item* BasicBlockItemType::createItem() const
     item->hardness = hardness;
     item->toolId = toolId;
     item->speedModifier = speedModifier;
+    item->interactable = 1;
     return item;
 }
 

+ 1 - 1
FactoryCraft/Item.cpp

@@ -99,7 +99,7 @@ float Item::getMaxHp() const
 bool Item::canBeStackedWith(const Item* zItem) const
 {
     return itemTypeId == zItem->itemTypeId && durability == maxDurability
-        && zItem->durability == zItem->maxDurability && maxHp == zItem->maxHp
+        && zItem->durability == zItem->durability && maxHp == zItem->maxHp
         && eatable == zItem->eatable && placeable == zItem->placeable
         && equippable == zItem->eatable && solid == zItem->solid
         && usable == zItem->usable && maxStackSize == zItem->maxStackSize