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();
}
}
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;
}
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);
}
}
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();
}
}
}
}
}
}
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);
}
}
Aggregations