feat: helper methods, cleanup and builder fixes

This commit is contained in:
Michael Hillcox 2021-05-05 18:05:24 +01:00
parent a7c9655586
commit e8b797bac3

View file

@ -33,200 +33,109 @@ public class BlockRecipeGenerator extends RecipeProvider {
.key('S', Tags.Items.SEEDS) .key('S', Tags.Items.SEEDS)
.build(consumer); .build(consumer);
//Empowerer //Empowerer
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.EMPOWERER.get()) Recipe.shaped(ActuallyBlocks.EMPOWERER.get())
.patternLine(" R ") .pattern(" R ", " B ", "CDC")
.patternLine(" B ") .key('R', ActuallyItems.RESTONIA_CRYSTAL.get())
.patternLine("CDC") .key('B', ActuallyItems.BATTERY_DOUBLE.get())
.key('R', ActuallyItems.RESTONIA_CRYSTAL.get()) .key('C', ActuallyBlocks.IRON_CASING.get())
.key('B', ActuallyItems.BATTERY_DOUBLE.get()) .key('D', ActuallyBlocks.DISPLAY_STAND.get())
.key('C', ActuallyBlocks.IRON_CASING.get()) .build(consumer);
.key('D', ActuallyBlocks.DISPLAY_STAND.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Tiny Torch //Tiny Torch
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.TINY_TORCH.get(), 2) Recipe.shaped(ActuallyBlocks.TINY_TORCH.get(), 2)
.patternLine("C") .pattern("C", "S")
.patternLine("S") .key('C', ActuallyTags.Items.TINY_COALS)
.key('C', ActuallyTags.Items.TINY_COALS) .key('S', Tags.Items.RODS_WOODEN)
.key('S', Tags.Items.RODS_WOODEN) .build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "tiny_torch"));
.addCriterion("", hasItem(Items.AIR))
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "tiny_torch"));
//Fireworks Box //Fireworks Box
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.FIREWORK_BOX.get()) Recipe.shaped(ActuallyBlocks.FIREWORK_BOX.get())
.patternLine("GFG") .pattern("GFG", "SAS", "CCC")
.patternLine("SAS") .key('G', Tags.Items.GUNPOWDER)
.patternLine("CCC") .key('S', Tags.Items.RODS_WOODEN)
.key('G', Tags.Items.GUNPOWDER) .key('A', ActuallyBlocks.IRON_CASING.get())
.key('S', Tags.Items.RODS_WOODEN) .key('F', Items.FIREWORK_ROCKET)
.key('A', ActuallyBlocks.IRON_CASING.get()) .key('C', ActuallyItems.ENORI_CRYSTAL.get())
.key('F', Items.FIREWORK_ROCKET) .build(consumer);
.key('C', ActuallyItems.ENORI_CRYSTAL.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Shock Suppressor //Shock Suppressor
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.SHOCK_SUPPRESSOR.get()) Recipe.shaped(ActuallyBlocks.SHOCK_SUPPRESSOR.get())
.patternLine("OAO") .pattern("OAO", "ACA", "OAO")
.patternLine("ACA") .key('A', ActuallyItems.VOID_EMPOWERED_CRYSTAL.get())
.patternLine("OAO") .key('O', Tags.Items.OBSIDIAN)
.key('A', ActuallyItems.VOID_EMPOWERED_CRYSTAL.get()) .key('C', ActuallyItems.COIL_ADVANCED.get())
.key('O', Tags.Items.OBSIDIAN) .build(consumer);
.key('C', ActuallyItems.COIL_ADVANCED.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Display Stand //Display Stand
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.DISPLAY_STAND.get()) Recipe.shaped(ActuallyBlocks.DISPLAY_STAND.get())
.patternLine(" R ") .pattern(" R ", "EEE", "GGG")
.patternLine("EEE") .key('R', ActuallyItems.COIL_ADVANCED.get())
.patternLine("GGG") .key('E', ActuallyBlocks.ETHETIC_GREEN_BLOCK.get())
.key('R', ActuallyItems.COIL_ADVANCED.get()) .key('G', ActuallyBlocks.ETHETIC_WHITE_BLOCK.get())
.key('E', ActuallyBlocks.ETHETIC_GREEN_BLOCK.get()) .build(consumer);
.key('G', ActuallyBlocks.ETHETIC_WHITE_BLOCK.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Vertical Digger //Vertical Digger
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.MINER.get()) Recipe.shaped(ActuallyBlocks.MINER.get())
.patternLine("IRI") .pattern("IRI", "RCR", "IDI")
.patternLine("RCR") .key('R', Tags.Items.STORAGE_BLOCKS_REDSTONE)
.patternLine("IDI") .key('I', ActuallyBlocks.IRON_CASING.get())
.key('R', Tags.Items.STORAGE_BLOCKS_REDSTONE) .key('C', ActuallyItems.VOID_EMPOWERED_CRYSTAL.get())
.key('I', ActuallyBlocks.IRON_CASING.get()) .key('D', ActuallyItems.DRILL.get())
.key('C', ActuallyItems.VOID_EMPOWERED_CRYSTAL.get()) .build(consumer);
.key('D', ActuallyItems.DRILL.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Black Quartz Wall //Black Quartz Wall
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.BLACK_QUARTZ_WALL.get()) Recipe.wall(ActuallyBlocks.BLACK_QUARTZ_WALL.get(), ActuallyBlocks.BLACK_QUARTZ_PILLAR_BLOCK.get(), consumer);
.patternLine("QQQ")
.patternLine("QQQ")
.key('Q', ActuallyBlocks.BLACK_QUARTZ_PILLAR_BLOCK.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Black Quartz Slab //Black Quartz Slab
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.BLACK_QUARTZ_SLAB.get()) Recipe.slab(ActuallyBlocks.BLACK_QUARTZ_SLAB.get(), ActuallyBlocks.BLACK_QUARTZ_PILLAR_BLOCK.get(), consumer);
.patternLine("QQQ")
.key('Q', ActuallyBlocks.BLACK_QUARTZ_PILLAR_BLOCK.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Black Quartz Stairs //Black Quartz Stairs
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.BLACK_QUARTZ_STAIR.get()) Recipe.stairs(ActuallyBlocks.BLACK_QUARTZ_STAIR.get(), ActuallyBlocks.BLACK_QUARTZ_PILLAR_BLOCK.get(), consumer);
.patternLine("Q ")
.patternLine("QQ ")
.patternLine("QQQ")
.key('Q', ActuallyBlocks.BLACK_QUARTZ_PILLAR_BLOCK.get())
.build(consumer);
//Pillar Black Quartz Wall //Pillar Black Quartz Wall
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.BLACK_QUARTZ_PILLAR_WALL.get()) Recipe.wall(ActuallyBlocks.BLACK_QUARTZ_PILLAR_WALL.get(), ActuallyBlocks.BLACK_QUARTZ_PILLAR_BLOCK.get(), consumer);
.patternLine("QQQ")
.patternLine("QQQ")
.key('Q', ActuallyBlocks.BLACK_QUARTZ_PILLAR_BLOCK.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Pillar Black Quartz Slab //Pillar Black Quartz Slab
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.BLACK_QUARTZ_PILLAR_SLAB.get()) Recipe.slab(ActuallyBlocks.BLACK_QUARTZ_PILLAR_SLAB.get(), ActuallyBlocks.BLACK_QUARTZ_PILLAR_BLOCK.get(), consumer);
.patternLine("QQQ")
.key('Q', ActuallyBlocks.BLACK_QUARTZ_PILLAR_BLOCK.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Pillar Black Quartz Stairs //Pillar Black Quartz Stairs
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.BLACK_QUARTZ_PILLAR_STAIR.get()) Recipe.stairs(ActuallyBlocks.BLACK_QUARTZ_PILLAR_STAIR.get(), ActuallyBlocks.BLACK_QUARTZ_PILLAR_BLOCK.get(), consumer);
.patternLine("Q ")
.patternLine("QQ ")
.patternLine("QQQ")
.key('Q', ActuallyBlocks.BLACK_QUARTZ_PILLAR_BLOCK.get())
.build(consumer);
//Chiseled Black Quartz Wall //Chiseled Black Quartz Wall
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.CHISELED_BLACK_QUARTZ_WALL.get()) Recipe.wall(ActuallyBlocks.CHISELED_BLACK_QUARTZ_WALL.get(), ActuallyBlocks.CHISELED_BLACK_QUARTZ_BLOCK.get(), consumer);
.patternLine("QQQ")
.patternLine("QQQ")
.key('Q', ActuallyBlocks.CHISELED_BLACK_QUARTZ_BLOCK.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Chiseled Black Quartz Slab //Chiseled Black Quartz Slab
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.CHISELED_BLACK_QUARTZ_SLAB.get()) Recipe.slab(ActuallyBlocks.CHISELED_BLACK_QUARTZ_SLAB.get(), ActuallyBlocks.CHISELED_BLACK_QUARTZ_BLOCK.get(), consumer);
.patternLine("QQQ")
.key('Q', ActuallyBlocks.CHISELED_BLACK_QUARTZ_BLOCK.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Chiseled Black Quartz Stairs //Chiseled Black Quartz Stairs
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.CHISELED_BLACK_QUARTZ_STAIR.get()) Recipe.stairs(ActuallyBlocks.CHISELED_BLACK_QUARTZ_STAIR.get(), ActuallyBlocks.CHISELED_BLACK_QUARTZ_BLOCK.get(), consumer);
.patternLine("Q ")
.patternLine("QQ ")
.patternLine("QQQ")
.key('Q', ActuallyBlocks.CHISELED_BLACK_QUARTZ_BLOCK.get())
.build(consumer);
//Ethetic White Wall //Ethetic White Wall
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.ETHETIC_WHITE_WALL.get()) Recipe.wall(ActuallyBlocks.ETHETIC_WHITE_WALL.get(), ActuallyBlocks.ETHETIC_WHITE_BLOCK.get(), consumer);
.patternLine("QQQ")
.patternLine("QQQ")
.key('Q', ActuallyBlocks.ETHETIC_WHITE_BLOCK.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Ethetic White Slab //Ethetic White Slab
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.ETHETIC_WHITE_SLAB.get()) Recipe.slab(ActuallyBlocks.ETHETIC_WHITE_SLAB.get(), ActuallyBlocks.ETHETIC_WHITE_BLOCK.get(), consumer);
.patternLine("QQQ")
.key('Q', ActuallyBlocks.ETHETIC_WHITE_BLOCK.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Ethetic White Stairs //Ethetic White Stairs
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.ETHETIC_WHITE_STAIRS.get()) Recipe.stairs(ActuallyBlocks.ETHETIC_WHITE_STAIRS.get(), ActuallyBlocks.ETHETIC_WHITE_BLOCK.get(), consumer);
.patternLine("Q ")
.patternLine("QQ ")
.patternLine("QQQ")
.key('Q', ActuallyBlocks.ETHETIC_WHITE_BLOCK.get())
.build(consumer);
//Ethetic Green Wall // Ethetic Green Wall
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.ETHETIC_GREEN_WALL.get()) Recipe.wall(ActuallyBlocks.ETHETIC_GREEN_WALL.get(), ActuallyBlocks.ETHETIC_GREEN_BLOCK.get(), consumer);
.patternLine("QQQ")
.patternLine("QQQ")
.key('Q', ActuallyBlocks.ETHETIC_GREEN_BLOCK.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Ethetic Green Slab // Ethetic Green Slab
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.ETHETIC_GREEN_SLAB.get()) Recipe.slab(ActuallyBlocks.ETHETIC_GREEN_SLAB.get(), ActuallyBlocks.ETHETIC_GREEN_BLOCK.get(), consumer);
.patternLine("QQQ")
.key('Q', ActuallyBlocks.ETHETIC_GREEN_BLOCK.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Ethetic Green Stairs // Ethetic Green Stairs
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.ETHETIC_GREEN_STAIRS.get()) Recipe.stairs(ActuallyBlocks.ETHETIC_GREEN_STAIRS.get(), ActuallyBlocks.ETHETIC_GREEN_BLOCK.get(), consumer);
.patternLine("Q ")
.patternLine("QQ ")
.patternLine("QQQ")
.key('Q', ActuallyBlocks.ETHETIC_GREEN_BLOCK.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
//Atomic Reconstructor // Atomic Reconstructor
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.get()) Recipe.shaped(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.get())
.patternLine("IRI") .pattern("IRI", "RCR", "IRI")
.patternLine("RCR") .key('R', Tags.Items.DUSTS_REDSTONE)
.patternLine("IRI") .key('I', Tags.Items.INGOTS_IRON)
.key('R', Tags.Items.DUSTS_REDSTONE) .key('C', ActuallyBlocks.IRON_CASING.get())
.key('I', Tags.Items.INGOTS_IRON) .build(consumer);
.key('C', ActuallyBlocks.IRON_CASING.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer);
} }
@Override @Override
@ -239,10 +148,30 @@ public class BlockRecipeGenerator extends RecipeProvider {
return new Shapeless(result); return new Shapeless(result);
} }
public static Shapeless shapeless(IItemProvider result, int count) {
return new Shapeless(result, count);
}
public static Shaped shaped(IItemProvider result) { public static Shaped shaped(IItemProvider result) {
return new Shaped(result); return new Shaped(result);
} }
public static Shaped shaped(IItemProvider result, int count) {
return new Shaped(result, count);
}
public static void stairs(IItemProvider result, IItemProvider resource, Consumer<IFinishedRecipe> consumer) {
Recipe.shaped(result).patternSingleKey('Q', resource, "Q ", "QQ ", "QQQ").build(consumer);
}
public static void wall(IItemProvider result, IItemProvider resource, Consumer<IFinishedRecipe> consumer) {
Recipe.shaped(result).patternSingleKey('Q', resource, "QQQ", "QQQ").build(consumer);
}
public static void slab(IItemProvider result, IItemProvider resource, Consumer<IFinishedRecipe> consumer) {
Recipe.shaped(result).patternSingleKey('Q', resource, "QQQ").build(consumer);
}
private static class Shapeless extends ShapelessRecipeBuilder { private static class Shapeless extends ShapelessRecipeBuilder {
public Shapeless(IItemProvider result) { public Shapeless(IItemProvider result) {
this(result, 1); this(result, 1);
@ -292,6 +221,15 @@ public class BlockRecipeGenerator extends RecipeProvider {
return this; return this;
} }
public Shaped patternSingleKey(char key, IItemProvider resource, String... lines) {
this.key(key, resource);
for (String line : lines) {
this.patternLine(line);
}
return this;
}
@Override @Override
public void build(Consumer<IFinishedRecipe> consumerIn) { public void build(Consumer<IFinishedRecipe> consumerIn) {
this.addCriterion("has_book", hasItem(ActuallyItems.ITEM_BOOKLET.get())); this.addCriterion("has_book", hasItem(ActuallyItems.ITEM_BOOKLET.get()));