Search in sources :

Example 1 with DataGenContext

use of com.tterrag.registrate.providers.DataGenContext in project Create by Creators-of-Create.

the class BlockStateGen method cartAssembler.

public static NonNullBiConsumer<DataGenContext<Block, CartAssemblerBlock>, RegistrateBlockstateProvider> cartAssembler() {
    return (c, p) -> p.getVariantBuilder(c.get()).forAllStates(state -> {
        CartAssembleRailType type = state.getValue(CartAssemblerBlock.RAIL_TYPE);
        Boolean powered = state.getValue(CartAssemblerBlock.POWERED);
        Boolean backwards = state.getValue(CartAssemblerBlock.BACKWARDS);
        RailShape shape = state.getValue(CartAssemblerBlock.RAIL_SHAPE);
        int yRotation = shape == RailShape.EAST_WEST ? 270 : 0;
        if (backwards)
            yRotation += 180;
        return ConfiguredModel.builder().modelFile(p.models().getExistingFile(p.modLoc("block/" + c.getName() + "/block_" + type.getSerializedName() + (powered ? "_powered" : "")))).rotationY(yRotation % 360).build();
    });
}
Also used : RadialChassisBlock(com.simibubi.create.content.contraptions.components.structureMovement.chassis.RadialChassisBlock) ResourceLocation(net.minecraft.resources.ResourceLocation) MultiPartBlockStateBuilder(net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder) Direction(net.minecraft.core.Direction) ModelFile(net.minecraftforge.client.model.generators.ModelFile) BiFunction(java.util.function.BiFunction) Pointing(com.simibubi.create.foundation.utility.Pointing) BlockState(net.minecraft.world.level.block.state.BlockState) HashMap(java.util.HashMap) EncasedPipeBlock(com.simibubi.create.content.contraptions.fluids.pipes.EncasedPipeBlock) Function(java.util.function.Function) LinearChassisBlock(com.simibubi.create.content.contraptions.components.structureMovement.chassis.LinearChassisBlock) CartAssemblerBlock(com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerBlock) Axis(net.minecraft.core.Direction.Axis) BooleanProperty(net.minecraft.world.level.block.state.properties.BooleanProperty) AxisDirection(net.minecraft.core.Direction.AxisDirection) Vector(java.util.Vector) Pair(org.apache.commons.lang3.tuple.Pair) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) FluidPipeBlock(com.simibubi.create.content.contraptions.fluids.pipes.FluidPipeBlock) DataGenContext(com.tterrag.registrate.providers.DataGenContext) BlockStateProperties(net.minecraft.world.level.block.state.properties.BlockStateProperties) IdentityHashMap(java.util.IdentityHashMap) Iterate(com.simibubi.create.foundation.utility.Iterate) ImmutableMap(com.google.common.collect.ImmutableMap) BlazeBurnerBlock(com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock) RegistrateBlockstateProvider(com.tterrag.registrate.providers.RegistrateBlockstateProvider) RailShape(net.minecraft.world.level.block.state.properties.RailShape) List(java.util.List) NonNullBiConsumer(com.tterrag.registrate.util.nullness.NonNullBiConsumer) ConfiguredModel(net.minecraftforge.client.model.generators.ConfiguredModel) DirectionalAxisKineticBlock(com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock) Block(net.minecraft.world.level.block.Block) CartAssembleRailType(com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssembleRailType) RailShape(net.minecraft.world.level.block.state.properties.RailShape) CartAssembleRailType(com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssembleRailType)

Example 2 with DataGenContext

use of com.tterrag.registrate.providers.DataGenContext in project Create by Creators-of-Create.

the class BlockStateGen method encasedPipe.

