Search in sources :

Example 1 with BlockBuilder

use of com.tterrag.registrate.builders.BlockBuilder 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)

Example 2 with BlockBuilder

use of com.tterrag.registrate.builders.BlockBuilder in project Create by Creators-of-Create.

the class BuilderTransformers method bearing.

public static <B extends Block, P> NonNullUnaryOperator<BlockBuilder<B, P>> bearing(String prefix, String backTexture, boolean woodenTop) {
    ResourceLocation baseBlockModelLocation = Create.asResource("block/bearing/block");
    ResourceLocation baseItemModelLocation = Create.asResource("block/bearing/item");
    ResourceLocation topTextureLocation = Create.asResource("block/bearing_top" + (woodenTop ? "_wooden" : ""));
    ResourceLocation nookTextureLocation = Create.asResource("block/" + (woodenTop ? "andesite" : "brass") + "_casing");
    ResourceLocation sideTextureLocation = Create.asResource("block/" + prefix + "_bearing_side");
    ResourceLocation backTextureLocation = Create.asResource("block/" + backTexture);
    return b -> b.initialProperties(SharedProperties::stone).properties(p -> p.noOcclusion()).blockstate((c, p) -> p.directionalBlock(c.get(), p.models().withExistingParent(c.getName(), baseBlockModelLocation).texture("side", sideTextureLocation).texture("nook", nookTextureLocation).texture("back", backTextureLocation))).item().model((c, p) -> p.withExistingParent(c.getName(), baseItemModelLocation).texture("top", topTextureLocation).texture("side", sideTextureLocation).texture("back", backTextureLocation)).build();
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) DyeColor(net.minecraft.world.item.DyeColor) PistonType(net.minecraft.world.level.block.state.properties.PistonType) AllTags.axeOrPickaxe(com.simibubi.create.AllTags.axeOrPickaxe) EncasedCTBehaviour(com.simibubi.create.content.contraptions.relays.encased.EncasedCTBehaviour) ModelFile(net.minecraftforge.client.model.generators.ModelFile) ItemUseOverrides(com.simibubi.create.foundation.block.ItemUseOverrides) BlockBuilder(com.tterrag.registrate.builders.BlockBuilder) HashMap(java.util.HashMap) Supplier(java.util.function.Supplier) EncasedCogCTBehaviour(com.simibubi.create.content.contraptions.relays.encased.EncasedCogCTBehaviour) BlockStressDefaults(com.simibubi.create.foundation.block.BlockStressDefaults) AllTags.pickaxeOnly(com.simibubi.create.AllTags.pickaxeOnly) Axis(net.minecraft.core.Direction.Axis) AxisDirection(net.minecraft.core.Direction.AxisDirection) CreateRegistrate.connectedTextures(com.simibubi.create.foundation.data.CreateRegistrate.connectedTextures) Create(com.simibubi.create.Create) ItemLike(net.minecraft.world.level.ItemLike) Map(java.util.Map) AllItemTags(com.simibubi.create.AllTags.AllItemTags) CreateRegistrate.casingConnectivity(com.simibubi.create.foundation.data.CreateRegistrate.casingConnectivity) EncasedCogwheelBlock(com.simibubi.create.content.contraptions.relays.encased.EncasedCogwheelBlock) AllBlocks(com.simibubi.create.AllBlocks) Nullable(javax.annotation.Nullable) BlockBehaviour(net.minecraft.world.level.block.state.BlockBehaviour) BlockStateProperties(net.minecraft.world.level.block.state.properties.BlockStateProperties) BeltTunnelBlock(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock) EncasedShaftBlock(com.simibubi.create.content.contraptions.relays.encased.EncasedShaftBlock) RenderType(net.minecraft.client.renderer.RenderType) Shape(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.Shape) SoundType(net.minecraft.world.level.block.SoundType) MechanicalPistonGenerator(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonGenerator) CasingBlock(com.simibubi.create.content.contraptions.base.CasingBlock) CTSpriteShiftEntry(com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry) ConfiguredModel(net.minecraftforge.client.model.generators.ConfiguredModel) NonNullUnaryOperator(com.tterrag.registrate.util.nullness.NonNullUnaryOperator) ValveHandleBlock(com.simibubi.create.content.contraptions.components.crank.ValveHandleBlock) Block(net.minecraft.world.level.block.Block) BlockStateGen.axisBlock(com.simibubi.create.foundation.data.BlockStateGen.axisBlock) RotatedPillarKineticBlock(com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock) AllBlockTags(com.simibubi.create.AllTags.AllBlockTags) BeltTunnelItem(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelItem) Rarity(net.minecraft.world.item.Rarity) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 3 with BlockBuilder

use of com.tterrag.registrate.builders.BlockBuilder in project Create by Creators-of-Create.

the class BuilderTransformers method beltTunnel.

