Fixes #1836
This commit is contained in:
parent
9075f320d4
commit
0b39eb9863
1 changed files with 29 additions and 2 deletions
|
@ -24,16 +24,21 @@
|
||||||
|
|
||||||
package techreborn.api.recipe.recipes;
|
package techreborn.api.recipe.recipes;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import net.minecraft.inventory.CraftingInventory;
|
import net.minecraft.inventory.CraftingInventory;
|
||||||
import net.minecraft.inventory.Inventory;
|
import net.minecraft.inventory.Inventory;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.recipe.Ingredient;
|
import net.minecraft.recipe.Ingredient;
|
||||||
import net.minecraft.recipe.RecipeSerializer;
|
import net.minecraft.recipe.RecipeSerializer;
|
||||||
import net.minecraft.recipe.ShapedRecipe;
|
import net.minecraft.recipe.ShapedRecipe;
|
||||||
|
import net.minecraft.tag.ItemTags;
|
||||||
|
import net.minecraft.tag.Tag;
|
||||||
import net.minecraft.util.DefaultedList;
|
import net.minecraft.util.DefaultedList;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.JsonHelper;
|
import net.minecraft.util.JsonHelper;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.common.crafting.RebornRecipe;
|
import reborncore.common.crafting.RebornRecipe;
|
||||||
import reborncore.common.crafting.RebornRecipeType;
|
import reborncore.common.crafting.RebornRecipeType;
|
||||||
|
@ -53,8 +58,9 @@ public class RollingMachineRecipe extends RebornRecipe {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserialize(JsonObject jsonObject) {
|
public void deserialize(JsonObject jsonObject) {
|
||||||
shaped = JsonHelper.getObject(jsonObject, "shaped");
|
JsonObject json = JsonHelper.getObject(jsonObject, "shaped");
|
||||||
shapedRecipe = RecipeSerializer.SHAPED.read(getId(), shaped);
|
shapedRecipe = RecipeSerializer.SHAPED.read(getId(), json);
|
||||||
|
shaped = withoutTags(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,6 +68,27 @@ public class RollingMachineRecipe extends RebornRecipe {
|
||||||
jsonObject.add("shaped", shaped);
|
jsonObject.add("shaped", shaped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//This needs to be done to remove the item tags, and replace them with just items for when syncing to the server
|
||||||
|
private JsonObject withoutTags(JsonObject jsonObject) {
|
||||||
|
JsonObject key = jsonObject.get("key").getAsJsonObject();
|
||||||
|
key.entrySet().forEach(entry -> {
|
||||||
|
if(entry.getValue().isJsonObject()){
|
||||||
|
JsonObject value = entry.getValue().getAsJsonObject();
|
||||||
|
if(value.has("tag")){
|
||||||
|
|
||||||
|
Identifier tag = new Identifier(value.get("tag").getAsString());
|
||||||
|
Tag<Item> itemTag = ItemTags.getContainer().get(tag);
|
||||||
|
Item item = Iterables.get(itemTag.values(), 0);
|
||||||
|
|
||||||
|
//Remove the tag, and replace it with a basic s
|
||||||
|
value.remove("tag");
|
||||||
|
value.addProperty("item", Registry.ITEM.getId(item).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DefaultedList<RebornIngredient> getRebornIngredients() {
|
public DefaultedList<RebornIngredient> getRebornIngredients() {
|
||||||
return DefaultedList.of();
|
return DefaultedList.of();
|
||||||
|
|
Loading…
Add table
Reference in a new issue