public static <P extends EncasedPipeBlock> NonNullBiConsumer<DataGenContext<Block, P>, RegistrateBlockstateProvider> encasedPipe() {
    return (c, p) -> {
        ModelFile open = AssetLookup.partialBaseModel(c, p, "open");
        ModelFile flat = AssetLookup.partialBaseModel(c, p, "flat");
        MultiPartBlockStateBuilder builder = p.getMultipartBuilder(c.get());
        for (boolean flatPass : Iterate.trueAndFalse) for (Direction d : Iterate.directions) {
            int verticalAngle = d == Direction.UP ? 90 : d == Direction.DOWN ? -90 : 0;
            builder.part().modelFile(flatPass ? flat : open).rotationX(verticalAngle).rotationY((int) (d.toYRot() + (d.getAxis().isVertical() ? 90 : 0)) % 360).addModel().condition(EncasedPipeBlock.FACING_TO_PROPERTY_MAP.get(d), !flatPass).end();
        }
    };
}
Also used : RadialChassisBlock(com.simibubi.create.content.contraptions.components.structureMovement.chassis.RadialChassisBlock) ResourceLocation(net.minecraft.resources.ResourceLocation) MultiPartBlockStateBuilder(net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder) Direction(net.minecraft.core.Direction) ModelFile(net.minecraftforge.client.model.generators.ModelFile) BiFunction(java.util.function.BiFunction) Pointing(com.simibubi.create.foundation.utility.Pointing) BlockState(net.minecraft.world.level.block.state.BlockState) HashMap(java.util.HashMap) EncasedPipeBlock(com.simibubi.create.content.contraptions.fluids.pipes.EncasedPipeBlock) Function(java.util.function.Function) LinearChassisBlock(com.simibubi.create.content.contraptions.components.structureMovement.chassis.LinearChassisBlock) CartAssemblerBlock(com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerBlock) Axis(net.minecraft.core.Direction.Axis) BooleanProperty(net.minecraft.world.level.block.state.properties.BooleanProperty) AxisDirection(net.minecraft.core.Direction.AxisDirection) Vector(java.util.Vector) Pair(org.apache.commons.lang3.tuple.Pair) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) FluidPipeBlock(com.simibubi.create.content.contraptions.fluids.pipes.FluidPipeBlock) DataGenContext(com.tterrag.registrate.providers.DataGenContext) BlockStateProperties(net.minecraft.world.level.block.state.properties.BlockStateProperties) IdentityHashMap(java.util.IdentityHashMap) Iterate(com.simibubi.create.foundation.utility.Iterate) ImmutableMap(com.google.common.collect.ImmutableMap) BlazeBurnerBlock(com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock) RegistrateBlockstateProvider(com.tterrag.registrate.providers.RegistrateBlockstateProvider) RailShape(net.minecraft.world.level.block.state.properties.RailShape) List(java.util.List) NonNullBiConsumer(com.tterrag.registrate.util.nullness.NonNullBiConsumer) ConfiguredModel(net.minecraftforge.client.model.generators.ConfiguredModel) DirectionalAxisKineticBlock(com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock) Block(net.minecraft.world.level.block.Block) CartAssembleRailType(com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssembleRailType) MultiPartBlockStateBuilder(net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder) ModelFile(net.minecraftforge.client.model.generators.ModelFile) Direction(net.minecraft.core.Direction) AxisDirection(net.minecraft.core.Direction.AxisDirection)

Example 3 with DataGenContext

use of com.tterrag.registrate.providers.DataGenContext in project Create by Creators-of-Create.

the class WindowGen method connectedGlassPane.

