Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
use source code
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Apr 10, 2023
1 parent f0eaea1 commit 901a78a
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 54 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 7 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ plugins {
id 'maven-publish'
}

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17

version = project.mod_version
group = project.maven_group
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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ 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

# Dependencies
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
115 changes: 81 additions & 34 deletions src/main/java/ho/artisan/createreibugfix/api/REICreates.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -46,90 +41,142 @@
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<EntryIngredient> ingredientsOf(@NotNull ProcessingRecipe<?> recipe) {
public static @NotNull List<EntryIngredient> ingredientsOf(@NotNull ProcessingRecipe<?> recipe) {
return ingredientsOf(recipe.getIngredients(), recipe.getFluidIngredients());
}

/**
@since 1.0.0
@author Phoupraw
*/
@Contract(pure = true)
@NotNull
public static List<EntryIngredient> ingredientsOf(@NotNull SequencedRecipe<?> recipe0) {
ProcessingRecipe<?> recipe = recipe0.getRecipe();
public static @NotNull List<EntryIngredient> ingredientsOf(@NotNull SequencedRecipe<?> recipe0) {
var recipe = recipe0.getRecipe();
DefaultedList<Ingredient> 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<EntryIngredient> ingredientsOf(@NotNull DefaultedList<Ingredient> ingredients, @NotNull DefaultedList<FluidIngredient> fluidIngredients) {
public static @NotNull List<EntryIngredient> ingredientsOf(@NotNull DefaultedList<Ingredient> ingredients, @NotNull DefaultedList<FluidIngredient> fluidIngredients) {
List<EntryIngredient> list = new LinkedList<>();
for (Pair<Ingredient, MutableInt> condensed : ItemHelper.condenseIngredients(ingredients)) {
Collection<ItemConvertible> 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<FluidIngredient> 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<EntryIngredient> resultsOf(@NotNull ProcessingRecipe<?> recipe) {
public static @NotNull List<EntryIngredient> resultsOf(@NotNull ProcessingRecipe<?> recipe) {
return resultsOf(recipe.getRollableResults(), recipe.getFluidResults());
}

/**
@since 1.0.0
@author Phoupraw
*/
@Contract(pure = true)
@NotNull
public static List<EntryIngredient> resultsOf(@NotNull SequencedRecipe<?> recipe0) {
ProcessingRecipe<?> recipe = recipe0.getRecipe();
LinkedList<ProcessingOutput> rollableResults = new LinkedList<>(recipe.getRollableResults());
public static @NotNull List<EntryIngredient> 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<EntryIngredient> resultsOf(@NotNull List<ProcessingOutput> rollableResults, @NotNull DefaultedList<FluidStack> fluidResults) {
public static @NotNull List<EntryIngredient> resultsOf(@NotNull List<ProcessingOutput> rollableResults, @NotNull DefaultedList<io.github.fabricators_of_create.porting_lib.util.FluidStack> fluidResults) {
List<EntryIngredient> list = new LinkedList<>();
for (ProcessingOutput rollableResult : rollableResults) {
list.add(EntryIngredients.of(rollableResult.getStack().copy()));
}
Iterator<FluidStack> 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;
}

/**
如果是流体:
<ul>
<li>如果不满一桶,则不会渲染完整一格,而是根据数量减少流体格高度,见{@link CreateRecipeCategory#setFluidRenderRatio}。
<li>工具提示中以mB为单位,见{@link CreateRecipeCategory#setFluidTooltip}。
</ul>
如果是物品:与{@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<EntryStack<?>> 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);
}
return slot;
}

private REICreates() {

}
}
}

0 comments on commit 901a78a

Please sign in to comment.