Jelajahi Sumber

fix problems with campfire dialog, inventory network updates and loading campfire blocks

Kolja Strohm 4 bulan lalu
induk
melakukan
56f02a1a53

+ 1 - 1
FactoryCraft/BlockType.cpp

@@ -175,7 +175,7 @@ Block* BlockType::loadBlock(Framework::Vec3<int> position,
     Framework::StreamReader* zReader,
     int dimensionId) const
 {
-    Block* result = createBlock(position, dimensionId);
+    Block* result = createBlockAt(position, dimensionId, 0);
     loadSuperBlock(result, zReader, dimensionId);
     return result;
 }

+ 2 - 0
FactoryCraft/Entity.cpp

@@ -705,6 +705,8 @@ void Entity::api(Framework::StreamReader* zRequest,
             delete[] guiId;
             break;
         }
+    case 2: // TODO: component request
+        break;
     }
 }
 

+ 7 - 7
FactoryCraft/FireBasedProcessingBlockComponent.cpp

@@ -71,11 +71,11 @@ bool FireBasedProcessingBlockComponent::consumeFuel()
         if (fuelSlot)
         {
             ItemStack* fuelStack
-                = fuelSlot->takeItemsOut(1, Direction::NO_DIRECTION);
+                = zBlock->takeItemsOut(fuelSlot, 1, Direction::NO_DIRECTION);
             if (fuelStack)
             {
                 // TODO: check if item is burnable and how much fuel it provides
-                fuelBuffer += 100;
+                fuelBuffer += 1000;
                 maxFuelBuffer = fuelBuffer;
                 fuelStack->release();
                 changed = 1;
@@ -101,13 +101,13 @@ bool FireBasedProcessingBlockComponent::consumeFuel()
         if (fuelSlot && fireStartingSlot)
         {
             ItemStack* fuelStack
-                = fuelSlot->takeItemsOut(1, Direction::NO_DIRECTION);
-            ItemStack* fireStartingStack
-                = fireStartingSlot->takeItemsOut(1, Direction::NO_DIRECTION);
+                = zBlock->takeItemsOut(fuelSlot, 1, Direction::NO_DIRECTION);
+            ItemStack* fireStartingStack = zBlock->takeItemsOut(
+                fireStartingSlot, 1, Direction::NO_DIRECTION);
             if (fuelStack && fireStartingStack)
             {
                 // TODO: check if item is burnable and how much fuel it provides
-                fuelBuffer += 100;
+                fuelBuffer += 1000;
                 maxFuelBuffer = fuelBuffer;
                 burning = true;
                 fuelStack->release();
@@ -362,7 +362,7 @@ bool FireBasedProcessingBlockComponent::hasFreeSpace(
     const Item* zItem, int amount)
 {
     int addable = zBlock->numberOfAddableItems(
-        zItem, NO_DIRECTION, inputInventorySlotName);
+        zItem, NO_DIRECTION, outputInventorySlotName);
     return addable >= amount;
 }
 

+ 5 - 5
FactoryCraft/Inventory.cpp

@@ -701,8 +701,8 @@ bool Inventory::isAllAvailable(Framework::RCArray<RecipieInput>& inputs,
     return 1;
 }
 
-void Inventory::consume(Framework::RCArray<RecipieInput>& inputs,
-    const Framework::Text& slotName) const
+void Inventory::consume(
+    Framework::RCArray<RecipieInput>& inputs, const Framework::Text& slotName)
 {
     for (RecipieInput* input : inputs)
     {
@@ -716,8 +716,8 @@ void Inventory::consume(Framework::RCArray<RecipieInput>& inputs,
             {
                 if (consumed + slot->getNumberOfItems() >= input->getAmount())
                 {
-                    slot->takeItemsOut(
-                            input->getAmount() - consumed, NO_DIRECTION)
+                    takeItemsOut(
+                        slot, input->getAmount() - consumed, NO_DIRECTION)
                         ->release();
                     consumed = input->getAmount();
                     break;
@@ -725,7 +725,7 @@ void Inventory::consume(Framework::RCArray<RecipieInput>& inputs,
                 else
                 {
                     consumed += slot->getNumberOfItems();
-                    slot->takeItemsOut(slot->getNumberOfItems(), NO_DIRECTION)
+                    takeItemsOut(slot, slot->getNumberOfItems(), NO_DIRECTION)
                         ->release();
                 }
             }

+ 1 - 1
FactoryCraft/Inventory.h

@@ -131,7 +131,7 @@ public:
     bool isAllAvailable(Framework::RCArray<RecipieInput>& inputs,
         const Framework::Text& slotName) const;
     void consume(Framework::RCArray<RecipieInput>& inputs,
-        const Framework::Text& slotName) const;
+        const Framework::Text& slotName);
     Framework::ArrayIterator<ItemSlot*> begin();
     Framework::ArrayIterator<ItemSlot*> end();
     void inventoryApi(Framework::StreamReader* zRequest,

+ 8 - 8
FactoryCraft/UIElement.cpp

@@ -137,37 +137,37 @@ Framework::XML::Element* UIElement::toUIML(
     result->setAttribute("id", id);
     if (!marginLeft.istGleich("0"))
     {
-        result->setAttribute("marginLeft", marginLeft);
+        result->setAttribute("margin-left", marginLeft);
     }
     if (!marginRight.istGleich("0"))
     {
-        result->setAttribute("marginRight", marginRight);
+        result->setAttribute("margin-right", marginRight);
     }
     if (!marginTop.istGleich("0"))
     {
-        result->setAttribute("marginTop", marginTop);
+        result->setAttribute("margin-top", marginTop);
     }
     if (!marginBottom.istGleich("0"))
     {
-        result->setAttribute("marginBottom", marginBottom);
+        result->setAttribute("margin-bottom", marginBottom);
     }
     result->setAttribute("width", width);
     result->setAttribute("height", height);
     if (alignLeft.getLength() > 0)
     {
-        result->setAttribute("alignLeft", alignLeft);
+        result->setAttribute("align-left", alignLeft);
     }
     if (alignRight.getLength() > 0)
     {
-        result->setAttribute("alignRight", alignRight);
+        result->setAttribute("align-right", alignRight);
     }
     if (alignTop.getLength() > 0)
     {
-        result->setAttribute("alignTop", alignTop);
+        result->setAttribute("align-top", alignTop);
     }
     if (alignBottom.getLength() > 0)
     {
-        result->setAttribute("alignBottom", alignBottom);
+        result->setAttribute("align-bottom", alignBottom);
     }
     if (style.getLength() > 0)
     {

+ 3 - 3
Windows Version/data/blocks/blockTypes.json

@@ -1241,7 +1241,7 @@
               "id": "player_label",
               "width": "100%",
               "height": "auto",
-              "style": "7003",
+              "style": "0x7003",
               "marginBottom": 9,
               "alignBottom": "player_inventory",
               "text": "Player Inventory"
@@ -1435,7 +1435,7 @@
               "type": "fuelState",
               "id": "fuel_state",
               "marginBottom": 10,
-              "alignBottom": "fuel",
+              "alignBottom": "fuel_input",
               "alignLeft": "start_input",
               "marginLeft": 10,
               "width": 50,
@@ -1485,7 +1485,7 @@
               "id": "player_label",
               "width": "100%",
               "height": "auto",
-              "style": "7003",
+              "style": "0x7003",
               "marginBottom": 9,
               "alignBottom": "player_inventory",
               "text": "Player Inventory"