use of com.simibubi.create.content.contraptions.processing.ProcessingRecipe in project Create by Creators-of-Create.
the class SequencedRecipe method fromJson.
public static SequencedRecipe<?> fromJson(JsonObject json, SequencedAssemblyRecipe parent, int index) {
ResourceLocation parentId = parent.getId();
Recipe<?> recipe = RecipeManager.fromJson(new ResourceLocation(parentId.getNamespace(), parentId.getPath() + "_step_" + index), json);
if (recipe instanceof ProcessingRecipe<?> && recipe instanceof IAssemblyRecipe) {
ProcessingRecipe<?> processingRecipe = (ProcessingRecipe<?>) recipe;
IAssemblyRecipe assemblyRecipe = (IAssemblyRecipe) recipe;
if (assemblyRecipe.supportsAssembly()) {
Ingredient transit = Ingredient.of(parent.getTransitionalItem());
processingRecipe.getIngredients().set(0, index == 0 ? Ingredient.merge(ImmutableList.of(transit, parent.getIngredient())) : transit);
SequencedRecipe<?> sequencedRecipe = new SequencedRecipe<>(processingRecipe);
return sequencedRecipe;
}
}
throw new JsonParseException("Not a supported recipe type");
}
use of com.simibubi.create.content.contraptions.processing.ProcessingRecipe in project Create by Creators-of-Create.
the class CrushingWheelControllerTileEntity method applyRecipe.
private void applyRecipe() {
Optional<ProcessingRecipe<RecipeWrapper>> recipe = findRecipe();
List<ItemStack> list = new ArrayList<>();
if (recipe.isPresent()) {
int rolls = inventory.getStackInSlot(0).getCount();
inventory.clear();
for (int roll = 0; roll < rolls; roll++) {
List<ItemStack> rolledResults = recipe.get().rollResults();
for (int i = 0; i < rolledResults.size(); i++) {
ItemStack stack = rolledResults.get(i);
ItemHelper.addToList(stack, list);
}
}
for (int slot = 0; slot < list.size() && slot + 1 < inventory.getSlots(); slot++) inventory.setStackInSlot(slot + 1, list.get(slot));
} else {
inventory.clear();
}
}
use of com.simibubi.create.content.contraptions.processing.ProcessingRecipe in project Create by Creators-of-Create.
the class CreateRecipeCategory method getRenderedSlot.
public static AllGuiTextures getRenderedSlot(Recipe<?> recipe, int index) {
AllGuiTextures jeiSlot = AllGuiTextures.JEI_SLOT;
if (!(recipe instanceof ProcessingRecipe))
return jeiSlot;
ProcessingRecipe<?> processingRecipe = (ProcessingRecipe<?>) recipe;
List<ProcessingOutput> rollableResults = processingRecipe.getRollableResults();
if (rollableResults.size() <= index)
return jeiSlot;
if (processingRecipe.getRollableResults().get(index).getChance() == 1)
return jeiSlot;
return AllGuiTextures.JEI_CHANCE_SLOT;
}
use of com.simibubi.create.content.contraptions.processing.ProcessingRecipe in project Create by Creators-of-Create.
the class ProcessingRecipeGen method create.
/**
* Create a processing recipe with a single itemstack ingredient, using its id
* as the name of the recipe
*/
protected <T extends ProcessingRecipe<?>> GeneratedRecipe create(String namespace, Supplier<ItemLike> singleIngredient, UnaryOperator<ProcessingRecipeBuilder<T>> transform) {
ProcessingRecipeSerializer<T> serializer = getSerializer();
GeneratedRecipe generatedRecipe = c -> {
ItemLike iItemProvider = singleIngredient.get();
transform.apply(new ProcessingRecipeBuilder<>(serializer.getFactory(), new ResourceLocation(namespace, iItemProvider.asItem().getRegistryName().getPath())).withItemIngredients(Ingredient.of(iItemProvider))).build(c);
};
all.add(generatedRecipe);
return generatedRecipe;
}
use of com.simibubi.create.content.contraptions.processing.ProcessingRecipe in project Create by Creators-of-Create.
the class SequencedRecipe method readFromBuffer.
public static SequencedRecipe<?> readFromBuffer(FriendlyByteBuf buffer) {
ResourceLocation resourcelocation = buffer.readResourceLocation();
ResourceLocation resourcelocation1 = buffer.readResourceLocation();
RecipeSerializer<?> serializer = ForgeRegistries.RECIPE_SERIALIZERS.getValue(resourcelocation);
if (!(serializer instanceof ProcessingRecipeSerializer))
throw new JsonParseException("Not a supported recipe type");
@SuppressWarnings("rawtypes") ProcessingRecipe recipe = (ProcessingRecipe) serializer.fromNetwork(resourcelocation1, buffer);
return new SequencedRecipe<>(recipe);
}
Aggregations