DEADSOFTWARE

Store block references intead of ids
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / GameItems.java
index 7cf525263a52dec4c252f87d6e91129b45ada223..370f1b0081367e6d601100cf7b630576f1091fcd 100644 (file)
@@ -14,6 +14,7 @@ import ru.deadsoftware.cavedroid.misc.Assets;
 import ru.deadsoftware.cavedroid.misc.utils.AssetLoader;
 import ru.deadsoftware.cavedroid.misc.utils.SpriteOrigin;
 
+import java.io.FileInputStream;
 import java.util.*;
 
 public class GameItems {
@@ -54,12 +55,6 @@ public class GameItems {
         return getBlock(id) instanceof Block.Slab;
     }
 
-    public static boolean fluidCanFlowThere(int thisId, int thatId) {
-        return thatId == 0 || (!getBlock(thatId).hasCollision() && !isFluid(thatId)) ||
-                (isWater(thisId) && isWater(thatId) && thisId < thatId) ||
-                (isLava(thisId) && isLava(thatId) && thisId < thatId);
-    }
-
     public static Block getBlock(int id) {
         return blocks.getValueAt(id);
     }
@@ -147,6 +142,7 @@ public class GameItems {
                 int id = Assets.getIntFromJson(block, "id", count);
                 int dropCount = Assets.getIntFromJson(block, "drop_count", 1);
                 String fullBlock = Assets.getStringFromJson(block, "full_block", null);
+                int state = Assets.getIntFromJson(block, "state", 0);
                 blocksIds.put(key, id);
 
                 if (count >= id) {
@@ -177,8 +173,8 @@ public class GameItems {
                 );
 
                 Block newBlock = switch (meta) {
-                    case "water" -> new Block.Water(params, 5);
-                    case "lava" -> new Block.Lava(params, 5);
+                    case "water" -> new Block.Water(params, state);
+                    case "lava" -> new Block.Lava(params, state);
                     case "slab" -> new Block.Slab(params, fullBlock);
                     default -> new Block.Normal(params);
                 };