Add stonecutting data provider and stonecutting recipes

This commit is contained in:
Vincent Lee committed 2019-10-22 18:22:59 -05:00
1 parent 7ac78d9df2
commit febe12e680
100 files changed
+870 -5

No files matched your search

@@ -324,11 +324,7 @@ public final class ModFluffBlocks {
props = Block.Properties.create(Material.ROCK).hardnessAndResistance(1.5F, 10).sound(SoundType.STONE);
ILexiconable marimorph = (world, pos, player, lex) -> LexiconData.marimorphosis;
variants = new String[] {
"forest", "plains", "mountain", "fungal",
"swamp", "desert", "taiga", "mesa"
};
for (String variant : variants) {
for (String variant : LibBlockNames.METAMORPHIC_VARIANTS) {
base = new BlockModLexiconable(props, marimorph);
register(r, base, LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone");
register(r, new BlockBiomeStoneStairs(base.getDefaultState(), props), base.getRegistryName().getPath() + STAIR_SUFFIX);
@@ -12,5 +12,6 @@ public class DataGenerators {
evt.getGenerator().addProvider(new BlockLootProvider(evt.getGenerator()));
evt.getGenerator().addProvider(new BlockTagProvider(evt.getGenerator()));
evt.getGenerator().addProvider(new ItemTagProvider(evt.getGenerator()));
evt.getGenerator().addProvider(new StonecuttingProvider(evt.getGenerator()));
}
}
@@ -0,0 +1,96 @@
package vazkii.botania.common.data;
import com.google.gson.JsonObject;
import net.minecraft.advancements.Advancement;
import net.minecraft.block.Block;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.data.RecipeProvider;
import net.minecraft.data.SingleItemRecipeBuilder;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.ForgeRegistries;
import vazkii.botania.common.lib.LibBlockNames;
import vazkii.botania.common.lib.LibMisc;
import vazkii.botania.common.lib.ResourceLocationHelper;
import javax.annotation.Nullable;
import java.util.function.Consumer;
import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
public class StonecuttingProvider extends RecipeProvider {
public StonecuttingProvider(DataGenerator generator) {
super(generator);
}
@Override
protected void registerRecipes(Consumer<IFinishedRecipe> consumer) {
for(String variant : LibBlockNames.METAMORPHIC_VARIANTS) {
registerForMetamorphic(variant, consumer);
}
}
private static void registerForMetamorphic(String variant, Consumer<IFinishedRecipe> consumer) {
Block base = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone"));
Block slab = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone" + LibBlockNames.SLAB_SUFFIX));
Block stair = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone" + LibBlockNames.STAIR_SUFFIX));
Block brick = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks"));
Block brickSlab = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks" + LibBlockNames.SLAB_SUFFIX));
Block brickStair = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks" + LibBlockNames.STAIR_SUFFIX));
Block chiseledBrick = ForgeRegistries.BLOCKS.getValue(prefix("chiseled_" + LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks"));
Block cobble = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone"));
Block cobbleSlab = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone" + LibBlockNames.SLAB_SUFFIX));
Block cobbleStair = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone" + LibBlockNames.STAIR_SUFFIX));
Block cobbleWall = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone" + LibBlockNames.WALL_SUFFIX));
consumer.accept(stonecutting(base, slab, 2));
consumer.accept(stonecutting(base, stair));
consumer.accept(stonecutting(base, brick));
consumer.accept(stonecutting(base, brickSlab, 2));
consumer.accept(stonecutting(base, brickStair));
consumer.accept(stonecutting(base, chiseledBrick));
consumer.accept(stonecutting(brick, brickSlab, 2));
consumer.accept(stonecutting(brick, brickStair));
consumer.accept(stonecutting(brick, chiseledBrick));
consumer.accept(stonecutting(cobble, cobbleSlab, 2));
consumer.accept(stonecutting(cobble, cobbleStair));
consumer.accept(stonecutting(cobble, cobbleWall));
}
private static ResourceLocation idFor(IItemProvider a, IItemProvider b) {
return prefix("stonecutting/" + a.asItem().getRegistryName().getPath() + "_to_" + b.asItem().getRegistryName().getPath());
}
private static IFinishedRecipe stonecutting(IItemProvider input, IItemProvider output) {
return stonecutting(input, output, 1);
}
private static IFinishedRecipe stonecutting(IItemProvider input, IItemProvider output, int count) {
return new Result(idFor(input, output), IRecipeSerializer.STONECUTTING, Ingredient.fromItems(input), output.asItem(), count);
}
// Wrapper without advancements
public static class Result extends SingleItemRecipeBuilder.Result {
public Result(ResourceLocation id, IRecipeSerializer<?> serializer, Ingredient input, Item result, int count) {
super(id, serializer, "", input, result, count, null, null);
}
@Nullable
@Override
public JsonObject getAdvancementJson() {
return null;
}
@Nullable
@Override
public ResourceLocation getAdvancementID() {
return null;
}
}
}
@@ -138,6 +138,10 @@ public final class LibBlockNames {
public static final String ALT_GRASS_SUFFIX = "_grass";
public static final String ANIMATED_TORCH = "animated_torch";
public static final String METAMORPHIC_PREFIX = "metamorphic_";
public static final String[] METAMORPHIC_VARIANTS = {
"forest", "plains", "mountain", "fungal",
"swamp", "desert", "taiga", "mesa"
};
public static final String SLAB_SUFFIX = "_slab";
public static final String STAIR_SUFFIX = "_stairs";
public static final String WALL_SUFFIX = "_wall";