Search in sources :

Example 11 with PartialModel

use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.

the class HandCrankRenderer method renderSafe.

@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
    if (Backend.canUseInstancing(te.getLevel()))
        return;
    BlockState state = te.getBlockState();
    Block block = state.getBlock();
    PartialModel renderedHandle = null;
    if (block instanceof HandCrankBlock)
        renderedHandle = ((HandCrankBlock) block).getRenderedHandle();
    if (renderedHandle == null)
        return;
    Direction facing = state.getValue(FACING);
    SuperByteBuffer handle = CachedBufferer.partialFacing(renderedHandle, state, facing.getOpposite());
    HandCrankTileEntity crank = (HandCrankTileEntity) te;
    kineticRotationTransform(handle, te, facing.getAxis(), (crank.independentAngle + partialTicks * crank.chasingVelocity) / 360, light);
    handle.renderInto(ms, buffer.getBuffer(RenderType.solid()));
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) Block(net.minecraft.world.level.block.Block) Direction(net.minecraft.core.Direction) PartialModel(com.jozufozu.flywheel.core.PartialModel)

Example 12 with PartialModel

use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.

the class SawRenderer method renderBlade.

protected void renderBlade(SawTileEntity te, PoseStack ms, MultiBufferSource buffer, int light) {
    BlockState blockState = te.getBlockState();
    PartialModel partial;
    float speed = te.getSpeed();
    boolean rotate = false;
    if (SawBlock.isHorizontal(blockState)) {
        if (speed > 0) {
            partial = AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE;
        } else if (speed < 0) {
            partial = AllBlockPartials.SAW_BLADE_HORIZONTAL_REVERSED;
        } else {
            partial = AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE;
        }
    } else {
        if (te.getSpeed() > 0) {
            partial = AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE;
        } else if (speed < 0) {
            partial = AllBlockPartials.SAW_BLADE_VERTICAL_REVERSED;
        } else {
            partial = AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE;
        }
        if (blockState.getValue(SawBlock.AXIS_ALONG_FIRST_COORDINATE))
            rotate = true;
    }
    SuperByteBuffer superBuffer = CachedBufferer.partialFacing(partial, blockState);
    if (rotate) {
        superBuffer.rotateCentered(Direction.UP, AngleHelper.rad(90));
    }
    superBuffer.color(0xFFFFFF).light(light).renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped()));
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) PartialModel(com.jozufozu.flywheel.core.PartialModel)

Example 13 with PartialModel

use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.

the class EngineRenderer method renderSafe.

@Override
protected void renderSafe(T te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    if (Backend.canUseInstancing(te.getLevel()))
        return;
    Block block = te.getBlockState().getBlock();
    if (block instanceof EngineBlock) {
        EngineBlock engineBlock = (EngineBlock) block;
        PartialModel frame = engineBlock.getFrameModel();
        if (frame != null) {
            Direction facing = te.getBlockState().getValue(EngineBlock.FACING);
            float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing));
            CachedBufferer.partial(frame, te.getBlockState()).rotateCentered(Direction.UP, angle).translate(0, 0, -1).light(light).renderInto(ms, buffer.getBuffer(RenderType.solid()));
        }
    }
}
Also used : Block(net.minecraft.world.level.block.Block) Direction(net.minecraft.core.Direction) PartialModel(com.jozufozu.flywheel.core.PartialModel)

Example 14 with PartialModel

use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.

the class BlazeBurnerRenderer method renderSafe.

@Override
protected void renderSafe(BlazeBurnerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    HeatLevel heatLevel = te.getHeatLevelFromBlock();
    if (heatLevel == HeatLevel.NONE)
        return;
    float renderTick = AnimationTickHolder.getRenderTime(te.getLevel()) + (te.hashCode() % 13) * 16f;
    float offset = (Mth.sin((float) ((renderTick / 16f) % (2 * Math.PI))) + .5f) / 16f;
    PartialModel blazeModel = AllBlockPartials.BLAZES.get(heatLevel);
    SuperByteBuffer blazeBuffer = CachedBufferer.partial(blazeModel, te.getBlockState());
    blazeBuffer.rotateCentered(Direction.UP, AngleHelper.rad(te.headAngle.getValue(partialTicks)));
    blazeBuffer.translate(0, offset, 0);
    blazeBuffer.light(LightTexture.FULL_BRIGHT).renderInto(ms, buffer.getBuffer(RenderType.solid()));
}
Also used : SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) HeatLevel(com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel) PartialModel(com.jozufozu.flywheel.core.PartialModel)