private static BlockEntry<ConnectedGlassPaneBlock> connectedGlassPane(String name, Supplier<? extends Block> parent, Supplier<CTSpriteShiftEntry> ctshift, ResourceLocation sideTexture, ResourceLocation itemSideTexture, ResourceLocation topTexture, Supplier<Supplier<RenderType>> renderType) {
    NonNullConsumer<? super ConnectedGlassPaneBlock> connectedTextures = connectedTextures(() -> new GlassPaneCTBehaviour(ctshift.get()));
    String CGPparents = "block/connected_glass_pane/";
    String prefix = name + "_pane_";
    Function<RegistrateBlockstateProvider, ModelFile> post = getPaneModelProvider(CGPparents, prefix, "post", sideTexture, topTexture), side = getPaneModelProvider(CGPparents, prefix, "side", sideTexture, topTexture), sideAlt = getPaneModelProvider(CGPparents, prefix, "side_alt", sideTexture, topTexture), noSide = getPaneModelProvider(CGPparents, prefix, "noside", sideTexture, topTexture), noSideAlt = getPaneModelProvider(CGPparents, prefix, "noside_alt", sideTexture, topTexture);
    NonNullBiConsumer<DataGenContext<Block, ConnectedGlassPaneBlock>, RegistrateBlockstateProvider> stateProvider = (c, p) -> p.paneBlock(c.get(), post.apply(p), side.apply(p), sideAlt.apply(p), noSide.apply(p), noSideAlt.apply(p));
    return glassPane(name, parent, itemSideTexture, topTexture, ConnectedGlassPaneBlock::new, renderType, connectedTextures, stateProvider);
}
Also used : HorizontalCTBehaviour(com.simibubi.create.foundation.block.connected.HorizontalCTBehaviour) BlockEntry(com.tterrag.registrate.util.entry.BlockEntry) ResourceLocation(net.minecraft.resources.ResourceLocation) Tags(net.minecraftforge.common.Tags) ShapedRecipeBuilder(net.minecraft.data.recipes.ShapedRecipeBuilder) EntityType(net.minecraft.world.entity.EntityType) ModelFile(net.minecraftforge.client.model.generators.ModelFile) BlockState(net.minecraft.world.level.block.state.BlockState) ConnectedGlassBlock(com.simibubi.create.content.palettes.ConnectedGlassBlock) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Properties(net.minecraft.world.level.block.state.BlockBehaviour.Properties) RegistrateRecipeProvider(com.tterrag.registrate.providers.RegistrateRecipeProvider) BlockGetter(net.minecraft.world.level.BlockGetter) ConnectedGlassPaneBlock(com.simibubi.create.content.palettes.ConnectedGlassPaneBlock) CreateRegistrate.connectedTextures(com.simibubi.create.foundation.data.CreateRegistrate.connectedTextures) Create(com.simibubi.create.Create) ItemLike(net.minecraft.world.level.ItemLike) BlockTags(net.minecraft.tags.BlockTags) AllSpriteShifts(com.simibubi.create.AllSpriteShifts) NonNullFunction(com.tterrag.registrate.util.nullness.NonNullFunction) DataGenContext(com.tterrag.registrate.providers.DataGenContext) WindowBlock(com.simibubi.create.content.palettes.WindowBlock) RenderType(net.minecraft.client.renderer.RenderType) RegistrateBlockstateProvider(com.tterrag.registrate.providers.RegistrateBlockstateProvider) DataIngredient(com.tterrag.registrate.util.DataIngredient) NonNullConsumer(com.tterrag.registrate.util.nullness.NonNullConsumer) Blocks(net.minecraft.world.level.block.Blocks) ConnectedTextureBehaviour(com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour) CTSpriteShiftEntry(com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry) NonNullBiConsumer(com.tterrag.registrate.util.nullness.NonNullBiConsumer) BlockPos(net.minecraft.core.BlockPos) Block(net.minecraft.world.level.block.Block) WoodType(net.minecraft.world.level.block.state.properties.WoodType) GlassPaneCTBehaviour(com.simibubi.create.foundation.block.connected.GlassPaneCTBehaviour) GlassPaneBlock(com.simibubi.create.content.palettes.GlassPaneBlock) GlassPaneCTBehaviour(com.simibubi.create.foundation.block.connected.GlassPaneCTBehaviour) ModelFile(net.minecraftforge.client.model.generators.ModelFile) RegistrateBlockstateProvider(com.tterrag.registrate.providers.RegistrateBlockstateProvider) DataGenContext(com.tterrag.registrate.providers.DataGenContext) ConnectedGlassPaneBlock(com.simibubi.create.content.palettes.ConnectedGlassPaneBlock)

Aggregations

DataGenContext (com.tterrag.registrate.providers.DataGenContext)3 RegistrateBlockstateProvider (com.tterrag.registrate.providers.RegistrateBlockstateProvider)3 NonNullBiConsumer (com.tterrag.registrate.util.nullness.NonNullBiConsumer)3 Function (java.util.function.Function)3 ResourceLocation (net.minecraft.resources.ResourceLocation)3 Block (net.minecraft.world.level.block.Block)3 BlockState (net.minecraft.world.level.block.state.BlockState)3 ModelFile (net.minecraftforge.client.model.generators.ModelFile)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 DirectionalAxisKineticBlock (com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock)2 LinearChassisBlock (com.simibubi.create.content.contraptions.components.structureMovement.chassis.LinearChassisBlock)2 RadialChassisBlock (com.simibubi.create.content.contraptions.components.structureMovement.chassis.RadialChassisBlock)2 CartAssembleRailType (com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssembleRailType)2 CartAssemblerBlock (com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerBlock)2 EncasedPipeBlock (com.simibubi.create.content.contraptions.fluids.pipes.EncasedPipeBlock)2 FluidPipeBlock (com.simibubi.create.content.contraptions.fluids.pipes.FluidPipeBlock)2 BlazeBurnerBlock (com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock)2 Iterate (com.simibubi.create.foundation.utility.Iterate)2 Pointing (com.simibubi.create.foundation.utility.Pointing)2