mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-10-31 22:50:50 +01:00
feat: added wrapper for builders in recipes
This commit is contained in:
parent
354a118a1f
commit
8edd6de4d2
1 changed files with 131 additions and 65 deletions
|
@ -6,10 +6,12 @@ import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||||
import net.minecraft.data.*;
|
import net.minecraft.data.*;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.util.IItemProvider;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.common.Tags;
|
import net.minecraftforge.common.Tags;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class BlockRecipeGenerator extends RecipeProvider {
|
public class BlockRecipeGenerator extends RecipeProvider {
|
||||||
|
@ -20,92 +22,156 @@ public class BlockRecipeGenerator extends RecipeProvider {
|
||||||
@Override
|
@Override
|
||||||
protected void registerRecipes(Consumer<IFinishedRecipe> consumer) {
|
protected void registerRecipes(Consumer<IFinishedRecipe> consumer) {
|
||||||
//Battery Box
|
//Battery Box
|
||||||
ShapelessRecipeBuilder.shapelessRecipe(ActuallyBlocks.BATTERY_BOX.get())
|
Recipe.shapeless(ActuallyBlocks.BATTERY_BOX.get()).ingredients(ActuallyBlocks.ENERGIZER.get(), ActuallyBlocks.ENERVATOR.get(), ActuallyItems.COIL.get()).build(consumer);
|
||||||
.addIngredient(ActuallyBlocks.ENERGIZER.get())
|
|
||||||
.addIngredient(ActuallyBlocks.ENERVATOR.get())
|
|
||||||
.addIngredient(ActuallyItems.COIL.get())
|
|
||||||
.addCriterion("", hasItem(Items.AIR))
|
|
||||||
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "battery_box"));
|
|
||||||
|
|
||||||
//Farmer
|
//Farmer
|
||||||
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.FARMER.get())
|
Recipe.shaped(ActuallyBlocks.FARMER.get())
|
||||||
.patternLine("ISI")
|
.pattern("ISI", "SCS", "ISI")
|
||||||
.patternLine("SCS")
|
.key('I', ActuallyBlocks.CRYSTAL_ENORI.get())
|
||||||
.patternLine("ISI")
|
.key('C', ActuallyBlocks.IRON_CASING.get())
|
||||||
.key('I', ActuallyBlocks.CRYSTAL_ENORI.get())
|
.key('S', Tags.Items.SEEDS)
|
||||||
.key('C', ActuallyBlocks.IRON_CASING.get())
|
.build(consumer);
|
||||||
.key('S', Tags.Items.SEEDS)
|
|
||||||
.addCriterion("", hasItem(Items.AIR))
|
|
||||||
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "farmer"));
|
|
||||||
|
|
||||||
//Empowerer
|
//Empowerer
|
||||||
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.EMPOWERER.get())
|
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.EMPOWERER.get())
|
||||||
.patternLine(" R ")
|
.patternLine(" R ")
|
||||||
.patternLine(" B ")
|
.patternLine(" B ")
|
||||||
.patternLine("CDC")
|
.patternLine("CDC")
|
||||||
.key('R', ActuallyItems.RESTONIA_CRYSTAL.get())
|
.key('R', ActuallyItems.RESTONIA_CRYSTAL.get())
|
||||||
.key('B', ActuallyItems.BATTERY_DOUBLE.get())
|
.key('B', ActuallyItems.BATTERY_DOUBLE.get())
|
||||||
.key('C', ActuallyBlocks.IRON_CASING.get())
|
.key('C', ActuallyBlocks.IRON_CASING.get())
|
||||||
.key('D', ActuallyBlocks.DISPLAY_STAND.get())
|
.key('D', ActuallyBlocks.DISPLAY_STAND.get())
|
||||||
.addCriterion("", hasItem(Items.AIR))
|
.addCriterion("", hasItem(Items.AIR))
|
||||||
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "empowerer"));
|
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "empowerer"));
|
||||||
|
|
||||||
//Tiny Torch coal
|
//Tiny Torch coal
|
||||||
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.TINY_TORCH.get(), 2)
|
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.TINY_TORCH.get(), 2)
|
||||||
.patternLine("C")
|
.patternLine("C")
|
||||||
.patternLine("S")
|
.patternLine("S")
|
||||||
.key('C', ActuallyItems.TINY_COAL.get())
|
.key('C', ActuallyItems.TINY_COAL.get())
|
||||||
.key('S', Tags.Items.RODS_WOODEN)
|
.key('S', Tags.Items.RODS_WOODEN)
|
||||||
.addCriterion("", hasItem(Items.AIR))
|
.addCriterion("", hasItem(Items.AIR))
|
||||||
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "tiny_torch_coal"));
|
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "tiny_torch_coal"));
|
||||||
|
|
||||||
//Tiny Torch charcoal
|
//Tiny Torch charcoal
|
||||||
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.TINY_TORCH.get(), 2)
|
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.TINY_TORCH.get(), 2)
|
||||||
.patternLine("C")
|
.patternLine("C")
|
||||||
.patternLine("S")
|
.patternLine("S")
|
||||||
.key('C', ActuallyItems.TINY_CHARCOAL.get())
|
.key('C', ActuallyItems.TINY_CHARCOAL.get())
|
||||||
.key('S', Tags.Items.RODS_WOODEN)
|
.key('S', Tags.Items.RODS_WOODEN)
|
||||||
.addCriterion("", hasItem(Items.AIR))
|
.addCriterion("", hasItem(Items.AIR))
|
||||||
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "tiny_torch_charcoal"));
|
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "tiny_torch_charcoal"));
|
||||||
|
|
||||||
//Fireworks Box
|
//Fireworks Box
|
||||||
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.FIREWORK_BOX.get())
|
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.FIREWORK_BOX.get())
|
||||||
.patternLine("GFG")
|
.patternLine("GFG")
|
||||||
.patternLine("SAS")
|
.patternLine("SAS")
|
||||||
.patternLine("CCC")
|
.patternLine("CCC")
|
||||||
.key('G', Tags.Items.GUNPOWDER)
|
.key('G', Tags.Items.GUNPOWDER)
|
||||||
.key('S', Tags.Items.RODS_WOODEN)
|
.key('S', Tags.Items.RODS_WOODEN)
|
||||||
.key('A', ActuallyBlocks.IRON_CASING.get())
|
.key('A', ActuallyBlocks.IRON_CASING.get())
|
||||||
.key('F', Items.FIREWORK_ROCKET)
|
.key('F', Items.FIREWORK_ROCKET)
|
||||||
.key('C', ActuallyItems.ENORI_CRYSTAL.get())
|
.key('C', ActuallyItems.ENORI_CRYSTAL.get())
|
||||||
.addCriterion("", hasItem(Items.AIR))
|
.addCriterion("", hasItem(Items.AIR))
|
||||||
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "firework_box"));
|
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "firework_box"));
|
||||||
|
|
||||||
//Shock Suppressor
|
//Shock Suppressor
|
||||||
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.SHOCK_SUPPRESSOR.get())
|
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.SHOCK_SUPPRESSOR.get())
|
||||||
.patternLine("OAO")
|
.patternLine("OAO")
|
||||||
.patternLine("ACA")
|
.patternLine("ACA")
|
||||||
.patternLine("OAO")
|
.patternLine("OAO")
|
||||||
.key('A', ActuallyItems.VOID_EMPOWERED_CRYSTAL.get())
|
.key('A', ActuallyItems.VOID_EMPOWERED_CRYSTAL.get())
|
||||||
.key('O', Tags.Items.OBSIDIAN)
|
.key('O', Tags.Items.OBSIDIAN)
|
||||||
.key('C', ActuallyItems.COIL_ADVANCED.get())
|
.key('C', ActuallyItems.COIL_ADVANCED.get())
|
||||||
.addCriterion("", hasItem(Items.AIR))
|
.addCriterion("", hasItem(Items.AIR))
|
||||||
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "shock_suppressor"));
|
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "shock_suppressor"));
|
||||||
|
|
||||||
//Display Stand
|
//Display Stand
|
||||||
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.DISPLAY_STAND.get())
|
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.DISPLAY_STAND.get())
|
||||||
.patternLine(" R ")
|
.patternLine(" R ")
|
||||||
.patternLine("EEE")
|
.patternLine("EEE")
|
||||||
.patternLine("GGG")
|
.patternLine("GGG")
|
||||||
.key('R', ActuallyItems.COIL_ADVANCED.get())
|
.key('R', ActuallyItems.COIL_ADVANCED.get())
|
||||||
.key('E', ActuallyBlocks.ETHETIC_GREEN_BLOCK.get())
|
.key('E', ActuallyBlocks.ETHETIC_GREEN_BLOCK.get())
|
||||||
.key('G', ActuallyBlocks.ETHETIC_WHITE_BLOCK.get())
|
.key('G', ActuallyBlocks.ETHETIC_WHITE_BLOCK.get())
|
||||||
.addCriterion("", hasItem(Items.AIR))
|
.addCriterion("", hasItem(Items.AIR))
|
||||||
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "display_stand"));
|
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "display_stand"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void saveRecipeAdvancement(DirectoryCache cache, JsonObject cache2, Path advancementJson) {
|
protected void saveRecipeAdvancement(DirectoryCache cache, JsonObject cache2, Path advancementJson) {
|
||||||
//Nope...
|
//Nope...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Recipe {
|
||||||
|
public static Shapeless shapeless(IItemProvider result) {
|
||||||
|
return new Shapeless(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Shaped shaped(IItemProvider result) {
|
||||||
|
return new Shaped(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Shapeless extends ShapelessRecipeBuilder {
|
||||||
|
public Shapeless(IItemProvider result) {
|
||||||
|
this(result, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Shapeless(IItemProvider result, int countIn) {
|
||||||
|
super(result, countIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Shapeless ingredients(IItemProvider... ingredients) {
|
||||||
|
Arrays.asList(ingredients).forEach(this::addIngredient);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void build(Consumer<IFinishedRecipe> consumer) {
|
||||||
|
this.addCriterion("has_book", hasItem(ActuallyItems.ITEM_BOOKLET.get()));
|
||||||
|
super.build(consumer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void build(Consumer<IFinishedRecipe> consumer, ResourceLocation location) {
|
||||||
|
this.addCriterion("has_book", hasItem(ActuallyItems.ITEM_BOOKLET.get()));
|
||||||
|
super.build(consumer, location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Shaped extends ShapedRecipeBuilder {
|
||||||
|
public Shaped(IItemProvider resultIn) {
|
||||||
|
this(resultIn, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Shaped(IItemProvider resultIn, int countIn) {
|
||||||
|
super(resultIn, countIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Shaped pattern(String line1, String line2, String line3) {
|
||||||
|
this.patternLine(line1);
|
||||||
|
this.patternLine(line2);
|
||||||
|
this.patternLine(line3);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Shaped pattern(String line1, String line2) {
|
||||||
|
this.patternLine(line1);
|
||||||
|
this.patternLine(line2);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void build(Consumer<IFinishedRecipe> consumerIn) {
|
||||||
|
this.addCriterion("has_book", hasItem(ActuallyItems.ITEM_BOOKLET.get()));
|
||||||
|
super.build(consumerIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void build(Consumer<IFinishedRecipe> consumerIn, ResourceLocation id) {
|
||||||
|
this.addCriterion("has_book", hasItem(ActuallyItems.ITEM_BOOKLET.get()));
|
||||||
|
super.build(consumerIn, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue