Skip to content

Commit

Permalink
1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
MelanX committed Jun 25, 2023
1 parent 3ea9230 commit 39b84a1
Show file tree
Hide file tree
Showing 29 changed files with 403 additions and 250 deletions.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Expand Up @@ -2,13 +2,13 @@ name: Bug Report
description: Report an issue with supported versions of RecipePrinter
labels: [ bug ]
body:
- type: input
- type: dropdown
id: mc-version
attributes:
label: Minecraft version
placeholder: eg. 1.18.2
validations:
required: true
options:
- 1.18.2
- 1.19.4
- type: input
id: libx-version
attributes:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -24,7 +24,7 @@ maven {
```
2. Add the following to your dependencies:
```groovy
runtimeOnly fg.deobf("io.github.noeppi_noeppi.mods:LibX:1.18.2-3.2.0")
runtimeOnly fg.deobf("org.moddingx:LibX:1.19-4.0.7")
runtimeOnly fg.deobf("de.melanx.recipeprinter:RecipePrinter:1.18.2-3.2+")
```
3. Start game.
Expand Down
16 changes: 6 additions & 10 deletions build.gradle
@@ -1,17 +1,13 @@
buildscript {
apply from: 'https://moddingx.github.io/ModUtils/v4/buildscript.gradle', to: buildscript
apply from: 'https://moddingx.github.io/ModUtils/v5/buildscript.gradle', to: buildscript
}

apply from: 'https://moddingx.github.io/ModUtils/v4/mod.gradle'
apply from: 'https://moddingx.github.io/ModUtils/v5/mod.gradle'
apply plugin: 'org.moddingx.modgradle.cursedep'

repositories {
maven {
name = "JEI"
url = "https://dvs1.progwml6.com/files/maven/"
}
maven {
name = "botania"
name = "BlameJared"
url = "https://maven.blamejared.com/"
}
maven {
Expand All @@ -25,8 +21,8 @@ repositories {
}

dependencies {
annotationProcessor fg.deobf("org.moddingx:LibX:1.19-4.0.7")
annotationProcessor fg.deobf("org.moddingx:LibX:1.19.4-4.4.11")

implementation fg.deobf("org.moddingx:LibX:1.19-4.0.7")
implementation fg.deobf("mezz.jei:jei-1.19-forge:11.0.2.230")
implementation fg.deobf("org.moddingx:LibX:1.19.4-4.4.11")
implementation fg.deobf("mezz.jei:jei-1.19.4-forge:13.1.0.15")
}
23 changes: 0 additions & 23 deletions gradle.properties
@@ -1,25 +1,2 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

# mod properties
modid=recipeprinter
group=de.melanx
base_version=4.0

# dependencies
forge_version=1.19.1-42.0.1
#mappings=sugarcane_2022.02.28-1.18.1

# Upload properties
upload_versions=1.19.1
upload_release=beta
modrinth_project=jCMrOyTG
modrinth_requirements=libx
curse_project=409823
curse_requirements=libx
curse_optionals=jei

# misc
local_maven=/var/www/maven
license_name=The Apache License, Version 2.0
license_url=https://www.apache.org/licenses/LICENSE-2.0.txt
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 12 additions & 7 deletions gradlew
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -143,12 +140,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
22 changes: 22 additions & 0 deletions mod.properties
@@ -0,0 +1,22 @@
# mod properties
modid=recipeprinter
group=de.melanx
base_version=4.0

# dependencies
forge_version=1.19.4-45.1.0
#mappings=sugarcane_2022.02.28-1.18.1

# Upload properties
upload_versions=1.19.4
upload_release=beta
upload_requirements=libx
upload_optionals=jei
curse_project=409823
modrinth_project=jCMrOyTG

# misc
local_maven=/var/www/maven
license=The Apache License, Version 2.0
license_url=https://www.apache.org/licenses/LICENSE-2.0.txt
changelog_repository=https://github.com/MelanX/RecipePrinter/commit/%H
2 changes: 1 addition & 1 deletion src/main/java/de/melanx/recipeprinter/RecipePrinter.java
Expand Up @@ -55,7 +55,7 @@ protected void setup(FMLCommonSetupEvent event) {
RecipeRenderers.registerRecipeRender(new BlastingRender());
RecipeRenderers.registerRecipeRender(new SmokingRender());
RecipeRenderers.registerRecipeRender(new CampfireRender());
RecipeRenderers.registerRecipeRender(new SmithingRender());
RecipeRenderers.registerRecipeRender(new SmithingTransformRender());
RecipeRenderers.registerRecipeRender(new StonecuttingRender());
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/de/melanx/recipeprinter/RecipeRenderers.java
@@ -1,6 +1,7 @@
package de.melanx.recipeprinter;

import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeType;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -9,6 +10,10 @@ public class RecipeRenderers {

private static final Map<Class<?>, IRecipeRender<?>> renders = new HashMap<>();

public static boolean isSupported(RecipeType<?> recipeType) {
return renders.values().stream().anyMatch(render -> render.getRecipeType() == recipeType);
}

public static void registerRecipeRender(IRecipeRender<?> render) {
renders.put(render.getRecipeClass(), render);
}
Expand Down
@@ -1,36 +1,40 @@
package de.melanx.recipeprinter.commands;

import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import de.melanx.recipeprinter.ModConfig;
import de.melanx.recipeprinter.RecipePrinter;
import de.melanx.recipeprinter.util.ImageHelper;
import de.melanx.recipeprinter.util.PrinterJob;
import de.melanx.recipeprinter.util.Util;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.ItemStack;
import org.moddingx.libx.render.target.ImageHelper;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class ItemCategoryCommand implements Command<CommandSourceStack> {

@Override
public int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ResourceLocation rl = context.getArgument("group", ResourceLocation.class);
CreativeModeTab group = Arrays.stream(CreativeModeTab.TABS).filter(g -> rl.getPath().equalsIgnoreCase(g.getRecipeFolderName())).findFirst().orElse(null);
String name = StringArgumentType.getString(context, "group");
CreativeModeTab group = CreativeModeTabs.allTabs().stream().filter(g -> g.getDisplayName().getString().equals(name)).findFirst().orElse(null);
if (group == null || !Util.isNormalItemCategory(group)) {
throw new SimpleCommandExceptionType(Component.literal("This ItemGroup does not exist.")).create();
}
NonNullList<ItemStack> stacks = NonNullList.create();
group.fillItemList(stacks);
stacks.addAll(group.getDisplayItems());

if (stacks.isEmpty()) {
throw new SimpleCommandExceptionType(Component.literal("This ItemGroup is empty")).create();
Expand All @@ -43,7 +47,7 @@ public int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxE
}
int effectiveFinalRows = rows;

Path path = context.getSource().getServer().getServerDirectory().toPath().resolve(RecipePrinter.getInstance().modid).resolve("item_groups").resolve(group.getRecipeFolderName().replace('/', '-') + ".png");
Path path = context.getSource().getServer().getServerDirectory().toPath().resolve(RecipePrinter.getInstance().modid).resolve("item_groups").resolve(group.getDisplayName().getString().replace('/', '-') + ".png");
if (!Files.exists(path.getParent())) {
try {
Files.createDirectories(path.getParent());
Expand All @@ -52,9 +56,17 @@ public int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxE
}
}

ImageHelper.addRenderJob(itemsPerRow * 18 + 8, rows * 18 + 24, ModConfig.scale, (poseStack, buffer) -> Util.renderItemCategory(poseStack, buffer, stacks, effectiveFinalRows, itemsPerRow, group), path);
CompletableFuture<NativeImage> img = ImageHelper.render(new PrinterJob(itemsPerRow * 18 + 8, rows * 18 + 24, ModConfig.scale, (poseStack, buffer) -> {
Util.renderItemCategory(poseStack, buffer, stacks, effectiveFinalRows, itemsPerRow, group);
}));

context.getSource().sendSuccess(Component.literal("Started rendering ItemGroup " + group.getRecipeFolderName()), true);
try {
img.get().writeToFile(path);
} catch (IOException | InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}

context.getSource().sendSuccess(Component.literal("Started rendering ItemGroup " + group.getDisplayName().getString()), true);

return 0;
}
Expand Down
41 changes: 29 additions & 12 deletions src/main/java/de/melanx/recipeprinter/commands/JeiCommand.java
@@ -1,31 +1,37 @@
package de.melanx.recipeprinter.commands;

import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.context.CommandContext;
import de.melanx.recipeprinter.ModConfig;
import de.melanx.recipeprinter.RecipePrinter;
import de.melanx.recipeprinter.jei.PrinterJEI;
import de.melanx.recipeprinter.util.ImageHelper;
import de.melanx.recipeprinter.util.PrinterJob;
import mezz.jei.api.gui.IRecipeLayoutDrawable;
import mezz.jei.api.ingredients.IIngredientType;
import mezz.jei.api.ingredients.ITypedIngredient;
import mezz.jei.api.recipe.category.IRecipeCategory;
import mezz.jei.api.runtime.IIngredientVisibility;
import mezz.jei.common.Internal;
import mezz.jei.common.focus.FocusGroup;
import mezz.jei.common.gui.recipes.layout.RecipeLayout;
import mezz.jei.library.focus.FocusGroup;
import mezz.jei.library.gui.recipes.RecipeLayout;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeManager;
import org.moddingx.libx.render.target.ImageHelper;

import javax.annotation.Nonnull;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;

import static de.melanx.recipeprinter.jei.PrinterJEI.REG;
Expand All @@ -43,6 +49,11 @@ public <V> boolean isIngredientVisible(@Nonnull IIngredientType<V> ingredientTyp
public <V> boolean isIngredientVisible(@Nonnull ITypedIngredient<V> typedIngredient) {
return true;
}

@Override
public void registerListener(@Nonnull IListener listener) {
// NO-OP
}
};

@Override
Expand Down Expand Up @@ -75,17 +86,23 @@ public int run(CommandContext<CommandSourceStack> context) {
}
}

RecipeLayout<?> layout;
Optional<IRecipeLayoutDrawable<Recipe<?>>> optLayout;
try {
//noinspection unchecked
layout = RecipeLayout.create(-1, (IRecipeCategory<Recipe<?>>) recipeCategory, iRecipe, FocusGroup.EMPTY, Internal.getRegisteredIngredients(), INGREDIENT_VISIBILITY, REG.getJeiHelpers().getModIdHelper(), 0, 0, PrinterJEI.TEXTURES);
if (layout != null) {
ImageHelper.addRenderJob(recipeCategory.getBackground().getWidth() + 8, recipeCategory.getBackground().getHeight() + 8, ModConfig.scale * 2., (poseStack, buffer) -> {
RecipePrinter.getInstance().logger.debug("Printing {} {} {}%", recipeCategory.getRecipeType().getUid(), iRecipe.getId(), Mth.floor(100. * i.getAndIncrement() / matches.get()));
poseStack.translate(4, 4, 0);
layout.drawRecipe(poseStack, -10, -10);
}, path);
}
optLayout = RecipeLayout.create((IRecipeCategory<Recipe<?>>) recipeCategory, iRecipe, FocusGroup.EMPTY, REG.getJeiHelpers().getIngredientManager(), INGREDIENT_VISIBILITY, REG.getJeiHelpers().getModIdHelper(), Internal.getTextures());
optLayout.ifPresent(layout -> {
CompletableFuture<NativeImage> img = ImageHelper.render(new PrinterJob(recipeCategory.getBackground().getWidth() + 8, recipeCategory.getBackground().getHeight() + 8, ModConfig.scale,
(poseStack, buffer) -> {
RecipePrinter.getInstance().logger.debug("Printing {} {} {}%", recipeCategory.getRecipeType().getUid(), iRecipe.getId(), Mth.floor(100. * i.getAndIncrement() / matches.get()));
poseStack.translate(4, 4, 0);
layout.drawRecipe(poseStack, -10, -10);
}));
try {
img.get().writeToFile(path);
} catch (InterruptedException | IOException | ExecutionException e) {
throw new RuntimeException(e);
}
});
} catch (Exception e) {
RecipePrinter.getInstance().logger.error("Could not print recipe {}: {}", iRecipe.getId(), e.getMessage());
}
Expand Down

0 comments on commit 39b84a1

Please sign in to comment.