use of com.simibubi.create.foundation.fluid.FluidIngredient in project Create by Creators-of-Create.
the class BasinCategory method setRecipe.
@Override
public void setRecipe(IRecipeLayout recipeLayout, BasinRecipe recipe, IIngredients iingredients) {
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
NonNullList<FluidIngredient> fluidIngredients = recipe.getFluidIngredients();
List<Pair<Ingredient, MutableInt>> ingredients = ItemHelper.condenseIngredients(recipe.getIngredients());
List<ItemStack> itemOutputs = recipe.getRollableResultsAsItemStacks();
NonNullList<FluidStack> fluidOutputs = recipe.getFluidResults();
int size = ingredients.size() + fluidIngredients.size();
int xOffset = size < 3 ? (3 - size) * 19 / 2 : 0;
int yOffset = 0;
int i;
for (i = 0; i < ingredients.size(); i++) {
itemStacks.init(i, true, 16 + xOffset + (i % 3) * 19, 50 - (i / 3) * 19 + yOffset);
List<ItemStack> stacks = new ArrayList<>();
Pair<Ingredient, MutableInt> pair = ingredients.get(i);
Ingredient ingredient = pair.getFirst();
MutableInt amount = pair.getSecond();
for (ItemStack itemStack : ingredient.getItems()) {
ItemStack stack = itemStack.copy();
stack.setCount(amount.getValue());
stacks.add(stack);
}
itemStacks.set(i, stacks);
}
int j;
for (j = 0; j < fluidIngredients.size(); j++) {
int i2 = i + j;
fluidStacks.init(j, true, 17 + xOffset + (i2 % 3) * 19, 51 - (i2 / 3) * 19 + yOffset);
List<FluidStack> stacks = fluidIngredients.get(j).getMatchingFluidStacks();
fluidStacks.set(j, withImprovedVisibility(stacks));
}
int outSize = fluidOutputs.size() + recipe.getRollableResults().size();
int outputIndex = 0;
if (!itemOutputs.isEmpty())
addStochasticTooltip(itemStacks, recipe.getRollableResults(), i);
for (; outputIndex < outSize; outputIndex++) {
int xPosition = 141 - (outSize % 2 != 0 && outputIndex == outSize - 1 ? 0 : outputIndex % 2 == 0 ? 10 : -9);
int yPosition = -19 * (outputIndex / 2) + 50 + yOffset;
if (itemOutputs.size() > outputIndex) {
itemStacks.init(i, false, xPosition, yPosition + yOffset);
itemStacks.set(i, itemOutputs.get(outputIndex));
i++;
} else {
fluidStacks.init(j, false, xPosition + 1, yPosition + 1 + yOffset);
fluidStacks.set(j, withImprovedVisibility(fluidOutputs.get(outputIndex - itemOutputs.size())));
j++;
}
}
addFluidTooltip(fluidStacks, fluidIngredients, fluidOutputs);
HeatCondition requiredHeat = recipe.getRequiredHeat();
if (!requiredHeat.testBlazeBurner(HeatLevel.NONE)) {
itemStacks.init(i, true, 133, 80);
itemStacks.set(i, AllBlocks.BLAZE_BURNER.asStack());
i++;
}
if (!requiredHeat.testBlazeBurner(HeatLevel.KINDLED)) {
itemStacks.init(i, true, 152, 80);
itemStacks.set(i, AllItems.BLAZE_CAKE.asStack());
i++;
}
}
use of com.simibubi.create.foundation.fluid.FluidIngredient in project Create by Creators-of-Create.
the class SpoutCategory method setRecipe.
@Override
public void setRecipe(IRecipeLayout recipeLayout, FillingRecipe recipe, IIngredients ingredients) {
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
FluidIngredient fluidIngredient = recipe.getRequiredFluid();
List<ItemStack> matchingIngredients = Arrays.asList(recipe.getIngredients().get(0).getItems());
fluidStacks.init(0, true, 27, 32);
fluidStacks.set(0, withImprovedVisibility(fluidIngredient.getMatchingFluidStacks()));
itemStacks.init(0, true, 26, 50);
itemStacks.set(0, matchingIngredients);
itemStacks.init(1, false, 131, 50);
itemStacks.set(1, recipe.getResultItem());
addFluidTooltip(fluidStacks, ImmutableList.of(fluidIngredient), Collections.emptyList());
}
use of com.simibubi.create.foundation.fluid.FluidIngredient in project Create by Creators-of-Create.
the class ProcessingRecipeSerializer method readFromJson.
protected T readFromJson(ResourceLocation recipeId, JsonObject json) {
ProcessingRecipeBuilder<T> builder = new ProcessingRecipeBuilder<>(factory, recipeId);
NonNullList<Ingredient> ingredients = NonNullList.create();
NonNullList<FluidIngredient> fluidIngredients = NonNullList.create();
NonNullList<ProcessingOutput> results = NonNullList.create();
NonNullList<FluidStack> fluidResults = NonNullList.create();
for (JsonElement je : GsonHelper.getAsJsonArray(json, "ingredients")) {
if (FluidIngredient.isFluidIngredient(je))
fluidIngredients.add(FluidIngredient.deserialize(je));
else
ingredients.add(Ingredient.fromJson(je));
}
for (JsonElement je : GsonHelper.getAsJsonArray(json, "results")) {
JsonObject jsonObject = je.getAsJsonObject();
if (GsonHelper.isValidNode(jsonObject, "fluid"))
fluidResults.add(FluidHelper.deserializeFluidStack(jsonObject));
else
results.add(ProcessingOutput.deserialize(je));
}
builder.withItemIngredients(ingredients).withItemOutputs(results).withFluidIngredients(fluidIngredients).withFluidOutputs(fluidResults);
if (GsonHelper.isValidNode(json, "processingTime"))
builder.duration(GsonHelper.getAsInt(json, "processingTime"));
if (GsonHelper.isValidNode(json, "heatRequirement"))
builder.requiresHeat(HeatCondition.deserialize(GsonHelper.getAsString(json, "heatRequirement")));
T recipe = builder.build();
recipe.readAdditional(json);
return recipe;
}
use of com.simibubi.create.foundation.fluid.FluidIngredient in project Create by Creators-of-Create.
the class FillingBySpout method fillItem.
public static ItemStack fillItem(Level world, int requiredAmount, ItemStack stack, FluidStack availableFluid) {
FluidStack toFill = availableFluid.copy();
toFill.setAmount(requiredAmount);
wrapper.setItem(0, stack);
FillingRecipe fillingRecipe = SequencedAssemblyRecipe.getRecipe(world, wrapper, AllRecipeTypes.FILLING.getType(), FillingRecipe.class).filter(fr -> fr.getRequiredFluid().test(toFill)).orElseGet(() -> {
for (Recipe<RecipeWrapper> recipe : world.getRecipeManager().getRecipesFor(AllRecipeTypes.FILLING.getType(), wrapper, world)) {
FillingRecipe fr = (FillingRecipe) recipe;
FluidIngredient requiredFluid = fr.getRequiredFluid();
if (requiredFluid.test(toFill))
return fr;
}
return null;
});
if (fillingRecipe != null) {
List<ItemStack> results = fillingRecipe.rollResults();
availableFluid.shrink(requiredAmount);
stack.shrink(1);
return results.isEmpty() ? ItemStack.EMPTY : results.get(0);
}
return GenericItemFilling.fillItem(world, requiredAmount, stack, availableFluid);
}
use of com.simibubi.create.foundation.fluid.FluidIngredient in project Create by Creators-of-Create.
the class FillingBySpout method getRequiredAmountForItem.
public static int getRequiredAmountForItem(Level world, ItemStack stack, FluidStack availableFluid) {
wrapper.setItem(0, stack);
Optional<FillingRecipe> assemblyRecipe = SequencedAssemblyRecipe.getRecipe(world, wrapper, AllRecipeTypes.FILLING.getType(), FillingRecipe.class);
if (assemblyRecipe.isPresent()) {
FluidIngredient requiredFluid = assemblyRecipe.get().getRequiredFluid();
if (requiredFluid.test(availableFluid))
return requiredFluid.getRequiredAmount();
}
for (Recipe<RecipeWrapper> recipe : world.getRecipeManager().getRecipesFor(AllRecipeTypes.FILLING.getType(), wrapper, world)) {
FillingRecipe fillingRecipe = (FillingRecipe) recipe;
FluidIngredient requiredFluid = fillingRecipe.getRequiredFluid();
if (requiredFluid.test(availableFluid))
return requiredFluid.getRequiredAmount();
}
return GenericItemFilling.getRequiredAmountForItem(world, stack, availableFluid);
}
Aggregations