Search in sources :

Example 1 with FlywheelTileEntity

use of com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity in project Create by Creators-of-Create.

the class EngineTileEntity method attachWheel.

public void attachWheel() {
    Direction engineFacing = getBlockState().getValue(EngineBlock.FACING);
    BlockPos wheelPos = worldPosition.relative(engineFacing, 2);
    BlockState wheelState = level.getBlockState(wheelPos);
    if (!AllBlocks.FLYWHEEL.has(wheelState))
        return;
    Direction wheelFacing = wheelState.getValue(FlywheelBlock.HORIZONTAL_FACING);
    if (wheelFacing.getAxis() != engineFacing.getClockWise().getAxis())
        return;
    if (FlywheelBlock.isConnected(wheelState) && FlywheelBlock.getConnection(wheelState) != engineFacing.getOpposite())
        return;
    BlockEntity te = level.getBlockEntity(wheelPos);
    if (te.isRemoved())
        return;
    if (te instanceof FlywheelTileEntity) {
        if (!FlywheelBlock.isConnected(wheelState))
            FlywheelBlock.setConnection(level, te.getBlockPos(), te.getBlockState(), engineFacing.getOpposite());
        poweredWheel = (FlywheelTileEntity) te;
        refreshWheelSpeed();
    }
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) FlywheelTileEntity(com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity) BlockPos(net.minecraft.core.BlockPos) Direction(net.minecraft.core.Direction) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 2 with FlywheelTileEntity

use of com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity in project Create by Creators-of-Create.

the class KineticNetwork method calculateCapacity.

public float calculateCapacity() {
    float presentCapacity = 0;
    containsFlywheel = false;
    for (Iterator<KineticTileEntity> iterator = sources.keySet().iterator(); iterator.hasNext(); ) {
        KineticTileEntity te = iterator.next();
        if (te.getLevel().getBlockEntity(te.getBlockPos()) != te) {
            iterator.remove();
            continue;
        }
        containsFlywheel |= te instanceof FlywheelTileEntity;
        presentCapacity += getActualCapacityOf(te);
    }
    float newMaxStress = presentCapacity + unloadedCapacity;
    return newMaxStress;
}
Also used : KineticTileEntity(com.simibubi.create.content.contraptions.base.KineticTileEntity) FlywheelTileEntity(com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity)

Example 3 with FlywheelTileEntity

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

the class SteelFlywheelRenderer 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.STEEL_FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true, rotation, flip).light(light).renderInto(ms, vb);
            this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.STEEL_FLYWHEEL_LOWER_ROTATING, blockState), connection), false, true, rotation, flip).light(light).renderInto(ms, vb);
            this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.STEEL_FLYWHEEL_UPPER_SLIDING, blockState), connection), true, false, rotation, flip).light(light).renderInto(ms, vb);
            this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.STEEL_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)

Example 4 with FlywheelTileEntity

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

the class SteamEngineTileEntity method attachWheel.

public void attachWheel() {
    Direction engineFacing = this.getBlockState().getValue(EngineBlock.FACING);
    BlockPos wheelPos = this.worldPosition.relative(engineFacing, 2);
    BlockState wheelState = this.level.getBlockState(wheelPos);
    if (this.getFlywheel() == wheelState.getBlock()) {
        Direction wheelFacing = wheelState.getValue(FlywheelBlock.HORIZONTAL_FACING);
        if (wheelFacing.getAxis() == engineFacing.getClockWise().getAxis()) {
            if (!FlywheelBlock.isConnected(wheelState) || FlywheelBlock.getConnection(wheelState) == engineFacing.getOpposite()) {
                TileEntity te = this.level.getBlockEntity(wheelPos);
                if (!te.isRemoved()) {
                    if (te instanceof FlywheelTileEntity) {
                        if (!FlywheelBlock.isConnected(wheelState)) {
                            FlywheelBlock.setConnection(this.level, te.getBlockPos(), te.getBlockState(), engineFacing.getOpposite());
                        }
                        this.poweredWheel = (FlywheelTileEntity) te;
                        this.refreshWheelSpeed();
                    }
                }
            }
        }
    }
}
Also used : EngineTileEntity(com.simibubi.create.content.contraptions.components.flywheel.engine.EngineTileEntity) FlywheelTileEntity(com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) BlockState(net.minecraft.block.BlockState) FlywheelTileEntity(com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity) BlockPos(net.minecraft.util.math.BlockPos) Direction(net.minecraft.util.Direction)

Example 5 with FlywheelTileEntity

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

the class BronzeFlywheelRenderer 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.BRONZE_FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true, rotation, flip).light(light).renderInto(ms, vb);
            this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.BRONZE_FLYWHEEL_LOWER_ROTATING, blockState), connection), false, true, rotation, flip).light(light).renderInto(ms, vb);
            this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.BRONZE_FLYWHEEL_UPPER_SLIDING, blockState), connection), true, false, rotation, flip).light(light).renderInto(ms, vb);
            this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.BRONZE_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