Search in sources :

Example 6 with FlywheelTileEntity

use of com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity in project SteamPowered by TeamMoegMC.

the class CastIronFlywheelRenderer method renderSafe.

protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
    super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
    if (!Backend.getInstance().canUseInstancing(te.getLevel())) {
        BlockState blockState = te.getBlockState();
        FlywheelTileEntity wte = (FlywheelTileEntity) te;
        // Mixin starts
        FlywheelTileEntityAccess access = (FlywheelTileEntityAccess) wte;
        float speed = access.getVisualSpeed().get(partialTicks) * 3.0F / 10.0F;
        float angle = access.getAngle() + speed * partialTicks;
        // Mixin ends
        IVertexBuilder vb = buffer.getBuffer(RenderType.solid());
        if (FlywheelBlock.isConnected(blockState)) {
            Direction connection = FlywheelBlock.getConnection(blockState);
            light = WorldRenderer.getLightColor(te.getLevel(), blockState, te.getBlockPos().relative(connection));
            float rotation = connection.getAxis() == Direction.Axis.X ^ connection.getAxisDirection() == Direction.AxisDirection.NEGATIVE ? -angle : angle;
            boolean flip = blockState.getValue(FlywheelBlock.CONNECTION) == FlywheelBlock.ConnectionState.LEFT;
            this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.CAST_IRON_FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true, rotation, flip).light(light).renderInto(ms, vb);
            this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.CAST_IRON_FLYWHEEL_LOWER_ROTATING, blockState), connection), false, true, rotation, flip).light(light).renderInto(ms, vb);
            this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.CAST_IRON_FLYWHEEL_UPPER_SLIDING, blockState), connection), true, false, rotation, flip).light(light).renderInto(ms, vb);
            this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.CAST_IRON_FLYWHEEL_LOWER_SLIDING, blockState), connection), false, false, rotation, flip).light(light).renderInto(ms, vb);
        }
        this.renderFlywheel(te, ms, light, blockState, angle, vb);
    }
}
Also used : FlywheelTileEntityAccess(com.teammoeg.steampowered.mixin.FlywheelTileEntityAccess) BlockState(net.minecraft.block.BlockState) FlywheelTileEntity(com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity) Direction(net.minecraft.util.Direction) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

Aggregations

FlywheelTileEntity (com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity)6 BlockState (net.minecraft.block.BlockState)4 Direction (net.minecraft.util.Direction)4 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)3 FlywheelTileEntityAccess (com.teammoeg.steampowered.mixin.FlywheelTileEntityAccess)3 KineticTileEntity (com.simibubi.create.content.contraptions.base.KineticTileEntity)1 EngineTileEntity (com.simibubi.create.content.contraptions.components.flywheel.engine.EngineTileEntity)1 BlockPos (net.minecraft.core.BlockPos)1 Direction (net.minecraft.core.Direction)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)1 BlockState (net.minecraft.world.level.block.state.BlockState)1