Browse Source

Fix Craft recipe loader bug and add digging data

JasonWang 6 năm trước cách đây
mục cha
commit
24f8c6509d

+ 25 - 25
data/crafting.txt

@@ -177,37 +177,37 @@ CraftingTable		  = WoodPlanks^-1, 1:1, 1:2, 2:1, 2:2
 ##
 #
 ## Axes:
-#DiamondAxe = Stick, 2:2, 2:3 | Diamond,     2:1, 1:1, 1:2
-#DiamondAxe = Stick, 2:2, 2:3 | Diamond,     2:1, 3:1, 3:2
-#GoldenAxe  = Stick, 2:2, 2:3 | GoldIngot,   2:1, 1:1, 1:2
-#GoldenAxe  = Stick, 2:2, 2:3 | GoldIngot,   2:1, 3:1, 3:2
-#IronAxe    = Stick, 2:2, 2:3 | IronIngot,   2:1, 1:1, 1:2
-#IronAxe    = Stick, 2:2, 2:3 | IronIngot,   2:1, 3:1, 3:2
-#StoneAxe   = Stick, 2:2, 2:3 | Cobblestone, 2:1, 1:1, 1:2
-#StoneAxe   = Stick, 2:2, 2:3 | Cobblestone, 2:1, 3:1, 3:2
-#WoodenAxe  = Stick, 2:2, 2:3 | Planks^-1,   2:1, 1:1, 1:2
-#WoodenAxe  = Stick, 2:2, 2:3 | Planks^-1,   2:1, 3:1, 3:2
+DiamondAxe = Stick, 2:2, 2:3 | Diamond,     2:1, 1:1, 1:2
+DiamondAxe = Stick, 2:2, 2:3 | Diamond,     2:1, 3:1, 3:2
+GoldenAxe  = Stick, 2:2, 2:3 | GoldIngot,   2:1, 1:1, 1:2
+GoldenAxe  = Stick, 2:2, 2:3 | GoldIngot,   2:1, 3:1, 3:2
+IronAxe    = Stick, 2:2, 2:3 | IronIngot,   2:1, 1:1, 1:2
+IronAxe    = Stick, 2:2, 2:3 | IronIngot,   2:1, 3:1, 3:2
+StoneAxe   = Stick, 2:2, 2:3 | Cobblestone, 2:1, 1:1, 1:2
+StoneAxe   = Stick, 2:2, 2:3 | Cobblestone, 2:1, 3:1, 3:2
+WoodenAxe  = Stick, 2:2, 2:3 | WoodPlanks^-1,   2:1, 1:1, 1:2
+WoodenAxe  = Stick, 2:2, 2:3 | WoodPlanks^-1,   2:1, 3:1, 3:2
 #
 ## Pickaxes:
-#DiamondPickaxe = Stick, 2:2, 2:3 | Diamond,     1:1, 2:1, 3:1
-#GoldenPickaxe  = Stick, 2:2, 2:3 | GoldIngot,   1:1, 2:1, 3:1
-#IronPickaxe    = Stick, 2:2, 2:3 | IronIngot,   1:1, 2:1, 3:1
-#StonePickaxe   = Stick, 2:2, 2:3 | Cobblestone, 1:1, 2:1, 3:1
-#WoodenPickaxe  = Stick, 2:2, 2:3 | Planks^-1,   1:1, 2:1, 3:1
+DiamondPickaxe = Stick, 2:2, 2:3 | Diamond,     1:1, 2:1, 3:1
+GoldenPickaxe  = Stick, 2:2, 2:3 | GoldIngot,   1:1, 2:1, 3:1
+IronPickaxe    = Stick, 2:2, 2:3 | IronIngot,   1:1, 2:1, 3:1
+StonePickaxe   = Stick, 2:2, 2:3 | Cobblestone, 1:1, 2:1, 3:1
+WoodenPickaxe  = Stick, 2:2, 2:3 | WoodPlanks^-1,   1:1, 2:1, 3:1
 #
 ## Shovels:
-#DiamondShovel = Stick, 2:2, 2:3 | Diamond,     2:1
-#GoldenShovel  = Stick, 2:2, 2:3 | GoldIngot,   2:1
-#IronShovel    = Stick, 2:2, 2:3 | IronIngot,   2:1
-#StoneShovel   = Stick, 2:2, 2:3 | Cobblestone, 2:1
-#WoodenShovel  = Stick, 2:2, 2:3 | Planks^-1,   2:1
+DiamondShovel = Stick, 2:2, 2:3 | Diamond,     2:1
+GoldenShovel  = Stick, 2:2, 2:3 | GoldIngot,   2:1
+IronShovel    = Stick, 2:2, 2:3 | IronIngot,   2:1
+StoneShovel   = Stick, 2:2, 2:3 | Cobblestone, 2:1
+WoodenShovel  = Stick, 2:2, 2:3 | WoodPlanks^-1,   2:1
 #
 ## Hoes:
-#DiamondHoe = Stick, 2:2, 2:3 | Diamond,     2:1, *:1
-#GoldenHoe  = Stick, 2:2, 2:3 | GoldIngot,   2:1, *:1
-#IronHoe    = Stick, 2:2, 2:3 | IronIngot,   2:1, *:1
-#StoneHoe   = Stick, 2:2, 2:3 | Cobblestone, 2:1, *:1
-#WoodenHoe  = Stick, 2:2, 2:3 | Planks^-1,   2:1, *:1
+DiamondHoe = Stick, 2:2, 2:3 | Diamond,     2:1, *:1
+GoldenHoe  = Stick, 2:2, 2:3 | GoldIngot,   2:1, *:1
+IronHoe    = Stick, 2:2, 2:3 | IronIngot,   2:1, *:1
+StoneHoe   = Stick, 2:2, 2:3 | Cobblestone, 2:1, *:1
+WoodenHoe  = Stick, 2:2, 2:3 | WoodPlanks^-1,   2:1, *:1
 #
 #Bucket         = IronIngot, 1:1, 2:2, 3:1
 #Compass        = IronIngot, 2:1, 1:2, 3:2, 2:3 | RedstoneDust, 2:2

