-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SizedFluidIngredientComponent, attempted fixing mixin bug, fixe…
…d some recipe component bugs
- Loading branch information
1 parent
f0efecb
commit a32e2a7
Showing
13 changed files
with
119 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/java/dev/latvian/mods/kubejs/recipe/component/SizedFluidIngredientComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package dev.latvian.mods.kubejs.recipe.component; | ||
|
||
import com.mojang.serialization.Codec; | ||
import dev.latvian.mods.kubejs.fluid.FluidLike; | ||
import dev.latvian.mods.kubejs.fluid.FluidWrapper; | ||
import dev.latvian.mods.kubejs.recipe.KubeRecipe; | ||
import dev.latvian.mods.kubejs.recipe.RecipeKey; | ||
import dev.latvian.mods.kubejs.recipe.ReplacementMatch; | ||
import dev.latvian.mods.kubejs.recipe.schema.RecipeSchema; | ||
import dev.latvian.mods.rhino.Context; | ||
import dev.latvian.mods.rhino.type.TypeInfo; | ||
import net.minecraft.world.level.material.Fluid; | ||
import net.neoforged.neoforge.fluids.FluidStack; | ||
import net.neoforged.neoforge.fluids.crafting.FluidIngredient; | ||
import net.neoforged.neoforge.fluids.crafting.SizedFluidIngredient; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class SizedFluidIngredientComponent implements RecipeComponent<SizedFluidIngredient> { | ||
public static final SizedFluidIngredientComponent FLAT = new SizedFluidIngredientComponent("flat_sized_fluid_ingredient", SizedFluidIngredient.FLAT_CODEC); | ||
public static final SizedFluidIngredientComponent NESTED = new SizedFluidIngredientComponent("nested_sized_fluid_ingredient", SizedFluidIngredient.NESTED_CODEC); | ||
|
||
public final String name; | ||
public final Codec<SizedFluidIngredient> codec; | ||
|
||
public SizedFluidIngredientComponent(String name, Codec<SizedFluidIngredient> codec) { | ||
this.name = name; | ||
this.codec = codec; | ||
} | ||
|
||
@Override | ||
public Codec<SizedFluidIngredient> codec() { | ||
return codec; | ||
} | ||
|
||
@Override | ||
public TypeInfo typeInfo() { | ||
return FluidWrapper.SIZED_INGREDIENT_TYPE_INFO; | ||
} | ||
|
||
@Override | ||
public boolean hasPriority(Context cx, KubeRecipe recipe, Object from) { | ||
return from instanceof SizedFluidIngredient || from instanceof FluidIngredient || from instanceof FluidStack || from instanceof Fluid; | ||
} | ||
|
||
@Override | ||
public boolean matches(KubeRecipe recipe, SizedFluidIngredient value, ReplacementMatch match) { | ||
return match instanceof FluidLike m && m.contains((FluidLike) value.ingredient()); | ||
} | ||
|
||
@Override | ||
public String checkEmpty(RecipeKey<SizedFluidIngredient> key, SizedFluidIngredient value) { | ||
if (value.ingredient().isEmpty()) { | ||
return "SizedIngredient '" + key.name + "' can't be empty!"; | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public String createUniqueId(SizedFluidIngredient value) { | ||
return value == null || value.ingredient().isEmpty() || value.ingredient().hasNoFluids() ? null : RecipeSchema.normalizeId(value.ingredient().getStacks()[0].getFluid().kjs$getId()).replace('/', '_'); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package dev.latvian.mods.kubejs.util; | ||
|
||
// TODO: Remove | ||
public enum JSObjectType { | ||
ANY, | ||
MAP, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters