diff --git a/README.md b/README.md index aae1d7e..87b0032 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Fix CreateFabric Recipe display on REI issues. Code from [Create's Delight Fabri ## Code references - Create's Delight (Fabric 1.19.x) [MIT([`fabric.mod.json`](https://github.com/Phoupraw/CreateSDelightFabricJava/blob/e203b6a14d272013463cdfde49512a9ea13f5769/src/main/resources/fabric.mod.json#L18)), CC0([`LICENSE`](https://github.com/Phoupraw/CreateSDelightFabricJava/blob/master/LICENSE))] -- Phoupraw's Common (Fabric) (Decompiled `REICreates.java`) [MIT(`fabric.mod.json`), CC0(`LICENSE`)] +- Phoupraw's Common (Fabric) (Decompiled `REICreates.java`) [MIT(`fabric.mod.json`), CC0(`LICENSE`)] (0.1.1 and below) ## License diff --git a/build.gradle b/build.gradle index cd96696..01dfe63 100644 --- a/build.gradle +++ b/build.gradle @@ -5,6 +5,8 @@ plugins { id 'maven-publish' } +sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 + version = project.mod_version group = project.maven_group archivesBaseName = project.archives_base_name @@ -12,12 +14,12 @@ archivesBaseName = project.archives_base_name repositories { mavenLocal() mavenCentral() - maven { url = "https://mvn.devos.one/snapshots/" }// Create, Porting Lib, Forge Tags, Milk Lib, Registrate + maven { url = "https://mvn.devos.one/snapshots/" } // Create, Porting Lib, Forge Tags, Milk Lib, Registrate maven { url = "https://api.modrinth.com/maven" } - maven { url = "https://maven.tterrag.com/" }// Flywheel - maven { url = "https://maven.shedaniel.me/" }// Cloth Config, REI - maven { url = "https://jitpack.io/" }// Mixin Extras, Fabric ASM - maven { url = "https://maven.jamieswhiteshirt.com/libs-release" }// Reach Entity Attributes + maven { url = "https://maven.tterrag.com/" } // Flywheel + maven { url = "https://maven.shedaniel.me/" } // Cloth Config, REI + maven { url = "https://jitpack.io/" } // Mixin Extras, Fabric ASM + maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes } dependencies { @@ -32,11 +34,6 @@ dependencies { modImplementation "io.github.fabricators_of_create:Porting-Lib:${portinglib_version}" modLocalRuntime "maven.modrinth:forge-config-api-port:${forgeconfigapiport_version}" modImplementation "me.shedaniel:RoughlyEnoughItems-fabric:${rei_version}" - //modImplementation fileTree(dir: 'libs', include: ['*.jar']) -} - -base { - } processResources { @@ -48,18 +45,11 @@ processResources { } tasks.withType(JavaCompile).configureEach { - // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. it.options.release = 17 } java { - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. withSourcesJar() - - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 } jar { diff --git a/gradle.properties b/gradle.properties index 0164670..381d52a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ org.gradle.parallel=true loader_version=0.14.17 # Mod Properties - mod_version=0.1.1-mc1.18.x + mod_version=0.1.2-mc1.18.x maven_group=ho.artisan.createreibugfix archives_base_name=CreateFabricREIBugFix @@ -17,7 +17,6 @@ org.gradle.parallel=true fabric_version=0.76.0+1.18.2 rei_version=8.3.594 - farmersdelight_version=1.2.5 forgeconfigapiport_version=3.2.4 create_version=0.5.0.i-983+1.18.2 portinglib_version=1.2.869-beta+1.18.2 diff --git a/src/main/java/ho/artisan/createreibugfix/api/REICreates.java b/src/main/java/ho/artisan/createreibugfix/api/REICreates.java index 2d6924e..209e27e 100644 --- a/src/main/java/ho/artisan/createreibugfix/api/REICreates.java +++ b/src/main/java/ho/artisan/createreibugfix/api/REICreates.java @@ -1,5 +1,5 @@ /* - * This file is licensed under the MIT License, part of Phoupraw's Common. + * This file is licensed under the MIT License, part of Create's Delight. * Copyright (c) 2021~2023 Phoupraw * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -30,12 +30,7 @@ import com.simibubi.create.foundation.fluid.FluidIngredient; import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.utility.Pair; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import io.github.fabricators_of_create.porting_lib.util.FluidStack; +import dev.architectury.fluid.FluidStack; import me.shedaniel.math.Point; import me.shedaniel.rei.api.client.gui.widgets.Slot; import me.shedaniel.rei.api.client.gui.widgets.Widgets; @@ -46,84 +41,135 @@ import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; +import net.minecraft.recipe.Recipe; import net.minecraft.util.collection.DefaultedList; import org.apache.commons.lang3.mutable.MutableInt; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +/** + 和机械动力有关的REI工具方法。 + @since 1.0.0 + @author Phoupraw + */ public final class REICreates { + /** + @see CreateRecipeCategory#convertToREIFluids(List) + @since 1.0.0 + @author Phoupraw + */ @Contract(pure = true) public static EntryIngredient ingredientOf(@NotNull FluidIngredient fluidIngredient) { return EntryIngredients.of(VanillaEntryTypes.FLUID, CreateRecipeCategory.convertToREIFluids(fluidIngredient.getMatchingFluidStacks())); } + /** + @return 包含物品原料和流体原料的列表 + @see EntryIngredients#ofIngredients(List) + @see #ingredientOf(FluidIngredient) + @see Recipe#getIngredients() + @see ProcessingRecipe#getFluidIngredients() + @since 1.0.0 + @author Phoupraw + */ @Contract(pure = true) - @NotNull - public static List ingredientsOf(@NotNull ProcessingRecipe recipe) { + public static @NotNull List ingredientsOf(@NotNull ProcessingRecipe recipe) { return ingredientsOf(recipe.getIngredients(), recipe.getFluidIngredients()); } + /** + @since 1.0.0 + @author Phoupraw + */ @Contract(pure = true) - @NotNull - public static List ingredientsOf(@NotNull SequencedRecipe recipe0) { - ProcessingRecipe recipe = recipe0.getRecipe(); + public static @NotNull List ingredientsOf(@NotNull SequencedRecipe recipe0) { + var recipe = recipe0.getRecipe(); DefaultedList ingredients = DefaultedList.of(); ingredients.addAll(recipe.getIngredients()); ingredients.remove(0); return ingredientsOf(ingredients, recipe.getFluidIngredients()); } + /** + @since 1.0.0 + @author Phoupraw + */ @Contract(pure = true) - @NotNull - public static List ingredientsOf(@NotNull DefaultedList ingredients, @NotNull DefaultedList fluidIngredients) { + public static @NotNull List ingredientsOf(@NotNull DefaultedList ingredients, @NotNull DefaultedList fluidIngredients) { List list = new LinkedList<>(); for (Pair condensed : ItemHelper.condenseIngredients(ingredients)) { Collection items = new LinkedList<>(); - for (ItemStack matchingStack : (condensed.getFirst()).getMatchingStacks()) { + for (ItemStack matchingStack : condensed.getFirst().getMatchingStacks()) { items.add(matchingStack.getItem()); } - list.add(EntryIngredients.ofItems(items, (condensed.getSecond()).getValue())); + list.add(EntryIngredients.ofItems(items, condensed.getSecond().getValue())); } - Iterator it = fluidIngredients.iterator(); - while (it.hasNext()) { - list.add(ingredientOf(it.next())); + for (FluidIngredient fluidIngredient : fluidIngredients) { + list.add(ingredientOf(fluidIngredient)); } return list; } + /** + @return 包含 {@link ProcessingRecipe#getRollableResults()}和{@link ProcessingRecipe#getFluidResults()}。 + @see EntryIngredients#of(ItemStack) + @see EntryIngredients#of(FluidStack) + @since 1.0.0 + @author Phoupraw + */ @Contract(pure = true) - @NotNull - public static List resultsOf(@NotNull ProcessingRecipe recipe) { + public static @NotNull List resultsOf(@NotNull ProcessingRecipe recipe) { return resultsOf(recipe.getRollableResults(), recipe.getFluidResults()); } + /** + @since 1.0.0 + @author Phoupraw + */ @Contract(pure = true) - @NotNull - public static List resultsOf(@NotNull SequencedRecipe recipe0) { - ProcessingRecipe recipe = recipe0.getRecipe(); - LinkedList rollableResults = new LinkedList<>(recipe.getRollableResults()); + public static @NotNull List resultsOf(@NotNull SequencedRecipe recipe0) { + var recipe = recipe0.getRecipe(); + var rollableResults = new LinkedList<>(recipe.getRollableResults()); rollableResults.remove(0); return resultsOf(rollableResults, recipe.getFluidResults()); } + /** + @since 1.0.0 + @author Phoupraw + */ @Contract(pure = true) - @NotNull - public static List resultsOf(@NotNull List rollableResults, @NotNull DefaultedList fluidResults) { + public static @NotNull List resultsOf(@NotNull List rollableResults, @NotNull DefaultedList fluidResults) { List list = new LinkedList<>(); for (ProcessingOutput rollableResult : rollableResults) { list.add(EntryIngredients.of(rollableResult.getStack().copy())); } - Iterator it = fluidResults.iterator(); - while (it.hasNext()) { - FluidStack fluidResult = it.next(); - list.add(EntryIngredients.of(dev.architectury.fluid.FluidStack.create(fluidResult.getFluid(), fluidResult.getAmount(), fluidResult.getTag()))); + for (io.github.fabricators_of_create.porting_lib.util.FluidStack fluidResult : fluidResults) { + list.add(EntryIngredients.of(FluidStack.create(fluidResult.getFluid(), fluidResult.getAmount(), fluidResult.getTag()))); } return list; } + /** + 如果是流体: +
    +
  • 如果不满一桶,则不会渲染完整一格,而是根据数量减少流体格高度,见{@link CreateRecipeCategory#setFluidRenderRatio}。 +
  • 工具提示中以mB为单位,见{@link CreateRecipeCategory#setFluidTooltip}。 +
+ 如果是物品:与{@link Widgets#createSlot(Point)}完全相同。 + @param pos {@link Widgets#createSlot(Point)}的参数 + @param entries 可以为{@link EntryIngredient}。 + @see #ingredientsOf + @see #resultsOf + @since 1.0.0 + @author Phoupraw + */ public static Slot slotOf(Point pos, Collection> entries) { - Slot slot = Widgets.createSlot(pos).entries(entries); - if (entries.iterator().next().getValue() instanceof dev.architectury.fluid.FluidStack) { + var slot = Widgets.createSlot(pos).entries(entries); + if (entries.iterator().next().getValue() instanceof FluidStack) { CreateRecipeCategory.setFluidRenderRatio(slot); CreateRecipeCategory.setFluidTooltip(slot); } @@ -131,5 +177,6 @@ public static Slot slotOf(Point pos, Collection> entries) { } private REICreates() { + } -} +} \ No newline at end of file