use of com.simibubi.create.content.contraptions.components.structureMovement.bearing.SailBlock in project Create_Aeronautics by Eriksonnaren.
the class SimulatedContraptionRigidbody method updateWings.
void updateWings() {
for (Map.Entry<BlockPos, BlockState> entry : entity.sails.entrySet()) {
Vector3d pos = getLocalCoordinate(entry.getKey());
Vector3d vel = getLocalVelocityAtPosition(pos);
Vector3d normal = getFacingVector(entry.getValue());
Vector3d force = normal.scale(-0.8f * normal.dot(vel));
addForce(force, pos);
}
for (Map.Entry<UUID, ControlledContraptionEntity> contraptionEntityEntry : entity.subContraptions.entrySet()) {
// TODO: make propellers not provide lift
if (contraptionEntityEntry.getValue() != null) {
Contraption subContraption = contraptionEntityEntry.getValue().getContraption();
for (Map.Entry<BlockPos, Template.BlockInfo> blockStateEntry : subContraption.getBlocks().entrySet()) {
if (blockStateEntry.getValue().state.getBlock() instanceof SailBlock) {
Vector3d pos = contraptionEntityEntry.getValue().applyRotation(VecHelper.getCenterOf(blockStateEntry.getKey()), 0);
pos.subtract(centerOfMass);
Vector3d vel = getLocalVelocityAtPosition(pos);
Vector3d normal = getFacingVector(blockStateEntry.getValue().state);
normal = contraptionEntityEntry.getValue().applyRotation(normal, 0);
Vector3d force = normal.scale(-0.8f * normal.dot(vel));
addForce(force, pos);
}
}
}
}
}
Aggregations