+ 9 - 0
data/digging.txt

@@ -0,0 +1,9 @@
+# This file describes Minecase digging table.
+# <GetBlock> = <Block> | <Tool>
+Dirt = GrassBlock | Air
+Air = Stone | *
+Cobblestone = Stone | DiamondPickaxe
+Cobblestone = Stone | GoldenPickaxe
+Cobblestone = Stone | IronPickaxe
+Cobblestone = Stone | StonePickaxe
+Cobblestone = Stone | WoodenPickaxe

+ 7 - 5
src/MineCase.Core/CraftingRecipeLoader.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.IO;
+using System.Linq;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Text;
@@ -61,29 +62,32 @@ namespace MineCase
                 recipe.Output.ItemCount = byte.Parse(ToString(resultSpan.Slice(resultSplitter + 1)));
             }
 
+            var recipeSlots = new List<CraftingRecipeSlot>();
             var restSpan = ingredientsSpan;
             while (!restSpan.IsEmpty)
             {
                 var ingredientSplitter = restSpan.IndexOf('|');
                 var ingredientSpan = ingredientSplitter == -1 ? restSpan : restSpan.Slice(0, ingredientSplitter);
-                ParseIngredient(ingredientSpan, recipe);
+                ParseIngredient(ingredientSpan, recipe, recipeSlots);
                 if (ingredientSplitter == -1)
                     break;
                 else
                     restSpan = restSpan.Slice(ingredientSplitter + 1);
             }
 
+            recipe.Inputs = recipeSlots.ToArray();
+            NormalizeIngredients(recipe);
+
             Recipes.Add(recipe);
         }
 
-        private void ParseIngredient(Span<char> ingredientSpan, CraftingRecipe recipe)
+        private void ParseIngredient(Span<char> ingredientSpan, CraftingRecipe recipe, List<CraftingRecipeSlot> recipeSlots)
         {
             var slot = new Slot { ItemCount = 1 };
             var splitter = ingredientSpan.IndexOf(',');
             ParseItem(ingredientSpan.Slice(0, splitter), ref slot);
             var distributionSpan = ingredientSpan.Slice(splitter + 1);
 
-            var recipeSlots = new List<CraftingRecipeSlot>();
             do
             {
                 var positionSplitter = distributionSpan.IndexOf(',');
@@ -131,8 +135,6 @@ namespace MineCase
                     distributionSpan = distributionSpan.Slice(positionSplitter + 1);
             }
             while (true);
-            recipe.Inputs = recipeSlots.ToArray();
-            NormalizeIngredients(recipe);
         }
 
         private void NormalizeIngredients(CraftingRecipe recipe)

+ 10 - 0
src/MineCase.Server.Grains/World/Decoration/Biomes/BiomeHillDecoratorGrain.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MineCase.Server.World.Decoration.Biomes
+{
+    public class BiomeHillDecoratorGrain : BiomeDecoratorGrain, IBiomeHillDecorator
+    {
+    }
+}

+ 10 - 0
src/MineCase.Server.Grains/World/Decoration/Biomes/BiomeRiverDecoratorGrain.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MineCase.Server.World.Decoration.Biomes
+{
+    public class BiomeRiverDecoratorGrain : BiomeDecoratorGrain, IBiomeRiverDecorator
+    {
+    }
+}

+ 10 - 0
src/MineCase.Server.Grains/World/Decoration/Biomes/BiomeSwampDecoratorGrain.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MineCase.Server.World.Decoration.Biomes
+{
+    public class BiomeSwampDecoratorGrain : BiomeDecoratorGrain, IBiomeSwampDecorator
+    {
+    }
+}

+ 10 - 0
src/MineCase.Server.Grains/World/Decoration/Biomes/BiomeTaigaDecoratorGrain.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MineCase.Server.World.Decoration.Biomes
+{
+    public class BiomeTaigaDecoratorGrain : BiomeDecoratorGrain, IBiomeTaigaDecorator
+    {
+    }
+}

+ 10 - 0
src/MineCase.Server.Interfaces/World/Decoration/Biomes/IBiomeHillDecorator.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MineCase.Server.World.Decoration.Biomes
+{
+    public interface IBiomeHillDecorator : IBiomeDecorator
+    {
+    }
+}

+ 10 - 0
src/MineCase.Server.Interfaces/World/Decoration/Biomes/IBiomeRiverDecorator.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MineCase.Server.World.Decoration.Biomes
+{
+    public interface IBiomeRiverDecorator : IBiomeDecorator
+    {
+    }
+}

+ 10 - 0
src/MineCase.Server.Interfaces/World/Decoration/Biomes/IBiomeSwampDecorator.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MineCase.Server.World.Decoration.Biomes
+{
+    public interface IBiomeSwampDecorator : IBiomeDecorator
+    {
+    }
+}

+ 10 - 0
src/MineCase.Server.Interfaces/World/Decoration/Biomes/IBiomeTaigaDecorator.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MineCase.Server.World.Decoration.Biomes
+{
+    public interface IBiomeTaigaDecorator : IBiomeDecorator
+    {
+    }
+}