Skip to content

Commit

Permalink
Changed data structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Jan 28, 2024
1 parent 735e75e commit 922b98c
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import org.jetbrains.annotations.Nullable;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.mojang.datafixers.util.Pair;
import mods.railcraft.api.core.RailcraftConstants;
import mods.railcraft.api.core.RecipeJsonKeys;
import mods.railcraft.world.item.crafting.RailcraftRecipeSerializers;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Tuple;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
Expand All @@ -26,7 +26,7 @@ public class CrusherRecipeBuilder {
private static final int MAX_SLOTS = 9;

private final Ingredient ingredient;
private final List<Tuple<ItemStack, Double>> probabilityItems;
private final List<Pair<ItemStack, Double>> probabilityItems;
private final int processTime;

private CrusherRecipeBuilder(Ingredient ingredient, int processTime) {
Expand Down Expand Up @@ -54,7 +54,7 @@ public CrusherRecipeBuilder addResult(ItemLike item, int quantity, double probab
}

var itemStack = new ItemStack(item, quantity);
probabilityItems.add(new Tuple<>(itemStack, probability));
probabilityItems.add(new Pair<>(itemStack, probability));
return this;
}

Expand All @@ -78,11 +78,11 @@ private static class Result implements FinishedRecipe {

private final ResourceLocation id;
private final Ingredient ingredient;
private final List<Tuple<ItemStack, Double>> probabilityItems;
private final List<Pair<ItemStack, Double>> probabilityItems;
private final int processTime;

public Result(ResourceLocation resourceLocation, Ingredient ingredient,
List<Tuple<ItemStack, Double>> probabilityItems,
List<Pair<ItemStack, Double>> probabilityItems,
int processTime) {
this.id = resourceLocation;
this.ingredient = ingredient;
Expand All @@ -100,10 +100,10 @@ public void serializeRecipeData(JsonObject jsonOut) {

var itemStackObject = new JsonObject();
itemStackObject.addProperty(RecipeJsonKeys.ITEM,
ForgeRegistries.ITEMS.getKey(item.getA().getItem()).toString());
itemStackObject.addProperty(RecipeJsonKeys.COUNT, item.getA().getCount());
ForgeRegistries.ITEMS.getKey(item.getFirst().getItem()).toString());
itemStackObject.addProperty(RecipeJsonKeys.COUNT, item.getFirst().getCount());
pattern.add(RecipeJsonKeys.RESULT, itemStackObject);
pattern.addProperty(RecipeJsonKeys.PROBABILITY, item.getB());
pattern.addProperty(RecipeJsonKeys.PROBABILITY, item.getSecond());
result.add(pattern);
}
jsonOut.add(RecipeJsonKeys.OUTPUTS, result);
Expand Down

0 comments on commit 922b98c

Please sign in to comment.