-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
381 additions
and
36 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/generated/resources/data/avaritia/advancements/recipes/misc/infinity_catalyst.json
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,35 @@ | ||
{ | ||
"parent": "minecraft:recipes/root", | ||
"criteria": { | ||
"has_item": { | ||
"conditions": { | ||
"items": [ | ||
{ | ||
"items": [ | ||
"avaritia:neutron_ingot" | ||
] | ||
} | ||
] | ||
}, | ||
"trigger": "minecraft:inventory_changed" | ||
}, | ||
"has_the_recipe": { | ||
"conditions": { | ||
"recipe": "avaritia:infinity_catalyst" | ||
}, | ||
"trigger": "minecraft:recipe_unlocked" | ||
} | ||
}, | ||
"requirements": [ | ||
[ | ||
"has_item", | ||
"has_the_recipe" | ||
] | ||
], | ||
"rewards": { | ||
"recipes": [ | ||
"avaritia:infinity_catalyst" | ||
] | ||
}, | ||
"sends_telemetry_event": true | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/generated/resources/data/avaritia/recipes/infinity_catalyst.json
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,30 @@ | ||
{ | ||
"type": "avaritia:infinity_catalyst_craft", | ||
"category": "misc", | ||
"ingredients": [ | ||
{ | ||
"item": "minecraft:emerald_block" | ||
}, | ||
{ | ||
"item": "avaritia:crystal_matrix_ingot" | ||
}, | ||
{ | ||
"item": "avaritia:neutron_ingot" | ||
}, | ||
{ | ||
"item": "avaritia:cosmic_meatballs" | ||
}, | ||
{ | ||
"item": "avaritia:ultimate_stew" | ||
}, | ||
{ | ||
"item": "avaritia:endest_pearl" | ||
}, | ||
{ | ||
"item": "avaritia:record_fragment" | ||
} | ||
], | ||
"result": { | ||
"item": "avaritia:infinity_catalyst" | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...on/crafting/recipe/ICompressorRecipe.java → ...pi/common/crafting/ICompressorRecipe.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
2 changes: 1 addition & 1 deletion
2
.../common/crafting/recipe/ICraftRecipe.java → ...tia/api/common/crafting/ICraftRecipe.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
2 changes: 1 addition & 1 deletion
2
...ommon/crafting/recipe/ISpecialRecipe.java → ...a/api/common/crafting/ISpecialRecipe.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
2 changes: 2 additions & 0 deletions
2
src/main/java/committee/nova/mods/avaritia/common/crafting/recipe/CompressorRecipe.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
90 changes: 90 additions & 0 deletions
90
...java/committee/nova/mods/avaritia/common/crafting/recipe/InfinityCatalystCraftRecipe.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,90 @@ | ||
package committee.nova.mods.avaritia.common.crafting.recipe; | ||
|
||
import com.google.gson.JsonObject; | ||
import committee.nova.mods.avaritia.init.handler.SingularityRegistryHandler; | ||
import committee.nova.mods.avaritia.init.registry.ModItems; | ||
import committee.nova.mods.avaritia.init.registry.ModRecipeSerializers; | ||
import committee.nova.mods.avaritia.util.SingularityUtils; | ||
import net.minecraft.core.NonNullList; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.GsonHelper; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.crafting.Ingredient; | ||
import net.minecraft.world.item.crafting.RecipeSerializer; | ||
import net.minecraftforge.items.IItemHandler; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Name: Avaritia-forge / InfinityCatalystRecipe | ||
* Author: cnlimiter | ||
* CreateTime: 2023/9/16 17:19 | ||
* Description: | ||
*/ | ||
|
||
public class InfinityCatalystCraftRecipe extends ShapelessExtremeCraftingRecipe{ | ||
private boolean ingredientsLoaded = false; | ||
public InfinityCatalystCraftRecipe(ResourceLocation recipeId, NonNullList<Ingredient> inputs) { | ||
super(recipeId, inputs, new ItemStack(ModItems.infinity_catalyst.get())); | ||
} | ||
|
||
@Override | ||
public @NotNull NonNullList<Ingredient> getIngredients() { | ||
if (!this.ingredientsLoaded) { | ||
SingularityRegistryHandler.getInstance().getSingularities() | ||
.stream() | ||
.filter(singularity -> singularity.getIngredient() != Ingredient.EMPTY) | ||
.limit(74) | ||
.map(SingularityUtils::getItemForSingularity) | ||
.map(Ingredient::of) | ||
.forEach(super.getIngredients()::add); | ||
|
||
this.ingredientsLoaded = true; | ||
} | ||
return super.getIngredients(); | ||
} | ||
|
||
@Override | ||
public boolean matches(IItemHandler inventory) { | ||
var ingredients = this.getIngredients(); | ||
return !ingredients.isEmpty() && super.matches(inventory); | ||
} | ||
|
||
@Override | ||
public @NotNull RecipeSerializer<?> getSerializer() { | ||
return ModRecipeSerializers.INFINITY_SERIALIZER.get(); | ||
} | ||
|
||
public static class Serializer implements RecipeSerializer<InfinityCatalystCraftRecipe> { | ||
@Override | ||
public @NotNull InfinityCatalystCraftRecipe fromJson(@NotNull ResourceLocation recipeId, @NotNull JsonObject json) { | ||
NonNullList<Ingredient> inputs = NonNullList.create(); | ||
var ingredients = GsonHelper.getAsJsonArray(json, "ingredients"); | ||
|
||
for (int i = 0; i < ingredients.size(); i++) { | ||
inputs.add(Ingredient.fromJson(ingredients.get(i))); | ||
} | ||
return new InfinityCatalystCraftRecipe(recipeId, inputs); | ||
} | ||
|
||
@Override | ||
public InfinityCatalystCraftRecipe fromNetwork(@NotNull ResourceLocation recipeId, @NotNull FriendlyByteBuf buffer) { | ||
int size = buffer.readVarInt(); | ||
var inputs = NonNullList.withSize(size, Ingredient.EMPTY); | ||
|
||
for (int i = 0; i < size; ++i) { | ||
inputs.set(i, Ingredient.fromNetwork(buffer)); | ||
} | ||
return new InfinityCatalystCraftRecipe(recipeId, inputs); | ||
} | ||
|
||
@Override | ||
public void toNetwork(@NotNull FriendlyByteBuf buffer, @NotNull InfinityCatalystCraftRecipe recipe) { | ||
buffer.writeVarInt(recipe.inputs.size()); | ||
|
||
for (var ingredient : recipe.inputs) { | ||
ingredient.toNetwork(buffer); | ||
} | ||
} | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
src/main/java/committee/nova/mods/avaritia/init/compat/jei/category/CompressorCategory.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
2 changes: 1 addition & 1 deletion
2
...a/committee/nova/mods/avaritia/init/compat/jei/category/ExtremeCraftingTableCategory.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
Oops, something went wrong.