generated from neoforged/MDK
-
Notifications
You must be signed in to change notification settings - Fork 16
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
1 parent
8d5b169
commit 0e735d5
Showing
6 changed files
with
209 additions
and
1 deletion.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...ted/resources/data/justdirethings/advancements/recipes/misc/gooblock_tier1-goospread.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,34 @@ | ||
{ | ||
"parent": "minecraft:recipes/root", | ||
"criteria": { | ||
"has_goo_block": { | ||
"conditions": { | ||
"items": [ | ||
{ | ||
"items": [ | ||
"justdirethings:gooblock_tier1" | ||
] | ||
} | ||
] | ||
}, | ||
"trigger": "minecraft:inventory_changed" | ||
}, | ||
"has_the_recipe": { | ||
"conditions": { | ||
"recipe": "justdirethings:gooblock_tier1-goospread" | ||
}, | ||
"trigger": "minecraft:recipe_unlocked" | ||
} | ||
}, | ||
"requirements": [ | ||
[ | ||
"has_the_recipe", | ||
"has_goo_block" | ||
] | ||
], | ||
"rewards": { | ||
"recipes": [ | ||
"justdirethings:gooblock_tier1-goospread" | ||
] | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/generated/resources/data/justdirethings/recipes/gooblock_tier1-goospread.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,10 @@ | ||
{ | ||
"type": "justdirethings:goospread", | ||
"id": "justdirethings:goospread1", | ||
"input": { | ||
"Name": "minecraft:iron_block" | ||
}, | ||
"output": { | ||
"Name": "justdirethings:gooblock_tier1" | ||
} | ||
} |
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
121 changes: 121 additions & 0 deletions
121
src/main/java/com/direwolf20/justdirethings/datagen/recipes/GooSpreadRecipeBuilder.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,121 @@ | ||
package com.direwolf20.justdirethings.datagen.recipes; | ||
|
||
import com.direwolf20.justdirethings.JustDireThings; | ||
import net.minecraft.advancements.Advancement; | ||
import net.minecraft.advancements.AdvancementRequirements; | ||
import net.minecraft.advancements.AdvancementRewards; | ||
import net.minecraft.advancements.Criterion; | ||
import net.minecraft.advancements.critereon.RecipeUnlockedTrigger; | ||
import net.minecraft.core.NonNullList; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.data.recipes.RecipeBuilder; | ||
import net.minecraft.data.recipes.RecipeCategory; | ||
import net.minecraft.data.recipes.RecipeOutput; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.tags.TagKey; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.crafting.Ingredient; | ||
import net.minecraft.world.level.ItemLike; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
|
||
public class GooSpreadRecipeBuilder implements RecipeBuilder { | ||
/*private final RecipeCategory category; | ||
private final Item result; | ||
private final int count; | ||
private final ItemStack resultStack; // Neo: add stack result support */ | ||
|
||
@Nullable | ||
private String group; | ||
|
||
private final ResourceLocation id; | ||
protected final BlockState input; | ||
protected final BlockState output; | ||
private final NonNullList<Ingredient> ingredients = NonNullList.create(); | ||
private final Map<String, Criterion<?>> criteria = new LinkedHashMap<>(); | ||
|
||
public GooSpreadRecipeBuilder(ResourceLocation id, BlockState input, BlockState output) { | ||
this.id = id; | ||
this.input = input; | ||
this.output = output; | ||
} | ||
|
||
public static GooSpreadRecipeBuilder shapeless(ResourceLocation id, BlockState input, BlockState output) { | ||
return new GooSpreadRecipeBuilder(id, input, output); | ||
} | ||
|
||
public GooSpreadRecipeBuilder requires(TagKey<Item> pTag) { | ||
return this.requires(Ingredient.of(pTag)); | ||
} | ||
|
||
public GooSpreadRecipeBuilder requires(ItemLike pItem) { | ||
return this.requires(pItem, 1); | ||
} | ||
|
||
public GooSpreadRecipeBuilder requires(ItemLike pItem, int pQuantity) { | ||
for (int i = 0; i < pQuantity; ++i) { | ||
this.requires(Ingredient.of(pItem)); | ||
} | ||
|
||
return this; | ||
} | ||
|
||
public GooSpreadRecipeBuilder requires(Ingredient pIngredient) { | ||
return this.requires(pIngredient, 1); | ||
} | ||
|
||
public GooSpreadRecipeBuilder requires(Ingredient pIngredient, int pQuantity) { | ||
for (int i = 0; i < pQuantity; ++i) { | ||
this.ingredients.add(pIngredient); | ||
} | ||
|
||
return this; | ||
} | ||
|
||
public GooSpreadRecipeBuilder unlockedBy(String pName, Criterion<?> pCriterion) { | ||
this.criteria.put(pName, pCriterion); | ||
return this; | ||
} | ||
|
||
public GooSpreadRecipeBuilder group(@Nullable String pGroupName) { | ||
this.group = pGroupName; | ||
return this; | ||
} | ||
|
||
@Override | ||
public Item getResult() { | ||
return ItemStack.EMPTY.getItem(); | ||
} | ||
|
||
public void save(RecipeOutput pRecipeOutput) { | ||
//this.save(pRecipeOutput, new ResourceLocation(JustDireThings.MODID, this.output.getBlock(). + "-goorecipe")); | ||
this.save(pRecipeOutput, new ResourceLocation(JustDireThings.MODID, BuiltInRegistries.BLOCK.getKey(this.output.getBlock()).getPath() + "-goospread")); | ||
} | ||
|
||
@Override | ||
public void save(RecipeOutput pRecipeOutput, ResourceLocation pId) { | ||
this.ensureValid(pId); | ||
Advancement.Builder advancement$builder = pRecipeOutput.advancement() | ||
.addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(pId)) | ||
.rewards(AdvancementRewards.Builder.recipe(pId)) | ||
.requirements(AdvancementRequirements.Strategy.OR); | ||
this.criteria.forEach(advancement$builder::addCriterion); | ||
GooSpreadRecipe shapelessrecipe = new GooSpreadRecipe( | ||
this.id, | ||
this.input, | ||
this.output | ||
); | ||
pRecipeOutput.accept(pId, shapelessrecipe, advancement$builder.build(pId.withPrefix("recipes/" + RecipeCategory.MISC.getFolderName() + "/"))); | ||
} | ||
|
||
private void ensureValid(ResourceLocation pId) { | ||
if (this.criteria.isEmpty()) { | ||
throw new IllegalStateException("No way of obtaining recipe " + pId); | ||
} | ||
} | ||
} |
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