Search in sources :

Example 1 with WeatherState

use of net.minecraft.world.level.block.WeatheringCopper.WeatherState in project Create by Creators-of-Create.

the class CopperBlockSet method createEntry.

protected <T extends Block> BlockEntry<?> createEntry(AbstractRegistrate<?> registrate, Variant<T> variant, WeatherState state, boolean waxed) {
    String name = "";
    if (waxed) {
        name += "waxed_";
    }
    name += getWeatherStatePrefix(state);
    name += this.name;
    String suffix = variant.getSuffix();
    if (!suffix.equals(""))
        name = Lang.nonPluralId(name);
    name += suffix;
    Supplier<Block> baseBlock = BASE_BLOCKS.get(state);
    BlockBuilder<T, ?> builder = registrate.block(name, variant.getFactory(this, state, waxed)).initialProperties(() -> baseBlock.get()).loot((lt, block) -> variant.generateLootTable(lt, block, this, state, waxed)).blockstate((ctx, prov) -> variant.generateBlockState(ctx, prov, this, state, waxed)).recipe((c, p) -> variant.generateRecipes(entries.get(BlockVariant.INSTANCE)[state.ordinal()], c, p)).transform(AllTags.pickaxeOnly()).tag(BlockTags.NEEDS_STONE_TOOL).simpleItem();
    if (variant == BlockVariant.INSTANCE && state == WeatherState.UNAFFECTED)
        builder.recipe((c, p) -> mainBlockRecipe.accept(c, p));
    if (waxed) {
        builder.recipe((ctx, prov) -> {
            Block unwaxed = get(variant, state, false).get();
            ShapelessRecipeBuilder.shapeless(ctx.get()).requires(unwaxed).requires(Items.HONEYCOMB).unlockedBy("has_unwaxed", RegistrateRecipeProvider.has(unwaxed)).save(prov, new ResourceLocation(ctx.getId().getNamespace(), "crafting/" + generalDirectory + ctx.getName() + "_from_honeycomb"));
        });
    }
    return builder.register();
}
Also used : BlockEntry(com.tterrag.registrate.util.entry.BlockEntry) ResourceLocation(net.minecraft.resources.ResourceLocation) Items(net.minecraft.world.item.Items) BlockBuilder(com.tterrag.registrate.builders.BlockBuilder) WeatheringCopperSlabBlock(net.minecraft.world.level.block.WeatheringCopperSlabBlock) BlockState(net.minecraft.world.level.block.state.BlockState) HashMap(java.util.HashMap) ArrayUtils(org.apache.commons.lang3.ArrayUtils) SlabBlock(net.minecraft.world.level.block.SlabBlock) Supplier(java.util.function.Supplier) AllTags(com.simibubi.create.AllTags) RegistrateBlockLootTables(com.tterrag.registrate.providers.loot.RegistrateBlockLootTables) Properties(net.minecraft.world.level.block.state.BlockBehaviour.Properties) RegistrateRecipeProvider(com.tterrag.registrate.providers.RegistrateRecipeProvider) Locale(java.util.Locale) ShapelessRecipeBuilder(net.minecraft.data.recipes.ShapelessRecipeBuilder) Map(java.util.Map) BlockTags(net.minecraft.tags.BlockTags) NonNullFunction(com.tterrag.registrate.util.nullness.NonNullFunction) Lang(com.simibubi.create.foundation.utility.Lang) DataGenContext(com.tterrag.registrate.providers.DataGenContext) WeatheringCopperStairBlock(net.minecraft.world.level.block.WeatheringCopperStairBlock) WeatheringCopperFullBlock(net.minecraft.world.level.block.WeatheringCopperFullBlock) WeatherState(net.minecraft.world.level.block.WeatheringCopper.WeatherState) Iterate(com.simibubi.create.foundation.utility.Iterate) EnumMap(java.util.EnumMap) RegistrateBlockstateProvider(com.tterrag.registrate.providers.RegistrateBlockstateProvider) DataIngredient(com.tterrag.registrate.util.DataIngredient) Blocks(net.minecraft.world.level.block.Blocks) Objects(java.util.Objects) AbstractRegistrate(com.tterrag.registrate.AbstractRegistrate) NonNullBiConsumer(com.tterrag.registrate.util.nullness.NonNullBiConsumer) Block(net.minecraft.world.level.block.Block) StairBlock(net.minecraft.world.level.block.StairBlock) ModelProvider(net.minecraftforge.client.model.generators.ModelProvider) ResourceLocation(net.minecraft.resources.ResourceLocation) WeatheringCopperSlabBlock(net.minecraft.world.level.block.WeatheringCopperSlabBlock) SlabBlock(net.minecraft.world.level.block.SlabBlock) WeatheringCopperStairBlock(net.minecraft.world.level.block.WeatheringCopperStairBlock) WeatheringCopperFullBlock(net.minecraft.world.level.block.WeatheringCopperFullBlock) Block(net.minecraft.world.level.block.Block) StairBlock(net.minecraft.world.level.block.StairBlock)

Aggregations

AllTags (com.simibubi.create.AllTags)1 Iterate (com.simibubi.create.foundation.utility.Iterate)1 Lang (com.simibubi.create.foundation.utility.Lang)1 AbstractRegistrate (com.tterrag.registrate.AbstractRegistrate)1 BlockBuilder (com.tterrag.registrate.builders.BlockBuilder)1 DataGenContext (com.tterrag.registrate.providers.DataGenContext)1 RegistrateBlockstateProvider (com.tterrag.registrate.providers.RegistrateBlockstateProvider)1 RegistrateRecipeProvider (com.tterrag.registrate.providers.RegistrateRecipeProvider)1 RegistrateBlockLootTables (com.tterrag.registrate.providers.loot.RegistrateBlockLootTables)1 DataIngredient (com.tterrag.registrate.util.DataIngredient)1 BlockEntry (com.tterrag.registrate.util.entry.BlockEntry)1 NonNullBiConsumer (com.tterrag.registrate.util.nullness.NonNullBiConsumer)1 NonNullFunction (com.tterrag.registrate.util.nullness.NonNullFunction)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Supplier (java.util.function.Supplier)1 ShapelessRecipeBuilder (net.minecraft.data.recipes.ShapelessRecipeBuilder)1