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

@ -34,198 +34,107 @@ public class BlockRecipeGenerator extends RecipeProvider {
.build(consumer); .build(consumer);
//Empowerer //Empowerer
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.EMPOWERER.get()) Recipe.shaped(ActuallyBlocks.EMPOWERER.get())
.patternLine(" R ") .pattern(" R ", " B ", "CDC")
.patternLine(" B ")
.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))
.build(consumer); .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)
.addCriterion("", hasItem(Items.AIR))
.build(consumer, new ResourceLocation(ActuallyAdditions.MODID, "tiny_torch")); .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")
.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))
.build(consumer); .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")
.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))
.build(consumer); .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")
.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))
.build(consumer); .build(consumer);
//Vertical Digger //Vertical Digger
ShapedRecipeBuilder.shapedRecipe(ActuallyBlocks.MINER.get()) Recipe.shaped(ActuallyBlocks.MINER.get())
.patternLine("IRI") .pattern("IRI", "RCR", "IDI")
.patternLine("RCR")
.patternLine("IDI")
.key('R', Tags.Items.STORAGE_BLOCKS_REDSTONE) .key('R', Tags.Items.STORAGE_BLOCKS_REDSTONE)
.key('I', ActuallyBlocks.IRON_CASING.get()) .key('I', ActuallyBlocks.IRON_CASING.get())
.key('C', ActuallyItems.VOID_EMPOWERED_CRYSTAL.get()) .key('C', ActuallyItems.VOID_EMPOWERED_CRYSTAL.get())
.key('D', ActuallyItems.DRILL.get()) .key('D', ActuallyItems.DRILL.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer); .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")
.patternLine("IRI")
.key('R', Tags.Items.DUSTS_REDSTONE) .key('R', Tags.Items.DUSTS_REDSTONE)
.key('I', Tags.Items.INGOTS_IRON) .key('I', Tags.Items.INGOTS_IRON)
.key('C', ActuallyBlocks.IRON_CASING.get()) .key('C', ActuallyBlocks.IRON_CASING.get())
.addCriterion("", hasItem(Items.AIR))
.build(consumer); .build(consumer);
} }
@ -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()));