mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +00:00 
			
		
		
		
	fix: recipes with nbt
it looks like the recipes need to be regenerated
This commit is contained in:
		| @@ -29,8 +29,10 @@ public final class ImpostorRecipe extends ShapedRecipe | |||||||
|         { |         { | ||||||
|             String group = JsonHelper.getString( json, "group", "" ); |             String group = JsonHelper.getString( json, "group", "" ); | ||||||
|             ShapedRecipe recipe = RecipeSerializer.SHAPED.read( identifier, json ); |             ShapedRecipe recipe = RecipeSerializer.SHAPED.read( identifier, json ); | ||||||
|             ItemStack result = ShapedRecipe.outputFromJson( JsonHelper.getObject( json, "result" ) ); |             JsonObject resultObject = JsonHelper.getObject( json, "result" ); | ||||||
|             return new ImpostorRecipe( identifier, group, recipe.getWidth(), recipe.getHeight(), recipe.getIngredients(), result ); |             ItemStack itemStack = ShapedRecipe.outputFromJson( resultObject ); | ||||||
|  |             RecipeUtil.setNbt( itemStack, resultObject ); | ||||||
|  |             return new ImpostorRecipe( identifier, group, recipe.getWidth(), recipe.getHeight(), recipe.getIngredients(), itemStack ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|   | |||||||
| @@ -41,9 +41,10 @@ public final class ImpostorShapelessRecipe extends ShapelessRecipe | |||||||
|             { |             { | ||||||
|                 throw new JsonParseException( "Too many ingredients for shapeless recipe the max is 9" ); |                 throw new JsonParseException( "Too many ingredients for shapeless recipe the max is 9" ); | ||||||
|             } |             } | ||||||
|  |             JsonObject resultObject = JsonHelper.getObject( json, "result" ); | ||||||
|             ItemStack itemstack = ShapedRecipe.outputFromJson( JsonHelper.getObject( json, "result" ) ); |             ItemStack itemStack = ShapedRecipe.outputFromJson( resultObject ); | ||||||
|             return new ImpostorShapelessRecipe( id, s, itemstack, ingredients ); |             RecipeUtil.setNbt( itemStack, resultObject ); | ||||||
|  |             return new ImpostorShapelessRecipe( id, s, itemStack, ingredients ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         private DefaultedList<Ingredient> readIngredients( JsonArray arrays ) |         private DefaultedList<Ingredient> readIngredients( JsonArray arrays ) | ||||||
|   | |||||||
| @@ -8,11 +8,11 @@ package dan200.computercraft.shared.util; | |||||||
|  |  | ||||||
| import com.google.common.collect.Maps; | import com.google.common.collect.Maps; | ||||||
| import com.google.common.collect.Sets; | import com.google.common.collect.Sets; | ||||||
| import com.google.gson.JsonArray; | import com.google.gson.*; | ||||||
| import com.google.gson.JsonElement; | import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||||||
| import com.google.gson.JsonObject; |  | ||||||
| import com.google.gson.JsonSyntaxException; |  | ||||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||||
|  | import net.minecraft.item.ItemStack; | ||||||
|  | import net.minecraft.nbt.NbtHelper; | ||||||
| import net.minecraft.recipe.Ingredient; | import net.minecraft.recipe.Ingredient; | ||||||
| import net.minecraft.util.JsonHelper; | import net.minecraft.util.JsonHelper; | ||||||
| import net.minecraft.util.collection.DefaultedList; | import net.minecraft.util.collection.DefaultedList; | ||||||
| @@ -24,6 +24,7 @@ import java.util.Set; | |||||||
|  |  | ||||||
| public final class RecipeUtil | public final class RecipeUtil | ||||||
| { | { | ||||||
|  |     private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); | ||||||
|     private RecipeUtil() {} |     private RecipeUtil() {} | ||||||
|  |  | ||||||
|     public static ShapedTemplate getTemplate( JsonObject json ) |     public static ShapedTemplate getTemplate( JsonObject json ) | ||||||
| @@ -111,6 +112,22 @@ public final class RecipeUtil | |||||||
|         throw new JsonSyntaxException( "Unknown computer family '" + familyName + "' for field " + name ); |         throw new JsonSyntaxException( "Unknown computer family '" + familyName + "' for field " + name ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public static void setNbt( ItemStack itemStack, JsonObject result ) | ||||||
|  |     { | ||||||
|  |         JsonElement nbtElement = result.get( "nbt" ); | ||||||
|  |         if ( nbtElement != null ) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 itemStack.setNbt( NbtHelper.method_32260( nbtElement.isJsonObject() ? GSON.toJson( nbtElement ) : nbtElement.getAsString() ) ); | ||||||
|  |             } | ||||||
|  |             catch( CommandSyntaxException e ) | ||||||
|  |             { | ||||||
|  |                 throw new JsonSyntaxException( "Invalid NBT entry: " + e.getMessage() ); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public static class ShapedTemplate |     public static class ShapedTemplate | ||||||
|     { |     { | ||||||
|         public final int width; |         public final int width; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Nikita Savyolov
					Nikita Savyolov