public static <B extends BeltTunnelBlock> NonNullUnaryOperator<BlockBuilder<B, CreateRegistrate>> beltTunnel(String type, ResourceLocation particleTexture) {
    return b -> b.initialProperties(SharedProperties::stone).addLayer(() -> RenderType::cutoutMipped).properties(BlockBehaviour.Properties::noOcclusion).transform(pickaxeOnly()).blockstate((c, p) -> p.getVariantBuilder(c.get()).forAllStates(state -> {
        String id = "block/" + type + "_tunnel";
        Shape shape = state.getValue(BeltTunnelBlock.SHAPE);
        if (shape == BeltTunnelBlock.Shape.CLOSED)
            shape = BeltTunnelBlock.Shape.STRAIGHT;
        String shapeName = shape.getSerializedName();
        return ConfiguredModel.builder().modelFile(p.models().withExistingParent(id + "/" + shapeName, p.modLoc("block/belt_tunnel/" + shapeName)).texture("1", p.modLoc(id + "_top")).texture("2", p.modLoc(id)).texture("3", p.modLoc(id + "_top_window")).texture("particle", particleTexture)).rotationY(state.getValue(BeltTunnelBlock.HORIZONTAL_AXIS) == Axis.X ? 0 : 90).build();
    })).item(BeltTunnelItem::new).model((c, p) -> {
        String id = type + "_tunnel";
        p.withExistingParent("item/" + id, p.modLoc("block/belt_tunnel/item")).texture("1", p.modLoc("block/" + id + "_top")).texture("2", p.modLoc("block/" + id)).texture("particle", particleTexture);
    }).build();
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) DyeColor(net.minecraft.world.item.DyeColor) PistonType(net.minecraft.world.level.block.state.properties.PistonType) AllTags.axeOrPickaxe(com.simibubi.create.AllTags.axeOrPickaxe) EncasedCTBehaviour(com.simibubi.create.content.contraptions.relays.encased.EncasedCTBehaviour) ModelFile(net.minecraftforge.client.model.generators.ModelFile) ItemUseOverrides(com.simibubi.create.foundation.block.ItemUseOverrides) BlockBuilder(com.tterrag.registrate.builders.BlockBuilder) HashMap(java.util.HashMap) Supplier(java.util.function.Supplier) EncasedCogCTBehaviour(com.simibubi.create.content.contraptions.relays.encased.EncasedCogCTBehaviour) BlockStressDefaults(com.simibubi.create.foundation.block.BlockStressDefaults) AllTags.pickaxeOnly(com.simibubi.create.AllTags.pickaxeOnly) Axis(net.minecraft.core.Direction.Axis) AxisDirection(net.minecraft.core.Direction.AxisDirection) CreateRegistrate.connectedTextures(com.simibubi.create.foundation.data.CreateRegistrate.connectedTextures) Create(com.simibubi.create.Create) ItemLike(net.minecraft.world.level.ItemLike) Map(java.util.Map) AllItemTags(com.simibubi.create.AllTags.AllItemTags) CreateRegistrate.casingConnectivity(com.simibubi.create.foundation.data.CreateRegistrate.casingConnectivity) EncasedCogwheelBlock(com.simibubi.create.content.contraptions.relays.encased.EncasedCogwheelBlock) AllBlocks(com.simibubi.create.AllBlocks) Nullable(javax.annotation.Nullable) BlockBehaviour(net.minecraft.world.level.block.state.BlockBehaviour) BlockStateProperties(net.minecraft.world.level.block.state.properties.BlockStateProperties) BeltTunnelBlock(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock) EncasedShaftBlock(com.simibubi.create.content.contraptions.relays.encased.EncasedShaftBlock) RenderType(net.minecraft.client.renderer.RenderType) Shape(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.Shape) SoundType(net.minecraft.world.level.block.SoundType) MechanicalPistonGenerator(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonGenerator) CasingBlock(com.simibubi.create.content.contraptions.base.CasingBlock) CTSpriteShiftEntry(com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry) ConfiguredModel(net.minecraftforge.client.model.generators.ConfiguredModel) NonNullUnaryOperator(com.tterrag.registrate.util.nullness.NonNullUnaryOperator) ValveHandleBlock(com.simibubi.create.content.contraptions.components.crank.ValveHandleBlock) Block(net.minecraft.world.level.block.Block) BlockStateGen.axisBlock(com.simibubi.create.foundation.data.BlockStateGen.axisBlock) RotatedPillarKineticBlock(com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock) AllBlockTags(com.simibubi.create.AllTags.AllBlockTags) BeltTunnelItem(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelItem) Rarity(net.minecraft.world.item.Rarity) Shape(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.Shape) BlockBehaviour(net.minecraft.world.level.block.state.BlockBehaviour) BeltTunnelItem(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelItem) RenderType(net.minecraft.client.renderer.RenderType)

Aggregations

BlockBuilder (com.tterrag.registrate.builders.BlockBuilder)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Supplier (java.util.function.Supplier)3 ResourceLocation (net.minecraft.resources.ResourceLocation)3 Block (net.minecraft.world.level.block.Block)3 AllBlocks (com.simibubi.create.AllBlocks)2 AllBlockTags (com.simibubi.create.AllTags.AllBlockTags)2 AllItemTags (com.simibubi.create.AllTags.AllItemTags)2 AllTags.axeOrPickaxe (com.simibubi.create.AllTags.axeOrPickaxe)2 AllTags.pickaxeOnly (com.simibubi.create.AllTags.pickaxeOnly)2 Create (com.simibubi.create.Create)2 CasingBlock (com.simibubi.create.content.contraptions.base.CasingBlock)2 RotatedPillarKineticBlock (com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock)2 ValveHandleBlock (com.simibubi.create.content.contraptions.components.crank.ValveHandleBlock)2 MechanicalPistonGenerator (com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonGenerator)2 EncasedCTBehaviour (com.simibubi.create.content.contraptions.relays.encased.EncasedCTBehaviour)2 EncasedCogCTBehaviour (com.simibubi.create.content.contraptions.relays.encased.EncasedCogCTBehaviour)2 EncasedCogwheelBlock (com.simibubi.create.content.contraptions.relays.encased.EncasedCogwheelBlock)2 EncasedShaftBlock (com.simibubi.create.content.contraptions.relays.encased.EncasedShaftBlock)2