mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Re-added the recipes for trick apples
This commit is contained in:
parent
75dd84943c
commit
39939d5d7c
9 changed files with 143 additions and 0 deletions
|
@ -57,6 +57,7 @@ public interface UItems {
|
|||
|
||||
static void bootstrap() {
|
||||
Toxics.bootstrap();
|
||||
URecipes.bootstrap();
|
||||
|
||||
FabricItemGroupBuilder.create(new Identifier("unicopia", "items")).appendItems(list -> {
|
||||
list.addAll(VanillaOverrides.REGISTRY.stream().map(Item::getStackForRender).collect(Collectors.toList()));
|
||||
|
|
28
src/main/java/com/minelittlepony/unicopia/item/URecipes.java
Normal file
28
src/main/java/com/minelittlepony/unicopia/item/URecipes.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package com.minelittlepony.unicopia.item;
|
||||
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.recipe.ShapelessRecipe;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
public interface URecipes {
|
||||
|
||||
RecipeSerializer<ShapelessRecipe> ZAP_APPLE_SERIALIZER = register("crafting_zap_apple", new ZapAppleRecipe.Serializer());
|
||||
|
||||
static <T extends Recipe<?>> RecipeType<T> register(final String id) {
|
||||
return Registry.register(Registry.RECIPE_TYPE, new Identifier("unicopia", id), new RecipeType<T>() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static <S extends RecipeSerializer<T>, T extends Recipe<?>> S register(String id, S serializer) {
|
||||
return Registry.register(Registry.RECIPE_SERIALIZER, new Identifier("unicopia", id), serializer);
|
||||
}
|
||||
|
||||
static void bootstrap() {}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.minelittlepony.unicopia.item;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.ShapelessRecipe;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
|
||||
public class ZapAppleRecipe extends ShapelessRecipe {
|
||||
|
||||
public ZapAppleRecipe(Identifier id, String group, ItemStack output, DefaultedList<Ingredient> input) {
|
||||
super(id, group, output, input);
|
||||
}
|
||||
|
||||
public static class Serializer extends ShapelessRecipe.Serializer {
|
||||
@Override
|
||||
public ShapelessRecipe read(Identifier identifier, JsonObject json) {
|
||||
String group = JsonHelper.getString(json, "group", "");
|
||||
DefaultedList<Ingredient> ingredients = getIngredients(JsonHelper.getArray(json, "ingredients"));
|
||||
|
||||
if (ingredients.isEmpty()) {
|
||||
throw new JsonParseException("No ingredients for shapeless recipe");
|
||||
} else if (ingredients.size() > 9) {
|
||||
throw new JsonParseException("Too many ingredients for shapeless recipe");
|
||||
}
|
||||
|
||||
ItemStack stack = UItems.ZAP_APPLE.getStackForRender();
|
||||
stack.getOrCreateTag().putString("appearance", JsonHelper.getString(json, "appearance"));
|
||||
|
||||
return new ZapAppleRecipe(identifier, group, stack, ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShapelessRecipe read(Identifier identifier, PacketByteBuf input) {
|
||||
String group = input.readString(32767);
|
||||
|
||||
DefaultedList<Ingredient> ingredients = DefaultedList.ofSize(input.readVarInt(), Ingredient.EMPTY);
|
||||
|
||||
for(int j = 0; j < ingredients.size(); ++j) {
|
||||
ingredients.set(j, Ingredient.fromPacket(input));
|
||||
}
|
||||
|
||||
return new ZapAppleRecipe(identifier, group, input.readItemStack(), ingredients);
|
||||
}
|
||||
|
||||
private static DefaultedList<Ingredient> getIngredients(JsonArray json) {
|
||||
DefaultedList<Ingredient> defaultedList = DefaultedList.of();
|
||||
|
||||
for (int i = 0; i < json.size(); ++i) {
|
||||
Ingredient ingredient = Ingredient.fromJson(json.get(i));
|
||||
if (!ingredient.isEmpty()) {
|
||||
defaultedList.add(ingredient);
|
||||
}
|
||||
}
|
||||
|
||||
return defaultedList;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type": "smelting",
|
||||
"ingredient": {
|
||||
"item": "unicopia:zap_apple"
|
||||
},
|
||||
"result": "unicopia:cooked_zap_apple",
|
||||
"experience": 0.2,
|
||||
"cookingtime": 430
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"type": "unicopia:crafting_zap_apple",
|
||||
"ingredients": [
|
||||
{ "item": "unicopia:zap_apple" },
|
||||
{ "item": "minecraft:green_dye" }
|
||||
],
|
||||
"appearance": "unicopia:green_apple"
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"type": "unicopia:crafting_zap_apple",
|
||||
"ingredients": [
|
||||
{ "item": "unicopia:zap_apple" },
|
||||
{ "item": "minecraft:red_dye" }
|
||||
],
|
||||
"appearance": "minecraft:apple"
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"type": "unicopia:crafting_zap_apple",
|
||||
"ingredients": [
|
||||
{ "item": "unicopia:zap_apple" },
|
||||
{ "item": "minecraft:yellow_dye" }
|
||||
],
|
||||
"appearance": "unicopia:sour_apple"
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"type": "unicopia:crafting_zap_apple",
|
||||
"ingredients": [
|
||||
{ "item": "unicopia:zap_apple" },
|
||||
{ "item": "minecraft:orange_dye" }
|
||||
],
|
||||
"appearance": "unicopia:sweet_apple"
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"type": "unicopia:crafting_zap_apple",
|
||||
"ingredients": [
|
||||
{ "item": "unicopia:zap_apple" },
|
||||
{ "item": "minecraft:rotten_flesh" }
|
||||
],
|
||||
"appearance": "unicopia:cooked_zap_apple"
|
||||
}
|
Loading…
Reference in a new issue