Example 15 with PartialModel

use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.

the class CuckooClockRenderer method renderSafe.

@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
    if (!(te instanceof CuckooClockTileEntity))
        return;
    CuckooClockTileEntity clock = (CuckooClockTileEntity) te;
    BlockState blockState = te.getBlockState();
    Direction direction = blockState.getValue(CuckooClockBlock.HORIZONTAL_FACING);
    VertexConsumer vb = buffer.getBuffer(RenderType.solid());
    // Render Hands
    SuperByteBuffer hourHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_HOUR_HAND, blockState);
    SuperByteBuffer minuteHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState);
    float hourAngle = clock.hourHand.get(partialTicks);
    float minuteAngle = clock.minuteHand.get(partialTicks);
    rotateHand(hourHand, hourAngle, direction).light(light).renderInto(ms, vb);
    rotateHand(minuteHand, minuteAngle, direction).light(light).renderInto(ms, vb);
    // Doors
    SuperByteBuffer leftDoor = CachedBufferer.partial(AllBlockPartials.CUCKOO_LEFT_DOOR, blockState);
    SuperByteBuffer rightDoor = CachedBufferer.partial(AllBlockPartials.CUCKOO_RIGHT_DOOR, blockState);
    float angle = 0;
    float offset = 0;
    if (clock.animationType != null) {
        float value = clock.animationProgress.get(partialTicks);
        int step = clock.animationType == Animation.SURPRISE ? 3 : 15;
        for (int phase = 30; phase <= 60; phase += step) {
            float local = value - phase;
            if (local < -step / 3)
                continue;
            else if (local < 0)
                angle = Mth.lerp(((value - (phase - 5)) / 5), 0, 135);
            else if (local < step / 3)
                angle = 135;
            else if (local < 2 * step / 3)
                angle = Mth.lerp(((value - (phase + 5)) / 5), 135, 0);
        }
    }
    rotateDoor(leftDoor, angle, true, direction).light(light).renderInto(ms, vb);
    rotateDoor(rightDoor, angle, false, direction).light(light).renderInto(ms, vb);
    // Figure
    if (clock.animationType != Animation.NONE) {
        offset = -(angle / 135) * 1 / 2f + 10 / 16f;
        PartialModel partialModel = (clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER);
        SuperByteBuffer figure = CachedBufferer.partial(partialModel, blockState);
        figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.getCounterClockWise())));
        figure.translate(offset, 0, 0);
        figure.light(light).renderInto(ms, vb);
    }
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) VertexConsumer(com.mojang.blaze3d.vertex.VertexConsumer) Direction(net.minecraft.core.Direction) PartialModel(com.jozufozu.flywheel.core.PartialModel)

Aggregations

PartialModel (com.jozufozu.flywheel.core.PartialModel)17 SuperByteBuffer (com.simibubi.create.foundation.render.SuperByteBuffer)11 Direction (net.minecraft.core.Direction)8 BlockState (net.minecraft.world.level.block.state.BlockState)8 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)5 PoseStack (com.mojang.blaze3d.vertex.PoseStack)4 TransformStack (com.jozufozu.flywheel.util.transform.TransformStack)2 AxisDirection (net.minecraft.core.Direction.AxisDirection)2 Block (net.minecraft.world.level.block.Block)2 Vec3 (net.minecraft.world.phys.Vec3)2 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)2 Matrix3f (com.mojang.math.Matrix3f)1 Quaternion (com.mojang.math.Quaternion)1 IRotate (com.simibubi.create.content.contraptions.base.IRotate)1 Mode (com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode)1 HeatLevel (com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel)1 BlueprintSection (com.simibubi.create.content.curiosities.tools.BlueprintEntity.BlueprintSection)1 SpriteShiftEntry (com.simibubi.create.foundation.block.render.SpriteShiftEntry)1 SmartFluidTankBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour)1 TankSegment (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment)1