DEADSOFTWARE

Support reading item ids from json
authorfredboy <fredboy@protonmail.com>
Thu, 18 Apr 2024 17:47:09 +0000 (00:47 +0700)
committerfredboy <fredboy@protonmail.com>
Thu, 18 Apr 2024 17:47:09 +0000 (00:47 +0700)
android/assets/json/game_items.json
core/src/ru/deadsoftware/cavedroid/game/GameItems.java
core/src/ru/deadsoftware/cavedroid/game/objects/Block.kt
core/src/ru/deadsoftware/cavedroid/game/objects/Item.kt

index 7afdfb1599413c593437c547a02f6866cead1cb3..d997cead101698d8b10355a5b57232b5845539e4 100644 (file)
 {
   "blocks": {
-    "none": {
+    "bed_l": {
+      "background": true,
       "collision": false,
+      "drop": "none",
+      "hp": 21,
+      "id": 23,
       "transparent": true
     },
-    "stone": {
-      "hp": 450,
-      "drop": "cobblestone"
+    "bed_r": {
+      "background": true,
+      "collision": false,
+      "drop": "none",
+      "hp": 21,
+      "id": 24,
+      "transparent": true
     },
-    "grass": {
-      "hp": 54,
-      "drop": "dirt"
+    "bedrock": {
+      "hp": -1,
+      "id": 7
     },
-    "dirt": {
-      "hp": 45
+    "brick_slab": {
+      "hp": 600,
+      "id": 56,
+      "texture": "bricks",
+      "top": 8,
+      "transparent": true
     },
-    "cobblestone": {
-      "hp": 600
+    "bricks": {
+      "hp": 600,
+      "id": 28
     },
-    "planks_oak": {
-      "hp": 180
+    "cactus": {
+      "block_required": true,
+      "hp": 39,
+      "id": 59,
+      "left": 1,
+      "right": 1,
+      "transparent": true
     },
-    "sapling_oak": {
-      "hp": 0,
-      "collision": false,
-      "background": false,
-      "transparent": true,
-      "block_required": true
+    "coal_ore": {
+      "drop": "coal",
+      "hp": 900,
+      "id": 14
     },
-    "bedrock": {
-      "hp": -1
+    "cobblestone": {
+      "hp": 600,
+      "id": 4
     },
-    "water": {
-      "hp": -1,
-      "collision": false,
-      "background": false,
-      "transparent": true,
-      "fluid": true,
-      "texture": "water_still",
-      "meta": "water",
-      "animated": true,
-      "frames": 16
+    "cobblestone_slab": {
+      "hp": 600,
+      "id": 55,
+      "texture": "cobblestone",
+      "top": 8,
+      "transparent": true
     },
-    "lava": {
-      "hp": -1,
+    "dandelion": {
+      "block_required": true,
       "collision": false,
-      "background": false,
-      "fluid": true,
-      "texture": "lava_still",
-      "meta": "lava",
-      "animated": true,
-      "frames": 16
+      "id": 29,
+      "transparent": true
     },
-    "sand": {
-      "hp": 45
+    "deadbush": {
+      "block_required": true,
+      "collision": false,
+      "id": 27,
+      "transparent": true
     },
-    "gravel": {
-      "hp": 54
+    "dirt": {
+      "hp": 45,
+      "id": 3
     },
-    "gold_ore": {
-      "hp": 900
+    "double_stone_slab": {
+      "drop": "stone_slab",
+      "hp": 600,
+      "id": 52,
+      "texture": "stone_slab"
     },
-    "iron_ore": {
-      "hp": 900
+    "glass": {
+      "drop": "none",
+      "hp": 27,
+      "id": 18,
+      "transparent": true
     },
-    "coal_ore": {
+    "gold_block": {
       "hp": 900,
-      "drop": "coal"
+      "id": 49
     },
-    "log_oak": {
-      "hp": 180
+    "gold_ore": {
+      "hp": 900,
+      "id": 12
     },
-    "leaves_oak": {
-      "hp": 21,
-      "transparent": true
+    "grass": {
+      "drop": "dirt",
+      "hp": 54,
+      "id": 2
     },
-    "sponge": {
-      "hp": 54
+    "gravel": {
+      "hp": 54,
+      "id": 11
     },
-    "glass": {
-      "hp": 27,
-      "drop": "none",
-      "background": false,
-      "transparent": true
+    "iron_block": {
+      "hp": 1500,
+      "id": 50
     },
-    "lapis_ore": {
+    "iron_ore": {
       "hp": 900,
-      "drop": "lapis"
+      "id": 13
     },
     "lapis_block": {
-      "hp": 900
-    },
-    "sandstone": {
-      "hp": 240
+      "hp": 900,
+      "id": 20
     },
-    "noteblock": {
-      "hp": 75
+    "lapis_ore": {
+      "drop": "lapis",
+      "hp": 900,
+      "id": 19
     },
-    "bed_l": {
-      "hp": 21,
-      "drop": "none",
+    "lava": {
+      "animated": true,
       "collision": false,
-      "background": true,
-      "transparent": true
+      "fluid": true,
+      "frames": 16,
+      "hp": -1,
+      "id": 9,
+      "meta": "lava",
+      "texture": "lava_still"
     },
-    "bed_r": {
-      "hp": 21,
-      "drop": "none",
+    "lava_12": {
+      "animated": true,
       "collision": false,
-      "background": true,
-      "transparent": true
+      "fluid": true,
+      "frames": 16,
+      "hp": -1,
+      "id": 65,
+      "meta": "lava",
+      "sprite_top": 4,
+      "texture": "lava_flow",
+      "top": 4
     },
-    "web": {
-      "hp": 1200,
+    "lava_16": {
+      "animated": true,
       "collision": false,
-      "background": false,
-      "transparent": true
+      "fluid": true,
+      "frames": 16,
+      "hp": -1,
+      "id": 64,
+      "meta": "lava",
+      "texture": "lava_flow"
     },
-    "tallgrass": {
-      "hp": 0,
+    "lava_4": {
+      "animated": true,
       "collision": false,
-      "background": false,
-      "transparent": true,
-      "block_required": true
+      "fluid": true,
+      "frames": 16,
+      "hp": -1,
+      "id": 67,
+      "meta": "lava",
+      "sprite_top": 12,
+      "texture": "lava_flow",
+      "top": 12
     },
-    "deadbush": {
-      "hp": 0,
+    "lava_8": {
+      "animated": true,
       "collision": false,
-      "background": false,
-      "transparent": true,
-      "block_required": true
-    },
-    "bricks": {
-      "hp": 600
+      "fluid": true,
+      "frames": 16,
+      "hp": -1,
+      "id": 66,
+      "meta": "lava",
+      "sprite_top": 8,
+      "texture": "lava_flow",
+      "top": 8
     },
-    "dandelion": {
-      "hp": 0,
-      "collision": false,
-      "background": false,
-      "transparent": true,
-      "block_required": true
+    "leaves_oak": {
+      "hp": 21,
+      "id": 16,
+      "transparent": true
     },
-    "rose": {
-      "hp": 0,
-      "collision": false,
-      "background": false,
-      "transparent": true,
-      "block_required": true
+    "log_oak": {
+      "hp": 180,
+      "id": 15
     },
     "mushroom_brown": {
-      "hp": 0,
+      "block_required": true,
       "collision": false,
-      "background": false,
-      "transparent": true,
-      "block_required": true
+      "id": 31,
+      "transparent": true
     },
     "mushroom_red": {
-      "hp": 0,
+      "block_required": true,
       "collision": false,
-      "background": false,
-      "transparent": true,
-      "block_required": true
-    },
-    "wool_colored_white": {
-      "hp": 75
-    },
-    "wool_colored_orange": {
-      "hp": 75
-    },
-    "wool_colored_magenta": {
-      "hp": 75
-    },
-    "wool_colored_light_blue": {
-      "hp": 75
-    },
-    "wool_colored_yellow": {
-      "hp": 75
-    },
-    "wool_colored_lime": {
-      "hp": 75
-    },
-    "wool_colored_pink": {
-      "hp": 75
-    },
-    "wool_colored_gray": {
-      "hp": 75
-    },
-    "wool_colored_silver": {
-      "hp": 75
-    },
-    "wool_colored_cyan": {
-      "hp": 75
+      "id": 32,
+      "transparent": true
     },
-    "wool_colored_purple": {
-      "hp": 75
+    "none": {
+      "collision": false,
+      "id": 0,
+      "transparent": true
     },
-    "wool_colored_blue": {
-      "hp": 75
+    "noteblock": {
+      "hp": 75,
+      "id": 22
     },
-    "wool_colored_brown": {
-      "hp": 75
+    "oak_slab": {
+      "hp": 180,
+      "id": 54,
+      "texture": "planks_oak",
+      "top": 8,
+      "transparent": true
     },
-    "wool_colored_green": {
-      "hp": 75
+    "obsidian": {
+      "hp": 1500,
+      "id": 68
     },
-    "wool_colored_red": {
-      "hp": 75
+    "planks_oak": {
+      "hp": 180,
+      "id": 5
     },
-    "wool_colored_black": {
-      "hp": 75
+    "rose": {
+      "block_required": true,
+      "collision": false,
+      "id": 30,
+      "transparent": true
     },
-    "gold_block": {
-      "hp": 900
+    "sand": {
+      "hp": 45,
+      "id": 10
     },
-    "iron_block": {
-      "hp": 1500
+    "sandstone": {
+      "hp": 240,
+      "id": 21
     },
-    "stone_slab": {
-      "top": 8,
+    "sandstone_slab": {
       "hp": 600,
-      "transparent": true,
-      "sprite_top": 8
+      "id": 53,
+      "texture": "sandstone",
+      "top": 8,
+      "transparent": true
     },
-    "double_stone_slab": {
-      "hp": 600,
-      "drop": "stone_slab",
-      "texture": "stone_slab"
+    "sapling_oak": {
+      "block_required": true,
+      "collision": false,
+      "id": 6,
+      "transparent": true
     },
-    "sandstone_slab": {
-      "top": 8,
-      "hp": 600,
-      "transparent": true,
-      "texture": "sandstone"
+    "sponge": {
+      "hp": 54,
+      "id": 17
     },
-    "oak_slab": {
-      "top": 8,
-      "hp": 180,
-      "transparent": true,
-      "texture": "planks_oak"
+    "stone": {
+      "drop": "cobblestone",
+      "hp": 450,
+      "id": 1
     },
-    "cobblestone_slab": {
-      "top": 8,
+    "stone_slab": {
       "hp": 600,
-      "transparent": true,
-      "texture": "cobblestone"
-    },
-    "brick_slab": {
+      "id": 51,
+      "sprite_top": 8,
       "top": 8,
-      "hp": 600,
-      "transparent": true,
-      "texture": "bricks"
+      "transparent": true
     },
     "stonebrick": {
-      "hp": 450
+      "hp": 450,
+      "id": 57
     },
     "stonebrick_slab": {
-      "top": 8,
       "hp": 450,
-      "transparent": true,
-      "texture": "stonebrick"
+      "id": 58,
+      "texture": "stonebrick",
+      "top": 8,
+      "transparent": true
     },
-    "cactus": {
-      "left": 1,
-      "right": 1,
-      "hp": 39,
-      "transparent": true,
-      "block_required": true
+    "tallgrass": {
+      "block_required": true,
+      "collision": false,
+      "id": 26,
+      "transparent": true
     },
-    "water_16": {
-      "hp": -1,
+    "water": {
+      "animated": true,
       "collision": false,
-      "background": false,
-      "transparent": true,
       "fluid": true,
-      "texture": "water_flow",
+      "frames": 16,
+      "hp": -1,
+      "id": 8,
       "meta": "water",
-      "animated": true,
-      "frames": 16
+      "texture": "water_still",
+      "transparent": true
     },
     "water_12": {
-      "top": 4,
-      "hp": -1,
+      "animated": true,
       "collision": false,
-      "background": false,
-      "transparent": true,
       "fluid": true,
-      "texture": "water_flow",
-      "meta": "water",
-      "animated": true,
       "frames": 16,
-      "sprite_top": 4
-    },
-    "water_8": {
-      "top": 8,
       "hp": -1,
-      "collision": false,
-      "background": false,
-      "transparent": true,
-      "fluid": true,
-      "texture": "water_flow",
+      "id": 61,
       "meta": "water",
-      "animated": true,
-      "frames": 16,
-      "sprite_top": 8
+      "sprite_top": 4,
+      "texture": "water_flow",
+      "top": 4,
+      "transparent": true
     },
-    "water_4": {
-      "top": 12,
-      "hp": -1,
+    "water_16": {
+      "animated": true,
       "collision": false,
-      "background": false,
-      "transparent": true,
       "fluid": true,
-      "texture": "water_flow",
-      "meta": "water",
-      "animated": true,
       "frames": 16,
-      "sprite_top": 12
-    },
-    "lava_16": {
       "hp": -1,
-      "collision": false,
-      "background": false,
-      "fluid": true,
-      "texture": "lava_flow",
-      "meta": "lava",
-      "animated": true,
-      "frames": 16
+      "id": 60,
+      "meta": "water",
+      "texture": "water_flow",
+      "transparent": true
     },
-    "lava_12": {
-      "top": 4,
-      "hp": -1,
+    "water_4": {
+      "animated": true,
       "collision": false,
-      "background": false,
       "fluid": true,
-      "texture": "lava_flow",
-      "meta": "lava",
-      "animated": true,
       "frames": 16,
-      "sprite_top": 4
-    },
-    "lava_8": {
-      "top": 8,
       "hp": -1,
+      "id": 63,
+      "meta": "water",
+      "sprite_top": 12,
+      "texture": "water_flow",
+      "top": 12,
+      "transparent": true
+    },
+    "water_8": {
+      "animated": true,
       "collision": false,
-      "background": false,
       "fluid": true,
-      "texture": "lava_flow",
-      "meta": "lava",
-      "animated": true,
       "frames": 16,
-      "sprite_top": 8
-    },
-    "lava_4": {
-      "top": 12,
       "hp": -1,
+      "id": 62,
+      "meta": "water",
+      "sprite_top": 8,
+      "texture": "water_flow",
+      "top": 8,
+      "transparent": true
+    },
+    "web": {
       "collision": false,
-      "background": false,
-      "fluid": true,
-      "texture": "lava_flow",
-      "meta": "lava",
-      "animated": true,
-      "frames": 16,
-      "sprite_top": 12
+      "hp": 1200,
+      "id": 25,
+      "transparent": true
+    },
+    "wool_colored_black": {
+      "hp": 75,
+      "id": 48
+    },
+    "wool_colored_blue": {
+      "hp": 75,
+      "id": 44
+    },
+    "wool_colored_brown": {
+      "hp": 75,
+      "id": 45
+    },
+    "wool_colored_cyan": {
+      "hp": 75,
+      "id": 42
+    },
+    "wool_colored_gray": {
+      "hp": 75,
+      "id": 40
+    },
+    "wool_colored_green": {
+      "hp": 75,
+      "id": 46
+    },
+    "wool_colored_light_blue": {
+      "hp": 75,
+      "id": 36
+    },
+    "wool_colored_lime": {
+      "hp": 75,
+      "id": 38
+    },
+    "wool_colored_magenta": {
+      "hp": 75,
+      "id": 35
+    },
+    "wool_colored_orange": {
+      "hp": 75,
+      "id": 34
+    },
+    "wool_colored_pink": {
+      "hp": 75,
+      "id": 39
+    },
+    "wool_colored_purple": {
+      "hp": 75,
+      "id": 43
+    },
+    "wool_colored_red": {
+      "hp": 75,
+      "id": 47
+    },
+    "wool_colored_silver": {
+      "hp": 75,
+      "id": 41
+    },
+    "wool_colored_white": {
+      "hp": 75,
+      "id": 33
+    },
+    "wool_colored_yellow": {
+      "hp": 75,
+      "id": 37
+    }
+  },
+  "items": {
+    "bedrock": {
+      "id": 7,
+      "name": "Bedrock",
+      "type": "block"
+    },
+    "brick_slab": {
+      "id": 51,
+      "name": "Brick Slab",
+      "type": "block"
+    },
+    "bricks": {
+      "id": 24,
+      "name": "Bricks",
+      "type": "block"
+    },
+    "bucket_empty": {
+      "id": 66,
+      "name": "Empty Bucket",
+      "origin_x": 0.25,
+      "type": "bucket"
+    },
+    "bucket_lava": {
+      "id": 68,
+      "name": "Lava Bucket",
+      "origin_x": 0.25,
+      "type": "bucket"
+    },
+    "bucket_water": {
+      "id": 67,
+      "name": "Water Bucket",
+      "origin_x": 0.25,
+      "type": "bucket"
+    },
+    "cactus": {
+      "id": 54,
+      "name": "Cactus",
+      "type": "block"
+    },
+    "coal_ore": {
+      "id": 14,
+      "name": "Coal Ore",
+      "type": "block"
+    },
+    "cobblestone": {
+      "id": 4,
+      "name": "Cobblestone",
+      "type": "block"
+    },
+    "cobblestone_slab": {
+      "id": 50,
+      "name": "Cobblestone Slab",
+      "type": "block"
+    },
+    "dandelion": {
+      "id": 25,
+      "name": "Dandelion",
+      "origin_x": 0.5,
+      "type": "block"
+    },
+    "deadbush": {
+      "id": 23,
+      "name": "Dead Bush",
+      "origin_x": 0.5,
+      "type": "block"
+    },
+    "diamond_shovel": {
+      "id": 64,
+      "name": "Diamond Shovel",
+      "origin_x": 0.125,
+      "type": "tool"
+    },
+    "diamond_sword": {
+      "id": 59,
+      "name": "Diamond Sword",
+      "origin_x": 0.125,
+      "type": "tool"
     },
-    "obsidian": {
-      "hp": 1500
-    }
-  },
-  "items": {
-    "none": {
-      "name": "",
+    "dirt": {
+      "id": 3,
+      "name": "Dirt",
       "type": "block"
     },
-    "stone": {
-      "name": "Stone",
+    "glass": {
+      "id": 17,
+      "name": "Glass",
+      "type": "block"
+    },
+    "gold_block": {
+      "id": 45,
+      "name": "Gold Block",
+      "type": "block"
+    },
+    "gold_ore": {
+      "id": 12,
+      "name": "Golden Ore",
       "type": "block"
     },
+    "gold_shovel": {
+      "id": 65,
+      "name": "Golden Shovel",
+      "origin_x": 0.125,
+      "type": "tool"
+    },
+    "gold_sword": {
+      "id": 60,
+      "name": "Golden Sword",
+      "origin_x": 0.125,
+      "type": "tool"
+    },
     "grass": {
+      "id": 2,
       "name": "Grass",
       "type": "block"
     },
-    "dirt": {
-      "name": "Dirt",
+    "gravel": {
+      "id": 11,
+      "name": "Gravel",
       "type": "block"
     },
-    "cobblestone": {
-      "name": "Cobblestone",
+    "iron_block": {
+      "id": 46,
+      "name": "Iron Block",
       "type": "block"
     },
-    "planks_oak": {
-      "name": "Oak Planks",
+    "iron_ore": {
+      "id": 13,
+      "name": "Iron Ore",
       "type": "block"
     },
-    "sapling_oak": {
-      "name": "Oak Sapling",
-      "type": "block"
+    "iron_shovel": {
+      "id": 63,
+      "name": "Iron Shovel",
+      "origin_x": 0.125,
+      "type": "tool"
     },
-    "bedrock": {
-      "name": "Bedrock",
+    "iron_sword": {
+      "id": 58,
+      "name": "Iron Sword",
+      "origin_x": 0.125,
+      "type": "tool"
+    },
+    "lapis_block": {
+      "id": 19,
+      "name": "Lapis Block",
       "type": "block"
     },
-    "water": {
-      "name": "Water",
+    "lapis_ore": {
+      "id": 18,
+      "name": "Lapis Ore",
       "type": "block"
     },
     "lava": {
+      "id": 9,
       "name": "Lava",
       "type": "block"
     },
-    "sand": {
-      "name": "Sand",
+    "leaves_oak": {
+      "id": 16,
+      "name": "Leaves",
       "type": "block"
     },
-    "gravel": {
-      "name": "Gravel",
+    "log_oak": {
+      "id": 15,
+      "name": "Wood",
       "type": "block"
     },
-    "gold_ore": {
-      "name": "Golden Ore",
+    "mushroom_brown": {
+      "id": 27,
+      "name": "Mushroom",
+      "origin_x": 0.5,
       "type": "block"
     },
-    "iron_ore": {
-      "name": "Iron Ore",
+    "mushroom_red": {
+      "id": 28,
+      "name": "Mushroom",
+      "origin_x": 0.5,
       "type": "block"
     },
-    "coal_ore": {
-      "name": "Coal Ore",
+    "none": {
+      "id": 0,
+      "name": "",
       "type": "block"
     },
-    "log_oak": {
-      "name": "Wood",
+    "oak_slab": {
+      "id": 49,
+      "name": "Oak Slab",
       "type": "block"
     },
-    "leaves_oak": {
-      "name": "Leaves",
+    "obsidian": {
+      "id": 55,
+      "name": "Obsidian",
       "type": "block"
     },
-    "glass": {
-      "name": "Glass",
+    "planks_oak": {
+      "id": 5,
+      "name": "Oak Planks",
       "type": "block"
     },
-    "lapis_ore": {
-      "name": "Lapis Ore",
+    "rose": {
+      "id": 26,
+      "name": "Rose",
+      "origin_x": 0.5,
       "type": "block"
     },
-    "lapis_block": {
-      "name": "Lapis Block",
+    "sand": {
+      "id": 10,
+      "name": "Sand",
       "type": "block"
     },
     "sandstone": {
+      "id": 20,
       "name": "Sandstone",
       "type": "block"
     },
-    "web": {
-      "name": "Cobweb",
+    "sandstone_slab": {
+      "id": 48,
+      "name": "Sandstone Slab",
       "type": "block"
     },
-    "tallgrass": {
-      "name": "Tall Grass",
-      "type": "block",
-      "origin_x": 0.5
-    },
-    "deadbush": {
-      "name": "Dead Bush",
-      "type": "block",
-      "origin_x": 0.5
-    },
-    "bricks": {
-      "name": "Bricks",
+    "sapling_oak": {
+      "id": 6,
+      "name": "Oak Sapling",
       "type": "block"
     },
-    "dandelion": {
-      "name": "Dandelion",
-      "type": "block",
-      "origin_x": 0.5
+    "stone": {
+      "id": 1,
+      "name": "Stone",
+      "type": "block"
     },
-    "rose": {
-      "name": "Rose",
-      "type": "block",
-      "origin_x": 0.5
+    "stone_shovel": {
+      "id": 62,
+      "name": "Stone Shovel",
+      "origin_x": 0.125,
+      "type": "tool"
     },
-    "mushroom_brown": {
-      "name": "Mushroom",
-      "type": "block",
-      "origin_x": 0.5
+    "stone_slab": {
+      "id": 47,
+      "name": "Stone Slab",
+      "type": "block"
     },
-    "mushroom_red": {
-      "name": "Mushroom",
-      "type": "block",
-      "origin_x": 0.5
+    "stone_sword": {
+      "id": 57,
+      "name": "Stone Sword",
+      "origin_x": 0.125,
+      "type": "tool"
     },
-    "wool_colored_white": {
-      "name": "Wool",
+    "stonebrick": {
+      "id": 52,
+      "name": "Stone Brick",
       "type": "block"
     },
-    "wool_colored_orange": {
-      "name": "Wool",
+    "stonebrick_slab": {
+      "id": 53,
+      "name": "Stone Brick Slab",
       "type": "block"
     },
-    "wool_colored_magenta": {
-      "name": "Wool",
+    "tallgrass": {
+      "id": 22,
+      "name": "Tall Grass",
+      "origin_x": 0.5,
       "type": "block"
     },
-    "wool_colored_light_blue": {
-      "name": "Wool",
+    "water": {
+      "id": 8,
+      "name": "Water",
       "type": "block"
     },
-    "wool_colored_yellow": {
-      "name": "Wool",
+    "web": {
+      "id": 21,
+      "name": "Cobweb",
       "type": "block"
     },
-    "wool_colored_lime": {
-      "name": "Wool",
-      "type": "block"
+    "wood_shovel": {
+      "id": 61,
+      "name": "Wooden Shovel",
+      "origin_x": 0.125,
+      "type": "tool"
     },
-    "wool_colored_pink": {
+    "wood_sword": {
+      "id": 56,
+      "name": "Wooden Sword",
+      "origin_x": 0.125,
+      "type": "tool"
+    },
+    "wool_colored_black": {
+      "id": 44,
       "name": "Wool",
       "type": "block"
     },
-    "wool_colored_gray": {
+    "wool_colored_blue": {
+      "id": 40,
       "name": "Wool",
       "type": "block"
     },
-    "wool_colored_silver": {
+    "wool_colored_brown": {
+      "id": 41,
       "name": "Wool",
       "type": "block"
     },
     "wool_colored_cyan": {
+      "id": 38,
       "name": "Wool",
       "type": "block"
     },
-    "wool_colored_purple": {
+    "wool_colored_gray": {
+      "id": 36,
       "name": "Wool",
       "type": "block"
     },
-    "wool_colored_blue": {
+    "wool_colored_green": {
+      "id": 42,
       "name": "Wool",
       "type": "block"
     },
-    "wool_colored_brown": {
+    "wool_colored_light_blue": {
+      "id": 32,
       "name": "Wool",
       "type": "block"
     },
-    "wool_colored_green": {
+    "wool_colored_lime": {
+      "id": 34,
       "name": "Wool",
       "type": "block"
     },
-    "wool_colored_red": {
+    "wool_colored_magenta": {
+      "id": 31,
       "name": "Wool",
       "type": "block"
     },
-    "wool_colored_black": {
+    "wool_colored_orange": {
+      "id": 30,
       "name": "Wool",
       "type": "block"
     },
-    "gold_block": {
-      "name": "Gold Block",
+    "wool_colored_pink": {
+      "id": 35,
+      "name": "Wool",
       "type": "block"
     },
-    "iron_block": {
-      "name": "Iron Block",
+    "wool_colored_purple": {
+      "id": 39,
+      "name": "Wool",
       "type": "block"
     },
-    "stone_slab": {
-      "name": "Stone Slab",
-      "type": "block",
-      "meta": "slab"
-    },
-    "sandstone_slab": {
-      "name": "Sandstone Slab",
-      "type": "block",
-      "meta": "slab"
-    },
-    "oak_slab": {
-      "name": "Oak Slab",
-      "type": "block",
-      "meta": "slab"
-    },
-    "cobblestone_slab": {
-      "name": "Cobblestone Slab",
-      "type": "block",
-      "meta": "slab"
-    },
-    "brick_slab": {
-      "name": "Brick Slab",
-      "type": "block",
-      "meta": "slab"
-    },
-    "stonebrick": {
-      "name": "Stone Brick",
+    "wool_colored_red": {
+      "id": 43,
+      "name": "Wool",
       "type": "block"
     },
-    "stonebrick_slab": {
-      "name": "Stone Brick Slab",
-      "type": "block",
-      "meta": "slab"
-    },
-    "cactus": {
-      "name": "Cactus",
+    "wool_colored_silver": {
+      "id": 37,
+      "name": "Wool",
       "type": "block"
     },
-    "obsidian": {
-      "name": "Obsidian",
+    "wool_colored_white": {
+      "id": 29,
+      "name": "Wool",
       "type": "block"
     },
-    "wood_sword": {
-      "name": "Wooden Sword",
-      "type": "tool",
-      "origin_x": 0.125
-    },
-    "stone_sword": {
-      "name": "Stone Sword",
-      "type": "tool",
-      "origin_x": 0.125
-    },
-    "iron_sword": {
-      "name": "Iron Sword",
-      "type": "tool",
-      "origin_x": 0.125
-    },
-    "diamond_sword": {
-      "name": "Diamond Sword",
-      "type": "tool",
-      "origin_x": 0.125
-    },
-    "gold_sword": {
-      "name": "Golden Sword",
-      "type": "tool",
-      "origin_x": 0.125
-    },
-    "wood_shovel": {
-      "name": "Wooden Shovel",
-      "type": "tool",
-      "origin_x": 0.125
-    },
-    "stone_shovel": {
-      "name": "Stone Shovel",
-      "type": "tool",
-      "origin_x": 0.125
-    },
-    "iron_shovel": {
-      "name": "Iron Shovel",
-      "type": "tool",
-      "origin_x": 0.125
-    },
-    "diamond_shovel": {
-      "name": "Diamond Shovel",
-      "type": "tool",
-      "origin_x": 0.125
-    },
-    "gold_shovel": {
-      "name": "Golden Shovel",
-      "type": "tool",
-      "origin_x": 0.125
-    },
-    "bucket_empty": {
-      "name": "Empty Bucket",
-      "type": "bucket",
-      "origin_x": 0.25,
-      "origin_y": 1
-    },
-    "bucket_water": {
-      "name": "Water Bucket",
-      "type": "bucket",
-      "origin_x": 0.25,
-      "origin_y": 1
-    },
-    "bucket_lava": {
-      "name": "Lava Bucket",
-      "type": "bucket",
-      "origin_x": 0.25,
-      "origin_y": 1
+    "wool_colored_yellow": {
+      "id": 33,
+      "name": "Wool",
+      "type": "block"
     }
   }
-}
\ No newline at end of file
+}
index 5ae4f19a92e70b96ede2cfcecf01c40fac27d8e5..a5d6c23f716681c78acf0d34f923d6fedbbaf3b0 100644 (file)
@@ -13,7 +13,7 @@ import ru.deadsoftware.cavedroid.misc.Assets;
 import ru.deadsoftware.cavedroid.misc.utils.AssetLoader;
 import ru.deadsoftware.cavedroid.misc.utils.SpriteOrigin;
 
-import java.util.HashMap;
+import java.util.*;
 
 public class GameItems {
 
@@ -113,6 +113,12 @@ public class GameItems {
 
     public static void load(AssetLoader assetLoader) {
         JsonValue json = Assets.jsonReader.parse(assetLoader.getAssetHandle("json/game_items.json"));
+
+        TreeSet<Block> blocksSet = new TreeSet<>(Comparator.comparingInt(Block::getId));
+        TreeSet<Item> itemsSet = new TreeSet<>(Comparator.comparingInt(Item::getId));
+
+
+        int count = 0;
         for (JsonValue block = json.get("blocks").child(); block != null; block = block.next()) {
             try {
                 String key = block.name();
@@ -137,11 +143,16 @@ public class GameItems {
                         new Texture(assetLoader.getAssetHandle("textures/blocks/" + tex + ".png"));
                 boolean animated = Assets.getBooleanFromJson(block, "animated", false);
                 int frames = Assets.getIntFromJson(block, "frames", 0);
-                int id = blocks.size;
+                int id = Assets.getIntFromJson(block, "id", count);
                 blocksIds.put(key, id);
 
+                if (count >= id) {
+                    count++;
+                }
+
                 Block newBlock = new Block(
                         id,
+                        key,
                         left,
                         top,
                         right,
@@ -162,11 +173,13 @@ public class GameItems {
                         clipWidth,
                         clipHeight
                 );
-                blocks.put(key, newBlock);
+                blocksSet.add(newBlock);
             } catch (GdxRuntimeException e) {
                 Gdx.app.error(TAG, e.getMessage());
             }
         }
+
+        count = 0;
         for (JsonValue item = json.get("items").child(); item != null; item = item.next()) {
             try {
                 String key = item.name();
@@ -182,13 +195,21 @@ public class GameItems {
                 originY = MathUtils.clamp(originY, 0f, 1f);
                 SpriteOrigin origin = new SpriteOrigin(originX, originY);
 
-                int id = items.size;
+                int id = Assets.getIntFromJson(item, "id", count);
+
+                if (count >= id) {
+                    count++;
+                }
+
                 itemsIds.put(key, id);
-                items.put(key, new Item(id, name, type, sprite, origin));
+                itemsSet.add(new Item(id, key, name, type, sprite, origin));
             } catch (GdxRuntimeException e) {
                 Gdx.app.error(TAG, e.getMessage());
             }
         }
+
+        blocksSet.forEach((block -> blocks.put(block.getKey(), block)));
+        itemsSet.forEach((item -> items.put(item.getKey(), item)));
     }
 
 }
\ No newline at end of file
index 215ac26c7a766a8ec0b9111c690343c215f5b0c1..3343c9ac294b6e18cb7e5812fc62d00ce99415a4 100644 (file)
@@ -35,6 +35,7 @@ private const val DEPRECATION_MESSAGE =
  */
 data class Block(
         val id: Int,
+        val key: String,
         val left: Int,
         val top: Int,
         val right: Int,
index cb0f7b7269c9526ca5649033371bbf6b485914c3..1932ff8cbb8e31c0887a92dc1fbbac32e18d0056 100644 (file)
@@ -6,6 +6,7 @@ import ru.deadsoftware.cavedroid.misc.utils.SpriteOrigin
 
 data class Item(
         val id: Int,
+        val key: String,
         val name: String,
         val type: String,
         val sprite: Sprite?,